ffi 1.9.21 → 1.9.22

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

Files changed (151) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +22 -0
  5. data/.gitmodules +3 -0
  6. data/.travis.yml +52 -0
  7. data/.yardopts +5 -0
  8. data/Gemfile +15 -0
  9. data/{spec/ffi/LICENSE.SPECS → LICENSE.SPECS} +1 -1
  10. data/README.md +1 -1
  11. data/Rakefile +28 -3
  12. data/appveyor.yml +22 -0
  13. data/ext/ffi_c/Call.c +1 -22
  14. data/ext/ffi_c/Call.h +0 -9
  15. data/ext/ffi_c/Closure.c +54 -0
  16. data/ext/ffi_c/{ClosurePool.h → Closure.h} +13 -23
  17. data/ext/ffi_c/Function.c +16 -25
  18. data/ext/ffi_c/Function.h +1 -2
  19. data/ext/ffi_c/FunctionInfo.c +0 -4
  20. data/ext/ffi_c/MethodHandle.c +33 -268
  21. data/ext/ffi_c/extconf.rb +3 -3
  22. data/ext/ffi_c/ffi.c +2 -2
  23. data/ext/ffi_c/libffi.bsd.mk +3 -3
  24. data/ext/ffi_c/libffi.darwin.mk +1 -1
  25. data/ext/ffi_c/libffi.gnu.mk +1 -1
  26. data/ext/ffi_c/libffi.mk +2 -2
  27. data/ext/ffi_c/libffi.vc.mk +1 -1
  28. data/ext/ffi_c/libffi.vc64.mk +1 -1
  29. data/ext/ffi_c/libffi/.appveyor.yml +48 -0
  30. data/ext/ffi_c/libffi/.gitignore +36 -0
  31. data/ext/ffi_c/libffi/.travis.yml +30 -0
  32. data/ext/ffi_c/libffi/.travis/install.sh +14 -0
  33. data/ext/ffi_c/libffi/Makefile.am +5 -3
  34. data/ext/ffi_c/libffi/acinclude.m4 +6 -0
  35. data/ext/ffi_c/libffi/autogen.sh +1 -1
  36. data/ext/ffi_c/libffi/config.guess +1466 -0
  37. data/ext/ffi_c/libffi/config.sub +1836 -0
  38. data/ext/ffi_c/libffi/configure.ac +2 -2
  39. data/ext/ffi_c/libffi/configure.host +15 -3
  40. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +11 -15
  41. data/ext/ffi_c/libffi/include/ffi.h.in +6 -1
  42. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +465 -59
  43. data/ext/ffi_c/libffi/src/aarch64/ffi.c +33 -10
  44. data/ext/ffi_c/libffi/src/aarch64/sysv.S +2 -2
  45. data/ext/ffi_c/libffi/src/arm/ffi.c +12 -1
  46. data/ext/ffi_c/libffi/src/arm/sysv.S +1 -1
  47. data/ext/ffi_c/libffi/src/closures.c +143 -97
  48. data/ext/ffi_c/libffi/src/ia64/unix.S +2 -0
  49. data/ext/ffi_c/libffi/src/mips/ffi.c +8 -0
  50. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  51. data/ext/ffi_c/libffi/src/mips/n32.S +2 -0
  52. data/ext/ffi_c/libffi/src/powerpc/aix.S +239 -1
  53. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +250 -3
  54. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +86 -5
  55. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +3 -0
  56. data/ext/ffi_c/libffi/src/x86/ffi.c +3 -1
  57. data/ext/ffi_c/libffi/src/x86/ffi64.c +26 -5
  58. data/ext/ffi_c/libffi/src/x86/sysv.S +2 -2
  59. data/ext/ffi_c/libffi/src/x86/unix64.S +1 -1
  60. data/ext/ffi_c/libffi/src/x86/win64.S +1 -1
  61. data/ext/ffi_c/libffi/testsuite/Makefile.am +2 -1
  62. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +2 -1
  63. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3float.c +95 -0
  64. data/ffi.gemspec +14 -1
  65. data/lib/ffi/library.rb +1 -1
  66. data/lib/ffi/version.rb +1 -1
  67. data/samples/getlogin.rb +8 -0
  68. data/samples/getpid.rb +8 -0
  69. data/samples/gettimeofday.rb +18 -0
  70. data/samples/hello.rb +7 -0
  71. data/samples/inotify.rb +60 -0
  72. data/samples/pty.rb +76 -0
  73. data/samples/qsort.rb +21 -0
  74. data/samples/sample_helper.rb +6 -0
  75. metadata +59 -81
  76. metadata.gz.sig +0 -0
  77. data/ext/ffi_c/ClosurePool.c +0 -283
  78. data/gen/Rakefile +0 -30
  79. data/libtest/Benchmark.c +0 -52
  80. data/libtest/BoolTest.c +0 -34
  81. data/libtest/BufferTest.c +0 -31
  82. data/libtest/ClosureTest.c +0 -205
  83. data/libtest/EnumTest.c +0 -51
  84. data/libtest/FunctionTest.c +0 -70
  85. data/libtest/GNUmakefile +0 -149
  86. data/libtest/GlobalVariable.c +0 -62
  87. data/libtest/LastErrorTest.c +0 -21
  88. data/libtest/NumberTest.c +0 -132
  89. data/libtest/PointerTest.c +0 -63
  90. data/libtest/ReferenceTest.c +0 -23
  91. data/libtest/StringTest.c +0 -34
  92. data/libtest/StructTest.c +0 -243
  93. data/libtest/UnionTest.c +0 -43
  94. data/libtest/VariadicTest.c +0 -99
  95. data/spec/ffi/async_callback_spec.rb +0 -35
  96. data/spec/ffi/bitmask_spec.rb +0 -575
  97. data/spec/ffi/bool_spec.rb +0 -32
  98. data/spec/ffi/buffer_spec.rb +0 -279
  99. data/spec/ffi/callback_spec.rb +0 -773
  100. data/spec/ffi/custom_param_type.rb +0 -37
  101. data/spec/ffi/custom_type_spec.rb +0 -74
  102. data/spec/ffi/dup_spec.rb +0 -52
  103. data/spec/ffi/enum_spec.rb +0 -423
  104. data/spec/ffi/errno_spec.rb +0 -20
  105. data/spec/ffi/ffi_spec.rb +0 -28
  106. data/spec/ffi/fixtures/Benchmark.c +0 -52
  107. data/spec/ffi/fixtures/BitmaskTest.c +0 -51
  108. data/spec/ffi/fixtures/BoolTest.c +0 -34
  109. data/spec/ffi/fixtures/BufferTest.c +0 -31
  110. data/spec/ffi/fixtures/ClosureTest.c +0 -205
  111. data/spec/ffi/fixtures/EnumTest.c +0 -51
  112. data/spec/ffi/fixtures/FunctionTest.c +0 -142
  113. data/spec/ffi/fixtures/GNUmakefile +0 -149
  114. data/spec/ffi/fixtures/GlobalVariable.c +0 -62
  115. data/spec/ffi/fixtures/LastErrorTest.c +0 -21
  116. data/spec/ffi/fixtures/NumberTest.c +0 -132
  117. data/spec/ffi/fixtures/PipeHelper.h +0 -21
  118. data/spec/ffi/fixtures/PipeHelperPosix.c +0 -41
  119. data/spec/ffi/fixtures/PipeHelperWindows.c +0 -72
  120. data/spec/ffi/fixtures/PointerTest.c +0 -63
  121. data/spec/ffi/fixtures/ReferenceTest.c +0 -23
  122. data/spec/ffi/fixtures/StringTest.c +0 -34
  123. data/spec/ffi/fixtures/StructTest.c +0 -243
  124. data/spec/ffi/fixtures/UnionTest.c +0 -43
  125. data/spec/ffi/fixtures/VariadicTest.c +0 -99
  126. data/spec/ffi/fixtures/classes.rb +0 -438
  127. data/spec/ffi/function_spec.rb +0 -97
  128. data/spec/ffi/io_spec.rb +0 -16
  129. data/spec/ffi/library_spec.rb +0 -286
  130. data/spec/ffi/long_double.rb +0 -30
  131. data/spec/ffi/managed_struct_spec.rb +0 -68
  132. data/spec/ffi/memorypointer_spec.rb +0 -78
  133. data/spec/ffi/number_spec.rb +0 -247
  134. data/spec/ffi/platform_spec.rb +0 -114
  135. data/spec/ffi/pointer_spec.rb +0 -285
  136. data/spec/ffi/rbx/attach_function_spec.rb +0 -34
  137. data/spec/ffi/rbx/memory_pointer_spec.rb +0 -198
  138. data/spec/ffi/rbx/spec_helper.rb +0 -6
  139. data/spec/ffi/rbx/struct_spec.rb +0 -18
  140. data/spec/ffi/spec_helper.rb +0 -93
  141. data/spec/ffi/string_spec.rb +0 -118
  142. data/spec/ffi/strptr_spec.rb +0 -50
  143. data/spec/ffi/struct_by_ref_spec.rb +0 -43
  144. data/spec/ffi/struct_callback_spec.rb +0 -69
  145. data/spec/ffi/struct_initialize_spec.rb +0 -35
  146. data/spec/ffi/struct_packed_spec.rb +0 -50
  147. data/spec/ffi/struct_spec.rb +0 -882
  148. data/spec/ffi/typedef_spec.rb +0 -91
  149. data/spec/ffi/union_spec.rb +0 -67
  150. data/spec/ffi/variadic_spec.rb +0 -132
  151. data/spec/spec.opts +0 -4
