/Modules/_ctypes/libffi_osx/include/ffi_common.h

http://unladen-swallow.googlecode.com/ · C++ Header · 102 lines · 72 code · 15 blank · 15 comment · 1 complexity · 9c19f4410ff2245760080da84f61dc49 MD5 · raw file

  1. /* -----------------------------------------------------------------------
  2. ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
  3. Common internal definitions and macros. Only necessary for building
  4. libffi.
  5. ----------------------------------------------------------------------- */
  6. #ifndef FFI_COMMON_H
  7. #define FFI_COMMON_H
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #include "fficonfig.h"
  12. /* Do not move this. Some versions of AIX are very picky about where
  13. this is positioned. */
  14. #ifdef __GNUC__
  15. # define alloca __builtin_alloca
  16. #else
  17. # if HAVE_ALLOCA_H
  18. # include <alloca.h>
  19. # else
  20. # ifdef _AIX
  21. # pragma alloca
  22. # else
  23. # ifndef alloca /* predefined by HP cc +Olibcalls */
  24. char* alloca();
  25. # endif
  26. # endif
  27. # endif
  28. #endif
  29. /* Check for the existence of memcpy. */
  30. #if STDC_HEADERS
  31. # include <string.h>
  32. #else
  33. # ifndef HAVE_MEMCPY
  34. # define memcpy(d, s, n) bcopy((s), (d), (n))
  35. # endif
  36. #endif
  37. /*#if defined(FFI_DEBUG)
  38. #include <stdio.h>
  39. #endif*/
  40. #ifdef FFI_DEBUG
  41. #include <stdio.h>
  42. /*@exits@*/ void
  43. ffi_assert(
  44. /*@temp@*/ char* expr,
  45. /*@temp@*/ char* file,
  46. int line);
  47. void
  48. ffi_stop_here(void);
  49. void
  50. ffi_type_test(
  51. /*@temp@*/ /*@out@*/ ffi_type* a,
  52. /*@temp@*/ char* file,
  53. int line);
  54. # define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
  55. # define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
  56. # define FFI_ASSERT_VALID_TYPE(x) ffi_type_test(x, __FILE__, __LINE__)
  57. #else
  58. # define FFI_ASSERT(x)
  59. # define FFI_ASSERT_AT(x, f, l)
  60. # define FFI_ASSERT_VALID_TYPE(x)
  61. #endif // #ifdef FFI_DEBUG
  62. #define ALIGN(v, a) (((size_t)(v) + (a) - 1) & ~((a) - 1))
  63. /* Perform machine dependent cif processing */
  64. ffi_status
  65. ffi_prep_cif_machdep(
  66. ffi_cif* cif);
  67. /* Extended cif, used in callback from assembly routine */
  68. typedef struct extended_cif {
  69. /*@dependent@*/ ffi_cif* cif;
  70. /*@dependent@*/ void* rvalue;
  71. /*@dependent@*/ void** avalue;
  72. } extended_cif;
  73. /* Terse sized type definitions. */
  74. typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
  75. typedef signed int SINT8 __attribute__((__mode__(__QI__)));
  76. typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
  77. typedef signed int SINT16 __attribute__((__mode__(__HI__)));
  78. typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
  79. typedef signed int SINT32 __attribute__((__mode__(__SI__)));
  80. typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
  81. typedef signed int SINT64 __attribute__((__mode__(__DI__)));
  82. typedef float FLOAT32;
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif // #ifndef FFI_COMMON_H