beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-wideint-type-private.h
blob84a3cbab0d204dedb63701e5f2822e74e3633461
1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2004 Keith Packard
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Keith Packard
32 * Contributor(s):
33 * Keith R. Packard <keithp@keithp.com>
37 #ifndef CAIRO_WIDEINT_TYPE_H
38 #define CAIRO_WIDEINT_TYPE_H
40 #include "cairo.h"
42 #if HAVE_CONFIG_H
43 #include "config.h"
44 #endif
46 #if HAVE_STDINT_H
47 # include <stdint.h>
48 #elif HAVE_INTTYPES_H
49 # include <inttypes.h>
50 #elif HAVE_SYS_INT_TYPES_H
51 # include <sys/int_types.h>
52 #elif defined(_MSC_VER)
53 typedef __int8 int8_t;
54 typedef unsigned __int8 uint8_t;
55 typedef __int16 int16_t;
56 typedef unsigned __int16 uint16_t;
57 typedef __int32 int32_t;
58 typedef unsigned __int32 uint32_t;
59 typedef __int64 int64_t;
60 typedef unsigned __int64 uint64_t;
61 # ifndef HAVE_UINT64_T
62 # define HAVE_UINT64_T 1
63 # endif
64 #else
65 #error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
66 #endif
68 #ifndef INT16_MIN
69 # define INT16_MIN (-32767-1)
70 #endif
71 #ifndef INT16_MAX
72 # define INT16_MAX (32767)
73 #endif
74 #ifndef UINT16_MAX
75 # define UINT16_MAX (65535)
76 #endif
77 #ifndef INT32_MIN
78 # define INT32_MIN (-2147483647-1)
79 #endif
80 #ifndef INT32_MAX
81 # define INT32_MAX (2147483647)
82 #endif
83 #ifndef UINT32_MAX
84 # define UINT32_MAX (4294967295U)
85 #endif
87 #if HAVE_BYTESWAP_H
88 # include <byteswap.h>
89 #endif
90 #ifndef bswap_16
91 # define bswap_16(p) \
92 (((((uint16_t)(p)) & 0x00ff) << 8) | \
93 (((uint16_t)(p)) >> 8));
94 #endif
95 #ifndef bswap_32
96 # define bswap_32(p) \
97 (((((uint32_t)(p)) & 0x000000ff) << 24) | \
98 ((((uint32_t)(p)) & 0x0000ff00) << 8) | \
99 ((((uint32_t)(p)) & 0x00ff0000) >> 8) | \
100 ((((uint32_t)(p))) >> 24));
101 #endif
104 #if !HAVE_UINT64_T
106 typedef struct _cairo_uint64 {
107 uint32_t lo, hi;
108 } cairo_uint64_t, cairo_int64_t;
110 #else
112 typedef uint64_t cairo_uint64_t;
113 typedef int64_t cairo_int64_t;
115 #endif
117 typedef struct _cairo_uquorem64 {
118 cairo_uint64_t quo;
119 cairo_uint64_t rem;
120 } cairo_uquorem64_t;
122 typedef struct _cairo_quorem64 {
123 cairo_int64_t quo;
124 cairo_int64_t rem;
125 } cairo_quorem64_t;
127 /* gcc has a non-standard name. */
128 #if HAVE___UINT128_T && !HAVE_UINT128_T
129 typedef __uint128_t uint128_t;
130 typedef __int128_t int128_t;
131 #define HAVE_UINT128_T 1
132 #endif
134 #if !HAVE_UINT128_T
136 typedef struct cairo_uint128 {
137 cairo_uint64_t lo, hi;
138 } cairo_uint128_t, cairo_int128_t;
140 #else
142 typedef uint128_t cairo_uint128_t;
143 typedef int128_t cairo_int128_t;
145 #endif
147 typedef struct _cairo_uquorem128 {
148 cairo_uint128_t quo;
149 cairo_uint128_t rem;
150 } cairo_uquorem128_t;
152 typedef struct _cairo_quorem128 {
153 cairo_int128_t quo;
154 cairo_int128_t rem;
155 } cairo_quorem128_t;
158 #endif /* CAIRO_WIDEINT_H */