blob: 46bb06d642d056c7f5cfe4619107dfeb4a12f25d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2010-2016. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* %CopyrightEnd%
*/
/*
* Common structures for both erl_driver.h and erl_nif.h
*/
#ifndef __ERL_DRV_NIF_H__
#define __ERL_DRV_NIF_H__
typedef struct {
int driver_major_version;
int driver_minor_version;
char *erts_version;
char *otp_release;
int thread_support;
int smp_support;
int async_threads;
int scheduler_threads;
int nif_major_version;
int nif_minor_version;
int dirty_scheduler_support;
} ErlDrvSysInfo;
typedef struct {
int suggested_stack_size;
} ErlDrvThreadOpts;
typedef enum {
ERL_DIRTY_JOB_CPU_BOUND = 1,
ERL_DIRTY_JOB_IO_BOUND = 2
} ErlDirtyJobFlags;
/* Values for enif_select AND mode arg for driver_select() */
enum ErlNifSelectFlags {
ERL_NIF_SELECT_READ = (1 << 0),
ERL_NIF_SELECT_WRITE = (1 << 1),
ERL_NIF_SELECT_STOP = (1 << 2)
};
enum ErlNifSelectReturn {
ERL_NIF_SELECT_ERROR = (1 << 0),
ERL_NIF_SELECT_STOP_CALLED = (1 << 1),
ERL_NIF_SELECT_STOP_SCHEDULED = (1 << 2),
ERL_NIF_SELECT_INVALID_EVENT = (1 << 3),
ERL_NIF_SELECT_FAILED = (1 << 4)
};
#ifdef SIZEOF_CHAR
# define SIZEOF_CHAR_SAVED__ SIZEOF_CHAR
# undef SIZEOF_CHAR
#endif
#ifdef SIZEOF_SHORT
# define SIZEOF_SHORT_SAVED__ SIZEOF_SHORT
# undef SIZEOF_SHORT
#endif
#ifdef SIZEOF_INT
# define SIZEOF_INT_SAVED__ SIZEOF_INT
# undef SIZEOF_INT
#endif
#ifdef SIZEOF_LONG
# define SIZEOF_LONG_SAVED__ SIZEOF_LONG
# undef SIZEOF_LONG
#endif
#ifdef SIZEOF_LONG_LONG
# define SIZEOF_LONG_LONG_SAVED__ SIZEOF_LONG_LONG
# undef SIZEOF_LONG_LONG
#endif
#include "erl_int_sizes_config.h"
#if defined(SIZEOF_CHAR_SAVED__) && SIZEOF_CHAR_SAVED__ != SIZEOF_CHAR
# error SIZEOF_CHAR mismatch
#endif
#if defined(SIZEOF_SHORT_SAVED__) && SIZEOF_SHORT_SAVED__ != SIZEOF_SHORT
# error SIZEOF_SHORT mismatch
#endif
#if defined(SIZEOF_INT_SAVED__) && SIZEOF_INT_SAVED__ != SIZEOF_INT
# error SIZEOF_INT mismatch
#endif
#if defined(SIZEOF_LONG_SAVED__) && SIZEOF_LONG_SAVED__ != SIZEOF_LONG
# error SIZEOF_LONG mismatch
#endif
#if defined(SIZEOF_LONG_LONG_SAVED__) && SIZEOF_LONG_LONG_SAVED__ != SIZEOF_LONG_LONG
# error SIZEOF_LONG_LONG mismatch
#endif
#if !defined(__GNUC__) && (defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_))
typedef unsigned __int64 ErlNapiUInt64;
typedef signed __int64 ErlNapiSInt64;
#define ERL_NAPI_SINT64_MAX__ 9223372036854775807i64
#define ERL_NAPI_SINT64_MIN__ (-ERL_NAPI_SINT64_MAX__ - 1i64)
#elif SIZEOF_LONG == 8
typedef unsigned long ErlNapiUInt64;
typedef signed long ErlNapiSInt64;
#define ERL_NAPI_SINT64_MAX__ 9223372036854775807L
#define ERL_NAPI_SINT64_MIN__ (-ERL_NAPI_SINT64_MAX__ - 1L)
#elif SIZEOF_LONG_LONG == 8
typedef unsigned long long ErlNapiUInt64;
typedef signed long long ErlNapiSInt64;
#define ERL_NAPI_SINT64_MAX__ 9223372036854775807LL
#define ERL_NAPI_SINT64_MIN__ (-ERL_NAPI_SINT64_MAX__ - 1LL)
#else
# error No 64-bit integer type
#endif
#if SIZEOF_VOID_P == 8
typedef ErlNapiUInt64 ErlNapiUInt;
typedef ErlNapiSInt64 ErlNapiSInt;
#elif SIZEOF_VOID_P == 4
# if SIZEOF_LONG == SIZEOF_VOID_P
typedef unsigned long ErlNapiUInt;
typedef signed long ErlNapiSInt;
# elif SIZEOF_INT == SIZEOF_VOID_P
typedef unsigned int ErlNapiUInt;
typedef signed int ErlNapiSInt;
# else
# error No 32-bit integer type
# endif
#else
# error Not support arch
#endif
#define ERTS_NAPI_TIME_ERROR__ ERL_NAPI_SINT64_MIN__
#define ERTS_NAPI_SEC__ 0
#define ERTS_NAPI_MSEC__ 1
#define ERTS_NAPI_USEC__ 2
#define ERTS_NAPI_NSEC__ 3
#endif /* __ERL_DRV_NIF_H__ */
|