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