X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilctypes.h;h=e98bc8c82bdf47f18a85b4f0a4f7a1d0a9df2897;hp=c763f8fa3b6be5fa1b6f613bbc0a926cdd6d2354;hb=c257b555225193e54d85daf541d29578b3c93882;hpb=f658940d02cf2fd893296b6a7825b42502573668 diff --git a/lib/silcutil/silctypes.h b/lib/silcutil/silctypes.h index c763f8fa..e98bc8c8 100644 --- a/lib/silcutil/silctypes.h +++ b/lib/silcutil/silctypes.h @@ -1,10 +1,10 @@ /* - silctypes.h + silctypes.h Author: Pekka Riikonen - Copyright (C) 2002 Pekka Riikonen + Copyright (C) 2002 - 2004 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -79,6 +79,10 @@ * * SOURCE */ +#ifdef SILC_MACOSX +#define bool _Bool +#endif + #ifndef __cplusplus #ifndef bool #define bool unsigned char @@ -491,4 +495,91 @@ do { \ (((SilcUInt32)(l) & (SilcUInt32)0xFF000000UL) >> 24)) /***/ +/****d* silcutil/SILCTypes/SILC_PTR_TO_32 + * + * NAME + * + * #define SILC_PTR_TO_32 ... + * + * DESCRIPTION + * + * Type casts a pointer's value into a 32-bit integer. Use this to + * avoid compiler warnings when type casting pointers to integers + * of different size. + * + * SOURCE + */ +#if SILC_SIZEOF_VOID_P < 8 +#define SILC_PTR_TO_32(_ptr__) ((SilcUInt32)(_ptr__)) +#else +#define SILC_PTR_TO_32(_ptr__) \ + ((SilcUInt32)((SilcUInt64)(_ptr__) & (SilcUInt32)0xFFFFFFFFUL)) +#endif +/***/ + +/****d* silcutil/SILCTypes/SILC_PTR_TO_64 + * + * NAME + * + * #define SILC_PTR_TO_64 ... + * + * DESCRIPTION + * + * Type casts a pointer's value into a 64-bit integer. Use this to + * avoid compiler warnings when type casting pointers to integers + * of different size. + * + * SOURCE + */ +#if SILC_SIZEOF_VOID_P < 8 +#define SILC_PTR_TO_64(_ptr__) ((SilcUInt64)((SilcUInt32)(_ptr__))) +#else +#define SILC_PTR_TO_64(_ptr__) \ + ((SilcUInt64)((SilcUInt64)(_ptr__) & (SilcUInt32)0xFFFFFFFFUL)) +#endif +/***/ + +/****d* silcutil/SILCTypes/SILC_32_TO_PTR + * + * NAME + * + * #define SILC_PTR_TO_32 ... + * + * DESCRIPTION + * + * Type casts a 32-bit integer value into a pointer. Use this to + * avoid compiler warnings when type casting integers to pointers of + * different size. + * + * SOURCE + */ +#if SILC_SIZEOF_VOID_P < 8 +#define SILC_32_TO_PTR(_ival__) ((void *)((SilcUInt32)(_ival__))) +#else +#define SILC_32_TO_PTR(_ival__) ((void *)((SilcUInt64)(_ival__))) +#endif +/***/ + +/****d* silcutil/SILCTypes/SILC_64_TO_PTR + * + * NAME + * + * #define SILC_PTR_TO_64 ... + * + * DESCRIPTION + * + * Type casts a 64-bit integer value into a pointer. Use this to + * avoid compiler warnings when type casting integers to pointers of + * different size. + * + * SOURCE + */ +#if SILC_SIZEOF_VOID_P < 8 +#define SILC_64_TO_PTR(_ival__) \ + ((void *)((SilcUInt32)((SilcUInt64)(_ival__) & (SilcUInt32)0xFFFFFFFFUL))) +#else +#define SILC_64_TO_PTR(_ival__) ((void *)((SilcUInt64)(_ival__))) +#endif +/***/ + #endif /* SILCTYPES_H */