The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/lib/libkern/htons.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: htons.c,v 1.11 2003/12/04 13:57:31 keihan Exp $        */
    2 
    3 /*
    4  * Written by J.T. Conklin <jtc@NetBSD.org>.
    5  * Public domain.
    6  */
    7 
    8 #include <sys/cdefs.h>
    9 #if defined(LIBC_SCCS) && !defined(lint)
   10 __RCSID("$NetBSD: htons.c,v 1.11 2003/12/04 13:57:31 keihan Exp $");
   11 #endif
   12 
   13 #include <sys/types.h>
   14 
   15 #undef htons
   16 
   17 uint16_t
   18 htons(x)
   19         uint16_t x;
   20 {
   21 #if BYTE_ORDER == LITTLE_ENDIAN
   22         u_char *s = (u_char *) &x;
   23         return (uint16_t)(s[0] << 8 | s[1]);
   24 #else
   25         return x;
   26 #endif
   27 }

Cache object: f1b35d58bcef957f882d86cc758e45ae


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.