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

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