"Fossies" - the Fresh Open Source Software Archive

Member "usr/include/machine/_endian.h" (19 Aug 2019, 968 Bytes) of package /windows/misc/cygwin-20190819-x86.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* machine/_endian.h
    2 
    3 This file is part of Cygwin.
    4 
    5 This software is a copyrighted work licensed under the terms of the
    6 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    7 details. */
    8 
    9 #ifndef __MACHINE_ENDIAN_H__
   10 #error "must be included via <machine/endian.h>"
   11 #endif /* !__MACHINE_ENDIAN_H__ */
   12 
   13 #include <_ansi.h>
   14 #include <bits/endian.h>
   15 
   16 #define _LITTLE_ENDIAN __LITTLE_ENDIAN
   17 #define _BIG_ENDIAN    __BIG_ENDIAN
   18 #define _PDP_ENDIAN    __PDP_ENDIAN
   19 #define _BYTE_ORDER    __BYTE_ORDER
   20 
   21 #define __machine_host_to_from_network_defined
   22 
   23 _ELIDABLE_INLINE __uint32_t __ntohl(__uint32_t);
   24 _ELIDABLE_INLINE __uint16_t __ntohs(__uint16_t);
   25 
   26 _ELIDABLE_INLINE __uint32_t
   27 __ntohl(__uint32_t _x)
   28 {
   29     __asm__("bswap %0" : "=r" (_x) : "0" (_x));
   30     return _x;
   31 }
   32 
   33 _ELIDABLE_INLINE __uint16_t
   34 __ntohs(__uint16_t _x)
   35 {
   36     __asm__("xchgb %b0,%h0"     /* swap bytes       */
   37         : "=Q" (_x)
   38         :  "0" (_x));
   39     return _x;
   40 }
   41 
   42 #define __htonl(_x) __ntohl(_x)
   43 #define __htons(_x) __ntohs(_x)