merge 64-bit fixes from Fernando Lucas Rodriguez <fernando_lr@terra.es>
[debian/gcpegg] / byteorder.h
index 6071e53628796e9063736d940e6b53837676e271..783e904c0432e6109dcf737b54ce15fa15acdcd9 100644 (file)
     on RISC machines which typically require values to be
     aligned at an even multiple of their length.  */
 
-#define packShort(x) { \
-                       short s = htons((short) (x)); \
-                       memcpy(pktP, &s, sizeof(short)); \
-                       pktP += sizeof(short); \
+#define pack16(x) { \
+                       uint16 s = htons((uint16) (x)); \
+                       memcpy(pktP, &s, sizeof(uint16)); \
+                       pktP += sizeof(uint16); \
                     }
 
-#define packLong(x) { \
-                       long l = htonl((long) (x)); \
-                       memcpy(pktP, &l, sizeof(long)); \
-                       pktP += sizeof(long); \
+#define pack32(x) { \
+                       uint32 i = htonl((uint32) (x)); \
+                       memcpy(pktP, &i, sizeof(uint32)); \
+                       pktP += sizeof(uint32); \
                    }
 
-#define packByte(x) { \
+#define pack8(x) { \
                        char c = (x); \
                        memcpy(pktP, &c, sizeof(char)); \
                        pktP += sizeof(char); \
                    }
 
-#define packBytes(x, n) { \
+#define pack8s(x, n) { \
                            memcpy(pktP, x, n); \
                            pktP += n; \
                        }
     pktP.  Note that the argument of these macros must be
     an lvalue. */
 
-#define unpackShort(x) { \
-                           short s; \
-                           memcpy(&s, pktP, sizeof(short)); \
-                           pktP += sizeof(short); \
+#define unpack16(x) { \
+                           uint16 s; \
+                           memcpy(&s, pktP, sizeof(uint16)); \
+                           pktP += sizeof(uint16); \
                            x = ntohs(s); \
                       }
 
-#define unpackLong(x) { \
-                          long l; \
-                          memcpy(&l, pktP, sizeof(long)); \
-                          pktP += sizeof(long); \
-                          x = ntohl(l); \
+#define unpack32(x) { \
+                          uint32 i; \
+                          memcpy(&i, pktP, sizeof(uint32)); \
+                          pktP += sizeof(uint32); \
+                          x = ntohl(i); \
                      }
 
-#define unpackByte(x) { \
+#define unpack8(x) { \
                        *((char *) &x) = (char) *pktP++; \
                      }
 
-#define unpackBytes(x, n) { \
+#define unpack8s(x, n) { \
                            memcpy(x, pktP, n); \
                            pktP += n; \
                          }