mercurial/util.h
changeset 16437 d126a0d16856
parent 16393 ee163a9cf37c
child 16629 1435866c1937
equal deleted inserted replaced
16436:e98460f6089d 16437:d126a0d16856
   123 typedef unsigned long uint32_t;
   123 typedef unsigned long uint32_t;
   124 typedef unsigned __int64 uint64_t;
   124 typedef unsigned __int64 uint64_t;
   125 #else
   125 #else
   126 #include <stdint.h>
   126 #include <stdint.h>
   127 #endif
   127 #endif
   128 static uint32_t ntohl(uint32_t x)
       
   129 {
       
   130 	return ((x & 0x000000ffUL) << 24) |
       
   131 	       ((x & 0x0000ff00UL) <<  8) |
       
   132 	       ((x & 0x00ff0000UL) >>  8) |
       
   133 	       ((x & 0xff000000UL) >> 24);
       
   134 }
       
   135 #else
   128 #else
   136 /* not windows */
   129 /* not windows */
   137 #include <sys/types.h>
   130 #include <sys/types.h>
   138 #if defined __BEOS__ && !defined __HAIKU__
   131 #if defined __BEOS__ && !defined __HAIKU__
   139 #include <ByteOrder.h>
   132 #include <ByteOrder.h>
   149 
   142 
   150 #ifdef __linux
   143 #ifdef __linux
   151 #define inline __inline
   144 #define inline __inline
   152 #endif
   145 #endif
   153 
   146 
       
   147 static inline uint32_t getbe32(const char *c)
       
   148 {
       
   149 	const unsigned char *d = (const unsigned char *)c;
       
   150 
       
   151 	return ((d[0] << 24) |
       
   152 		(d[1] << 16) |
       
   153 		(d[2] << 8) |
       
   154 		(d[3]));
       
   155 }
       
   156 
       
   157 static inline void putbe32(uint32_t x, char *c)
       
   158 {
       
   159 	c[0] = (x >> 24) & 0xff;
       
   160 	c[1] = (x >> 16) & 0xff;
       
   161 	c[2] = (x >> 8) & 0xff;
       
   162 	c[3] = (x) & 0xff;
       
   163 }
       
   164 
   154 #endif /* _HG_UTIL_H_ */
   165 #endif /* _HG_UTIL_H_ */