1 | /* |
---|
2 | * libcaca Colour ASCII-Art library |
---|
3 | * Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * This library is free software. It comes without any warranty, to |
---|
7 | * the extent permitted by applicable law. You can redistribute it |
---|
8 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
9 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
10 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
11 | */ |
---|
12 | |
---|
13 | /* |
---|
14 | * This file contains definitions for required C99 integer types. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef __CACA_TYPES_H__ |
---|
18 | #define __CACA_TYPES_H__ |
---|
19 | |
---|
20 | #if !defined _MSC_VER |
---|
21 | /* FIXME: detect platforms with <inttypes.h> and no <stdint.h> */ |
---|
22 | # include <stdint.h> |
---|
23 | # include <unistd.h> |
---|
24 | |
---|
25 | #elif defined _MSC_STDINT_H_ /* msinttypes */ \ |
---|
26 | || defined NM_DEFINED_FIXED_WIDTH_TYPEDEFS /* Morpheme */ |
---|
27 | /* Someone already defined things for us: do nothing */ |
---|
28 | |
---|
29 | #else |
---|
30 | # if _MSC_VER >= 1600 |
---|
31 | /* Visual Studio 2010 and later */ |
---|
32 | # include <stdint.h> |
---|
33 | # else |
---|
34 | # include <intsafe.h> |
---|
35 | # if _MSC_VER >= 1300 |
---|
36 | typedef signed __int8 int8_t; |
---|
37 | typedef signed __int16 int16_t; |
---|
38 | typedef signed __int32 int32_t; |
---|
39 | typedef signed __int64 int64_t; |
---|
40 | typedef unsigned __int8 uint8_t; |
---|
41 | typedef unsigned __int16 uint16_t; |
---|
42 | typedef unsigned __int32 uint32_t; |
---|
43 | typedef unsigned __int64 uint64_t; |
---|
44 | # else |
---|
45 | typedef signed char int8_t; |
---|
46 | typedef signed short int16_t; |
---|
47 | typedef signed int int32_t; |
---|
48 | typedef signed long long int int64_t; |
---|
49 | typedef unsigned char uint8_t; |
---|
50 | typedef unsigned short uint16_t; |
---|
51 | typedef unsigned int uint32_t; |
---|
52 | typedef unsigned long long int uint64_t; |
---|
53 | # endif |
---|
54 | # endif |
---|
55 | # if defined _WIN64 |
---|
56 | /* Win64, (u)intptr_t and size_t are present */ |
---|
57 | typedef int ssize_t; |
---|
58 | # else |
---|
59 | /* Win32, only (u)intptr_t is present */ |
---|
60 | typedef int ssize_t; |
---|
61 | typedef unsigned int size_t; |
---|
62 | # endif |
---|
63 | #endif |
---|
64 | |
---|
65 | #if 0 |
---|
66 | /* fallback: nothing is known, we assume the platform is 32-bit and |
---|
67 | * sizeof(long) == sizeof(void *). We don't typedef directly because we |
---|
68 | * have no idea what other typedefs have already been made. */ |
---|
69 | typedef signed char _caca_int8_t; |
---|
70 | typedef signed short _caca_int16_t; |
---|
71 | typedef signed long int _caca_int32_t; |
---|
72 | typedef signed long long int _caca_int64_t; |
---|
73 | # undef int8_t |
---|
74 | # define int8_t _caca_int8_t |
---|
75 | # undef int16_t |
---|
76 | # define int16_t _caca_int16_t |
---|
77 | # undef int32_t |
---|
78 | # define int32_t _caca_int32_t |
---|
79 | # undef int64_t |
---|
80 | # define int64_t _caca_int64_t |
---|
81 | typedef unsigned char _caca_uint8_t; |
---|
82 | typedef unsigned short _caca_uint16_t; |
---|
83 | typedef unsigned long int _caca_uint32_t; |
---|
84 | typedef unsigned long long int _caca_uint64_t; |
---|
85 | # undef uint8_t |
---|
86 | # define uint8_t _caca_uint8_t |
---|
87 | # undef uint16_t |
---|
88 | # define uint16_t _caca_uint16_t |
---|
89 | # undef uint32_t |
---|
90 | # define uint32_t _caca_uint32_t |
---|
91 | # undef uint64_t |
---|
92 | # define uint64_t _caca_uint64_t |
---|
93 | typedef long int _caca_intptr_t; |
---|
94 | typedef unsigned long int _caca_uintptr_t; |
---|
95 | # undef intptr_t |
---|
96 | # define intptr_t _caca_intptr_t |
---|
97 | # undef uintptr_t |
---|
98 | # define uintptr_t _caca_uintptr_t |
---|
99 | typedef int _caca_ssize_t; |
---|
100 | typedef unsigned int _caca_size_t; |
---|
101 | # undef ssize_t |
---|
102 | # define ssize_t _caca_ssize_t |
---|
103 | # undef size_t |
---|
104 | # define size_t _caca_size_t |
---|
105 | #endif |
---|
106 | |
---|
107 | #endif /* __CACA_TYPES_H__ */ |
---|
108 | |
---|