Changeset 2827 for trunk/kLdr/kLdrHlp.h


Ignore:
Timestamp:
Oct 22, 2006, 8:05:28 PM (19 years ago)
Author:
bird
Message:

image format headers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdrHlp.h

    r2826 r2827  
    3232 * @internal
    3333 * @{ */
     34
    3435/** Get the minimum of two values. */
    3536#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 ) )
    3739/** Align a size_t value. */
    3840#define KLDR_ALIGN_Z(val, align)    ( ((val) + ((align) - 1)) & ~(size_t)((align) - 1) )
    3941/** Align a void * value. */
    4042#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
    4158
    4259/*
Note: See TracChangeset for help on using the changeset viewer.