1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
18 * The Initial Developer of the Original Code is
19 * Jim Blandy <jimb@mozilla.org>
20 * Portions created by the Initial Developer are Copyright (C) 2009
21 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either of the GNU General Public License Version 2 or later (the "GPL"),
25 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
37 #ifndef jsinttypes_h___
38 #define jsinttypes_h___
40 #include "js-config.h"
44 * JSInt<N>, JSUint<N> (for <N> = 8, 16, 32, and 64)
47 * JSInt<N> and JSUint<N> are signed and unsigned types known to be
48 * <N> bits long. Note that neither JSInt8 nor JSUInt8 is necessarily
49 * equivalent to a plain "char".
51 * JSIntPtr and JSUintPtr are signed and unsigned types capable of
52 * holding an object pointer.
54 * Use these types in public SpiderMonkey header files, not the
55 * corresponding types from the C standard <stdint.h> header. Windows
56 * doesn't support <stdint.h>, and Microsoft says it has no plans to
57 * do so in the future; this means that projects that embed
58 * SpiderMonkey often take matters into their own hands and define the
59 * standard types themselves. If we define them in our public
60 * headers, our definitions may conflict with embedders' (see bug
61 * 479258). The JS* types are in our namespace, and can be used
62 * without troubling anyone.
64 * Internal SpiderMonkey code wishing to use the type names ISO C
65 * defines in the standard header <stdint.h> can #include
66 * "jsstdint.h", which provides those types regardless of whether
67 * <stdint.h> itself is available.
70 #if defined(JS_HAVE_STDINT_H)
74 typedef int8_t JSInt8
;
75 typedef int16_t JSInt16
;
76 typedef int32_t JSInt32
;
77 typedef int64_t JSInt64
;
78 typedef intptr_t JSIntPtr
;
80 typedef uint8_t JSUint8
;
81 typedef uint16_t JSUint16
;
82 typedef uint32_t JSUint32
;
83 typedef uint64_t JSUint64
;
84 typedef uintptr_t JSUintPtr
;
88 #if defined(JS_HAVE___INTN)
90 typedef __int8 JSInt8
;
91 typedef __int16 JSInt16
;
92 typedef __int32 JSInt32
;
93 typedef __int64 JSInt64
;
95 typedef unsigned __int8 JSUint8
;
96 typedef unsigned __int16 JSUint16
;
97 typedef unsigned __int32 JSUint32
;
98 typedef unsigned __int64 JSUint64
;
100 #elif defined(JS_INT8_TYPE)
102 typedef signed JS_INT8_TYPE JSInt8
;
103 typedef signed JS_INT16_TYPE JSInt16
;
104 typedef signed JS_INT32_TYPE JSInt32
;
105 typedef signed JS_INT64_TYPE JSInt64
;
107 typedef unsigned JS_INT8_TYPE JSUint8
;
108 typedef unsigned JS_INT16_TYPE JSUint16
;
109 typedef unsigned JS_INT32_TYPE JSUint32
;
110 typedef unsigned JS_INT64_TYPE JSUint64
;
113 #error "couldn't find exact-width integer types"
116 /* Microsoft Visual C/C++ defines intptr_t and uintptr_t in <stddef.h>. */
117 #if defined(JS_STDDEF_H_HAS_INTPTR_T)
119 typedef intptr_t JSIntPtr
;
120 typedef uintptr_t JSUintPtr
;
122 /* Windows Mobile defines intptr_t and uintptr_t in <crtdefs.h>. Why not? */
123 #elif defined(JS_CRTDEFS_H_HAS_INTPTR_T)
125 typedef intptr_t JSIntPtr
;
126 typedef uintptr_t JSUintPtr
;
128 /* Failing that, the configure script will have found something. */
129 #elif defined(JS_INTPTR_TYPE)
130 typedef signed JS_INTPTR_TYPE JSIntPtr
;
131 typedef unsigned JS_INTPTR_TYPE JSUintPtr
;
134 #error "couldn't find pointer-sized integer types"
137 #endif /* JS_HAVE_STDINT_H */
139 #endif /* jsinttypes_h___ */