types.h (1012B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _TYPES_H_ 3#define _TYPES_H_ 4 5#include <stdbool.h> 6 7#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 8 9typedef unsigned char u8; 10typedef unsigned short u16; 11typedef unsigned int u32; 12typedef unsigned long long u64; 13typedef signed char s8; 14typedef short s16; 15typedef int s32; 16typedef long long s64; 17 18/* required for opal-api.h */ 19typedef u8 uint8_t; 20typedef u16 uint16_t; 21typedef u32 uint32_t; 22typedef u64 uint64_t; 23typedef s8 int8_t; 24typedef s16 int16_t; 25typedef s32 int32_t; 26typedef s64 int64_t; 27 28#define min(x,y) ({ \ 29 typeof(x) _x = (x); \ 30 typeof(y) _y = (y); \ 31 (void) (&_x == &_y); \ 32 _x < _y ? _x : _y; }) 33 34#define max(x,y) ({ \ 35 typeof(x) _x = (x); \ 36 typeof(y) _y = (y); \ 37 (void) (&_x == &_y); \ 38 _x > _y ? _x : _y; }) 39 40#define min_t(type, a, b) min(((type) a), ((type) b)) 41#define max_t(type, a, b) max(((type) a), ((type) b)) 42 43typedef int bool; 44 45#ifndef true 46#define true 1 47#endif 48 49#ifndef false 50#define false 0 51#endif 52#endif /* _TYPES_H_ */