ffi 1.1.6.pre2-x86-mingw32 → 1.2.0.pre2-x86-mingw32
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.
- data/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/README.md +104 -0
- data/Rakefile +36 -43
- data/ext/ffi_c/LongDouble.c +4 -0
- data/ext/ffi_c/LongDouble.c.orig +65 -0
- data/ext/ffi_c/MethodHandle.c +1 -1
- data/ext/ffi_c/Types.h +1 -0
- data/ext/ffi_c/Variadic.c +4 -0
- data/ext/ffi_c/extconf.rb +1 -0
- data/ext/ffi_c/libffi.bsd.mk +1 -1
- data/ext/ffi_c/libffi.darwin.mk +6 -4
- data/ext/ffi_c/libffi.mk +1 -1
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/ffi/autopointer.rb +9 -8
- data/lib/ffi/enum.rb +2 -1
- data/libtest/Benchmark.c +66 -0
- data/libtest/BoolTest.c +45 -0
- data/libtest/BufferTest.c +45 -0
- data/libtest/ClosureTest.c +204 -0
- data/libtest/EnumTest.c +48 -0
- data/libtest/FunctionTest.c +72 -0
- data/libtest/GNUmakefile +149 -0
- data/libtest/GlobalVariable.c +76 -0
- data/libtest/LastErrorTest.c +35 -0
- data/libtest/NumberTest.c +146 -0
- data/libtest/PointerTest.c +77 -0
- data/libtest/ReferenceTest.c +37 -0
- data/libtest/StringTest.c +48 -0
- data/libtest/StructTest.c +254 -0
- data/libtest/UnionTest.c +57 -0
- data/libtest/VariadicTest.c +76 -0
- data/spec/ffi/enum_spec.rb +4 -0
- data/spec/ffi/pointer_spec.rb +17 -0
- metadata +85 -40
- data/README.rdoc +0 -102
- data/tasks/ann.rake +0 -80
- data/tasks/extension.rake +0 -32
- data/tasks/gem.rake +0 -199
- data/tasks/git.rake +0 -41
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -50
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -301
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/yard.rake +0 -11
data/libtest/EnumTest.c
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2007 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
int test_untagged_enum(int val) {
|
22
|
+
return val;
|
23
|
+
}
|
24
|
+
|
25
|
+
int test_untagged_typedef_enum(int val) {
|
26
|
+
return val;
|
27
|
+
}
|
28
|
+
|
29
|
+
typedef enum {c1, c2, c3, c4} enum_type1;
|
30
|
+
enum_type1 test_tagged_typedef_enum1(enum_type1 val) {
|
31
|
+
return val;
|
32
|
+
}
|
33
|
+
|
34
|
+
typedef enum {c5 = 42, c6, c7, c8} enum_type2;
|
35
|
+
enum_type2 test_tagged_typedef_enum2(enum_type2 val) {
|
36
|
+
return val;
|
37
|
+
}
|
38
|
+
|
39
|
+
typedef enum {c9 = 42, c10, c11 = 4242, c12} enum_type3;
|
40
|
+
enum_type3 test_tagged_typedef_enum3(enum_type3 val) {
|
41
|
+
return val;
|
42
|
+
}
|
43
|
+
|
44
|
+
typedef enum {c13 = 42, c14 = 4242, c15 = 424242, c16 = 42424242} enum_type4;
|
45
|
+
enum_type4 test_tagged_typedef_enum4(enum_type4 val) {
|
46
|
+
return val;
|
47
|
+
}
|
48
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#ifdef _WIN32
|
22
|
+
#include <windows.h>
|
23
|
+
#define sleep(x) Sleep(x)
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#ifndef _WIN32
|
27
|
+
#include <unistd.h>
|
28
|
+
#include <pthread.h>
|
29
|
+
#endif
|
30
|
+
|
31
|
+
int testAdd(int a, int b)
|
32
|
+
{
|
33
|
+
return a + b;
|
34
|
+
};
|
35
|
+
|
36
|
+
int testFunctionAdd(int a, int b, int (*f)(int, int))
|
37
|
+
{
|
38
|
+
return f(a, b);
|
39
|
+
};
|
40
|
+
|
41
|
+
void testBlocking(int seconds) {
|
42
|
+
sleep(seconds);
|
43
|
+
};
|
44
|
+
|
45
|
+
struct async_data {
|
46
|
+
void (*fn)(int);
|
47
|
+
int value;
|
48
|
+
};
|
49
|
+
|
50
|
+
static void* asyncThreadCall(void *data)
|
51
|
+
{
|
52
|
+
struct async_data* d = (struct async_data *) data;
|
53
|
+
if (d != NULL && d->fn != NULL) {
|
54
|
+
(*d->fn)(d->value);
|
55
|
+
}
|
56
|
+
|
57
|
+
return NULL;
|
58
|
+
}
|
59
|
+
|
60
|
+
void testAsyncCallback(void (*fn)(int), int value)
|
61
|
+
{
|
62
|
+
#ifndef _WIN32
|
63
|
+
pthread_t t;
|
64
|
+
struct async_data d;
|
65
|
+
d.fn = fn;
|
66
|
+
d.value = value;
|
67
|
+
pthread_create(&t, NULL, asyncThreadCall, &d);
|
68
|
+
pthread_join(t, NULL);
|
69
|
+
#else
|
70
|
+
(*fn)(value);
|
71
|
+
#endif
|
72
|
+
}
|
data/libtest/GNUmakefile
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# -*- makefile -*-
|
2
|
+
|
3
|
+
ifeq ($(OS),)
|
4
|
+
BUILD_OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
5
|
+
OS := $(BUILD_OS)
|
6
|
+
endif
|
7
|
+
|
8
|
+
ifeq ($(CPU),)
|
9
|
+
CPU := $(shell uname -m | sed -e 's/i[345678]86/i386/')
|
10
|
+
endif
|
11
|
+
|
12
|
+
PLATFORM = $(CPU)-$(OS)
|
13
|
+
|
14
|
+
ifeq ($(OS), sunos)
|
15
|
+
OS = solaris
|
16
|
+
endif
|
17
|
+
|
18
|
+
SRC_DIR = libtest
|
19
|
+
BUILD_DIR ?= build
|
20
|
+
TEST_BUILD_DIR = $(BUILD_DIR)/libtest
|
21
|
+
# Set defaults to unix (linux/solaris/bsd)
|
22
|
+
PREFIX = lib
|
23
|
+
LIBEXT ?= so
|
24
|
+
LIBNAME = $(PREFIX)test.$(LIBEXT)
|
25
|
+
|
26
|
+
export MACOSX_DEPLOYMENT_TARGET=10.4
|
27
|
+
|
28
|
+
CCACHE := $(strip $(realpath $(shell which ccache 2> /dev/null)))
|
29
|
+
|
30
|
+
TEST_SRCS = $(wildcard $(SRC_DIR)/*.c)
|
31
|
+
TEST_OBJS := $(patsubst $(SRC_DIR)/%.c, $(TEST_BUILD_DIR)/%.o, $(TEST_SRCS))
|
32
|
+
|
33
|
+
#
|
34
|
+
# Compiler/linker flags from:
|
35
|
+
# http://weblogs.java.net/blog/kellyohair/archive/2006/01/compilation_of_1.html
|
36
|
+
JFLAGS = -fno-omit-frame-pointer -fno-strict-aliasing
|
37
|
+
OFLAGS = -O2 $(JFLAGS)
|
38
|
+
WFLAGS = -W -Wall -Wno-unused -Wno-parentheses
|
39
|
+
PICFLAGS = -fPIC
|
40
|
+
SOFLAGS = -shared
|
41
|
+
LDFLAGS += $(SOFLAGS)
|
42
|
+
|
43
|
+
IFLAGS = -I"$(BUILD_DIR)"
|
44
|
+
CFLAGS = $(OFLAGS) $(WFLAGS) $(IFLAGS) $(PICFLAGS) -D_REENTRANT
|
45
|
+
|
46
|
+
ifneq ($(strip $(findstring $(OS), win32, mingw, cygwin)),)
|
47
|
+
# For cygwin => win32-native builds, strip out cygwin deps
|
48
|
+
ifneq ($(findstring cygwin, $(BUILD_OS)),)
|
49
|
+
CC += -mno-cygwin -mwin32
|
50
|
+
LDFLAGS += -mno-cygwin -Wl,--add-stdcall-alias
|
51
|
+
endif
|
52
|
+
PICFLAGS=
|
53
|
+
LIBEXT=dll
|
54
|
+
CC = gcc
|
55
|
+
endif
|
56
|
+
|
57
|
+
ifeq ($(OS), darwin)
|
58
|
+
ifneq ($(findstring $(CPU),ppc),)
|
59
|
+
ARCHFLAGS += -arch ppc
|
60
|
+
endif
|
61
|
+
ifneq ($(findstring $(CPU),i386 x86_64),)
|
62
|
+
ARCHFLAGS += -arch i386 -arch x86_64
|
63
|
+
endif
|
64
|
+
CFLAGS += $(ARCHFLAGS) -DTARGET_RT_MAC_CFM=0
|
65
|
+
CFLAGS += -fno-common
|
66
|
+
LDFLAGS = $(ARCHFLAGS) -dynamiclib
|
67
|
+
# link against the universal libraries on ppc machines
|
68
|
+
LDFLAGS += -L$(MACSDK)/usr/lib
|
69
|
+
LIBEXT = dylib
|
70
|
+
FFI_CFLAGS += -isysroot $(MACSDK)
|
71
|
+
PICFLAGS =
|
72
|
+
SOFLAGS =
|
73
|
+
endif
|
74
|
+
|
75
|
+
ifeq ($(OS), linux)
|
76
|
+
SOFLAGS += -Wl,-soname,$(LIBNAME)
|
77
|
+
endif
|
78
|
+
|
79
|
+
ifeq ($(OS), solaris)
|
80
|
+
CC = /usr/sfw/bin/gcc -std=c99
|
81
|
+
LD = /usr/ccs/bin/ld
|
82
|
+
SOFLAGS = -shared -static-libgcc
|
83
|
+
endif
|
84
|
+
|
85
|
+
ifeq ($(OS), aix)
|
86
|
+
LIBEXT = a
|
87
|
+
SOFLAGS = -shared -static-libgcc
|
88
|
+
PICFLAGS += -pthread
|
89
|
+
endif
|
90
|
+
|
91
|
+
ifneq ($(findstring bsd, $(OS)),)
|
92
|
+
SOFLAGS = -shared -static-libgcc
|
93
|
+
CFLAGS += -pthread
|
94
|
+
LDFLAGS += -pthread
|
95
|
+
endif
|
96
|
+
|
97
|
+
ifeq ($(CPU), i386)
|
98
|
+
MODEL = 32
|
99
|
+
endif
|
100
|
+
|
101
|
+
ifeq ($(CPU), sparcv9)
|
102
|
+
MODEL = 64
|
103
|
+
endif
|
104
|
+
|
105
|
+
ifeq ($(CPU), amd64)
|
106
|
+
MODEL = 64
|
107
|
+
endif
|
108
|
+
|
109
|
+
ifeq ($(CPU), x86_64)
|
110
|
+
MODEL = 64
|
111
|
+
endif
|
112
|
+
|
113
|
+
ifeq ($(CPU), ppc64)
|
114
|
+
MODEL = 64
|
115
|
+
endif
|
116
|
+
|
117
|
+
ifeq ($(CPU), powerpc64)
|
118
|
+
MODEL = 64
|
119
|
+
endif
|
120
|
+
|
121
|
+
MODELFLAG =
|
122
|
+
ifneq ($(MODEL),)
|
123
|
+
MODELFLAG = -m$(MODEL)
|
124
|
+
endif
|
125
|
+
|
126
|
+
# On platforms (linux, solaris) that support both 32bit and 64bit, force building for one or the other
|
127
|
+
ifneq ($(or $(findstring linux, $(OS)), $(findstring solaris, $(OS))),)
|
128
|
+
# Change the CC/LD instead of CFLAGS/LDFLAGS, incase other things in the flags
|
129
|
+
# makes the libffi build choke
|
130
|
+
CC += $(MODELFLAG)
|
131
|
+
LD += $(MODELFLAG)
|
132
|
+
endif
|
133
|
+
|
134
|
+
LIBTEST = $(BUILD_DIR)/$(LIBNAME)
|
135
|
+
|
136
|
+
all: $(LIBTEST)
|
137
|
+
|
138
|
+
$(TEST_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
|
139
|
+
@mkdir -p $(@D)
|
140
|
+
$(CCACHE) $(CC) $(CFLAGS) -c $< -o $@
|
141
|
+
|
142
|
+
$(LIBTEST): $(TEST_OBJS)
|
143
|
+
$(CC) -o $@ $(LDFLAGS) $(TEST_OBJS) -lm
|
144
|
+
|
145
|
+
clean::
|
146
|
+
# nothing to do - ant will delete the build dir
|
147
|
+
|
148
|
+
debug::
|
149
|
+
@echo "SRCS=$(TEST_SRCS)"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include <sys/types.h>
|
22
|
+
#include <stdint.h>
|
23
|
+
|
24
|
+
typedef int8_t s8;
|
25
|
+
typedef uint8_t u8;
|
26
|
+
typedef int16_t s16;
|
27
|
+
typedef uint16_t u16;
|
28
|
+
typedef int32_t s32;
|
29
|
+
typedef uint32_t u32;
|
30
|
+
typedef int64_t s64;
|
31
|
+
typedef uint64_t u64;
|
32
|
+
typedef signed long sL;
|
33
|
+
typedef unsigned long uL;
|
34
|
+
typedef float f32;
|
35
|
+
typedef double f64;
|
36
|
+
#if !defined(__OpenBSD__)
|
37
|
+
typedef unsigned long ulong;
|
38
|
+
#endif
|
39
|
+
typedef void* pointer;
|
40
|
+
typedef void* P;
|
41
|
+
|
42
|
+
#define GVAR(T) \
|
43
|
+
extern T gvar_##T; \
|
44
|
+
T gvar_##T = (T) -1; \
|
45
|
+
T gvar_##T##_get() { return gvar_##T; }; \
|
46
|
+
void gvar_##T##_set(T v) { gvar_##T = v; }
|
47
|
+
|
48
|
+
GVAR(s8);
|
49
|
+
GVAR(u8);
|
50
|
+
GVAR(s16);
|
51
|
+
GVAR(u16);
|
52
|
+
GVAR(s32);
|
53
|
+
GVAR(u32);
|
54
|
+
GVAR(s64);
|
55
|
+
GVAR(u64);
|
56
|
+
GVAR(long);
|
57
|
+
GVAR(ulong);
|
58
|
+
GVAR(pointer);
|
59
|
+
|
60
|
+
struct gstruct {
|
61
|
+
long data;
|
62
|
+
};
|
63
|
+
|
64
|
+
struct gstruct gvar_gstruct = { -1 };
|
65
|
+
|
66
|
+
struct gstruct*
|
67
|
+
gvar_gstruct_get(void)
|
68
|
+
{
|
69
|
+
return &gvar_gstruct;
|
70
|
+
}
|
71
|
+
|
72
|
+
void
|
73
|
+
gvar_gstruct_set(const struct gstruct* val)
|
74
|
+
{
|
75
|
+
gvar_gstruct = *val;
|
76
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2008 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#if defined(_WIN32) || defined(__WIN32__)
|
22
|
+
# include <windows.h>
|
23
|
+
#else
|
24
|
+
# include <errno.h>
|
25
|
+
#endif
|
26
|
+
|
27
|
+
int setLastError(int error) {
|
28
|
+
#if defined(_WIN32) || defined(__WIN32__)
|
29
|
+
SetLastError(error);
|
30
|
+
#else
|
31
|
+
errno = error;
|
32
|
+
#endif
|
33
|
+
return -1;
|
34
|
+
}
|
35
|
+
|
@@ -0,0 +1,146 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2007 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include <sys/types.h>
|
22
|
+
#include <stdio.h>
|
23
|
+
#include <string.h>
|
24
|
+
#include <stdint.h>
|
25
|
+
|
26
|
+
#if defined(__sparc) && defined(__sun__)
|
27
|
+
#define fix_mem_access __asm("ta 6")
|
28
|
+
#else
|
29
|
+
#define fix_mem_access
|
30
|
+
#endif
|
31
|
+
|
32
|
+
typedef int8_t s8;
|
33
|
+
typedef uint8_t u8;
|
34
|
+
typedef int16_t s16;
|
35
|
+
typedef uint16_t u16;
|
36
|
+
typedef int32_t s32;
|
37
|
+
typedef uint32_t u32;
|
38
|
+
typedef int64_t s64;
|
39
|
+
typedef uint64_t u64;
|
40
|
+
typedef signed long sL;
|
41
|
+
typedef unsigned long uL;
|
42
|
+
typedef float f32;
|
43
|
+
typedef double f64;
|
44
|
+
typedef long double f128;
|
45
|
+
#if !defined(__OpenBSD__)
|
46
|
+
typedef unsigned long ulong;
|
47
|
+
#endif
|
48
|
+
|
49
|
+
#define ADD(T) T add_##T(T arg1, T arg2) { return arg1 + arg2; }
|
50
|
+
#define SUB(T) T sub_##T(T arg1, T arg2) { return arg1 - arg2; }
|
51
|
+
#define MUL(T) T mul_##T(T arg1, T arg2) { return arg1 * arg2; }
|
52
|
+
#define DIV(T) T div_##T(T arg1, T arg2) { return arg1 / arg2; }
|
53
|
+
#define RET(T) T ret_##T(T arg1) { return arg1; }
|
54
|
+
#define SET(T) static T T##_;void set_##T(T arg1) { T##_ = arg1; }
|
55
|
+
#define GET(T) T get_##T() { return T##_; }
|
56
|
+
typedef char* ptr;
|
57
|
+
#define TEST(T) ADD(T) SUB(T) MUL(T) DIV(T) RET(T) SET(T) GET(T)
|
58
|
+
TEST(s8);
|
59
|
+
TEST(u8);
|
60
|
+
TEST(s16);
|
61
|
+
TEST(u16);
|
62
|
+
TEST(s32);
|
63
|
+
TEST(u32);
|
64
|
+
TEST(s64);
|
65
|
+
TEST(u64);
|
66
|
+
TEST(float);
|
67
|
+
TEST(double);
|
68
|
+
TEST(long);
|
69
|
+
TEST(ulong);
|
70
|
+
TEST(f128);
|
71
|
+
|
72
|
+
#define ADD2(R, T1, T2) R add_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 + arg2; }
|
73
|
+
#define SUB2(R, T1, T2) R sub_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 - arg2; }
|
74
|
+
#define MUL2(R, T1, T2) R mul_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 * arg2; }
|
75
|
+
#define DIV2(R, T1, T2) R div_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 / arg2; }
|
76
|
+
|
77
|
+
#define T2__(R, T1, T2) ADD2(R, T1, T2) SUB2(R, T1, T2) MUL2(R, T1, T2) DIV2(R, T1, T2)
|
78
|
+
#define T2_(R, T1) \
|
79
|
+
T2__(R, T1, s8) T2__(R, T1, u8) \
|
80
|
+
T2__(R, T1, s16) T2__(R, T1, u16) \
|
81
|
+
T2__(R, T1, s32) T2__(R, T1, u32) \
|
82
|
+
T2__(R, T1, sL) T2__(R, T1, uL) \
|
83
|
+
T2__(R, T1, s64) T2__(R, T1, u64) \
|
84
|
+
|
85
|
+
#define TEST2(R) \
|
86
|
+
T2_(R, s8) T2_(R, u8) T2_(R, s16) T2_(R, u16) T2_(R, s32) T2_(R, u32) \
|
87
|
+
T2_(R, sL) T2_(R, uL) T2_(R, s64) T2_(R, u64)
|
88
|
+
|
89
|
+
#ifdef notyet
|
90
|
+
TEST2(s32)
|
91
|
+
TEST2(u32)
|
92
|
+
TEST2(s64)
|
93
|
+
TEST2(u64)
|
94
|
+
#endif
|
95
|
+
|
96
|
+
#define ADD3(R, T1, T2, T3) R add_##T1##T2##T3##_##R(T1 arg1, T2 arg2, T3 arg3) { return arg1 + arg2 + arg3; }
|
97
|
+
#define pack_f32(buf, v) do { float f = v; memcpy((buf), &f, sizeof(f)); } while(0)
|
98
|
+
#define pack_f64(buf, v) do { double f = v; memcpy((buf), &f, sizeof(f)); } while(0)
|
99
|
+
#define pack_int(buf, v) do { *(buf) = v; } while(0)
|
100
|
+
#define pack_s8 pack_int
|
101
|
+
#define pack_u8 pack_int
|
102
|
+
#define pack_s16 pack_int
|
103
|
+
#define pack_u16 pack_int
|
104
|
+
#define pack_s32 pack_int
|
105
|
+
#define pack_u32 pack_int
|
106
|
+
#define pack_s64 pack_int
|
107
|
+
#define pack_u64 pack_int
|
108
|
+
#define pack_sL pack_int
|
109
|
+
#define pack_uL pack_int
|
110
|
+
|
111
|
+
#define PACK3(R, T1, T2, T3) void pack_##T1##T2##T3##_##R(T1 arg1, T2 arg2, T3 arg3, R* r) { \
|
112
|
+
fix_mem_access; \
|
113
|
+
pack_##T1(&r[0], arg1); \
|
114
|
+
pack_##T2(&r[1], arg2); \
|
115
|
+
pack_##T3(&r[2], arg3); \
|
116
|
+
}
|
117
|
+
|
118
|
+
#define T3___(R, T1, T2, T3) PACK3(R, T1, T2, T3) /* SUB2(R, T1, T2) MUL2(R, T1, T2) DIV2(R, T1, T2) */
|
119
|
+
#define T3__(R, T1, T2) \
|
120
|
+
T3___(R, T1, T2, s8) T3___(R, T1, T2, u8) \
|
121
|
+
T3___(R, T1, T2, s16) T3___(R, T1, T2, u16) \
|
122
|
+
T3___(R, T1, T2, s32) T3___(R, T1, T2, u32) \
|
123
|
+
T3___(R, T1, T2, sL) T3___(R, T1, T2, uL) \
|
124
|
+
T3___(R, T1, T2, s64) T3___(R, T1, T2, u64) \
|
125
|
+
T3___(R, T1, T2, f32) T3___(R, T1, T2, f64) \
|
126
|
+
|
127
|
+
#define T3_(R, T1) \
|
128
|
+
T3__(R, T1, s8) T3__(R, T1, u8) \
|
129
|
+
T3__(R, T1, s16) T3__(R, T1, u16) \
|
130
|
+
T3__(R, T1, s32) T3__(R, T1, u32) \
|
131
|
+
T3__(R, T1, sL) T3__(R, T1, uL) \
|
132
|
+
T3__(R, T1, s64) T3__(R, T1, u64) \
|
133
|
+
T3__(R, T1, f32) T3__(R, T1, f64) \
|
134
|
+
|
135
|
+
#define TEST3(R) \
|
136
|
+
T3_(R, s8) T3_(R, u8) T3_(R, s16) T3_(R, u16) T3_(R, s32) T3_(R, u32) \
|
137
|
+
T3_(R, sL) T3_(R, uL) T3_(R, s64) T3_(R, u64) T3_(R, f32) T3_(R, f64)
|
138
|
+
|
139
|
+
TEST3(s64)
|
140
|
+
|
141
|
+
void
|
142
|
+
foo6(intptr_t i1, intptr_t i2, intptr_t i3, intptr_t i4, intptr_t i5, intptr_t i6) { }
|
143
|
+
|
144
|
+
void
|
145
|
+
foo5(intptr_t i1, intptr_t i2, intptr_t i3, intptr_t i4, intptr_t i5) { }
|
146
|
+
|