libreis
0.1.0
A simple header-based drop-in library
include
reis
base.h
Go to the documentation of this file.
1
7
#ifndef REIS_INCLUDE_BASE_H
8
#define REIS_INCLUDE_BASE_H
9
10
#include <stdlib.h>
11
#include <unistd.h>
12
#include <stdint.h>
13
#include <string.h>
14
#include <stdio.h>
15
#include <dirent.h>
16
#include <sys/stat.h>
17
#include <sys/time.h>
18
#include <sys/resource.h>
19
#include <sys/types.h>
20
#include <sys/prctl.h>
21
#include <signal.h>
22
#include <syslog.h>
23
#include <time.h>
24
#include <fcntl.h>
25
26
#ifdef __cplusplus
27
#include <atomic>
28
extern
"C"
{
29
#else
30
#include <stdatomic.h>
31
#endif
32
33
#if defined(__APPLE__)
34
#include <wchar.h>
35
#elif defined(__linux__)
36
#include <wchar.h>
37
#include <wctype.h>
38
#include <ctype.h>
39
#endif
40
41
#include <reis/memory.h>
42
43
#define VERISION "0.1.0"
44
45
#if defined(BENCHMARK) || defined(LIBREIS_DEBUG)
46
#pragma message "You are currently using a debug version of libreis."
47
#endif
48
49
/* GENERAL SETTINGS */
50
#define REISLIB_INT_MAX 2147483647
51
#define CHARSET "abcdefghijklmnopqrstuvwxyz"
52
#define CHARSET_LEN 26
53
#define MAX_CHARSET_SIZE 256
54
#define SUB 0x1A
// an empty char as not to interfere with '\0'
55
56
/* TYPES */
57
typedef
uint8_t u8;
58
typedef
uint16_t u16;
59
typedef
uint32_t u32;
60
typedef
uint64_t u64;
61
typedef
int8_t s8;
62
typedef
int16_t s16;
63
typedef
int32_t s32;
64
typedef
int64_t s64;
65
typedef
float
f32;
66
typedef
double
f64;
67
typedef
long
double
f128;
68
69
/* Define a boolean type. */
70
#if !defined(__cplusplus)
71
#if !defined(bool)
72
typedef
enum
__attribute__((__packed__)) {
false
,
true
} bool;
73
#endif
74
#endif
75
76
#define fnname(name) #name
77
78
/* Wacky macro used for construction and deconstruction of reis' types. */
79
#define $(T, ...) rsNew##T(__VA_ARGS__)
80
#define $_(T, S) rsFree##T(S)
81
82
/* For loop wrapper, ala Python */
83
#define foreach(item, arr) \
84
for ( size_t keep = 1, \
85
count = 0, \
86
size = sizeof(arr) / sizeof(*(arr)); \
87
keep && count != size; \
88
keep = !keep, count++) \
89
for (item = (arr)[count]; keep; keep = !keep)
90
91
#ifdef __cplusplus
92
}
93
#endif
94
95
#endif
// REIS_INCLUDE_BASE_H
Generated by
1.9.1