1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef SU_TYPES_H
26 /** Defined when <sofia-sip/su_types.h> has been included */
27 #define SU_TYPES_H
28 /**@file sofia-sip/su_types.h Basic integer types for @b su library.
29  *
30  * This include file provides <stdint.h> or <inttypes.h> types.
31  *
32  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
33  * @date Created: Thu Mar 18 19:40:51 1999 pessi
34  */
35 
36 #ifndef SU_CONFIG_H
37 #include <sofia-sip/su_config.h>
38 #endif
39 
40 #if SU_HAVE_STDINT
41 #include <stdint.h>
42 #elif SU_HAVE_INTTYPES
43 #include <inttypes.h>
44 #endif
45 
46 #if SU_HAVE_SYS_TYPES
47 #include <sys/types.h>
48 #endif
49 
50 #include <stddef.h>
51 
52 SOFIA_BEGIN_DECLS
53 
54 #if SU_HAVE_STDINT || SU_HAVE_INTTYPES
55 #define SU_S64_T int64_t
56 #define SU_U64_T uint64_t
57 #define SU_S32_T int32_t
58 #define SU_U32_T uint32_t
59 #define SU_S16_T int16_t
60 #define SU_U16_T uint16_t
61 #define SU_S8_T  int8_t
62 #define SU_U8_T  uint8_t
63 #define SU_LEAST64_T int_least64_t
64 #define SU_LEAST32_T int_least32_t
65 #define SU_LEAST16_T int_least16_t
66 #define SU_LEAST8_T int_least8_t
67 #endif
68 
69 #if DOXYGEN_ONLY || (!SU_HAVE_STDINT && !SU_HAVE_INTTYPES && SU_HAVE_WIN32)
70 
71 /* Use macros defined in <sofia-sip/su_configure_win32.h> */
72 
73 #ifndef _INTPTR_T_DEFINED
74 /** Integer type large enough to store pointers */
75 typedef SU_INTPTR_T intptr_t;
76 #endif
77 #ifndef _UINTPTR_T_DEFINED
78 /** Unsigned integer type large enough to store pointers */
79 typedef unsigned SU_INTPTR_T uintptr_t;
80 #endif
81 
82 /** 64-bit unsigned integer */
83 typedef SU_U64_T uint64_t;
84 /** 64-bit signed integer */
85 typedef SU_S64_T int64_t;
86 /** 32-bit unsigned integer */
87 typedef SU_U32_T uint32_t;
88 /** 32-bit signed integer */
89 typedef SU_S32_T int32_t;
90 /** 16-bit unsigned integer */
91 typedef SU_U16_T uint16_t;
92 /** 16-bit signed integer */
93 typedef SU_S16_T int16_t;
94 /** 8-bit unsigned integer */
95 typedef SU_U8_T  uint8_t;
96 /** 8-bit signed integer */
97 typedef SU_S8_T  int8_t;
98 
99 /** At least 64-bit integer */
100 typedef SU_LEAST64_T int_least64_t;
101 /** At least 32-bit integer */
102 typedef SU_LEAST32_T int_least32_t;
103 /** At least 16-bit integer */
104 typedef SU_LEAST16_T int_least16_t;
105 /** At least 8-bit integer */
106 typedef SU_LEAST8_T int_least8_t;
107 #endif
108 
109 #if !SU_HAVE_STDINT && !SU_HAVE_INTTYPES && !SU_HAVE_WIN32
110 #error "no integer types available."
111 #endif
112 
113 /* ---------------------------------------------------------------------- */
114 /* size_t types for binary compatibility */
115 
116 #ifdef SOFIA_SSIZE_T
117 /** POSIX type used for a count of bytes or an error indication. */
118 typedef SOFIA_SSIZE_T ssize_t;
119 #endif
120 
121 #ifdef SOFIA_ISIZE_T
122 /** Compatibility type.
123  *
124  * sofia-sip <= 1.12.1 often used int for count of bytes.
125  * When configured for compatibility with sofia-sip 1.12.0, this is defined
126  * as int, otherwise as size_t. Note that int is signed and size_t is
127  * unsigned.
128  *
129  * @since New in @VERSION_1_12_2.
130  */
131 typedef SOFIA_ISIZE_T isize_t;
132 #else
133 typedef size_t isize_t;
134 #endif
135 
136 #ifdef SOFIA_ISSIZE_T
137 /**Compatibility type.
138  *
139  * sofia-sip <= 1.12.1 used int for count of bytes.
140  * When configured for compatibility with sofia-sip 1.12.0, this is defined
141  * as int, otherwise as ssize_t. (-1 is used for error indication).
142  *
143  * @since New in @VERSION_1_12_2.
144  */
145 typedef SOFIA_ISSIZE_T issize_t;
146 #else
147 typedef ssize_t issize_t;
148 #endif
149 
150 #ifdef SOFIA_USIZE_T
151 /**Compatibility type.
152  *
153  * sofia-sip <= 1.12.1 sometimes used unsigned int for count of bytes.
154  * When configured for compatibility with sofia-sip 1.12.0, this is defined
155  * as unsigned int, otherwise as size_t.
156  *
157  * @since New in @VERSION_1_12_2.
158  */
159 typedef SOFIA_USIZE_T usize_t;
160 #else
161 typedef size_t usize_t;
162 #endif
163 
164 SOFIA_END_DECLS
165 
166 #endif /* SU_TYPES_H */
167