ffitarget.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
  2. Permission is hereby granted, free of charge, to any person obtaining
  3. a copy of this software and associated documentation files (the
  4. ``Software''), to deal in the Software without restriction, including
  5. without limitation the rights to use, copy, modify, merge, publish,
  6. distribute, sublicense, and/or sell copies of the Software, and to
  7. permit persons to whom the Software is furnished to do so, subject to
  8. the following conditions:
  9. The above copyright notice and this permission notice shall be
  10. included in all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
  12. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  14. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  15. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  16. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  17. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  18. #ifndef LIBFFI_TARGET_H
  19. #define LIBFFI_TARGET_H
  20. #ifndef LIBFFI_H
  21. #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
  22. #endif
  23. #ifndef LIBFFI_ASM
  24. #ifdef __ILP32__
  25. #define FFI_SIZEOF_ARG 8
  26. #define FFI_SIZEOF_JAVA_RAW 4
  27. typedef unsigned long long ffi_arg;
  28. typedef signed long long ffi_sarg;
  29. #elif defined(_WIN32)
  30. #define FFI_SIZEOF_ARG 8
  31. typedef unsigned long long ffi_arg;
  32. typedef signed long long ffi_sarg;
  33. #else
  34. typedef unsigned long ffi_arg;
  35. typedef signed long ffi_sarg;
  36. #endif
  37. typedef enum ffi_abi
  38. {
  39. FFI_FIRST_ABI = 0,
  40. FFI_SYSV,
  41. FFI_WIN64,
  42. FFI_LAST_ABI,
  43. #if defined(_WIN32)
  44. FFI_DEFAULT_ABI = FFI_WIN64
  45. #else
  46. FFI_DEFAULT_ABI = FFI_SYSV
  47. #endif
  48. } ffi_abi;
  49. #endif
  50. /* ---- Definitions for closures ----------------------------------------- */
  51. #define FFI_CLOSURES 1
  52. #define FFI_NATIVE_RAW_API 0
  53. #if defined (FFI_EXEC_TRAMPOLINE_TABLE) && FFI_EXEC_TRAMPOLINE_TABLE
  54. #ifdef __MACH__
  55. #define FFI_TRAMPOLINE_SIZE 16
  56. #define FFI_TRAMPOLINE_CLOSURE_OFFSET 16
  57. #else
  58. #error "No trampoline table implementation"
  59. #endif
  60. #else
  61. #define FFI_TRAMPOLINE_SIZE 24
  62. #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE
  63. #endif
  64. #ifdef _WIN32
  65. #define FFI_EXTRA_CIF_FIELDS unsigned is_variadic
  66. #endif
  67. #define FFI_TARGET_SPECIFIC_VARIADIC
  68. /* ---- Internal ---- */
  69. #if defined (__APPLE__)
  70. #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs
  71. #elif !defined(_WIN32) && !defined(__ANDROID__)
  72. /* iOS, Windows and Android reserve x18 for the system. Disable Go closures until
  73. a new static chain is chosen. */
  74. #define FFI_GO_CLOSURES 1
  75. #endif
  76. #ifndef _WIN32
  77. /* No complex type on Windows */
  78. #define FFI_TARGET_HAS_COMPLEX_TYPE
  79. #endif
  80. #endif