arch/cell/cell_lib/spert_common.h

Go to the documentation of this file.
00001 #ifndef __COMMON_H__
00002 #define __COMMON_H__
00003 
00004 
00005 #include <stdlib.h>
00006 
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00013 // Defines
00014 
00015 #ifndef TRUE
00016   #define TRUE (-1)
00017 #endif
00018 
00019 #ifndef FALSE
00020   #define FALSE (0)
00021 #endif
00022 
00023 #ifndef NULL
00024   #define NULL (0)
00025 #endif
00026 
00027 // SIZEOF_16 : Returns the size of the structure s rounded up to the nearest multiple of 16.
00028 //   NOTE: All of the values in this macro are constants so a good compiler should be able to reduce all of this to a constant.
00029 
00030 #define ROUNDUP_16(s)   (s + ((16 - (s & 15)) & 15))
00031 #define SIZEOF_16(s)    (sizeof(s) + ((16 - (sizeof(s) & 15)) & 15))
00032 
00033 #define ROUNDUP_128(s)  (s + ((128 - (s & 127)) & 127))
00034 #define SIZEOF_128(s)   (sizeof(s) + ((128 - (sizeof(s) & 127)) & 127))
00035 
00036 #define ROUNDUP(s,p2)   (s + ((p2 - (s & (p2 - 1))) & (p2 - 1)))
00037 #define SIZEOF(s,p2)    (sizeof(s) + ((p2 - (sizeof(s) & (p2 - 1))) & (p2 - 1)))
00038 
00039 //#define SIZEOF_16(s)   ( (((sizeof(s) & 0x0000000F)) == (0x00)) ? (int)(sizeof(s)) : (int)((sizeof(s) & 0xFFFFFFF0) + (0x10)) )
00040 //#define ROUNDUP_16(s)  ( ((((s) & 0x0000000F)) == (0x00)) ? (int)(s) : (int)(((s) & 0xFFFFFFF0) + (0x10)) )
00041 
00042 
00044 // Function Prototypes
00045 
00046 // These memory functions ensure that both the start and the end of the returned memory region
00047 //   are aligned (in bytes) on the specified byte boundries.
00048 // NOTE: Like the alloca_aligned() function calls alloca and as such, there is no need to free
00049 //   the memory returned by this function.  (See the man page for alloca for details.)
00050 extern void* malloc_aligned(size_t size, char alignment);
00051 extern void* calloc_aligned(size_t size, char alignment);
00052 //extern void* alloca_aligned(size_t size, char alignment, int zeroFlag);
00053 extern void free_aligned(void* ptr);
00054 
00055 
00056 #ifdef __cplusplus
00057 }
00058 #endif
00059 
00060 #endif //__COMMON_H__

Generated on Sun Jun 29 13:29:05 2008 for Charm++ by  doxygen 1.5.1