-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd.h
102 lines (78 loc) · 2.24 KB
/
std.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef STD_H
#define STD_H
#include <cygwin/version.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <wchar.h>
#include <errno.h>
#if CYGWIN_VERSION_API_MINOR >= 91
#include <argz.h>
#else
int argz_create (char *const argv[], char **argz, size_t *argz_len);
void argz_stringify (char *argz, size_t argz_len, int sep);
#endif
#if CYGWIN_VERSION_API_MINOR >= 74
#include <wctype.h>
#else
int iswalnum(wint_t);
int iswalpha(wint_t);
int iswspace(wint_t);
#endif
#if CYGWIN_VERSION_API_MINOR < 53
#define strlcpy(dst, src, len) snprintf(dst, len, "%s", src)
#endif
#if CYGWIN_VERSION_API_MINOR < 70
int asprintf(char **, const char *, ...);
int vasprintf(char **, const char *, va_list);
#endif
char *asform(const char *fmt, ...);
#define WINVER 0x500 // Windows 2000
#define _WIN32_WINNT WINVER
#define _WIN32_IE WINVER
#include <windef.h>
#ifdef DMALLOC
#include <dmalloc.h>
#endif
#define always_inline __attribute__((always_inline)) inline
#define unused(arg) unused_##arg __attribute__((unused))
#define no_return __attribute__((noreturn)) void
typedef signed char schar;
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef void (*void_fn)(void);
typedef uint xchar; // UTF-32
typedef wchar_t wchar; // UTF-16
typedef const char *string;
typedef const wchar *wstring;
#define null ((void *) 0)
#define __W(s) L##s
#define _W(s) __W(s)
#define lengthof(array) (sizeof(array) / sizeof(*(array)))
#define endof(array) (&(array)[lengthof(array)])
#define new(type) ((type *)malloc(sizeof(type)))
#define newn(type, n) ((type *)calloc((n), sizeof(type)))
#define renewn(p, n) ((typeof(p)) realloc((p), sizeof(*p) * (n)))
static inline void delete(const void *p) { free((void *)p); }
void strset(string *sp, string s);
#define when break; case
#define or : case
#define otherwise break; default
#ifdef TRACE
#define trace(xs...) \
printf("%s:%u:%s:", __FILE__, __LINE__, __func__); \
printf(" " xs); \
putchar('\n')
#else
#define trace(f, xs...) {}
#endif
#define sgn(x) ({ typeof(x) x_ = (x); (x_ > 0) - (x_ < 0); })
#define sqr(x) ({ typeof(x) x_ = (x); x_ * x_; })
#endif