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 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 alpha-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 #define __constant_ntohl(x) \
  36 ((unsigned int)((((unsigned int)(x) & 0x000000ffU) << 24) | \
  37                 (((unsigned int)(x) & 0x0000ff00U) <<  8) | \
  38                 (((unsigned int)(x) & 0x00ff0000U) >>  8) | \
  39                 (((unsigned int)(x) & 0xff000000U) >> 24)))
  40 
  41 extern __inline__ unsigned short int
  42 __ntohs(unsigned short int x)
     /* [previous][next][first][last][top][bottom][index][help] */
  43 {
  44         return (((x & 0x00ff) << 8) |
  45                 ((x & 0xff00) >> 8));
  46 }
  47 
  48 #define __constant_ntohs(x) \
  49 ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
  50                       (((unsigned short int)(x) & 0xff00) >> 8)))
  51 
  52 #define __htonl(x) __ntohl(x)
  53 #define __htons(x) __ntohs(x)
  54 #define __constant_htonl(x) __constant_ntohl(x)
  55 #define __constant_htons(x) __constant_ntohs(x)
  56 
  57 #ifdef  __OPTIMIZE__
  58 #  define ntohl(x) \
  59 (__builtin_constant_p((long)(x)) ? \
  60  __constant_ntohl((x)) : \
  61  __ntohl((x)))
  62 #  define ntohs(x) \
  63 (__builtin_constant_p((short)(x)) ? \
  64  __constant_ntohs((x)) : \
  65  __ntohs((x)))
  66 #  define htonl(x) \
  67 (__builtin_constant_p((long)(x)) ? \
  68  __constant_htonl((x)) : \
  69  __htonl((x)))
  70 #  define htons(x) \
  71 (__builtin_constant_p((short)(x)) ? \
  72  __constant_htons((x)) : \
  73  __htons((x)))
  74 #endif
  75 
  76 #endif

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