aboutsummaryrefslogtreecommitdiff
path: root/include/u.h
blob: 3cf3c7b7bd1c841fac7584f8c0c25c4e6a73559a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once

// ------------------------------------------------------------------------
// Freestanding headers

#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>

// ------------------------------------------------------------------------
// Modern type aliases

typedef char          byte;
typedef unsigned char ubyte, uchar;
typedef signed   char sbyte, schar;

typedef unsigned short ushort;
typedef signed   short sshort;

typedef unsigned int  uint;
typedef signed int    sint;

typedef unsigned long ulong;
typedef signed   long slong;

typedef unsigned long ulong;
typedef signed   long slong;

typedef          long long   vlong;
typedef unsigned long long  uvlong;
typedef signed   long long  svlong;

typedef uint8_t  uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;

typedef int8_t  int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;

typedef float  float32;
typedef double float64;

typedef uintptr_t uintptr;
typedef intptr_t  intptr;

typedef int error;

#define nil NULL

// ------------------------------------------------------------------
// Global macros

#define arrlen(Array) (sizeof(Array) / sizeof((Array)[0]))
#define arrend(Array) ((Array) + arrlen(Array))

#define MAX(x, y)        (((x) > (y)) ? (x) : (y))
#define MIN(x, y)        (((x) < (y)) ? (x) : (y))
#define CLAMP(x, lo, hi) (((x) < (lo)) ? (lo) : (((x) > (hi)) ? (hi) : (x)))