Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/include/ffi_common.h
5986 views
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
/*
11
* ===========================================================================
12
* Copyright (c) 2021, 2021 IBM Corp. and others
13
* ===========================================================================
14
*/
15
16
#ifndef FFI_COMMON_H
17
#define FFI_COMMON_H
18
19
#ifdef __cplusplus
20
extern "C" {
21
#endif
22
23
#include <fficonfig.h>
24
25
/* Do not move this. Some versions of AIX are very picky about where
26
this is positioned. */
27
#ifdef __THW_370__
28
#include <stdlib.h>
29
#else
30
#ifdef __GNUC__
31
# if HAVE_ALLOCA_H
32
# include <alloca.h>
33
# else
34
/* mingw64 defines this already in malloc.h. */
35
# ifndef alloca
36
# define alloca __builtin_alloca
37
# endif
38
# endif
39
# define MAYBE_UNUSED __attribute__((__unused__))
40
#else
41
# define MAYBE_UNUSED
42
# if HAVE_ALLOCA_H
43
# include <alloca.h>
44
# else
45
# ifdef _AIX
46
# pragma alloca
47
# else
48
# ifndef alloca /* predefined by HP cc +Olibcalls */
49
# ifdef _MSC_VER
50
# define alloca _alloca
51
# else
52
char *alloca ();
53
# endif
54
# endif
55
# endif
56
# endif
57
#endif
58
#endif
59
60
/* Check for the existence of memcpy. */
61
#if STDC_HEADERS
62
# include <string.h>
63
#else
64
# ifndef HAVE_MEMCPY
65
# define memcpy(d, s, n) bcopy ((s), (d), (n))
66
# endif
67
#endif
68
69
#if defined(FFI_DEBUG)
70
#include <stdio.h>
71
#endif
72
73
#ifdef FFI_DEBUG
74
void ffi_assert(char *expr, char *file, int line);
75
void ffi_stop_here(void);
76
void ffi_type_test(ffi_type *a, char *file, int line);
77
78
#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
79
#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
80
#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
81
#else
82
#define FFI_ASSERT(x)
83
#define FFI_ASSERT_AT(x, f, l)
84
#define FFI_ASSERT_VALID_TYPE(x)
85
#endif
86
87
#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
88
#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
89
90
/* v cast to size_t and aligned up to a multiple of a */
91
#define FFI_ALIGN ALIGN
92
/* v cast to size_t and aligned down to a multiple of a */
93
#define FFI_ALIGN_DOWN ALIGN_DOWN
94
95
/* Perform machine dependent cif processing */
96
ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
97
ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
98
unsigned int nfixedargs, unsigned int ntotalargs);
99
100
/* Extended cif, used in callback from assembly routine */
101
typedef struct
102
{
103
ffi_cif *cif;
104
void *rvalue;
105
void **avalue;
106
} extended_cif;
107
108
/* Terse sized type definitions. */
109
#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C) || defined(__THW_370__)
110
typedef unsigned char UINT8;
111
typedef signed char SINT8;
112
typedef unsigned short UINT16;
113
typedef signed short SINT16;
114
typedef unsigned int UINT32;
115
typedef signed int SINT32;
116
# ifdef _MSC_VER
117
typedef unsigned __int64 UINT64;
118
typedef signed __int64 SINT64;
119
# else
120
# include <inttypes.h>
121
typedef uint64_t UINT64;
122
typedef int64_t SINT64;
123
# endif
124
#else
125
typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
126
typedef signed int SINT8 __attribute__((__mode__(__QI__)));
127
typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
128
typedef signed int SINT16 __attribute__((__mode__(__HI__)));
129
typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
130
typedef signed int SINT32 __attribute__((__mode__(__SI__)));
131
typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
132
typedef signed int SINT64 __attribute__((__mode__(__DI__)));
133
#endif
134
135
typedef float FLOAT32;
136
137
#if !defined(__GNUC__) || !defined(__THW_370__)
138
#define __builtin_expect(x, expected_value) (x)
139
#endif
140
#define LIKELY(x) __builtin_expect(!!(x),1)
141
#define UNLIKELY(x) __builtin_expect((x)!=0,0)
142
143
#ifdef __cplusplus
144
}
145
#endif
146
147
#endif
148
149