[BACK]Return to ntohs.c CVS log [TXT][DIR] Up to [local] / prex-old / dev / lib

File: [local] / prex-old / dev / lib / ntohs.c (download)

Revision 1.1.1.1 (vendor branch), Tue Jun 3 09:38:42 2008 UTC (15 years, 11 months ago) by nbrk
Branch: MAIN, KOHSUKE
CVS Tags: PREX_0_8_BASE, PREX_0_7_BASE, HEAD
Changes since 1.1: +0 -0 lines

Yeah, this is an initial import of Prex, portable real-time microkernel 
operating system. I wanna hack it for non-profit but fun, so let it in.

/*
 * Written by J.T. Conklin <jtc@NetBSD.org>.
 * Public domain.
 */

#include <driver.h>
#include <sys/types.h>

#undef ntohs

uint16_t
ntohs(uint16_t x)
{
#if BYTE_ORDER == LITTLE_ENDIAN
	u_char *s = (u_char *) &x;
	return (uint16_t)(s[0] << 8 | s[1]);
#else
	return x;
#endif
}