blob: b5dff56607cfb49b9295c786c8f52ddcad0d4a8d [file] [log] [blame]
darinc63e1942006-04-06 06:07:42 +00001/*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
darinf12397f2005-09-24 03:28:28 +000021#ifndef STDINT_WIN32_H
22#define STDINT_WIN32_H
23
jocelyn.turcotte@nokia.com0e3a2072010-03-25 11:20:41 +000024#include <wtf/Platform.h>
kmccullod129ead2006-10-04 18:36:29 +000025
eric@webkit.orgc9e560a2009-09-16 19:29:54 +000026/* This file emulates enough of stdint.h on Windows to make JavaScriptCore and WebCore
27 compile using MSVC which does not ship with the stdint.h header. */
kmccullod129ead2006-10-04 18:36:29 +000028
eric@webkit.orgc9e560a2009-09-16 19:29:54 +000029#if !COMPILER(MSVC)
30#error "This stdint.h file should only be compiled with MSVC"
darinf12397f2005-09-24 03:28:28 +000031#endif
darinc63e1942006-04-06 06:07:42 +000032
jchaffraix@webkit.org3e088612008-05-07 17:16:03 +000033#include <limits.h>
34
darinc63e1942006-04-06 06:07:42 +000035typedef unsigned char uint8_t;
36typedef signed char int8_t;
darinf12397f2005-09-24 03:28:28 +000037typedef unsigned short uint16_t;
38typedef short int16_t;
39typedef unsigned int uint32_t;
40typedef int int32_t;
darinc63e1942006-04-06 06:07:42 +000041typedef __int64 int64_t;
darinf12397f2005-09-24 03:28:28 +000042typedef unsigned __int64 uint64_t;
43
jchaffraix@webkit.org3e088612008-05-07 17:16:03 +000044#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
45#ifndef SIZE_MAX
46#ifdef _WIN64
47#define SIZE_MAX _UI64_MAX
48#else
49#define SIZE_MAX _UI32_MAX
50#endif
51#endif
52#endif
53
darinf12397f2005-09-24 03:28:28 +000054#ifndef CASSERT
darinc63e1942006-04-06 06:07:42 +000055#define CASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
darinf12397f2005-09-24 03:28:28 +000056#endif
57
darinc63e1942006-04-06 06:07:42 +000058CASSERT(sizeof(int8_t) == 1, int8_t_is_one_byte)
59CASSERT(sizeof(uint8_t) == 1, uint8_t_is_one_byte)
60CASSERT(sizeof(int16_t) == 2, int16_t_is_two_bytes)
61CASSERT(sizeof(uint16_t) == 2, uint16_t_is_two_bytes)
62CASSERT(sizeof(int32_t) == 4, int32_t_is_four_bytes)
63CASSERT(sizeof(uint32_t) == 4, uint32_t_is_four_bytes)
eric@webkit.org7d7ceda2010-03-29 17:31:53 +000064CASSERT(sizeof(int64_t) == 8, int64_t_is_eight_bytes)
65CASSERT(sizeof(uint64_t) == 8, uint64_t_is_eight_bytes)
darinf12397f2005-09-24 03:28:28 +000066
67#endif