source: libpipi/trunk/pipi/pipi_types.h.in @ 4690

Last change on this file since 4690 was 4397, checked in by Sam Hocevar, 11 years ago

On Win32, define 32-bit C99 types as ints instead of longs, because
a lot of software (wrongly) assumes that int32_t is the same as int.

File size: 2.6 KB
Line 
1/*
2 *  libpipi       Pathetic image processing interface library
3 *  Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id$
7 *
8 *  This library is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14/*
15 *  This file contains definitions for the C99 integer types.
16 */
17
18#ifndef __PIPI_TYPES_H__
19#define __PIPI_TYPES_H__
20
21#ifndef PIPI_TYPES
22#   define PIPI_TYPES @PIPI_TYPES@
23#endif
24
25/* mode 1: standard <stdint.h> header is present, just include it */
26#if PIPI_TYPES == 1
27#   include <stdint.h>
28#   include <unistd.h>
29
30/* mode 2: standard <inttypes.h> header is present, just include it */
31#elif PIPI_TYPES == 2
32#   include <inttypes.h>
33#   include <unistd.h>
34
35/* mode 3: <windows.h> indicates Win32, only (u)intptr_t is present
36 * FIXME: Win64 probably doesn't work that way */
37#elif PIPI_TYPES == 3
38#include <windows.h>
39
40typedef signed char int8_t;
41typedef signed short int16_t;
42typedef signed int int32_t;
43typedef signed long long int int64_t;
44
45typedef unsigned char uint8_t;
46typedef unsigned short uint16_t;
47typedef unsigned int uint32_t;
48typedef unsigned long long int uint64_t;
49
50typedef int ssize_t;
51typedef unsigned int size_t;
52
53/* fallback: nothing is known, we assume the platform is 32-bit and
54 * sizeof(long) == sizeof(void *). We don't typedef directly because we
55 * have no idea what other typedefs have already been made. */
56#else
57typedef signed char _pipi_int8_t;
58typedef signed short _pipi_int16_t;
59typedef signed long int _pipi_int32_t;
60typedef signed long long int _pipi_int64_t;
61#   undef int8_t
62#   define int8_t _pipi_int8_t
63#   undef int16_t
64#   define int16_t _pipi_int16_t
65#   undef int32_t
66#   define int32_t _pipi_int32_t
67#   undef int64_t
68#   define int64_t _pipi_int64_t
69
70typedef unsigned char _pipi_uint8_t;
71typedef unsigned short _pipi_uint16_t;
72typedef unsigned long int _pipi_uint32_t;
73typedef unsigned long long int _pipi_uint64_t;
74#   undef uint8_t
75#   define uint8_t _pipi_uint8_t
76#   undef uint16_t
77#   define uint16_t _pipi_uint16_t
78#   undef uint32_t
79#   define uint32_t _pipi_uint32_t
80#   undef uint64_t
81#   define uint64_t _pipi_uint64_t
82
83typedef long int _pipi_intptr_t;
84typedef unsigned long int _pipi_uintptr_t;
85#   undef intptr_t
86#   define intptr_t _pipi_intptr_t
87#   undef uintptr_t
88#   define uintptr_t _pipi_uintptr_t
89
90typedef int _pipi_ssize_t;
91typedef unsigned int _pipi_size_t;
92#   undef ssize_t
93#   define ssize_t _pipi_ssize_t
94#   undef size_t
95#   define size_t _pipi_size_t
96
97#endif
98
99#endif /* __PIPI_TYPES_H__ */
100
Note: See TracBrowser for help on using the repository browser.