X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilctypes.h;h=c763f8fa3b6be5fa1b6f613bbc0a926cdd6d2354;hp=7d4594cfcae17d3c2e2982c8e35a386118a6f353;hb=0e2d331497aa57a383ff9b512a257910cded8f14;hpb=7e104ac4a8ff56c593ed715c5bad20fa410aa203 diff --git a/lib/silcutil/silctypes.h b/lib/silcutil/silctypes.h index 7d4594cf..c763f8fa 100644 --- a/lib/silcutil/silctypes.h +++ b/lib/silcutil/silctypes.h @@ -245,9 +245,9 @@ typedef SilcUInt32 * void *; /* Macros */ -#define GET_WORD(cp) ((SilcUInt32)(SilcUInt8)(cp)[0]) << 24 \ - | ((SilcUInt32)(SilcUInt8)(cp)[1] << 16) \ - | ((SilcUInt32)(SilcUInt8)(cp)[2] << 8) \ +#define SILC_GET_WORD(cp) ((SilcUInt32)(SilcUInt8)(cp)[0]) << 24 \ + | ((SilcUInt32)(SilcUInt8)(cp)[1] << 16) \ + | ((SilcUInt32)(SilcUInt8)(cp)[2] << 8) \ | ((SilcUInt32)(SilcUInt8)(cp)[3]) /****d* silcutil/SILCTypes/SILC_GET16_MSB @@ -302,10 +302,10 @@ do { \ * * SOURCE */ -#define SILC_GET64_MSB(l, cp) \ -do { \ - (l) = ((((SilcUInt64)GET_WORD((cp))) << 32) | \ - ((SilcUInt64)GET_WORD((cp) + 4))); \ +#define SILC_GET64_MSB(l, cp) \ +do { \ + (l) = ((((SilcUInt64)SILC_GET_WORD((cp))) << 32) | \ + ((SilcUInt64)SILC_GET_WORD((cp) + 4))); \ } while(0) /***/ @@ -455,4 +455,40 @@ do { \ } while(0) /***/ +/****d* silcutil/SILCTypes/SILC_SWAB_16 + * + * NAME + * + * #define SILC_SWAB_16 ... + * + * DESCRIPTION + * + * Swabs 16-bit unsigned integer byte order. + * + * SOURCE + */ +#define SILC_SWAB_16(l) \ + ((SilcUInt16)(((SilcUInt16)(l) & (SilcUInt16)0x00FFU) << 8) | \ + (((SilcUInt16)(l) & (SilcUInt16)0xFF00U) >> 8)) +/***/ + +/****d* silcutil/SILCTypes/SILC_SWAB_32 + * + * NAME + * + * #define SILC_SWAB_32 ... + * + * DESCRIPTION + * + * Swabs 32-bit unsigned integer byte order. + * + * SOURCE + */ +#define SILC_SWAB_32(l) \ + ((SilcUInt32)(((SilcUInt32)(l) & (SilcUInt32)0x000000FFUL) << 24) | \ + (((SilcUInt32)(l) & (SilcUInt32)0x0000FF00UL) << 8) | \ + (((SilcUInt32)(l) & (SilcUInt32)0x00FF0000UL) >> 8) | \ + (((SilcUInt32)(l) & (SilcUInt32)0xFF000000UL) >> 24)) +/***/ + #endif /* SILCTYPES_H */