su_types.h 4.34 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

Pekka Pessi's avatar
Pekka Pessi committed
25 26
#ifndef SU_TYPES_H
/** Defined when <sofia-sip/su_types.h> has been included */
Pekka Pessi's avatar
Pekka Pessi committed
27
#define SU_TYPES_H
Pekka Pessi's avatar
Pekka Pessi committed
28
/**@file sofia-sip/su_types.h Basic integer types for @b su library.
Pekka Pessi's avatar
Pekka Pessi committed
29 30
 *
 * This include file provides <stdint.h> or <inttypes.h> types.
31
 *
Pekka Pessi's avatar
Pekka Pessi committed
32 33 34 35 36
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 * @date Created: Thu Mar 18 19:40:51 1999 pessi
 */

#ifndef SU_CONFIG_H
37
#include <sofia-sip/su_config.h>
Pekka Pessi's avatar
Pekka Pessi committed
38 39 40 41 42 43 44 45 46 47 48 49
#endif

#if SU_HAVE_STDINT
#include <stdint.h>
#elif SU_HAVE_INTTYPES
#include <inttypes.h>
#endif

#if SU_HAVE_SYS_TYPES
#include <sys/types.h>
#endif

50 51
#include <stddef.h>

52 53
SOFIA_BEGIN_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
54 55 56 57 58 59 60 61 62
#if SU_HAVE_STDINT || SU_HAVE_INTTYPES
#define SU_S64_T int64_t
#define SU_U64_T uint64_t
#define SU_S32_T int32_t
#define SU_U32_T uint32_t
#define SU_S16_T int16_t
#define SU_U16_T uint16_t
#define SU_S8_T  int8_t
#define SU_U8_T  uint8_t
63 64 65 66
#define SU_LEAST64_T int_least64_t
#define SU_LEAST32_T int_least32_t
#define SU_LEAST16_T int_least16_t
#define SU_LEAST8_T int_least8_t
67 68 69 70
#endif

#if DOXYGEN_ONLY || (!SU_HAVE_STDINT && !SU_HAVE_INTTYPES && SU_HAVE_WIN32)

Pekka Pessi's avatar
Pekka Pessi committed
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 */
Pekka Pessi's avatar
Pekka Pessi committed
75
typedef SU_INTPTR_T intptr_t;
76
#endif
77
#ifndef _UINTPTR_T_DEFINED
78
/** Unsigned integer type large enough to store pointers */
79 80 81
typedef unsigned SU_INTPTR_T uintptr_t;
#endif

82
/** 64-bit unsigned integer */
Pekka Pessi's avatar
Pekka Pessi committed
83
typedef SU_U64_T uint64_t;
84
/** 64-bit signed integer */
Pekka Pessi's avatar
Pekka Pessi committed
85
typedef SU_S64_T int64_t;
86
/** 32-bit unsigned integer */
Pekka Pessi's avatar
Pekka Pessi committed
87
typedef SU_U32_T uint32_t;
88
/** 32-bit signed integer */
Pekka Pessi's avatar
Pekka Pessi committed
89
typedef SU_S32_T int32_t;
90
/** 16-bit unsigned integer */
Pekka Pessi's avatar
Pekka Pessi committed
91
typedef SU_U16_T uint16_t;
92
/** 16-bit signed integer */
Pekka Pessi's avatar
Pekka Pessi committed
93
typedef SU_S16_T int16_t;
94
/** 8-bit unsigned integer */
Pekka Pessi's avatar
Pekka Pessi committed
95
typedef SU_U8_T  uint8_t;
96
/** 8-bit signed integer */
Pekka Pessi's avatar
Pekka Pessi committed
97
typedef SU_S8_T  int8_t;
98 99 100 101 102 103 104 105 106

/** At least 64-bit integer */
typedef SU_LEAST64_T int_least64_t;
/** At least 32-bit integer */
typedef SU_LEAST32_T int_least32_t;
/** At least 16-bit integer */
typedef SU_LEAST16_T int_least16_t;
/** At least 8-bit integer */
typedef SU_LEAST8_T int_least8_t;
107 108 109
#endif

#if !SU_HAVE_STDINT && !SU_HAVE_INTTYPES && !SU_HAVE_WIN32
Pekka Pessi's avatar
Pekka Pessi committed
110 111 112
#error "no integer types available."
#endif

113 114 115 116
/* ---------------------------------------------------------------------- */
/* size_t types for binary compatibility */

#ifdef SOFIA_SSIZE_T
117
/** POSIX type used for a count of bytes or an error indication. */
118 119 120 121
typedef SOFIA_SSIZE_T ssize_t;
#endif

#ifdef SOFIA_ISIZE_T
122
/** Compatibility type.
123
 *
124
 * sofia-sip <= 1.12.1 often used int for count of bytes.
125 126 127
 * When configured for compatibility with sofia-sip 1.12.0, this is defined
 * as int, otherwise as size_t. Note that int is signed and size_t is
 * unsigned.
128 129
 *
 * @since New in @VERSION_1_12_2.
130
 */
131 132 133 134 135 136
typedef SOFIA_ISIZE_T isize_t;
#else
typedef size_t isize_t;
#endif

#ifdef SOFIA_ISSIZE_T
137
/**Compatibility type.
138
 *
139
 * sofia-sip <= 1.12.1 used int for count of bytes.
140 141
 * When configured for compatibility with sofia-sip 1.12.0, this is defined
 * as int, otherwise as ssize_t. (-1 is used for error indication).
142 143
 *
 * @since New in @VERSION_1_12_2.
144
 */
145 146 147 148 149 150
typedef SOFIA_ISSIZE_T issize_t;
#else
typedef ssize_t issize_t;
#endif

#ifdef SOFIA_USIZE_T
151
/**Compatibility type.
152
 *
153
 * sofia-sip <= 1.12.1 sometimes used unsigned int for count of bytes.
154 155
 * When configured for compatibility with sofia-sip 1.12.0, this is defined
 * as unsigned int, otherwise as size_t.
156 157
 *
 * @since New in @VERSION_1_12_2.
158
 */
159 160 161 162 163
typedef SOFIA_USIZE_T usize_t;
#else
typedef size_t usize_t;
#endif

164 165
SOFIA_END_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
166
#endif /* SU_TYPES_H */