63a3e1ec7f
Add macro to calculate size of a structure member BUG=chrome-os-partner:41125 BRANCH=None TEST=Compiles successfully Change-Id: I71bcefe1c3b32ad559d7764e77369c67d09422a0 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: b425a310c14eabad79caf97649db6469380bd602 Original-Change-Id: I377fff062729aa664f7db469b86764b0ad941c38 Original-Signed-off-by: Furquan Shaikh <furquan@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/276809 Original-Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com> Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Tested-by: Furquan Shaikh <furquan@chromium.org> Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org> Original-Trybot-Ready: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/10560 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
22 lines
547 B
C
22 lines
547 B
C
|
|
#include <arch/types.h>
|
|
|
|
#ifndef __SIZE_TYPE__
|
|
#define __SIZE_TYPE__ unsigned long
|
|
#endif
|
|
typedef __SIZE_TYPE__ size_t;
|
|
/* There is a GCC macro for a size_t type, but not
|
|
* for a ssize_t type. Below construct tricks GCC
|
|
* into making __SIZE_TYPE__ signed.
|
|
*/
|
|
#define unsigned signed
|
|
typedef __SIZE_TYPE__ ssize_t;
|
|
#undef unsigned
|
|
|
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
|
|
#define member_size(TYPE, MEMBER) (sizeof(((TYPE *) 0)->MEMBER))
|
|
|
|
/* Standard units. */
|
|
#define KiB (1<<10)
|
|
#define MiB (1<<20)
|
|
#define GiB (1<<30)
|