/js/src/ctypes/libffi/include/ffi_common.h

http://github.com/zpao/v8monkey · C Header · 122 lines · 90 code · 18 blank · 14 comment · 2 complexity · 6ac39dc1d5ec4b22e08fbdc45913f9e1 MD5 · raw file

  1. /* -----------------------------------------------------------------------
  2. ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
  3. Copyright (C) 2007 Free Software Foundation, Inc
  4. Common internal definitions and macros. Only necessary for building
  5. libffi.
  6. ----------------------------------------------------------------------- */
  7. #ifndef FFI_COMMON_H
  8. #define FFI_COMMON_H
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #include <fficonfig.h>
  13. /* Do not move this. Some versions of AIX are very picky about where
  14. this is positioned. */
  15. #ifdef __GNUC__
  16. /* mingw64 defines this already in malloc.h. */
  17. #ifndef alloca
  18. # define alloca __builtin_alloca
  19. #endif
  20. # define MAYBE_UNUSED __attribute__((__unused__))
  21. #else
  22. # define MAYBE_UNUSED
  23. # if HAVE_ALLOCA_H
  24. # include <alloca.h>
  25. # else
  26. # ifdef _AIX
  27. #pragma alloca
  28. # else
  29. # ifndef alloca /* predefined by HP cc +Olibcalls */
  30. # ifdef _MSC_VER
  31. # define alloca _alloca
  32. # else
  33. char *alloca ();
  34. # endif
  35. # endif
  36. # endif
  37. # endif
  38. #endif
  39. /* Check for the existence of memcpy. */
  40. #if STDC_HEADERS
  41. # include <string.h>
  42. #else
  43. # ifndef HAVE_MEMCPY
  44. # define memcpy(d, s, n) bcopy ((s), (d), (n))
  45. # endif
  46. #endif
  47. #if defined(FFI_DEBUG)
  48. #include <stdio.h>
  49. #endif
  50. #ifdef FFI_DEBUG
  51. void ffi_assert(char *expr, char *file, int line);
  52. void ffi_stop_here(void);
  53. void ffi_type_test(ffi_type *a, char *file, 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
  62. #define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
  63. #define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
  64. /* Perform machine dependent cif processing */
  65. ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
  66. /* Extended cif, used in callback from assembly routine */
  67. typedef struct
  68. {
  69. ffi_cif *cif;
  70. void *rvalue;
  71. void **avalue;
  72. } extended_cif;
  73. /* Terse sized type definitions. */
  74. #if defined(_MSC_VER) || defined(__sgi)
  75. typedef unsigned char UINT8;
  76. typedef signed char SINT8;
  77. typedef unsigned short UINT16;
  78. typedef signed short SINT16;
  79. typedef unsigned int UINT32;
  80. typedef signed int SINT32;
  81. # ifdef _MSC_VER
  82. typedef unsigned __int64 UINT64;
  83. typedef signed __int64 SINT64;
  84. # else
  85. # include <inttypes.h>
  86. typedef uint64_t UINT64;
  87. typedef int64_t SINT64;
  88. # endif
  89. #else
  90. typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
  91. typedef signed int SINT8 __attribute__((__mode__(__QI__)));
  92. typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
  93. typedef signed int SINT16 __attribute__((__mode__(__HI__)));
  94. typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
  95. typedef signed int SINT32 __attribute__((__mode__(__SI__)));
  96. typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
  97. typedef signed int SINT64 __attribute__((__mode__(__DI__)));
  98. #endif
  99. typedef float FLOAT32;
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif