/js/src/ctypes/libffi/src/x86/ffitarget.h

http://github.com/zpao/v8monkey · C Header · 121 lines · 71 code · 16 blank · 34 comment · 4 complexity · 14c1f7aebbfc39f17a9b79f9a421478e MD5 · raw file

  1. /* -----------------------------------------------------------------*-C-*-
  2. ffitarget.h - Copyright (c) 1996-2003, 2010 Red Hat, Inc.
  3. Copyright (C) 2008 Free Software Foundation, Inc.
  4. Target configuration macros for x86 and x86-64.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. ``Software''), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be included
  13. in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. DEALINGS IN THE SOFTWARE.
  22. ----------------------------------------------------------------------- */
  23. #ifndef LIBFFI_TARGET_H
  24. #define LIBFFI_TARGET_H
  25. /* ---- System specific configurations ----------------------------------- */
  26. /* For code common to all platforms on x86 and x86_64. */
  27. #define X86_ANY
  28. #if defined (X86_64) && defined (__i386__)
  29. #undef X86_64
  30. #define X86
  31. #endif
  32. #ifdef X86_WIN64
  33. #define FFI_SIZEOF_ARG 8
  34. #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
  35. #endif
  36. /* ---- Generic type definitions ----------------------------------------- */
  37. #ifndef LIBFFI_ASM
  38. #ifdef X86_WIN64
  39. #ifdef _MSC_VER
  40. typedef unsigned __int64 ffi_arg;
  41. typedef __int64 ffi_sarg;
  42. #else
  43. typedef unsigned long long ffi_arg;
  44. typedef long long ffi_sarg;
  45. #endif
  46. #else
  47. typedef unsigned long ffi_arg;
  48. typedef signed long ffi_sarg;
  49. #endif
  50. typedef enum ffi_abi {
  51. FFI_FIRST_ABI = 0,
  52. /* ---- Intel x86 Win32 ---------- */
  53. #ifdef X86_WIN32
  54. FFI_SYSV,
  55. FFI_STDCALL,
  56. FFI_LAST_ABI,
  57. /* TODO: Add fastcall support for the sake of completeness */
  58. FFI_DEFAULT_ABI = FFI_SYSV
  59. #elif defined(X86_WIN64)
  60. FFI_WIN64,
  61. FFI_LAST_ABI,
  62. FFI_DEFAULT_ABI = FFI_WIN64
  63. #else
  64. /* ---- Intel x86 and AMD x86-64 - */
  65. FFI_SYSV,
  66. FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
  67. FFI_LAST_ABI,
  68. #if defined(__i386__) || defined(__i386)
  69. FFI_DEFAULT_ABI = FFI_SYSV
  70. #else
  71. FFI_DEFAULT_ABI = FFI_UNIX64
  72. #endif
  73. #endif
  74. } ffi_abi;
  75. #endif
  76. /* ---- Definitions for closures ----------------------------------------- */
  77. #define FFI_CLOSURES 1
  78. #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
  79. #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
  80. #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
  81. #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
  82. #define FFI_TRAMPOLINE_SIZE 24
  83. #define FFI_NATIVE_RAW_API 0
  84. #else
  85. #ifdef X86_WIN32
  86. #define FFI_TRAMPOLINE_SIZE 13
  87. #else
  88. #ifdef X86_WIN64
  89. #define FFI_TRAMPOLINE_SIZE 29
  90. #define FFI_NATIVE_RAW_API 0
  91. #define FFI_NO_RAW_API 1
  92. #else
  93. #define FFI_TRAMPOLINE_SIZE 10
  94. #endif
  95. #endif
  96. #ifndef X86_WIN64
  97. #define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
  98. #endif
  99. #endif
  100. #endif