yakg 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +14 -0
- data/VERSION +1 -1
- data/vendor/gems/ruby/2.0.0/build_info/corefoundation-0.2.0.info +1 -0
- data/vendor/gems/ruby/2.0.0/build_info/ffi-1.8.1.info +1 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/CHANGELOG +12 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/LICENSE +8 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/README.md +40 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/array.rb +123 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/base.rb +197 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/boolean.rb +25 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/data.rb +42 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/date.rb +32 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/dictionary.rb +114 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/extensions.rb +158 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/null.rb +11 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/number.rb +98 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/string.rb +91 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation/version.rb +4 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/lib/corefoundation.rb +13 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/array_spec.rb +92 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/boolean_spec.rb +24 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/data_spec.rb +30 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/date_spec.rb +25 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/dictionary_spec.rb +81 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/extensions_spec.rb +127 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/null_spec.rb +7 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/number_spec.rb +52 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/spec_helper.rb +10 -0
- data/vendor/gems/ruby/2.0.0/gems/corefoundation-0.2.0/spec/string_spec.rb +48 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/COPYING +674 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/COPYING.LESSER +165 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/History.txt +1 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/LICENSE +14 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/README.md +109 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/Rakefile +219 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/ffi.gemspec +22 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/gen/Rakefile +30 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/gen/log +1 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/autopointer.rb +184 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/buffer.rb +4 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/callback.rb +4 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/enum.rb +162 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/errno.rb +33 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/ffi.iml +11 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/ffi.rb +33 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/io.rb +52 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/library.rb +489 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/managedstruct.rb +55 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/memorypointer.rb +1 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/arm-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-darwin/types.conf +100 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-linux/types.conf +103 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-openbsd/types.conf +126 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i386-windows/types.conf +105 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/i486-gnu/types.conf +107 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/ia64-linux/types.conf +104 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/mips-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/mipsel-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/powerpc-aix/types.conf +180 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/powerpc-linux/types.conf +100 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/x86_64-darwin/types.conf +100 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/x86_64-linux/types.conf +102 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/x86_64-netbsd/types.conf +126 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/x86_64-openbsd/types.conf +126 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform/x86_64-windows/types.conf +27 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/platform.rb +139 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/pointer.rb +122 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/struct.rb +356 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/struct_layout_builder.rb +211 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/tools/const_generator.rb +229 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/tools/generator.rb +60 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/tools/generator_task.rb +36 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/tools/struct_generator.rb +194 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/tools/types_generator.rb +135 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/types.rb +177 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/union.rb +32 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/variadic.rb +65 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi/version.rb +4 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi.rb +28 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/lib/ffi_c.bundle +0 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/Benchmark.c +52 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/BoolTest.c +31 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/BufferTest.c +31 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/ClosureTest.c +190 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/EnumTest.c +34 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/FunctionTest.c +58 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/GNUmakefile +149 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/GlobalVariable.c +62 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/LastErrorTest.c +21 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/NumberTest.c +132 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/PointerTest.c +63 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/ReferenceTest.c +23 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/StringTest.c +34 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/StructTest.c +240 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/UnionTest.c +43 -0
- data/vendor/gems/ruby/2.0.0/gems/ffi-1.8.1/libtest/VariadicTest.c +62 -0
- data/vendor/gems/ruby/2.0.0/specifications/corefoundation-0.2.0.gemspec +42 -0
- data/vendor/gems/ruby/2.0.0/specifications/ffi-1.8.1.gemspec +42 -0
- data/yakg.gemspec +3 -2
- metadata +167 -76
@@ -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,62 @@
|
|
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 <stdint.h>
|
9
|
+
|
10
|
+
typedef int8_t s8;
|
11
|
+
typedef uint8_t u8;
|
12
|
+
typedef int16_t s16;
|
13
|
+
typedef uint16_t u16;
|
14
|
+
typedef int32_t s32;
|
15
|
+
typedef uint32_t u32;
|
16
|
+
typedef int64_t s64;
|
17
|
+
typedef uint64_t u64;
|
18
|
+
typedef signed long sL;
|
19
|
+
typedef unsigned long uL;
|
20
|
+
typedef float f32;
|
21
|
+
typedef double f64;
|
22
|
+
#if !defined(__OpenBSD__)
|
23
|
+
typedef unsigned long ulong;
|
24
|
+
#endif
|
25
|
+
typedef void* pointer;
|
26
|
+
typedef void* P;
|
27
|
+
|
28
|
+
#define GVAR(T) \
|
29
|
+
extern T gvar_##T; \
|
30
|
+
T gvar_##T = (T) -1; \
|
31
|
+
T gvar_##T##_get() { return gvar_##T; }; \
|
32
|
+
void gvar_##T##_set(T v) { gvar_##T = v; }
|
33
|
+
|
34
|
+
GVAR(s8);
|
35
|
+
GVAR(u8);
|
36
|
+
GVAR(s16);
|
37
|
+
GVAR(u16);
|
38
|
+
GVAR(s32);
|
39
|
+
GVAR(u32);
|
40
|
+
GVAR(s64);
|
41
|
+
GVAR(u64);
|
42
|
+
GVAR(long);
|
43
|
+
GVAR(ulong);
|
44
|
+
GVAR(pointer);
|
45
|
+
|
46
|
+
struct gstruct {
|
47
|
+
long data;
|
48
|
+
};
|
49
|
+
|
50
|
+
struct gstruct gvar_gstruct = { -1 };
|
51
|
+
|
52
|
+
struct gstruct*
|
53
|
+
gvar_gstruct_get(void)
|
54
|
+
{
|
55
|
+
return &gvar_gstruct;
|
56
|
+
}
|
57
|
+
|
58
|
+
void
|
59
|
+
gvar_gstruct_set(const struct gstruct* val)
|
60
|
+
{
|
61
|
+
gvar_gstruct = *val;
|
62
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2007 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* For licensing, see LICENSE.SPECS
|
5
|
+
*/
|
6
|
+
|
7
|
+
#if defined(_WIN32) || defined(__WIN32__)
|
8
|
+
# include <windows.h>
|
9
|
+
#else
|
10
|
+
# include <errno.h>
|
11
|
+
#endif
|
12
|
+
|
13
|
+
int setLastError(int error) {
|
14
|
+
#if defined(_WIN32) || defined(__WIN32__)
|
15
|
+
SetLastError(error);
|
16
|
+
#else
|
17
|
+
errno = error;
|
18
|
+
#endif
|
19
|
+
return -1;
|
20
|
+
}
|
21
|
+
|
@@ -0,0 +1,132 @@
|
|
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 <string.h>
|
10
|
+
#include <stdint.h>
|
11
|
+
|
12
|
+
#if defined(__sparc) && defined(__sun__)
|
13
|
+
#define fix_mem_access __asm("ta 6")
|
14
|
+
#else
|
15
|
+
#define fix_mem_access
|
16
|
+
#endif
|
17
|
+
|
18
|
+
typedef int8_t s8;
|
19
|
+
typedef uint8_t u8;
|
20
|
+
typedef int16_t s16;
|
21
|
+
typedef uint16_t u16;
|
22
|
+
typedef int32_t s32;
|
23
|
+
typedef uint32_t u32;
|
24
|
+
typedef int64_t s64;
|
25
|
+
typedef uint64_t u64;
|
26
|
+
typedef signed long sL;
|
27
|
+
typedef unsigned long uL;
|
28
|
+
typedef float f32;
|
29
|
+
typedef double f64;
|
30
|
+
typedef long double f128;
|
31
|
+
#if !defined(__OpenBSD__)
|
32
|
+
typedef unsigned long ulong;
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#define ADD(T) T add_##T(T arg1, T arg2) { return arg1 + arg2; }
|
36
|
+
#define SUB(T) T sub_##T(T arg1, T arg2) { return arg1 - arg2; }
|
37
|
+
#define MUL(T) T mul_##T(T arg1, T arg2) { return arg1 * arg2; }
|
38
|
+
#define DIV(T) T div_##T(T arg1, T arg2) { return arg1 / arg2; }
|
39
|
+
#define RET(T) T ret_##T(T arg1) { return arg1; }
|
40
|
+
#define SET(T) static T T##_;void set_##T(T arg1) { T##_ = arg1; }
|
41
|
+
#define GET(T) T get_##T() { return T##_; }
|
42
|
+
typedef char* ptr;
|
43
|
+
#define TEST(T) ADD(T) SUB(T) MUL(T) DIV(T) RET(T) SET(T) GET(T)
|
44
|
+
TEST(s8);
|
45
|
+
TEST(u8);
|
46
|
+
TEST(s16);
|
47
|
+
TEST(u16);
|
48
|
+
TEST(s32);
|
49
|
+
TEST(u32);
|
50
|
+
TEST(s64);
|
51
|
+
TEST(u64);
|
52
|
+
TEST(float);
|
53
|
+
TEST(double);
|
54
|
+
TEST(long);
|
55
|
+
TEST(ulong);
|
56
|
+
TEST(f128);
|
57
|
+
|
58
|
+
#define ADD2(R, T1, T2) R add_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 + arg2; }
|
59
|
+
#define SUB2(R, T1, T2) R sub_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 - arg2; }
|
60
|
+
#define MUL2(R, T1, T2) R mul_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 * arg2; }
|
61
|
+
#define DIV2(R, T1, T2) R div_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 / arg2; }
|
62
|
+
|
63
|
+
#define T2__(R, T1, T2) ADD2(R, T1, T2) SUB2(R, T1, T2) MUL2(R, T1, T2) DIV2(R, T1, T2)
|
64
|
+
#define T2_(R, T1) \
|
65
|
+
T2__(R, T1, s8) T2__(R, T1, u8) \
|
66
|
+
T2__(R, T1, s16) T2__(R, T1, u16) \
|
67
|
+
T2__(R, T1, s32) T2__(R, T1, u32) \
|
68
|
+
T2__(R, T1, sL) T2__(R, T1, uL) \
|
69
|
+
T2__(R, T1, s64) T2__(R, T1, u64) \
|
70
|
+
|
71
|
+
#define TEST2(R) \
|
72
|
+
T2_(R, s8) T2_(R, u8) T2_(R, s16) T2_(R, u16) T2_(R, s32) T2_(R, u32) \
|
73
|
+
T2_(R, sL) T2_(R, uL) T2_(R, s64) T2_(R, u64)
|
74
|
+
|
75
|
+
#ifdef notyet
|
76
|
+
TEST2(s32)
|
77
|
+
TEST2(u32)
|
78
|
+
TEST2(s64)
|
79
|
+
TEST2(u64)
|
80
|
+
#endif
|
81
|
+
|
82
|
+
#define ADD3(R, T1, T2, T3) R add_##T1##T2##T3##_##R(T1 arg1, T2 arg2, T3 arg3) { return arg1 + arg2 + arg3; }
|
83
|
+
#define pack_f32(buf, v) do { float f = v; memcpy((buf), &f, sizeof(f)); } while(0)
|
84
|
+
#define pack_f64(buf, v) do { double f = v; memcpy((buf), &f, sizeof(f)); } while(0)
|
85
|
+
#define pack_int(buf, v) do { *(buf) = v; } while(0)
|
86
|
+
#define pack_s8 pack_int
|
87
|
+
#define pack_u8 pack_int
|
88
|
+
#define pack_s16 pack_int
|
89
|
+
#define pack_u16 pack_int
|
90
|
+
#define pack_s32 pack_int
|
91
|
+
#define pack_u32 pack_int
|
92
|
+
#define pack_s64 pack_int
|
93
|
+
#define pack_u64 pack_int
|
94
|
+
#define pack_sL pack_int
|
95
|
+
#define pack_uL pack_int
|
96
|
+
|
97
|
+
#define PACK3(R, T1, T2, T3) void pack_##T1##T2##T3##_##R(T1 arg1, T2 arg2, T3 arg3, R* r) { \
|
98
|
+
fix_mem_access; \
|
99
|
+
pack_##T1(&r[0], arg1); \
|
100
|
+
pack_##T2(&r[1], arg2); \
|
101
|
+
pack_##T3(&r[2], arg3); \
|
102
|
+
}
|
103
|
+
|
104
|
+
#define T3___(R, T1, T2, T3) PACK3(R, T1, T2, T3) /* SUB2(R, T1, T2) MUL2(R, T1, T2) DIV2(R, T1, T2) */
|
105
|
+
#define T3__(R, T1, T2) \
|
106
|
+
T3___(R, T1, T2, s8) T3___(R, T1, T2, u8) \
|
107
|
+
T3___(R, T1, T2, s16) T3___(R, T1, T2, u16) \
|
108
|
+
T3___(R, T1, T2, s32) T3___(R, T1, T2, u32) \
|
109
|
+
T3___(R, T1, T2, sL) T3___(R, T1, T2, uL) \
|
110
|
+
T3___(R, T1, T2, s64) T3___(R, T1, T2, u64) \
|
111
|
+
T3___(R, T1, T2, f32) T3___(R, T1, T2, f64) \
|
112
|
+
|
113
|
+
#define T3_(R, T1) \
|
114
|
+
T3__(R, T1, s8) T3__(R, T1, u8) \
|
115
|
+
T3__(R, T1, s16) T3__(R, T1, u16) \
|
116
|
+
T3__(R, T1, s32) T3__(R, T1, u32) \
|
117
|
+
T3__(R, T1, sL) T3__(R, T1, uL) \
|
118
|
+
T3__(R, T1, s64) T3__(R, T1, u64) \
|
119
|
+
T3__(R, T1, f32) T3__(R, T1, f64) \
|
120
|
+
|
121
|
+
#define TEST3(R) \
|
122
|
+
T3_(R, s8) T3_(R, u8) T3_(R, s16) T3_(R, u16) T3_(R, s32) T3_(R, u32) \
|
123
|
+
T3_(R, sL) T3_(R, uL) T3_(R, s64) T3_(R, u64) T3_(R, f32) T3_(R, f64)
|
124
|
+
|
125
|
+
TEST3(s64)
|
126
|
+
|
127
|
+
void
|
128
|
+
foo6(intptr_t i1, intptr_t i2, intptr_t i3, intptr_t i4, intptr_t i5, intptr_t i6) { }
|
129
|
+
|
130
|
+
void
|
131
|
+
foo5(intptr_t i1, intptr_t i2, intptr_t i3, intptr_t i4, intptr_t i5) { }
|
132
|
+
|
@@ -0,0 +1,63 @@
|
|
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
|
+
|
@@ -0,0 +1,23 @@
|
|
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
|
+
|
@@ -0,0 +1,34 @@
|
|
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
|
+
|
@@ -0,0 +1,240 @@
|
|
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 <stdlib.h>
|
9
|
+
#include <stdbool.h>
|
10
|
+
#include <stdint.h>
|
11
|
+
#include <string.h>
|
12
|
+
#include <stdarg.h>
|
13
|
+
|
14
|
+
typedef char s8;
|
15
|
+
typedef short s16;
|
16
|
+
typedef int s32;
|
17
|
+
typedef long long s64;
|
18
|
+
typedef float f32;
|
19
|
+
typedef double f64;
|
20
|
+
|
21
|
+
typedef struct bugged_struct {
|
22
|
+
unsigned char visible;
|
23
|
+
unsigned int x;
|
24
|
+
unsigned int y;
|
25
|
+
short rx;
|
26
|
+
short ry;
|
27
|
+
unsigned char order;
|
28
|
+
unsigned char size;
|
29
|
+
} bugged_struct_t;
|
30
|
+
|
31
|
+
unsigned int
|
32
|
+
bugged_struct_size() {
|
33
|
+
return sizeof(bugged_struct_t);
|
34
|
+
}
|
35
|
+
|
36
|
+
struct test1 {
|
37
|
+
char b;
|
38
|
+
short s;
|
39
|
+
int i;
|
40
|
+
long long j;
|
41
|
+
long l;
|
42
|
+
float f;
|
43
|
+
double d;
|
44
|
+
char string[32];
|
45
|
+
};
|
46
|
+
|
47
|
+
struct struct_with_array {
|
48
|
+
char c;
|
49
|
+
int a[5];
|
50
|
+
};
|
51
|
+
|
52
|
+
struct nested {
|
53
|
+
int i;
|
54
|
+
};
|
55
|
+
|
56
|
+
struct container {
|
57
|
+
char first;
|
58
|
+
struct nested s;
|
59
|
+
};
|
60
|
+
|
61
|
+
int
|
62
|
+
struct_align_nested_struct(struct container* a) { return a->s.i; }
|
63
|
+
|
64
|
+
void*
|
65
|
+
struct_field_array(struct struct_with_array* s) { return &s->a; }
|
66
|
+
|
67
|
+
struct container*
|
68
|
+
struct_make_container_struct(int i)
|
69
|
+
{
|
70
|
+
static struct container cs;
|
71
|
+
memset(&cs, 0, sizeof(cs));
|
72
|
+
cs.first = 1;
|
73
|
+
cs.s.i = i;
|
74
|
+
return &cs;
|
75
|
+
}
|
76
|
+
|
77
|
+
#define T(x, type) \
|
78
|
+
type struct_field_##type(struct test1* t) { return t->x; } \
|
79
|
+
struct type##_align { char first; type value; }; \
|
80
|
+
type struct_align_##type(struct type##_align* a) { return a->value; }
|
81
|
+
|
82
|
+
T(b, s8);
|
83
|
+
T(s, s16);
|
84
|
+
T(i, s32);
|
85
|
+
T(j, s64);
|
86
|
+
T(f, f32);
|
87
|
+
T(d, f64);
|
88
|
+
T(l, long);
|
89
|
+
|
90
|
+
void
|
91
|
+
struct_set_string(struct test1* t, char* s)
|
92
|
+
{
|
93
|
+
strcpy(t->string, s);
|
94
|
+
}
|
95
|
+
|
96
|
+
struct test1*
|
97
|
+
struct_make_struct(char b, short s, int i, long long ll, float f, double d)
|
98
|
+
{
|
99
|
+
static struct test1 t;
|
100
|
+
memset(&t, 0, sizeof(t));
|
101
|
+
t.b = b;
|
102
|
+
t.s = s;
|
103
|
+
t.i = i;
|
104
|
+
t.j = ll;
|
105
|
+
t.f = f;
|
106
|
+
t.d = d;
|
107
|
+
return &t;
|
108
|
+
}
|
109
|
+
|
110
|
+
typedef int (*add_cb)(int a1, int a2);
|
111
|
+
typedef int (*sub_cb)(int a1, int a2);
|
112
|
+
struct test2 {
|
113
|
+
add_cb add_callback;
|
114
|
+
sub_cb sub_callback;
|
115
|
+
};
|
116
|
+
|
117
|
+
int
|
118
|
+
struct_call_add_cb(struct test2* t, int a1, int a2)
|
119
|
+
{
|
120
|
+
return t->add_callback(a1, a2);
|
121
|
+
}
|
122
|
+
|
123
|
+
int
|
124
|
+
struct_call_sub_cb(struct test2* t, int a1, int a2)
|
125
|
+
{
|
126
|
+
return t->sub_callback(a1, a2);
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
struct struct_with_array*
|
131
|
+
struct_make_struct_with_array(int a_0, int a_1, int a_2, int a_3, int a_4)
|
132
|
+
{
|
133
|
+
static struct struct_with_array s;
|
134
|
+
|
135
|
+
memset(&s, 0, sizeof(s));
|
136
|
+
|
137
|
+
s.a[0] = a_0;
|
138
|
+
s.a[1] = a_1;
|
139
|
+
s.a[2] = a_2;
|
140
|
+
s.a[3] = a_3;
|
141
|
+
s.a[4] = a_4;
|
142
|
+
|
143
|
+
return &s;
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
struct s8s32 {
|
148
|
+
char s8;
|
149
|
+
int s32;
|
150
|
+
};
|
151
|
+
|
152
|
+
struct s8s32
|
153
|
+
struct_return_s8s32()
|
154
|
+
{
|
155
|
+
struct s8s32 s;
|
156
|
+
s.s8 = 0x7f;
|
157
|
+
s.s32 = 0x12345678;
|
158
|
+
|
159
|
+
return s;
|
160
|
+
}
|
161
|
+
|
162
|
+
struct s8s32
|
163
|
+
struct_s8s32_set(char s8, int s32)
|
164
|
+
{
|
165
|
+
struct s8s32 s;
|
166
|
+
|
167
|
+
s.s8 = s8;
|
168
|
+
s.s32 = s32;
|
169
|
+
|
170
|
+
return s;
|
171
|
+
}
|
172
|
+
|
173
|
+
int
|
174
|
+
struct_s8s32_get_s8(struct s8s32 s)
|
175
|
+
{
|
176
|
+
return s.s8;
|
177
|
+
}
|
178
|
+
|
179
|
+
int
|
180
|
+
struct_s8s32_get_s32(struct s8s32 s)
|
181
|
+
{
|
182
|
+
return s.s32;
|
183
|
+
}
|
184
|
+
|
185
|
+
struct s8s32
|
186
|
+
struct_s8s32_ret_s8s32(struct s8s32 s)
|
187
|
+
{
|
188
|
+
return s;
|
189
|
+
}
|
190
|
+
|
191
|
+
// Pass a struct and an int arg, ensure the int arg is passed correctly
|
192
|
+
int
|
193
|
+
struct_s8s32_s32_ret_s32(struct s8s32 s, int s32)
|
194
|
+
{
|
195
|
+
return s32;
|
196
|
+
}
|
197
|
+
|
198
|
+
// Pass a struct and a long long arg, ensure the long long arg is passed correctly
|
199
|
+
long long
|
200
|
+
struct_s8s32_s64_ret_s64(struct s8s32 s, long long s64)
|
201
|
+
{
|
202
|
+
return s64;
|
203
|
+
}
|
204
|
+
|
205
|
+
// Pass a struct and a long long arg, ensure the long long arg is passed correctly
|
206
|
+
int
|
207
|
+
struct_s32_ptr_s32_s8s32_ret_s32(int s32a, void *ptr, int s32b, struct s8s32 s)
|
208
|
+
{
|
209
|
+
if (ptr != NULL) *(struct s8s32 *) ptr = s;
|
210
|
+
return s.s32;
|
211
|
+
}
|
212
|
+
|
213
|
+
// Pass a char *, copy into buffer length struct
|
214
|
+
struct struct_string {
|
215
|
+
char *bytes;
|
216
|
+
int len;
|
217
|
+
};
|
218
|
+
|
219
|
+
struct struct_string
|
220
|
+
struct_varargs_ret_struct_string(int len, ...)
|
221
|
+
{
|
222
|
+
struct struct_string ss;
|
223
|
+
va_list vl;
|
224
|
+
char* cp = NULL;
|
225
|
+
|
226
|
+
va_start(vl, len);
|
227
|
+
|
228
|
+
ss.len = len;
|
229
|
+
ss.bytes = va_arg(vl, char *);
|
230
|
+
if (ss.bytes != NULL) {
|
231
|
+
cp = malloc(strlen(ss.bytes) + 1);
|
232
|
+
strcpy(cp, ss.bytes);
|
233
|
+
ss.bytes = cp;
|
234
|
+
}
|
235
|
+
|
236
|
+
va_end(vl);
|
237
|
+
|
238
|
+
return ss;
|
239
|
+
}
|
240
|
+
|