@@ -1,63 +0,0 @@
1
- /*
2
- * Copyright (c) 2007 Wayne Meissner. All rights reserved.
3
- *
4
- * For licensing, see LICENSE.SPECS
5
- */
6
-
7
- #include <sys/types.h>
8
- #include <sys/param.h>
9
- #include <stdint.h>
10
- #include <stdio.h>
11
- #include <stdlib.h>
12
- #include <string.h>
13
- typedef void* ptr;
14
- typedef void* pointer;
15
- #ifdef _WIN32
16
- typedef char* caddr_t;
17
- #endif
18
-
19
- #define RET(T) T ptr_ret_##T(void* arg1, int offset) { \
20
- T tmp; memcpy(&tmp, (caddr_t) arg1 + offset, sizeof(tmp)); return tmp; \
21
- }
22
- #define SET(T) void ptr_set_##T(void* arg1, int offset, T value) { \
23
- memcpy((caddr_t) arg1 + offset, &value, sizeof(value)); \
24
- }
25
- #define TEST(T) SET(T) RET(T)
26
-
27
- TEST(int8_t);
28
- TEST(int16_t);
29
- TEST(int32_t);
30
- TEST(int64_t);
31
- TEST(float);
32
- TEST(double);
33
- TEST(pointer);
34
-
35
- void*
36
- ptr_return_array_element(void **ptrArray, int arrayIndex)
37
- {
38
- return ptrArray[arrayIndex];
39
- }
40
-
41
- void
42
- ptr_set_array_element(void **ptrArray, int arrayIndex, void *value)
43
- {
44
- ptrArray[arrayIndex] = value;
45
- }
46
-
47
- void*
48
- ptr_malloc(int size)
49
- {
50
- return calloc(1, size);
51
- }
52
- void
53
- ptr_free(void* ptr)
54
- {
55
- free(ptr);
56
- }
57
-
58
- void*
59
- ptr_from_address(uintptr_t addr)
60
- {
61
- return (void *) addr;
62
- }
63
-
@@ -1,23 +0,0 @@
1
- /*
2
- * Copyright (c) 2007 Wayne Meissner. All rights reserved.
3
- *
4
- * For licensing, see LICENSE.SPECS
5
- */
6
-
7
- #include <stdint.h>
8
-
9
- #define REF(T) void ref_##T(T arg, T* result) { *result = arg; }
10
- #define ADD(T) void ref_add_##T(T arg1, T arg2, T* result) { *result = arg1 + arg2; }
11
- #define SUB(T) void ref_sub_##T(T arg1, T arg2, T* result) { *result = arg1 - arg2; }
12
- #define MUL(T) void ref_mul_##T(T arg1, T arg2, T* result) { *result = arg1 * arg2; }
13
- #define DIV(T) void ref_div_##T(T arg1, T arg2, T* result) { *result = arg1 / arg2; }
14
- #define TEST(T) ADD(T) SUB(T) MUL(T) DIV(T) REF(T)
15
-
16
- TEST(int8_t);
17
- TEST(int16_t);
18
- TEST(int32_t);
19
- TEST(int64_t);
20
- TEST(float);
21
- TEST(double);
22
-
23
-
@@ -1,34 +0,0 @@
1
- /*
2
- * Copyright (c) 2007 Wayne Meissner. All rights reserved.
3
- *
4
- * For licensing, see LICENSE.SPECS
5
- */
6
-
7
- #include <string.h>
8
-
9
- int
10
- string_equals(const char* s1, const char* s2)
11
- {
12
- return strcmp(s1, s2) == 0;
13
- }
14
-
15
- void
16
- string_set(char* s1, const char* s2)
17
- {
18
- strcpy(s1, s2);
19
- }
20
- void
21
- string_concat(char* dst, const char* src)
22
- {
23
- strcat(dst, src);
24
- }
25
- void
26
- string_dummy(char* dummy)
27
- {
28
- }
29
- const char*
30
- string_null(void)
31
- {
32
- return NULL;
33
- }
34
-
@@ -1,243 +0,0 @@
1
- /*
2
- * Copyright (c) 2007 Wayne Meissner.
3
- * Copyright (c) 2009 Andrea Fazzi <andrea.fazzi@alcacoop.it>.
4
- *
5
- * All rights reserved.
6
- *
7
- * For licensing, see LICENSE.SPECS
8
- */
9
-
10
- #include <stdio.h>
11
- #include <stdlib.h>
12
- #include <stdbool.h>
13
- #include <stdint.h>
14
- #include <string.h>
15
- #include <stdarg.h>
16
-
17
- typedef char s8;
18
- typedef short s16;
19
- typedef int s32;
20
- typedef long long s64;
21
- typedef float f32;
22
- typedef double f64;
23
-
24
- typedef struct bugged_struct {
25
- unsigned char visible;
26
- unsigned int x;
27
- unsigned int y;
28
- short rx;
29
- short ry;
30
- unsigned char order;
31
- unsigned char size;
32
- } bugged_struct_t;
33
-
34
- unsigned int
35
- bugged_struct_size() {
36
- return sizeof(bugged_struct_t);
37
- }
38
-
39
- struct test1 {
40
- char b;
41
- short s;
42
- int i;
43
- long long j;
44
- long l;
45
- float f;
46
- double d;
47
- char string[32];
48
- };
49
-
50
- struct struct_with_array {
51
- char c;
52
- int a[5];
53
- };
54
-
55
- struct nested {
56
- int i;
57
- };
58
-
59
- struct container {
60
- char first;
61
- struct nested s;
62
- };
63
-
64
- int
65
- struct_align_nested_struct(struct container* a) { return a->s.i; }
66
-
67
- void*
68
- struct_field_array(struct struct_with_array* s) { return &s->a; }
69
-
70
- struct container*
71
- struct_make_container_struct(int i)
72
- {
73
- static struct container cs;
74
- memset(&cs, 0, sizeof(cs));
75
- cs.first = 1;
76
- cs.s.i = i;
77
- return &cs;
78
- }
79
-
80
- #define T(x, type) \
81
- type struct_field_##type(struct test1* t) { return t->x; } \
82
- struct type##_align { char first; type value; }; \
83
- type struct_align_##type(struct type##_align* a) { return a->value; }
84
-
85
- T(b, s8);
86
- T(s, s16);
87
- T(i, s32);
88
- T(j, s64);
89
- T(f, f32);
90
- T(d, f64);
91
- T(l, long);
92
-
93
- void
94
- struct_set_string(struct test1* t, char* s)
95
- {
96
- strcpy(t->string, s);
97
- }
98
-
99
- struct test1*
100
- struct_make_struct(char b, short s, int i, long long ll, float f, double d)
101
- {
102
- static struct test1 t;
103
- memset(&t, 0, sizeof(t));
104
- t.b = b;
105
- t.s = s;
106
- t.i = i;
107
- t.j = ll;
108
- t.f = f;
109
- t.d = d;
110
- return &t;
111
- }
112
-
113
- typedef int (*add_cb)(int a1, int a2);
114
- typedef int (*sub_cb)(int a1, int a2);
115
- struct test2 {
116
- add_cb add_callback;
117
- sub_cb sub_callback;
118
- };
119
-
120
- int
121
- struct_call_add_cb(struct test2* t, int a1, int a2)
122
- {
123
- return t->add_callback(a1, a2);
124
- }
125
-
126
- int
127
- struct_call_sub_cb(struct test2* t, int a1, int a2)
128
- {
129
- return t->sub_callback(a1, a2);
130
- }
131
-
132
-
133
- struct struct_with_array*
134
- struct_make_struct_with_array(int a_0, int a_1, int a_2, int a_3, int a_4)
135
- {
136
- static struct struct_with_array s;
137
-
138
- memset(&s, 0, sizeof(s));
139
-
140
- s.a[0] = a_0;
141
- s.a[1] = a_1;
142
- s.a[2] = a_2;
143
- s.a[3] = a_3;
144
- s.a[4] = a_4;
145
-
146
- return &s;
147
-
148
- }
149
-
150
- struct s8s32 {
151
- char s8;
152
- int s32;
153
- };
154
-
155
- struct s8s32
156
- struct_return_s8s32()
157
- {
158
- struct s8s32 s;
159
- s.s8 = 0x7f;
160
- s.s32 = 0x12345678;
161
-
162
- return s;
163
- }
164
-
165
- struct s8s32
166
- struct_s8s32_set(char s8, int s32)
167
- {
168
- struct s8s32 s;
169
-
170
- s.s8 = s8;
171
- s.s32 = s32;
172
-
173
- return s;
174
- }
175
-
176
- int
177
- struct_s8s32_get_s8(struct s8s32 s)
178
- {
179
- return s.s8;
180
- }
181
-
182
- int
183
- struct_s8s32_get_s32(struct s8s32 s)
184
- {
185
- return s.s32;
186
- }
187
-
188
- struct s8s32
189
- struct_s8s32_ret_s8s32(struct s8s32 s)
190
- {
191
- return s;
192
- }
193
-
194
- // Pass a struct and an int arg, ensure the int arg is passed correctly
195
- int
196
- struct_s8s32_s32_ret_s32(struct s8s32 s, int s32)
197
- {
198
- return s32;
199
- }
200
-
201
- // Pass a struct and a long long arg, ensure the long long arg is passed correctly
202
- long long
203
- struct_s8s32_s64_ret_s64(struct s8s32 s, long long s64)
204
- {
205
- return s64;
206
- }
207
-
208
- // Pass a struct and a long long arg, ensure the long long arg is passed correctly
209
- int
210
- struct_s32_ptr_s32_s8s32_ret_s32(int s32a, void *ptr, int s32b, struct s8s32 s)
211
- {
212
- if (ptr != NULL) *(struct s8s32 *) ptr = s;
213
- return s.s32;
214
- }
215
-
216
- // Pass a char *, copy into buffer length struct
217
- struct struct_string {
218
- char *bytes;
219
- int len;
220
- };
221
-
222
- struct struct_string
223
- struct_varargs_ret_struct_string(int len, ...)
224
- {
225
- struct struct_string ss;
226
- va_list vl;
227
- char* cp = NULL;
228
-
229
- va_start(vl, len);
230
-
231
- ss.len = len;
232
- ss.bytes = va_arg(vl, char *);
233
- if (ss.bytes != NULL) {
234
- cp = malloc(strlen(ss.bytes) + 1);
235
- strcpy(cp, ss.bytes);
236
- ss.bytes = cp;
237
- }
238
-
239
- va_end(vl);
240
-
241
- return ss;
242
- }
243
-
@@ -1,43 +0,0 @@
1
- /*
2
- * Copyright (c) 2007 Wayne Meissner. All rights reserved.
3
- *
4
- * For licensing, see LICENSE.SPECS
5
- */
6
-
7
- #include <stdio.h>
8
- #include <stdbool.h>
9
- #include <stdint.h>
10
- #include <string.h>
11
- #include <stdlib.h>
12
-
13
- typedef char s8;
14
- typedef short s16;
15
- typedef int s32;
16
- typedef long long s64;
17
- typedef float f32;
18
- typedef double f64;
19
-
20
- typedef union union_test {
21
- char b;
22
- short s;
23
- int i;
24
- long long j;
25
- long l;
26
- float f;
27
- double d;
28
- s8 a[10];
29
- } union_test_t;
30
-
31
- #define T(x, type) \
32
- type union_align_##type(union_test_t* u) { return u->x; } \
33
- union_test_t* union_make_union_with_##type(type value) { static union_test_t u; u.x = value; return &u; }
34
-
35
- T(b, s8);
36
- T(s, s16);
37
- T(i, s32);
38
- T(j, s64);
39
- T(f, f32);
40
- T(d, f64);
41
- T(l, long);
42
-
43
- unsigned int union_size() { return sizeof(union_test_t); }
@@ -1,99 +0,0 @@
1
- /*
2
- * Copyright (c) 2007 Wayne Meissner. All rights reserved.
3
- *
4
- * For licensing, see LICENSE.SPECS
5
- */
6
-
7
- #include <sys/types.h>
8
- #include <stdio.h>
9
- #include <stdint.h>
10
- #include <string.h>
11
- #include <stdarg.h>
12
-
13
- typedef int8_t s8;
14
- typedef uint8_t u8;
15
- typedef int16_t s16;
16
- typedef uint16_t u16;
17
- typedef int32_t s32;
18
- typedef uint32_t u32;
19
- typedef int64_t s64;
20
- typedef uint64_t u64;
21
- typedef signed long sL;
22
- typedef unsigned long uL;
23
- typedef float F;
24
- typedef double D;
25
-
26
- void pack_varargs(s64* buf, const char* fmt, ...)
27
- {
28
- va_list ap;
29
- int c;
30
- double d;
31
- va_start(ap, fmt);
32
- while ((c = *fmt++)) {
33
- switch (c) {
34
- case 'c':
35
- case 's':
36
- case 'i':
37
- *buf++ = va_arg(ap, s32);
38
- break;
39
- case 'l':
40
- *buf++ = va_arg(ap, long);
41
- break;
42
- case 'j':
43
- *buf++ = va_arg(ap, s64);
44
- break;
45
- case 'f':
46
- case 'd':
47
- d = va_arg(ap, double);
48
- memcpy(buf++, &d, sizeof(d));
49
- break;
50
- case 'C':
51
- case 'S':
52
- case 'I':
53
- *buf++ = va_arg(ap, u32);
54
- break;
55
- case 'L':
56
- *buf++ = va_arg(ap, unsigned long);
57
- break;
58
- }
59
- }
60
- va_end(ap);
61
- }
62
-
63
- int pack_varargs2(s64* buf, int retval, const char* fmt, ...)
64
- {
65
- va_list ap;
66
- int c;
67
- double d;
68
- va_start(ap, fmt);
69
- while ((c = *fmt++)) {
70
- switch (c) {
71
- case 'c':
72
- case 's':
73
- case 'i':
74
- *buf++ = va_arg(ap, s32);
75
- break;
76
- case 'l':
77
- *buf++ = va_arg(ap, long);
78
- break;
79
- case 'j':
80
- *buf++ = va_arg(ap, s64);
81
- break;
82
- case 'f':
83
- case 'd':
84
- d = va_arg(ap, double);
85
- memcpy(buf++, &d, sizeof(d));
86
- break;
87
- case 'C':
88
- case 'S':
89
- case 'I':
90
- *buf++ = va_arg(ap, u32);
91
- break;
92
- case 'L':
93
- *buf++ = va_arg(ap, unsigned long);
94
- break;
95
- }
96
- }
97
- va_end(ap);
98
- return retval + 1;
99
- }