1 | /* $Id: shtypes.h 2546 2011-10-01 19:49:54Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * Wrapper for missing types and such.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2007-2010 knut st. osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * This file is part of kBuild.
|
---|
11 | *
|
---|
12 | * kBuild is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * kBuild is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with kBuild; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | *
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef ___shtypes_h___
|
---|
29 | #define ___shtypes_h___
|
---|
30 |
|
---|
31 | #include "k/kTypes.h" /* Use these, not the ones below. */
|
---|
32 |
|
---|
33 | #include <sys/types.h>
|
---|
34 | #include <stdlib.h>
|
---|
35 | #ifdef __HAIKU__
|
---|
36 | # include <posix/signal.h> /* silly */
|
---|
37 | #elif !defined(_MSC_VER)
|
---|
38 | # include <sys/signal.h>
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | #ifdef _MSC_VER
|
---|
42 | typedef signed char int8_t;
|
---|
43 | typedef unsigned char uint8_t;
|
---|
44 | typedef short int16_t;
|
---|
45 | typedef unsigned short uint16_t;
|
---|
46 | typedef int int32_t;
|
---|
47 | typedef unsigned int uint32_t;
|
---|
48 | typedef _int64 int64_t;
|
---|
49 | typedef unsigned _int64 uint64_t;
|
---|
50 | # if _MSC_VER >= 1400
|
---|
51 | # include <io.h> /* intptr_t and uintptr_t */
|
---|
52 | # else
|
---|
53 | typedef KIPTR intptr_t;
|
---|
54 | typedef KUPTR uintptr_t;
|
---|
55 | # endif
|
---|
56 |
|
---|
57 | #define INT16_C(c) (c)
|
---|
58 | #define INT32_C(c) (c)
|
---|
59 | #define INT64_C(c) (c ## LL)
|
---|
60 |
|
---|
61 | #define UINT8_C(c) (c)
|
---|
62 | #define UINT16_C(c) (c)
|
---|
63 | #define UINT32_C(c) (c ## U)
|
---|
64 | #define UINT64_C(c) (c ## ULL)
|
---|
65 |
|
---|
66 | #define INTMAX_C(c) (c ## LL)
|
---|
67 | #define UINTMAX_C(c) (c ## ULL)
|
---|
68 |
|
---|
69 | #undef INT8_MIN
|
---|
70 | #define INT8_MIN (-0x7f-1)
|
---|
71 | #undef INT16_MIN
|
---|
72 | #define INT16_MIN (-0x7fff-1)
|
---|
73 | #undef INT32_MIN
|
---|
74 | #define INT32_MIN (-0x7fffffff-1)
|
---|
75 | #undef INT64_MIN
|
---|
76 | #define INT64_MIN (-0x7fffffffffffffffLL-1)
|
---|
77 |
|
---|
78 | #undef INT8_MAX
|
---|
79 | #define INT8_MAX 0x7f
|
---|
80 | #undef INT16_MAX
|
---|
81 | #define INT16_MAX 0x7fff
|
---|
82 | #undef INT32_MAX
|
---|
83 | #define INT32_MAX 0x7fffffff
|
---|
84 | #undef INT64_MAX
|
---|
85 | #define INT64_MAX 0x7fffffffffffffffLL
|
---|
86 |
|
---|
87 | #undef UINT8_MAX
|
---|
88 | #define UINT8_MAX 0xff
|
---|
89 | #undef UINT16_MAX
|
---|
90 | #define UINT16_MAX 0xffff
|
---|
91 | #undef UINT32_MAX
|
---|
92 | #define UINT32_MAX 0xffffffffU
|
---|
93 | #undef UINT64_MAX
|
---|
94 | #define UINT64_MAX 0xffffffffffffffffULL
|
---|
95 |
|
---|
96 | typedef int pid_t;
|
---|
97 | typedef unsigned short uid_t;
|
---|
98 | typedef unsigned short gid_t;
|
---|
99 | typedef int mode_t;
|
---|
100 | typedef intptr_t ssize_t;
|
---|
101 |
|
---|
102 | #else
|
---|
103 | # include <stdint.h>
|
---|
104 | #endif
|
---|
105 |
|
---|
106 | struct shinstance;
|
---|
107 | typedef struct shinstance shinstance;
|
---|
108 |
|
---|
109 | #ifdef _MSC_VER
|
---|
110 | typedef uint32_t shsigset_t;
|
---|
111 | #else
|
---|
112 | typedef sigset_t shsigset_t;
|
---|
113 | #endif
|
---|
114 |
|
---|
115 | typedef void (*shsig_t)(shinstance *, int);
|
---|
116 | typedef struct shsigaction
|
---|
117 | {
|
---|
118 | shsig_t sh_handler;
|
---|
119 | shsigset_t sh_mask;
|
---|
120 | int sh_flags;
|
---|
121 | } shsigaction_t;
|
---|
122 |
|
---|
123 | /* SH_NORETURN_1 must be both on prototypes and definitions, while
|
---|
124 | SH_NORETURN_2 should at least be on the prototype. */
|
---|
125 | #ifdef _MSC_VER
|
---|
126 | # define SH_NORETURN_1 __declspec(noreturn)
|
---|
127 | # define SH_NORETURN_2
|
---|
128 | #else
|
---|
129 | # define SH_NORETURN_1
|
---|
130 | # define SH_NORETURN_2 __attribute__((__noreturn__))
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | #endif
|
---|
134 |
|
---|