/Modules/_ctypes/libffi/include/ffi_common.h

http://unladen-swallow.googlecode.com/ · C++ Header · 98 lines · 67 code · 18 blank · 13 comment · 1 complexity · 8dc0c5539602888ff32ddcc8fe0996f5 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. # define alloca __builtin_alloca
  17. # define MAYBE_UNUSED __attribute__((__unused__))
  18. #else
  19. # define MAYBE_UNUSED
  20. # if HAVE_ALLOCA_H
  21. # include <alloca.h>
  22. # else
  23. # ifdef _AIX
  24. #pragma alloca
  25. # else
  26. # ifndef alloca /* predefined by HP cc +Olibcalls */
  27. char *alloca ();
  28. # endif
  29. # endif
  30. # endif
  31. #endif
  32. /* Check for the existence of memcpy. */
  33. #if STDC_HEADERS
  34. # include <string.h>
  35. #else
  36. # ifndef HAVE_MEMCPY
  37. # define memcpy(d, s, n) bcopy ((s), (d), (n))
  38. # endif
  39. #endif
  40. #if defined(FFI_DEBUG)
  41. #include <stdio.h>
  42. #endif
  43. #ifdef FFI_DEBUG
  44. void ffi_assert(char *expr, char *file, int line);
  45. void ffi_stop_here(void);
  46. void ffi_type_test(ffi_type *a, char *file, int line);
  47. #define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
  48. #define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
  49. #define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
  50. #else
  51. #define FFI_ASSERT(x)
  52. #define FFI_ASSERT_AT(x, f, l)
  53. #define FFI_ASSERT_VALID_TYPE(x)
  54. #endif
  55. #define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
  56. #define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
  57. /* Perform machine dependent cif processing */
  58. ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
  59. /* Extended cif, used in callback from assembly routine */
  60. typedef struct
  61. {
  62. ffi_cif *cif;
  63. void *rvalue;
  64. void **avalue;
  65. } extended_cif;
  66. /* Terse sized type definitions. */
  67. typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
  68. typedef signed int SINT8 __attribute__((__mode__(__QI__)));
  69. typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
  70. typedef signed int SINT16 __attribute__((__mode__(__HI__)));
  71. typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
  72. typedef signed int SINT32 __attribute__((__mode__(__SI__)));
  73. typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
  74. typedef signed int SINT64 __attribute__((__mode__(__DI__)));
  75. typedef float FLOAT32;
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif