2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file MEM_sys_types.h
31 * A platform-independent definition of [u]intXX_t
32 * Plus the accompanying header include for htonl/ntohl
34 * This file includes <sys/types.h> to define [u]intXX_t types, where
35 * XX can be 8, 16, 32 or 64. Unfortunately, not all systems have this
37 * - Windows uses __intXX compiler-builtin types. These are signed,
38 * so we have to flip the signs.
39 * For these rogue platforms, we make the typedefs ourselves.
44 // DG: original BLO_sys_types.h is in source/blender/blenkernel
45 // but is not allowed be accessed here because of bad-level-call
46 // jesterKing: I've renamed this to MEM_sys_types.h, because otherwise
47 // doxygen would get a conflict
50 #ifndef __MEM_SYS_TYPES_H__
51 #define __MEM_SYS_TYPES_H__
57 #if defined(_WIN32) && !defined(FREE_WINDOWS)
59 /* The __intXX are built-in types of the visual complier! So we don't
60 * need to include anything else here. */
63 typedef signed __int8 int8_t;
64 typedef signed __int16 int16_t;
65 typedef signed __int32 int32_t;
66 typedef signed __int64 int64_t;
68 typedef unsigned __int8 uint8_t;
69 typedef unsigned __int16 uint16_t;
70 typedef unsigned __int32 uint32_t;
71 typedef unsigned __int64 uint64_t;
73 #ifndef _INTPTR_T_DEFINED
75 typedef __int64 intptr_t;
77 typedef long intptr_t;
79 #define _INTPTR_T_DEFINED
82 #ifndef _UINTPTR_T_DEFINED
84 typedef unsigned __int64 uintptr_t;
86 typedef unsigned long uintptr_t;
88 #define _UINTPTR_T_DEFINED
91 #elif defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
93 /* Linux-i386, Linux-Alpha, Linux-ppc */
99 # define UINT64_MAX 18446744073709551615
100 typedef uint8_t u_int8_t;
101 typedef uint16_t u_int16_t;
102 typedef uint32_t u_int32_t;
103 typedef uint64_t u_int64_t;
106 #elif defined (__APPLE__)
108 #include <inttypes.h>
110 #elif defined(FREE_WINDOWS)
111 #ifndef FREE_WINDOWS64
112 /* define htoln here, there must be a syntax error in winsock2.h in MinGW */
113 unsigned long __attribute__((__stdcall__)) htonl(unsigned long);
119 /* FreeBSD, Solaris */
120 #include <sys/types.h>
122 #endif /* ifdef platform for types */
128 #define htonl(x) correctByteOrder(x)
131 #define ntohl(x) correctByteOrder(x)
134 #elif defined (__FreeBSD__) || defined (__OpenBSD__)
135 #include <sys/param.h>
136 #elif defined (__APPLE__)
137 #include <sys/types.h>
138 #else /* sun linux */
139 #include <netinet/in.h>
140 #endif /* ifdef platform for htonl/ntohl */
146 #endif /* __MEM_SYS_TYPES_H__ */