cu/util.h: General Utilities
[Utilities]

Data Structures

union  cuP_alignment_u
struct  cuP_alignment_test_s

Defines

#define CU_SWAP(value_t, x, y)
#define CU_RETURN_UNLESS_FIRST_CALL
#define cu_ptr_context(type, field, ptr)   ((type *)((char *)(ptr) - offsetof(type, field)))
#define CU_FULL_ALIGNMENT   (sizeof(struct cuP_alignment_test_s) - sizeof(union cuP_alignment_u))
#define cu_aligned_floor(size)   ((size)/CU_FULL_ALIGNMENT*CU_FULL_ALIGNMENT)
#define cu_aligned_ceil(size)   (((size) + CU_FULL_ALIGNMENT - 1)/CU_FULL_ALIGNMENT*CU_FULL_ALIGNMENT)
#define CU_ALIGNED_SIZEOF(type)   cu_aligned_ceil(sizeof(type))
#define CU_ALIGNED_PTR_END(ptr)   ((void *)((char*)(ptr) + cu_aligned_ceil(sizeof(*ptr))))
#define CU_ALIGNED_PTR_FROM_END(ptr_t, ptr)   ((ptr_t)((char*)(ptr) - cu_aligned_ceil(sizeof(*(ptr_t)NULL))))
#define CU_ALIGNED_MARG_END(ptr_t, ptr)   CU_ALIGNED_PTR_END(CU_MARG(ptr_t, ptr))

Define Documentation

#define cu_ptr_context ( type,
field,
ptr   )     ((type *)((char *)(ptr) - offsetof(type, field)))

Assuming ptr points to field in type, returns a pointer to the whole type. Uses offsetof(type, field).

#define CU_RETURN_UNLESS_FIRST_CALL
Value:
do {                                                            \
        static int cuL_done = 0;                                        \
        if (cuL_done)                                                   \
            return;                                                     \
        cuL_done = 1;                                                   \
    } while (0)
#define CU_SWAP ( value_t,
x,
 ) 
Value:
do {                                                            \
        value_t cuL_tmp = (x);                                          \
        (x) = (y);                                                      \
        (y) = cuL_tmp;                                                  \
    } while (0)
Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.