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