Home | History | Annotate | Download | only in include
      1 /* -----------------------------------------------------------------------
      2    ffi_common.h - Copyright (c) 1996  Red Hat, Inc.
      3    Copyright (C) 2007 Free Software Foundation, Inc
      4 
      5    Common internal definitions and macros. Only necessary for building
      6    libffi.
      7    ----------------------------------------------------------------------- */
      8 
      9 #ifndef FFI_COMMON_H
     10 #define FFI_COMMON_H
     11 
     12 #ifdef __cplusplus
     13 extern "C" {
     14 #endif
     15 
     16 #include <fficonfig.h>
     17 
     18 /* Do not move this. Some versions of AIX are very picky about where
     19    this is positioned. */
     20 #ifdef __GNUC__
     21 //# define alloca __builtin_alloca  /* ANDROID removed, clashes w/bionic */
     22 # include <alloca.h>                /* ANDROID added */
     23 # define MAYBE_UNUSED __attribute__((__unused__))
     24 #else
     25 # define MAYBE_UNUSED
     26 # if HAVE_ALLOCA_H
     27 #  include <alloca.h>
     28 # else
     29 #  ifdef _AIX
     30  #pragma alloca
     31 #  else
     32 #   ifndef alloca /* predefined by HP cc +Olibcalls */
     33 char *alloca ();
     34 #   endif
     35 #  endif
     36 # endif
     37 #endif
     38 
     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 
     48 #if defined(FFI_DEBUG)
     49 #include <stdio.h>
     50 #endif
     51 
     52 #ifdef FFI_DEBUG
     53 void ffi_assert(char *expr, char *file, int line);
     54 void ffi_stop_here(void);
     55 void ffi_type_test(ffi_type *a, char *file, int line);
     56 
     57 #define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
     58 #define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
     59 #define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
     60 #else
     61 #define FFI_ASSERT(x)
     62 #define FFI_ASSERT_AT(x, f, l)
     63 #define FFI_ASSERT_VALID_TYPE(x)
     64 #endif
     65 
     66 #define ALIGN(v, a)  (((((size_t) (v))-1) | ((a)-1))+1)
     67 #define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
     68 
     69 /* Perform machine dependent cif processing */
     70 ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
     71 
     72 /* Extended cif, used in callback from assembly routine */
     73 typedef struct
     74 {
     75   ffi_cif *cif;
     76   void *rvalue;
     77   void **avalue;
     78 } extended_cif;
     79 
     80 /* Terse sized type definitions.  */
     81 typedef unsigned int UINT8  __attribute__((__mode__(__QI__)));
     82 typedef signed int   SINT8  __attribute__((__mode__(__QI__)));
     83 typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
     84 typedef signed int   SINT16 __attribute__((__mode__(__HI__)));
     85 typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
     86 typedef signed int   SINT32 __attribute__((__mode__(__SI__)));
     87 typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
     88 typedef signed int   SINT64 __attribute__((__mode__(__DI__)));
     89 
     90 typedef float FLOAT32;
     91 
     92 
     93 #ifdef __cplusplus
     94 }
     95 #endif
     96 
     97 #endif
     98 
     99 
    100