2021-06-16 19:54:50 +02:00
|
|
|
#ifndef _STDDEF_H
|
|
|
|
#define _STDDEF_H
|
2013-04-09 01:55:47 +02:00
|
|
|
|
|
|
|
#include <arch/types.h>
|
|
|
|
|
2021-06-16 19:46:17 +02:00
|
|
|
#ifndef __WCHAR_TYPE__
|
|
|
|
#define __WCHAR_TYPE__ int
|
|
|
|
#endif
|
|
|
|
#ifndef __cplusplus
|
|
|
|
typedef __WCHAR_TYPE__ wchar_t;
|
|
|
|
#endif
|
|
|
|
|
2013-04-09 01:55:47 +02:00
|
|
|
#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)
|
2017-08-04 00:58:14 +02:00
|
|
|
|
2018-08-20 20:47:19 +02:00
|
|
|
#define NSECS_PER_SEC 1000000000
|
2017-08-04 00:58:14 +02:00
|
|
|
#define USECS_PER_SEC 1000000
|
|
|
|
#define MSECS_PER_SEC 1000
|
2018-08-20 20:47:19 +02:00
|
|
|
#define NSECS_PER_MSEC (NSECS_PER_SEC / MSECS_PER_SEC)
|
|
|
|
#define NSECS_PER_USEC (NSECS_PER_SEC / USECS_PER_SEC)
|
2017-08-04 00:58:14 +02:00
|
|
|
#define USECS_PER_MSEC (USECS_PER_SEC / MSECS_PER_SEC)
|
2021-06-16 19:54:50 +02:00
|
|
|
|
|
|
|
#endif
|