2013-04-09 01:55:47 +02:00
|
|
|
|
|
|
|
#include <arch/types.h>
|
|
|
|
|
|
|
|
#ifndef __SIZE_TYPE__
|
|
|
|
#define __SIZE_TYPE__ unsigned long
|
|
|
|
#endif
|
|
|
|
typedef __SIZE_TYPE__ size_t;
|
2013-05-02 23:02:28 +02:00
|
|
|
/* 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
|
2013-04-09 01:55:47 +02:00
|
|
|
|
|
|
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
|
2015-06-11 14:17:32 +02:00
|
|
|
#define member_size(TYPE, MEMBER) (sizeof(((TYPE *) 0)->MEMBER))
|
2013-04-09 01:55:47 +02:00
|
|
|
|
2015-06-29 22:33:34 +02:00
|
|
|
#define check_member(structure, member, offset) _Static_assert( \
|
|
|
|
offsetof(struct structure, member) == offset, \
|
|
|
|
"`struct " #structure "` offset for `" #member "` is not " #offset)
|
|
|
|
|
2014-03-06 00:46:28 +01:00
|
|
|
/* Standard units. */
|
2017-06-27 21:51:20 +02:00
|
|
|
#define KiB (1 << 10)
|
|
|
|
#define MiB (1 << 20)
|
|
|
|
#define GiB (1 << 30)
|
2015-06-29 22:33:34 +02:00
|
|
|
|
|
|
|
#define KHz (1000)
|
|
|
|
#define MHz (1000*KHz)
|
|
|
|
#define GHz (1000*MHz)
|