stdint.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  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. #ifndef STDINT_WIN32_H
  21. #define STDINT_WIN32_H
  22. #include <wtf/Platform.h>
  23. /* This file emulates enough of stdint.h on Windows to make JavaScriptCore and WebCore
  24. compile using MSVC which does not ship with the stdint.h header. */
  25. #if !COMPILER(MSVC)
  26. #error "This stdint.h file should only be compiled with MSVC"
  27. #endif
  28. #include <limits.h>
  29. typedef unsigned char uint8_t;
  30. typedef signed char int8_t;
  31. typedef unsigned short uint16_t;
  32. typedef short int16_t;
  33. typedef unsigned int uint32_t;
  34. typedef int int32_t;
  35. typedef __int64 int64_t;
  36. typedef unsigned __int64 uint64_t;
  37. #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
  38. #ifndef SIZE_MAX
  39. #ifdef _WIN64
  40. #define SIZE_MAX _UI64_MAX
  41. #else
  42. #define SIZE_MAX _UI32_MAX
  43. #endif
  44. #endif
  45. #endif
  46. #ifndef CASSERT
  47. #define CASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
  48. #endif
  49. CASSERT(sizeof(int8_t) == 1, int8_t_is_one_byte)
  50. CASSERT(sizeof(uint8_t) == 1, uint8_t_is_one_byte)
  51. CASSERT(sizeof(int16_t) == 2, int16_t_is_two_bytes)
  52. CASSERT(sizeof(uint16_t) == 2, uint16_t_is_two_bytes)
  53. CASSERT(sizeof(int32_t) == 4, int32_t_is_four_bytes)
  54. CASSERT(sizeof(uint32_t) == 4, uint32_t_is_four_bytes)
  55. CASSERT(sizeof(int64_t) == 8, int64_t_is_eight_bytes)
  56. CASSERT(sizeof(uint64_t) == 8, uint64_t_is_eight_bytes)
  57. #endif