Ruby: ext/fiddle/libffi-3.2.1/include/ffi_common.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

ffi_common.h
Go to the documentation of this file.
1/* -----------------------------------------------------------------------
2 ffi_common.h - Copyright (C) 2011, 2012, 2013 Anthony Green
3 Copyright (C) 2007 Free Software Foundation, Inc
4 Copyright (c) 1996 Red Hat, Inc.
5
6 Common internal definitions and macros. Only necessary for building
7 libffi.
8 ----------------------------------------------------------------------- */
9
10#ifndef FFI_COMMON_H
11#define FFI_COMMON_H
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#include <fficonfig.h>
18
19/* Do not move this. Some versions of AIX are very picky about where
20 this is positioned. */
21#ifdef __GNUC__
22# if HAVE_ALLOCA_H
23# include <alloca.h>
24# else
25 /* mingw64 defines this already in malloc.h. */
26# ifndef alloca
27# define alloca __builtin_alloca
28# endif
29# endif
30# define MAYBE_UNUSED __attribute__((__unused__))
31#else
32# define MAYBE_UNUSED
33# if HAVE_ALLOCA_H
34# include <alloca.h>
35# else
36# ifdef _AIX
37# pragma alloca
38# else
39# ifndef alloca /* predefined by HP cc +Olibcalls */
40# ifdef _MSC_VER
41# define alloca _alloca
42# else
43char *alloca ();
44# endif
45# endif
46# endif
47# endif
48#endif
49
50/* Check for the existence of memcpy. */
51#if STDC_HEADERS
52# include <string.h>
53#else
54# ifndef HAVE_MEMCPY
55# define memcpy(d, s, n) bcopy ((s), (d), (n))
56# endif
57#endif
58
59#if defined(FFI_DEBUG)
60#include <stdio.h>
61#endif
62
63#ifdef FFI_DEBUG
64void ffi_assert(char *expr, char *file, int line);
65void ffi_stop_here(void);
66void ffi_type_test(ffi_type *a, char *file, int line);
67
68#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
69#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
70#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
71#else
72#define FFI_ASSERT(x)
73#define FFI_ASSERT_AT(x, f, l)
74#define FFI_ASSERT_VALID_TYPE(x)
75#endif
76
77#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
78#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
79
80/* Perform machine dependent cif processing */
81ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
82ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
83 unsigned int nfixedargs, unsigned int ntotalargs);
84
85/* Extended cif, used in callback from assembly routine */
86 typedef struct
87{
88 ffi_cif *cif;
89 void *rvalue;
90 void **avalue;
91} extended_cif;
92
93/* Terse sized type definitions. */
94#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)
95 typedef unsigned char UINT8;
96 typedef signed char SINT8;
97 typedef unsigned short UINT16;
98 typedef signed short SINT16;
99 typedef unsigned int UINT32;
100 typedef signed int SINT32;
101# ifdef _MSC_VER
102 typedef unsigned __int64 UINT64;
103 typedef signed __int64 SINT64;
104# else
105# include <inttypes.h>
106typedef uint64_t UINT64;
107typedef int64_t SINT64;
108# endif
109#else
110typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
111typedef signed int SINT8 __attribute__((__mode__(__QI__)));
112typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
113typedef signed int SINT16 __attribute__((__mode__(__HI__)));
114typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
115typedef signed int SINT32 __attribute__((__mode__(__SI__)));
116typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
117typedef signed int SINT64 __attribute__((__mode__(__DI__)));
118#endif
119
120 typedef float FLOAT32;
121
122#ifndef __GNUC__
123#define __builtin_expect(x, expected_value) (x)
124#endif
125#define LIKELY(x) __builtin_expect(!!(x),1)
126#define UNLIKELY(x) __builtin_expect((x)!=0,0)
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif
ffi_type_test
void ffi_type_test(ffi_type *a, char *file, int line)
Definition: debug.c:50
ffi_stop_here
void ffi_stop_here(void)
Definition: debug.c:32
ffi_assert
void ffi_assert(char *expr, char *file, int line)
Definition: debug.c:41
UINT16
unsigned short UINT16
Definition: ffi_common.h:97
SINT64
signed __int64 SINT64
Definition: ffi_common.h:103
SINT16
signed short SINT16
Definition: ffi_common.h:98
alloca
#define alloca
Definition: ffi_common.h:27
SINT32
signed int SINT32
Definition: ffi_common.h:100
ffi_prep_cif_machdep_var
ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsigned int ntotalargs)
Definition: ffi.c:289
FLOAT32
float FLOAT32
Definition: ffi_common.h:120
ffi_prep_cif_machdep
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
Definition: ffi.c:758
SINT8
signed char SINT8
Definition: ffi_common.h:96
UINT64
unsigned __int64 UINT64
Definition: ffi_common.h:102
UINT8
unsigned char UINT8
Definition: ffi_common.h:95
UINT32
unsigned int UINT32
Definition: ffi_common.h:99
fficonfig.h
__attribute__
void *PTR64 __attribute__((mode(DI)))
Definition: ffi.c:41
inttypes.h
C99 shim for <inttypes.h>
uint64_t
unsigned long long uint64_t
Definition: sha2.h:102
extended_cif
Definition: ffi_common.h:87
extended_cif::rvalue
void * rvalue
Definition: ffi_common.h:89
extended_cif::cif
ffi_cif * cif
Definition: ffi_common.h:88
extended_cif::avalue
void ** avalue
Definition: ffi_common.h:90
file
Definition: gzappend.c:170