PageRenderTime 56ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/pypy/translator/c/src/commondefs.h

https://bitbucket.org/dac_io/pypy
C++ Header | 119 lines | 67 code | 22 blank | 30 comment | 18 complexity | 1ae07d85aa9b00777e5840acc7c913a9 MD5 | raw file
  1. /************************************************************/
  2. /*** C header subsection: common types and macros ***/
  3. /* We only support the following two kinds of platform:
  4. int long long long void*
  5. --32-bit-- 32 32 64 32
  6. --64-bit-- 32 64 64 64
  7. In particular, Win64 is not supported because it has sizeof(long) == 4.
  8. To fix this, find and review all the places that cast a pointer to a long.
  9. Update:
  10. We are trying to lift this restriction for Win64:
  11. Win64 int long long long void*
  12. --64-bit-- 32 32 64 64
  13. The migration to this platform is complicated and tedious, because
  14. PyPy assumes that a void* fits into a long. Therefore, the created PyPy
  15. will (first) have a 64 bit int type. The dependency of sys.maxint must
  16. be removed in very many places, and the distinction between Python int
  17. and long must be changed in explicit range checks.
  18. This is work in progress with first successes.
  19. */
  20. #include <limits.h>
  21. #ifndef LLONG_MAX
  22. #define LLONG_MAX __LONG_LONG_MAX__
  23. #endif
  24. #ifndef LLONG_MIN
  25. #define LLONG_MIN (-LLONG_MAX - 1LL)
  26. #endif
  27. #if INT_MAX != 2147483647
  28. # error "unsupported value for INT_MAX"
  29. #endif
  30. #if INT_MIN != -2147483647-1
  31. # error "unsupported value for INT_MIN"
  32. #endif
  33. #if LLONG_MAX != 9223372036854775807LL
  34. # error "unsupported value for LLONG_MAX"
  35. #endif
  36. #if LLONG_MIN != -9223372036854775807LL-1LL
  37. # error "unsupported value for LLONG_MIN"
  38. #endif
  39. /******************** 32-bit support ********************/
  40. #if PYPY_LONG_BIT == 32
  41. # if LONG_MAX != 2147483647L
  42. # error "error in LONG_MAX (32-bit sources but a 64-bit compiler?)"
  43. # endif
  44. # if LONG_MIN != -2147483647L-1L
  45. # error "unsupported value for LONG_MIN"
  46. # endif
  47. # define SIZEOF_INT 4
  48. # define SIZEOF_LONG 4
  49. # define SIZEOF_LONG_LONG 8
  50. /******************** 64-bit support ********************/
  51. #else
  52. # ifndef _WIN64
  53. # if LONG_MAX != 9223372036854775807L
  54. # error "error in LONG_MAX (64-bit sources but a 32-bit compiler?)"
  55. # endif
  56. # if LONG_MIN != -9223372036854775807L-1L
  57. # error "unsupported value for LONG_MIN"
  58. # endif
  59. # define SIZEOF_INT 4
  60. # define SIZEOF_LONG 8
  61. # define SIZEOF_LONG_LONG 8
  62. /******************** Win-64 support ********************/
  63. # else
  64. # if LONG_MAX != 2147483647L
  65. # error "error in LONG_MAX (64-bit sources but incompatible compiler?)"
  66. # endif
  67. # if LONG_MIN != -2147483647L-1L
  68. # error "unsupported value for LONG_MIN"
  69. # endif
  70. # define SIZEOF_INT 4
  71. # define SIZEOF_LONG 4
  72. # define SIZEOF_LONG_LONG 8
  73. # endif
  74. #endif
  75. /********************************************************/
  76. #if ((-1) >> 1) > 0
  77. # define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
  78. ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J))
  79. #elif ((-1) >> 1) == -1
  80. # define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
  81. #else
  82. # error "uh? strange result"
  83. #endif
  84. #define HAVE_LONG_LONG 1
  85. #define Py_HUGE_VAL HUGE_VAL
  86. #ifdef _WIN32
  87. #ifndef MS_WINDOWS
  88. # define MS_WINDOWS /* a synonym */
  89. #endif
  90. #endif