Sha256: e6701c4405428d46c7073d5fb4019db54435ef802504c63bdb12bf8f10a6c0c6

Contents?: true

Size: 1.68 KB

Versions: 93

Compression:

Stored size: 1.68 KB

Contents

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <ffi.h>
#include "fficonfig.h"

#define MAX_ARGS 256


/* Define __UNUSED__ that also other compilers than gcc can run the tests.  */
#undef __UNUSED__
#if defined(__GNUC__)
#define __UNUSED__ __attribute__((__unused__))
#else
#define __UNUSED__
#endif

#define CHECK(x) (!(x) ? abort() : (void)0)

/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
   file open.  */
#ifdef HAVE_MMAP_ANON
# undef HAVE_MMAP_DEV_ZERO

# include <sys/mman.h>
# ifndef MAP_FAILED
#  define MAP_FAILED -1
# endif
# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
#  define MAP_ANONYMOUS MAP_ANON
# endif
# define USING_MMAP

#endif

#ifdef HAVE_MMAP_DEV_ZERO

# include <sys/mman.h>
# ifndef MAP_FAILED
#  define MAP_FAILED -1
# endif
# define USING_MMAP

#endif


/* MinGW kludge.  */
#ifdef _WIN64
#define PRIdLL "I64d"
#define PRIuLL "I64u"
#else
#define PRIdLL "lld"
#define PRIuLL "llu"
#endif

#ifdef USING_MMAP
static inline void *
allocate_mmap (size_t size)
{
  void *page;
#if defined (HAVE_MMAP_DEV_ZERO)
  static int dev_zero_fd = -1;
#endif

#ifdef HAVE_MMAP_DEV_ZERO
  if (dev_zero_fd == -1)
    {
      dev_zero_fd = open ("/dev/zero", O_RDONLY);
      if (dev_zero_fd == -1)
	{
	  perror ("open /dev/zero: %m");
	  exit (1);
	}
    }
#endif


#ifdef HAVE_MMAP_ANON
  page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
	       MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#endif
#ifdef HAVE_MMAP_DEV_ZERO
  page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
	       MAP_PRIVATE, dev_zero_fd, 0);
#endif

  if (page == MAP_FAILED)
    {
      perror ("virtual memory exhausted");
      exit (1);
    }

  return page;
}

#endif

Version data entries

93 entries across 91 versions & 8 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.7.4 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.7.3 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.7.2 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.7.1 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.7.0 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
ffi-0.6.4 ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.9 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.8 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.7 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.6 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.5 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.4 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.3 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.2 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.1 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.6.0 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.5.17 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.5.16 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h
classiccms-0.5.15 vendor/bundle/gems/ffi-1.0.11/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h