Changeset 2827 for trunk/kLdr/kLdrHlp.h
- Timestamp:
- Oct 22, 2006, 8:05:28 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/kLdrHlp.h
r2826 r2827 32 32 * @internal 33 33 * @{ */ 34 34 35 /** Get the minimum of two values. */ 35 36 #define KLDR_MIN(a, b) ((a) <= (b) ? (a) : (b)) 36 37 /** Calculate the offset of a structure member. */ 38 #define KLDR_OFFSETOF(strct, memb) ( (size_t)( ((strct *)0)->memb ) ) 37 39 /** Align a size_t value. */ 38 40 #define KLDR_ALIGN_Z(val, align) ( ((val) + ((align) - 1)) & ~(size_t)((align) - 1) ) 39 41 /** Align a void * value. */ 40 42 #define KLDR_ALIGN_P(pv, align) ( (void *)( ((uintptr_t)(pv) + ((align) - 1)) & ~(uintptr_t)((align) - 1) ) ) 43 /** @def KLDRHLP_LE2H_U16 44 * Unsigned 16-bit little-endian to host translation. */ 45 /** @def KLDRHLP_LE2H_U32 46 * Unsigned 32-bit little-endian to host translation. */ 47 #if 1 48 # define KLDRHLP_LE2H_U16(u16) ((uint16_t)(u16)) 49 # define KLDRHLP_LE2H_U32(u32) ((uint32_t)(u32)) 50 #else 51 # define KLDRHLP_LE2H_U16(u16) ( (uint16_t) (((u16) >> 8) | ((u16) << 8)) ) 52 # define KLDRHLP_LE2H_U32(u32) ( ( ((u32) & UINT32_C(0xff000000)) >> 24 ) \ 53 | ( ((u32) & UINT32_C(0x00ff0000)) >> 8 ) \ 54 | ( ((u32) & UINT32_C(0x0000ff00)) << 8 ) \ 55 | ( ((u32) & UINT32_C(0x000000ff)) << 24 ) \ 56 ) 57 #endif 41 58 42 59 /*
Note:
See TracChangeset
for help on using the changeset viewer.