1 // Basic type definitions for X86 cpus.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU GPLv3 license.
9 typedef unsigned char u8;
10 typedef signed char s8;
11 typedef unsigned short u16;
12 typedef signed short s16;
13 typedef unsigned int u32;
14 typedef signed int s32;
15 typedef unsigned long long u64;
16 typedef signed long long s64;
20 struct { u32 hi, lo; };
24 #define __VISIBLE __attribute__((externally_visible))
26 // Notes a function as externally visible in the 16bit code chunk.
27 #define VISIBLE16 __VISIBLE
28 // Notes a function as externally visible in the 32bit code chunk.
32 #define VISIBLE32 __VISIBLE
35 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
36 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
37 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
38 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
39 #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
40 #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
42 #define NULL ((void *)0)
44 #define PACKED __attribute__((packed))
46 #define barrier() __asm__ __volatile__("": : :"memory")
48 #define noinline __attribute__((noinline))
49 #define __always_inline inline __attribute__((always_inline))
51 #define __stringify_1(x) #x
52 #define __stringify(x) __stringify_1(x)