VirtualBox

source: kBuild/trunk/src/kash/shtypes.h

最後變更 在這個檔案是 3477,由 bird 提交於 4 年 前

kash: Use kHlpAssert instead of assert.h (debugger stops on the assertion rather than at exit process code).

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:keywords 設為 Id
檔案大小: 3.8 KB
 
1/* $Id: shtypes.h 3477 2020-09-17 21:52:16Z 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#include "k/kHlpAssert.h"
33
34#include <sys/types.h>
35#include <stdlib.h>
36#ifdef __HAIKU__
37# include <posix/signal.h> /* silly */
38#elif !defined(_MSC_VER)
39# include <sys/signal.h>
40#endif
41
42#ifdef _MSC_VER
43typedef signed char int8_t;
44typedef unsigned char uint8_t;
45typedef short int16_t;
46typedef unsigned short uint16_t;
47typedef int int32_t;
48typedef unsigned int uint32_t;
49typedef _int64 int64_t;
50typedef unsigned _int64 uint64_t;
51# if _MSC_VER >= 1400
52# include <io.h> /* intptr_t and uintptr_t */
53# else
54typedef KIPTR intptr_t;
55typedef KUPTR uintptr_t;
56# endif
57
58#define INT16_C(c) (c)
59#define INT32_C(c) (c)
60#define INT64_C(c) (c ## LL)
61
62#define UINT8_C(c) (c)
63#define UINT16_C(c) (c)
64#define UINT32_C(c) (c ## U)
65#define UINT64_C(c) (c ## ULL)
66
67#define INTMAX_C(c) (c ## LL)
68#define UINTMAX_C(c) (c ## ULL)
69
70#undef INT8_MIN
71#define INT8_MIN (-0x7f-1)
72#undef INT16_MIN
73#define INT16_MIN (-0x7fff-1)
74#undef INT32_MIN
75#define INT32_MIN (-0x7fffffff-1)
76#undef INT64_MIN
77#define INT64_MIN (-0x7fffffffffffffffLL-1)
78
79#undef INT8_MAX
80#define INT8_MAX 0x7f
81#undef INT16_MAX
82#define INT16_MAX 0x7fff
83#undef INT32_MAX
84#define INT32_MAX 0x7fffffff
85#undef INT64_MAX
86#define INT64_MAX 0x7fffffffffffffffLL
87
88#undef UINT8_MAX
89#define UINT8_MAX 0xff
90#undef UINT16_MAX
91#define UINT16_MAX 0xffff
92#undef UINT32_MAX
93#define UINT32_MAX 0xffffffffU
94#undef UINT64_MAX
95#define UINT64_MAX 0xffffffffffffffffULL
96
97typedef int pid_t;
98typedef unsigned short uid_t;
99typedef unsigned short gid_t;
100typedef int mode_t;
101typedef intptr_t ssize_t;
102
103#else
104# include <stdint.h>
105#endif
106
107struct shinstance;
108typedef struct shinstance shinstance;
109
110#ifdef _MSC_VER
111typedef uint32_t shsigset_t;
112#else
113typedef sigset_t shsigset_t;
114#endif
115
116typedef void (*shsig_t)(shinstance *, int);
117typedef struct shsigaction
118{
119 shsig_t sh_handler;
120 shsigset_t sh_mask;
121 int sh_flags;
122} shsigaction_t;
123
124/* SH_NORETURN_1 must be both on prototypes and definitions, while
125 SH_NORETURN_2 should at least be on the prototype. */
126#ifdef _MSC_VER
127# define SH_NORETURN_1 __declspec(noreturn)
128# define SH_NORETURN_2
129#else
130# define SH_NORETURN_1
131# define SH_NORETURN_2 __attribute__((__noreturn__))
132#endif
133
134/** @name Extra wide pid_t so we can safely add a sub-pid to the top.
135 * @{ */
136#ifndef SH_FORKED_MODE
137typedef KI64 shpid;
138# define SHPID_MAKE(pid, tid) ((shpid)(KU32)(pid) | (shpid)(KU32)(tid) << 32)
139# define SHPID_GET_PID(shpid) ((pid_t)(KU32)(shpid))
140# define SHPID_GET_TID(shpid) ((pid_t)((shpid) >> 32))
141# define SHPID_PRI KI64_PRI
142#else
143typedef pid_t shpid;
144# define SHPID_GET_PID(shpid) (shpid)
145# define SHPID_PRI KI32_PRI
146#endif
147/** @} */
148
149#endif
150
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette