Personal tools
You are here: Home Projects C++ Cfront releases Release 3.0.3 source incl-master proto-headers sys byteorder.h
Document Actions

byteorder.h

by Michael L Powell last modified 2007-01-26 03:21

Click here to get the file

Size 1.1 kB - File type text/plain

File contents

#usedby svr4 solaris sgi-svr4

/* in /usr/include/sys/byteorder.h, the conversion functions
   are defined in assembler (which is not acceptable to cfront) */

#ifndef _SYS_BYTEORDER_H
#define _SYS_BYTEORDER_H

#if !defined(vax) && !defined(ntohl) && !defined(lint) && !defined(i386)
/* big-endian */
#define ntohl(x) (x)
#define htonl(x) (x)
#define ntohs(x) (x)
#define htons(x) (x)

#elif defined(i386)

inline unsigned long
ntohl(unsigned long nl) {
	return (((nl<<24)&0xFF000000) +
		((nl<<8)&0xFF0000) +
		((nl>>8)&0xFF00) +
		((nl>>24)&0xFF));
}
inline unsigned long
htonl(unsigned long hl) {
	return (((hl<<24)&0xFF000000) +
		((hl<<8)&0xFF0000) +
		((hl>>8)&0xFF00) +
		((hl>>24)&0xFF));
}

inline unsigned short
ntohs(unsigned short ns) {
	return (((ns<<8)&0xFF00) +
		((ns>>8)&0xFF));
}
inline unsigned short
htons(unsigned short hs) {
	return (((hs<<8)&0xFF00) +
		((hs>>8)&0xFF));
}

#elif !defined(ntohl)

extern "C" {
	unsigned long ntohl(unsigned long);
	unsigned long htonl(unsigned long);
	unsigned short ntohs(unsigned short);
	unsigned short htons(unsigned short);
}

#endif

#endif



« December 2024 »
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: