ffitarget.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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(_M_ARM64)
  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_LAST_ABI,
  42. FFI_DEFAULT_ABI = FFI_SYSV
  43. } ffi_abi;
  44. #endif
  45. /* ---- Definitions for closures ----------------------------------------- */
  46. #define FFI_CLOSURES 1
  47. #define FFI_NATIVE_RAW_API 0
  48. #if defined (FFI_EXEC_TRAMPOLINE_TABLE) && FFI_EXEC_TRAMPOLINE_TABLE
  49. #ifdef __MACH__
  50. #define FFI_TRAMPOLINE_SIZE 16
  51. #define FFI_TRAMPOLINE_CLOSURE_OFFSET 16
  52. #else
  53. #error "No trampoline table implementation"
  54. #endif
  55. #else
  56. #define FFI_TRAMPOLINE_SIZE 24
  57. #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE
  58. #endif
  59. #ifdef _M_ARM64
  60. #define FFI_EXTRA_CIF_FIELDS unsigned is_variadic
  61. #endif
  62. /* ---- Internal ---- */
  63. #if defined (__APPLE__)
  64. #define FFI_TARGET_SPECIFIC_VARIADIC
  65. #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs
  66. #elif !defined(_M_ARM64)
  67. /* iOS and Windows reserve x18 for the system. Disable Go closures until
  68. a new static chain is chosen. */
  69. #define FFI_GO_CLOSURES 1
  70. #endif
  71. #ifndef _M_ARM64
  72. /* No complex type on Windows */
  73. #define FFI_TARGET_HAS_COMPLEX_TYPE
  74. #endif
  75. #endif