diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-09-08 13:34:43 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2015-09-22 21:21:34 +0000 |
commit | dc9f5cd54661e5ba3fffee7af0ba17dde9367b95 (patch) | |
tree | 43b5eca98ba0b09390ff9a6d1174c2e0cce94e1b /src/include/stddef.h | |
parent | 4b93a4f47a7457162d1be20eeffe57f81d5cd6af (diff) |
coreboot: introduce commonlib
Instead of reaching into src/include and re-writing code
allow for cleaner code sharing within coreboot and its
utilities. The additional thing needed at this point is
for the utilities to provide a printk() declaration within
a <console/console.h> file. That way code which uses printk()
can than be mapped properly to verbosity of utility parameters.
Change-Id: I9e46a279569733336bc0a018aed96bc924c07cdd
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/11592
Tested-by: build bot (Jenkins)
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'src/include/stddef.h')
-rw-r--r-- | src/include/stddef.h | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/src/include/stddef.h b/src/include/stddef.h index f87c65f089..b58f645a3b 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -1,6 +1,8 @@ #ifndef STDDEF_H #define STDDEF_H +#include <commonlib/helpers.h> + typedef long ptrdiff_t; #ifndef __SIZE_TYPE__ #define __SIZE_TYPE__ unsigned long @@ -19,38 +21,6 @@ typedef unsigned int wint_t; #define NULL ((void *)0) -/* Standard units. */ -#define KiB (1<<10) -#define MiB (1<<20) -#define GiB (1<<30) -/* Could we ever run into this one? I hope we get this much memory! */ -#define TiB (1<<40) - -#define KHz (1000) -#define MHz (1000 * KHz) -#define GHz (1000 * MHz) - -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -#if !defined(__clang__) -#define check_member(structure, member, offset) _Static_assert( \ - offsetof(struct structure, member) == offset, \ - "`struct " #structure "` offset for `" #member "` is not " #offset ) -#else -#define check_member(structure, member, offset) -#endif - -/** - * container_of - cast a member of a structure out to the containing structure - * @param ptr: the pointer to the member. - * @param type: the type of the container struct this is embedded in. - * @param member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - #ifdef __PRE_RAM__ #define ROMSTAGE_CONST const #else |