-
Notifications
You must be signed in to change notification settings - Fork 31
/
std.h
125 lines (106 loc) · 2.88 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* -*- Mode: C; Tab-Width: 4 -*- */
/* Include the standard system header files */
#ifndef _STD_H_
#define _STD_H_
#define _GNU_SOURCE
#define _THREAD_SAFE
#if defined(__OSF__) || defined(__osf__)
#define OS_OSF
#elif defined(linux)
#define OS_LINUX
#elif defined(__APPLE__)
#define OS_DARWIN
#elif defined(__FreeBSD__)
#define OS_FREEBSD
#else
#error "Unsupported OS"
#endif
#if defined(__alpha) || defined(__alpha__)
#define ARCH_ALPHA
#elif defined(__powerpc64__) || defined(__ppc64__)
#define ARCH_PPC64
#elif defined(__x86_64__)
#define ARCH_X86_64
#else
#error "Unsupported processor architecture"
#endif
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef OS_LINUX
#include <endian.h>
#else
#include <machine/endian.h>
#endif
#include "swapbytes.h"
#include <pthread.h>
typedef void* pthread_addr_t;
typedef void (*pthread_cleanuproutine_t) (void*);
typedef void* (*pthread_startroutine_t) (void*);
#ifndef OS_OSF
#define pthread_yield sched_yield
int pthread_get_expiration_np (const struct timespec *delta, struct timespec *abstime);
int pthread_delay_np (const struct timespec *interval);
#endif
#ifdef OS_OSF
/* These are the types defined in <stdint.h> which is newer than OSF */
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef long int int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint64_t;
typedef signed char int_least8_t;
typedef short int int_least16_t;
typedef int int_least32_t;
typedef long int int_least64_t;
typedef unsigned char uint_least8_t;
typedef unsigned short int uint_least16_t;
typedef unsigned int uint_least32_t;
typedef unsigned long int uint_least64_t;
typedef signed char int_fast8_t;
typedef long int int_fast16_t;
typedef long int int_fast32_t;
typedef long int int_fast64_t;
typedef unsigned char uint_fast8_t;
typedef unsigned long int uint_fast16_t;
typedef unsigned long int uint_fast32_t;
typedef unsigned long int uint_fast64_t;
typedef long int intptr_t;
typedef unsigned long int uintptr_t;
typedef long int intmax_t;
typedef unsigned long int uintmax_t;
#else
#include <stdint.h>
#ifdef OS_LINUX
#include <asm/types.h>
#endif
#define TRUE 1
#define FALSE 0
#define ESUCCESS 0
#endif
#include <limits.h>
/* ---*** TODO: Kludge 'till I figure out how I messed up the toolchain ... */
#ifndef _POSIX_PATH_MAX
#define _POSIX_PATH_MAX 256
#endif
#ifndef _POSIX_ARG_MAX
#define _POSIX_ARG_MAX 4096
#endif
#include <signal.h>
#if defined(OS_DARWIN) || defined(__FreeBSD__)
#include <ucontext.h>
#endif
typedef void (*sa_handler_t) (int);
typedef void (*sa_sigaction_t) (int, siginfo_t*, void*);
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <setjmp.h>
#include <poll.h>
#include <time.h>
#include <sched.h>
#endif