"Fossies" - the Fresh Open Source Software Archive

Member "dmidecode-3.2/types.h" (14 Sep 2018, 1395 Bytes) of package /linux/privat/dmidecode-3.2.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "types.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.1_vs_3.2.

    1 #ifndef TYPES_H
    2 #define TYPES_H
    3 
    4 #include "config.h"
    5 
    6 typedef unsigned char u8;
    7 typedef unsigned short u16;
    8 typedef signed short i16;
    9 typedef unsigned int u32;
   10 
   11 /*
   12  * You may use the following defines to adjust the type definitions
   13  * depending on the architecture:
   14  * - Define BIGENDIAN on big-endian systems.
   15  * - Define ALIGNMENT_WORKAROUND if your system doesn't support
   16  *   non-aligned memory access. In this case, we use a slower, but safer,
   17  *   memory access method. This should be done automatically in config.h
   18  *   for architectures which need it.
   19  */
   20 
   21 #ifdef BIGENDIAN
   22 typedef struct {
   23     u32 h;
   24     u32 l;
   25 } u64;
   26 #else
   27 typedef struct {
   28     u32 l;
   29     u32 h;
   30 } u64;
   31 #endif
   32 
   33 #if defined(ALIGNMENT_WORKAROUND) || defined(BIGENDIAN)
   34 static inline u64 U64(u32 low, u32 high)
   35 {
   36     u64 self;
   37 
   38     self.l = low;
   39     self.h = high;
   40 
   41     return self;
   42 }
   43 #endif
   44 
   45 /*
   46  * Per SMBIOS v2.8.0 and later, all structures assume a little-endian
   47  * ordering convention.
   48  */
   49 #if defined(ALIGNMENT_WORKAROUND) || defined(BIGENDIAN)
   50 #define WORD(x) (u16)((x)[0] + ((x)[1] << 8))
   51 #define DWORD(x) (u32)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
   52 #define QWORD(x) (U64(DWORD(x), DWORD(x + 4)))
   53 #else /* ALIGNMENT_WORKAROUND || BIGENDIAN */
   54 #define WORD(x) (u16)(*(const u16 *)(x))
   55 #define DWORD(x) (u32)(*(const u32 *)(x))
   56 #define QWORD(x) (*(const u64 *)(x))
   57 #endif /* ALIGNMENT_WORKAROUND || BIGENDIAN */
   58 
   59 #endif