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

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