root/include/asm-alpha/byteorder.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __ntohl
  2. __ntohs

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

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