root/include/asm-sparc/byteorder.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __ntohl
  2. __constant_ntohl
  3. __ntohs
  4. __constant_ntohs

   1 #ifndef _SPARC_BYTEORDER_H
   2 #define _SPARC_BYTEORDER_H
   3 
   4 #undef ntohl
   5 #undef ntohs
   6 #undef htonl
   7 #undef htons
   8 
   9 #define __BIG_ENDIAN
  10 #define __BIG_ENDIAN_BITFIELD
  11 
  12 extern unsigned long int        ntohl(unsigned long int);
  13 extern unsigned short int       ntohs(unsigned short int);
  14 extern unsigned long int        htonl(unsigned long int);
  15 extern unsigned short int       htons(unsigned short int);
  16 
  17 extern unsigned long int        __ntohl(unsigned long int);
  18 extern unsigned short int       __ntohs(unsigned short int);
  19 extern unsigned long int        __constant_ntohl(unsigned long int);
  20 extern unsigned short int       __constant_ntohs(unsigned short int);
  21 
  22 /*
  23  * The constant and non-constant versions here are the same.
  24  * Maybe I'll come up with an alpha-optimized routine for the
  25  * non-constant ones (the constant ones don't need it: gcc
  26  * will optimize it to the correct constant)
  27  */
  28 
  29 extern __inline__ unsigned long int
  30 __ntohl(unsigned long int x)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32         return (((x & 0x000000ffU) << 24) |
  33                 ((x & 0x0000ff00U) <<  8) |
  34                 ((x & 0x00ff0000U) >>  8) |
  35                 ((x & 0xff000000U) >> 24));
  36 }
  37 
  38 extern __inline__ unsigned long int
  39 __constant_ntohl(unsigned long int x)
     /* [previous][next][first][last][top][bottom][index][help] */
  40 {
  41         return (((x & 0x000000ffU) << 24) |
  42                 ((x & 0x0000ff00U) <<  8) |
  43                 ((x & 0x00ff0000U) >>  8) |
  44                 ((x & 0xff000000U) >> 24));
  45 }
  46 
  47 extern __inline__ unsigned short int
  48 __ntohs(unsigned short int x)
     /* [previous][next][first][last][top][bottom][index][help] */
  49 {
  50         return (((x & 0x00ff) << 8) |
  51                 ((x & 0xff00) >> 8));
  52 }
  53 
  54 extern __inline__ unsigned short int
  55 __constant_ntohs(unsigned short int x)
     /* [previous][next][first][last][top][bottom][index][help] */
  56 {
  57         return (((x & 0x00ff) << 8) |
  58                 ((x & 0xff00) >> 8));
  59 }
  60 
  61 #define __htonl(x) __ntohl(x)
  62 #define __htons(x) __ntohs(x)
  63 #define __constant_htonl(x) __constant_ntohl(x)
  64 #define __constant_htons(x) __constant_ntohs(x)
  65 
  66 #ifdef  __OPTIMIZE__
  67 #  define ntohl(x) \
  68 (__builtin_constant_p((long)(x)) ? \
  69  __constant_ntohl((x)) : \
  70  __ntohl((x)))
  71 #  define ntohs(x) \
  72 (__builtin_constant_p((short)(x)) ? \
  73  __constant_ntohs((x)) : \
  74  __ntohs((x)))
  75 #  define htonl(x) \
  76 (__builtin_constant_p((long)(x)) ? \
  77  __constant_htonl((x)) : \
  78  __htonl((x)))
  79 #  define htons(x) \
  80 (__builtin_constant_p((short)(x)) ? \
  81  __constant_htons((x)) : \
  82  __htons((x)))
  83 #endif
  84 
  85 #endif /* !(_SPARC_BYTEORDER_H) */

/* [previous][next][first][last][top][bottom][index][help] */