(root)/
gcc-13.2.0/
libffi/
testsuite/
libffi.call/
ffitest.h
       1  #include <stdlib.h>
       2  #include <stdio.h>
       3  #include <string.h>
       4  #include <fcntl.h>
       5  #include <ffi.h>
       6  #include "fficonfig.h"
       7  
       8  #if defined HAVE_STDINT_H
       9  #include <stdint.h>
      10  #endif
      11  
      12  #if defined HAVE_INTTYPES_H
      13  #include <inttypes.h>
      14  #endif
      15  
      16  #define MAX_ARGS 256
      17  
      18  #define CHECK(x) \
      19     do { \
      20        if(!(x)){ \
      21           printf("Check failed:\n%s\n", #x); \
      22           abort(); \
      23        } \
      24     } while(0)
      25  
      26  /* Define macros so that compilers other than gcc can run the tests.  */
      27  #undef __UNUSED__
      28  #if defined(__GNUC__)
      29  #define __UNUSED__ __attribute__((__unused__))
      30  #define __STDCALL__ __attribute__((stdcall))
      31  #define __THISCALL__ __attribute__((thiscall))
      32  #define __FASTCALL__ __attribute__((fastcall))
      33  #define __MSABI__ __attribute__((ms_abi))
      34  #else
      35  #define __UNUSED__
      36  #define __STDCALL__ __stdcall
      37  #define __THISCALL__ __thiscall
      38  #define __FASTCALL__ __fastcall
      39  #endif
      40  
      41  #ifndef ABI_NUM
      42  #define ABI_NUM FFI_DEFAULT_ABI
      43  #define ABI_ATTR
      44  #endif
      45  
      46  /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
      47     file open.  */
      48  #ifdef HAVE_MMAP_ANON
      49  # undef HAVE_MMAP_DEV_ZERO
      50  
      51  # include <sys/mman.h>
      52  # ifndef MAP_FAILED
      53  #  define MAP_FAILED -1
      54  # endif
      55  # if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
      56  #  define MAP_ANONYMOUS MAP_ANON
      57  # endif
      58  # define USING_MMAP
      59  
      60  #endif
      61  
      62  #ifdef HAVE_MMAP_DEV_ZERO
      63  
      64  # include <sys/mman.h>
      65  # ifndef MAP_FAILED
      66  #  define MAP_FAILED -1
      67  # endif
      68  # define USING_MMAP
      69  
      70  #endif
      71  
      72  /* MinGW kludge.  */
      73  #if defined(_WIN64) | defined(_WIN32)
      74  #define PRIdLL "I64d"
      75  #define PRIuLL "I64u"
      76  #else
      77  #define PRIdLL "lld"
      78  #define PRIuLL "llu"
      79  #endif
      80  
      81  /* Tru64 UNIX kludge.  */
      82  #if defined(__alpha__) && defined(__osf__)
      83  /* Tru64 UNIX V4.0 doesn't support %lld/%lld, but long is 64-bit.  */
      84  #undef PRIdLL
      85  #define PRIdLL "ld"
      86  #undef PRIuLL
      87  #define PRIuLL "lu"
      88  #define PRId8 "hd"
      89  #define PRIu8 "hu"
      90  #define PRId64 "ld"
      91  #define PRIu64 "lu"
      92  #define PRIuPTR "lu"
      93  #endif
      94  
      95  /* PA HP-UX kludge.  */
      96  #if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR)
      97  #define PRIuPTR "lu"
      98  #endif
      99  
     100  /* IRIX kludge.  */
     101  #if defined(__sgi)
     102  /* IRIX 6.5 <inttypes.h> provides all definitions, but only for C99
     103     compilations.  */
     104  #define PRId8 "hhd"
     105  #define PRIu8 "hhu"
     106  #if (_MIPS_SZLONG == 32)
     107  #define PRId64 "lld"
     108  #define PRIu64 "llu"
     109  #endif
     110  /* This doesn't match <inttypes.h>, which always has "lld" here, but the
     111     arguments are uint64_t, int64_t, which are unsigned long, long for
     112     64-bit in <sgidefs.h>.  */
     113  #if (_MIPS_SZLONG == 64)
     114  #define PRId64 "ld"
     115  #define PRIu64 "lu"
     116  #endif
     117  /* This doesn't match <inttypes.h>, which has "u" here, but the arguments
     118     are uintptr_t, which is always unsigned long.  */
     119  #define PRIuPTR "lu"
     120  #endif
     121  
     122  /* Solaris < 10 kludge.  */
     123  #if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR)
     124  #if defined(__arch64__) || defined (__x86_64__)
     125  #define PRIuPTR "lu"
     126  #else
     127  #define PRIuPTR "u"
     128  #endif
     129  #endif
     130  
     131  /* MSVC kludge.  */
     132  #if defined _MSC_VER
     133  #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
     134  #define PRIuPTR "lu"
     135  #define PRIu8 "u"
     136  #define PRId8 "d"
     137  #define PRIu64 "I64u"
     138  #define PRId64 "I64d"
     139  #endif
     140  #endif
     141  
     142  #ifndef PRIuPTR
     143  #define PRIuPTR "u"
     144  #endif