diff --git a/examples/demo.odin b/examples/demo.odin index 3ff904d88..85868e35b 100644 --- a/examples/demo.odin +++ b/examples/demo.odin @@ -729,17 +729,49 @@ explicit_procedure_overloading :: proc() { // add(1, 2.0); } -main :: proc() { - when true { - // general_stuff(); - // default_struct_values(); - // union_type(); - // parametric_polymorphism(); - // threading_example(); - // array_programming(); - // using_in(); - // named_proc_return_parameters(); - // enum_export(); - // explicit_procedure_overloading(); +complete_switch :: proc() { + { // enum + Foo :: enum #export { + A, + B, + C, + D, + } + + b := Foo.B; + f := Foo.A; + #complete switch f { + case A...C: fmt.println("A...C"); + // case A: fmt.println("A"); + // case B: fmt.println("B"); + // case C: fmt.println("C"); + case D: fmt.println("D"); + case: fmt.println("?"); + } + } + { // union + Foo :: union {int, bool}; + f: Foo = 123; + #complete switch _ in f { + case int: fmt.println("int"); + case bool: fmt.println("bool"); + case: + } + } +} + +main :: proc() { + when true { + general_stuff(); + default_struct_values(); + union_type(); + parametric_polymorphism(); + threading_example(); + array_programming(); + using_in(); + named_proc_return_parameters(); + enum_export(); + explicit_procedure_overloading(); + complete_switch(); } } diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 1014b8c46..840df6ad9 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -454,7 +454,7 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo case Entity_TypeName: { Type *t = base_type(e->type); if (t->kind == Type_Enum) { - for (isize i = 0; i < t->Enum.field_count; i++) { + for_array(i, t->Enum.fields) { Entity *f = t->Enum.fields[i]; if (!is_entity_exported(f)) continue; @@ -555,6 +555,52 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo return true; } + +struct TypeAndToken { + Type *type; + Token token; +}; + +void add_constant_switch_case(Checker *c, Map *seen, Operand operand, bool use_expr = true) { + if (operand.value.kind == ExactValue_Invalid) { + return; + } + HashKey key = hash_exact_value(operand.value); + TypeAndToken *found = map_get(seen, key); + if (found != nullptr) { + gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena); + defer (gb_temp_arena_memory_end(tmp)); + + isize count = multi_map_count(seen, key); + TypeAndToken *taps = gb_alloc_array(c->tmp_allocator, TypeAndToken, count); + + multi_map_get_all(seen, key, taps); + for (isize i = 0; i < count; i++) { + TypeAndToken tap = taps[i]; + if (are_types_identical(operand.type, tap.type)) { + TokenPos pos = tap.token.pos; + if (use_expr) { + gbString expr_str = expr_to_string(operand.expr); + error(operand.expr, + "Duplicate case '%s'\n" + "\tprevious case at %.*s(%td:%td)", + expr_str, + LIT(pos.file), pos.line, pos.column); + gb_string_free(expr_str); + } else { + error(operand.expr, + "Duplicate case found with previous case at %.*s(%td:%td)", + LIT(pos.file), pos.line, pos.column); + } + return; + } + } + } + + TypeAndToken tap = {operand.type, ast_node_token(operand.expr)}; + multi_map_insert(seen, key, tap); +} + void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) { ast_node(ss, SwitchStmt, node); @@ -611,12 +657,16 @@ void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) { } } - struct TypeAndToken { - Type *type; - Token token; - }; + bool complete = ss->complete; - Map seen = {}; // NOTE(bill): Multimap + if (complete) { + if (!is_type_enum(x.type)) { + error(x.expr, "#complete switch statement can be only used with an enum type"); + complete = false; + } + } + + Map seen = {}; // NOTE(bill): Multimap, Key: ExactValue map_init(&seen, heap_allocator()); defer (map_destroy(&seen)); @@ -680,9 +730,48 @@ void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) { default: error(ie->op, "Invalid interval operator"); continue; } + + Operand a1 = lhs; Operand b1 = rhs; check_comparison(c, &a1, &b1, op); + if (complete) { + if (lhs.mode != Addressing_Constant) { + error(lhs.expr, "#complete switch statement only allows constant case clauses"); + } + if (rhs.mode != Addressing_Constant) { + error(rhs.expr, "#complete switch statement only allows constant case clauses"); + } + } + + if (a1.mode != Addressing_Invalid && + lhs.mode == Addressing_Constant && rhs.mode == Addressing_Constant) { + ExactValue start = lhs.value; + ExactValue end = rhs.value; + ExactValue one = exact_value_i64(1); + match_exact_values(&one, &start); + for (ExactValue i = start; + compare_exact_values(op, i, end); + i = exact_value_add(i, one)) { + bool use_expr = false; + Operand x = lhs; + x.value = i; + if (compare_exact_values(Token_CmpEq, i, start)) { + use_expr = true; + } else if (compare_exact_values(Token_CmpEq, i, end)) { + x = rhs; + use_expr = true; + } + add_constant_switch_case(c, &seen, x, use_expr); + } + } else { + if (lhs.mode == Addressing_Constant) { + add_constant_switch_case(c, &seen, lhs); + } + if (rhs.mode == Addressing_Constant && op == Token_LtEq) { + add_constant_switch_case(c, &seen, rhs); + } + } } else { Operand y = {}; check_expr(c, &y, expr); @@ -704,47 +793,13 @@ void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) { continue; } if (y.mode != Addressing_Constant) { + if (complete) { + error(y.expr, "#complete switch statement only allows constant case clauses"); + } continue; } - - if (y.value.kind != ExactValue_Invalid) { - HashKey key = hash_exact_value(y.value); - TypeAndToken *found = map_get(&seen, key); - if (found != nullptr) { - gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena); - defer (gb_temp_arena_memory_end(tmp)); - - isize count = multi_map_count(&seen, key); - TypeAndToken *taps = gb_alloc_array(c->tmp_allocator, TypeAndToken, count); - - multi_map_get_all(&seen, key, taps); - bool continue_outer = false; - - for (isize i = 0; i < count; i++) { - TypeAndToken tap = taps[i]; - if (are_types_identical(y.type, tap.type)) { - TokenPos pos = tap.token.pos; - gbString expr_str = expr_to_string(y.expr); - error(y.expr, - "Duplicate case '%s'\n" - "\tprevious case at %.*s(%td:%td)", - expr_str, - LIT(pos.file), pos.line, pos.column); - gb_string_free(expr_str); - continue_outer = true; - break; - } - } - - - if (continue_outer) { - continue; - } - } - TypeAndToken tap = {y.type, ast_node_token(y.expr)}; - multi_map_insert(&seen, key, tap); - } + add_constant_switch_case(c, &seen, y); } } @@ -752,6 +807,47 @@ void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) { check_stmt_list(c, cc->stmts, mod_flags); check_close_scope(c); } + + if (complete) { + Type *et = base_type(x.type); + GB_ASSERT(is_type_enum(et)); + auto fields = et->Enum.fields; + + gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena); + defer (gb_temp_arena_memory_end(tmp)); + + Array unhandled = {}; + array_init(&unhandled, c->tmp_allocator, fields.count); + + for_array(i, fields) { + Entity *f = fields[i]; + if (f->kind != Entity_Constant) { + continue; + } + ExactValue v = f->Constant.value; + HashKey key = hash_exact_value(v); + auto found = map_get(&seen, key); + if (!found) { + array_add(&unhandled, f); + } + } + + if (unhandled.count > 0) { + if (unhandled.count == 1) { + error_no_newline(node, "Unhandled switch case: "); + } else { + error_no_newline(node, "Unhandled switch cases: "); + } + for_array(i, unhandled) { + Entity *f = unhandled[i]; + if (i > 0) { + gb_printf_err(", "); + } + gb_printf_err("%.*s", LIT(f->token.string)); + } + gb_printf_err("\n"); + } + } } @@ -812,6 +908,14 @@ void check_type_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) { return; } + bool complete = ss->complete; + if (complete) { + if (switch_kind != Switch_Union) { + error(node, "#complete switch statement may only be used with a union"); + complete = false; + } + } + bool is_ptr = is_type_pointer(x.type); // NOTE(bill): Check for multiple defaults @@ -935,6 +1039,44 @@ void check_type_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) { check_stmt_list(c, cc->stmts, mod_flags); check_close_scope(c); } + + if (complete) { + Type *ut = base_type(x.type); + GB_ASSERT(is_type_union(ut)); + auto variants = ut->Union.variants; + + gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena); + defer (gb_temp_arena_memory_end(tmp)); + + Array unhandled = {}; + array_init(&unhandled, c->tmp_allocator, variants.count); + + for_array(i, variants) { + Type *t = variants[i]; + auto found = map_get(&seen, hash_type(t)); + if (!found) { + array_add(&unhandled, t); + } + } + + if (unhandled.count > 0) { + if (unhandled.count == 1) { + error_no_newline(node, "Unhandled switch case: "); + } else { + error_no_newline(node, "Unhandled switch cases: "); + } + for_array(i, unhandled) { + Type *t = unhandled[i]; + if (i > 0) { + gb_printf_err(", "); + } + gbString s = type_to_string(t); + gb_printf_err("%s", s); + gb_string_free(s); + } + gb_printf_err("\n"); + } + } } void check_stmt_internal(Checker *c, AstNode *node, u32 flags) { diff --git a/src/check_type.cpp b/src/check_type.cpp index 47e27c27d..ebcd297db 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -794,9 +794,8 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod GB_ASSERT(fields.count <= et->fields.count); - enum_type->Enum.fields = fields.data; - enum_type->Enum.field_count = cast(i32)fields.count; - enum_type->Enum.is_export = et->is_export; + enum_type->Enum.fields = fields; + enum_type->Enum.is_export = et->is_export; if (et->is_export) { Scope *parent = c->context.scope->parent; for_array(i, fields) { diff --git a/src/dyncall/include/dyncall.h b/src/dyncall/include/dyncall.h deleted file mode 100644 index 28981472e..000000000 --- a/src/dyncall/include/dyncall.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - - Package: dyncall - Library: dyncall - File: dyncall/dyncall.h - Description: public header for library dyncall - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -/* - - dyncall C API - - REVISION - 2015/07/08 added SYS_PPC64 system call - 2015/01/16 added SYS_PPC32 system call - 2007/12/11 initial - -*/ - -#ifndef DYNCALL_H -#define DYNCALL_H - -#include "dyncall_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct DCCallVM_ DCCallVM; -typedef struct DCstruct_ DCstruct; - -/* Supported Calling Convention Modes */ - -#define DC_CALL_C_DEFAULT 0 -#define DC_CALL_C_ELLIPSIS 100 -#define DC_CALL_C_ELLIPSIS_VARARGS 101 -#define DC_CALL_C_X86_CDECL 1 -#define DC_CALL_C_X86_WIN32_STD 2 -#define DC_CALL_C_X86_WIN32_FAST_MS 3 -#define DC_CALL_C_X86_WIN32_FAST_GNU 4 -#define DC_CALL_C_X86_WIN32_THIS_MS 5 -#define DC_CALL_C_X86_WIN32_THIS_GNU 6 -#define DC_CALL_C_X64_WIN64 7 -#define DC_CALL_C_X64_SYSV 8 -#define DC_CALL_C_PPC32_DARWIN 9 -#define DC_CALL_C_PPC32_OSX DC_CALL_C_PPC32_DARWIN /* alias */ -#define DC_CALL_C_ARM_ARM_EABI 10 -#define DC_CALL_C_ARM_THUMB_EABI 11 -#define DC_CALL_C_ARM_ARMHF 30 -#define DC_CALL_C_MIPS32_EABI 12 -#define DC_CALL_C_MIPS32_PSPSDK DC_CALL_C_MIPS32_EABI /* alias - deprecated. */ -#define DC_CALL_C_PPC32_SYSV 13 -#define DC_CALL_C_PPC32_LINUX DC_CALL_C_PPC32_SYSV /* alias */ -#define DC_CALL_C_ARM_ARM 14 -#define DC_CALL_C_ARM_THUMB 15 -#define DC_CALL_C_MIPS32_O32 16 -#define DC_CALL_C_MIPS64_N32 17 -#define DC_CALL_C_MIPS64_N64 18 -#define DC_CALL_C_X86_PLAN9 19 -#define DC_CALL_C_SPARC32 20 -#define DC_CALL_C_SPARC64 21 -#define DC_CALL_C_ARM64 22 -#define DC_CALL_C_PPC64 23 -#define DC_CALL_C_PPC64_LINUX DC_CALL_C_PPC64 /* alias */ -#define DC_CALL_SYS_DEFAULT 200 -#define DC_CALL_SYS_X86_INT80H_LINUX 201 -#define DC_CALL_SYS_X86_INT80H_BSD 202 -#define DC_CALL_SYS_PPC32 210 -#define DC_CALL_SYS_PPC64 211 - -/* Error codes. */ - -#define DC_ERROR_NONE 0 -#define DC_ERROR_UNSUPPORTED_MODE -1 - -DC_API DCCallVM* dcNewCallVM (DCsize size); -DC_API void dcFree (DCCallVM* vm); -DC_API void dcReset (DCCallVM* vm); - -DC_API void dcMode (DCCallVM* vm, DCint mode); - -DC_API void dcArgBool (DCCallVM* vm, DCbool value); -DC_API void dcArgChar (DCCallVM* vm, DCchar value); -DC_API void dcArgShort (DCCallVM* vm, DCshort value); -DC_API void dcArgInt (DCCallVM* vm, DCint value); -DC_API void dcArgLong (DCCallVM* vm, DClong value); -DC_API void dcArgLongLong (DCCallVM* vm, DClonglong value); -DC_API void dcArgFloat (DCCallVM* vm, DCfloat value); -DC_API void dcArgDouble (DCCallVM* vm, DCdouble value); -DC_API void dcArgPointer (DCCallVM* vm, DCpointer value); -DC_API void dcArgStruct (DCCallVM* vm, DCstruct* s, DCpointer value); - -DC_API void dcCallVoid (DCCallVM* vm, DCpointer funcptr); -DC_API DCbool dcCallBool (DCCallVM* vm, DCpointer funcptr); -DC_API DCchar dcCallChar (DCCallVM* vm, DCpointer funcptr); -DC_API DCshort dcCallShort (DCCallVM* vm, DCpointer funcptr); -DC_API DCint dcCallInt (DCCallVM* vm, DCpointer funcptr); -DC_API DClong dcCallLong (DCCallVM* vm, DCpointer funcptr); -DC_API DClonglong dcCallLongLong (DCCallVM* vm, DCpointer funcptr); -DC_API DCfloat dcCallFloat (DCCallVM* vm, DCpointer funcptr); -DC_API DCdouble dcCallDouble (DCCallVM* vm, DCpointer funcptr); -DC_API DCpointer dcCallPointer (DCCallVM* vm, DCpointer funcptr); -DC_API void dcCallStruct (DCCallVM* vm, DCpointer funcptr, DCstruct* s, DCpointer returnValue); - -DC_API DCint dcGetError (DCCallVM* vm); - -#define DEFAULT_ALIGNMENT 0 -DC_API DCstruct* dcNewStruct (DCsize fieldCount, DCint alignment); -DC_API void dcStructField (DCstruct* s, DCint type, DCint alignment, DCsize arrayLength); -DC_API void dcSubStruct (DCstruct* s, DCsize fieldCount, DCint alignment, DCsize arrayLength); -/* Each dcNewStruct or dcSubStruct call must be paired with a dcCloseStruct. */ -DC_API void dcCloseStruct (DCstruct* s); -DC_API DCsize dcStructSize (DCstruct* s); -DC_API DCsize dcStructAlignment(DCstruct* s); -DC_API void dcFreeStruct (DCstruct* s); - -DC_API DCstruct* dcDefineStruct (const char* signature); - - -#ifdef __cplusplus -} -#endif - -#endif /* DYNCALL_H */ - diff --git a/src/dyncall/include/dyncall_alloc_wx.h b/src/dyncall/include/dyncall_alloc_wx.h deleted file mode 100644 index c948f0bd3..000000000 --- a/src/dyncall/include/dyncall_alloc_wx.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_alloc_wx.h - Description: Allocate write/executable memory - Interface - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_ALLOC_WX_HPP -#define DYNCALL_ALLOC_WX_HPP - -#include "dyncall_types.h" - -typedef int DCerror; - -#ifdef __cplusplus -extern "C" { -#endif - -DCerror dcAllocWX(DCsize size, void** p); -void dcFreeWX (void* p, DCsize size); - -#ifdef __cplusplus -} -#endif - - -#endif /* DYNCALL_ALLOC_WX_HPP */ - diff --git a/src/dyncall/include/dyncall_args.h b/src/dyncall/include/dyncall_args.h deleted file mode 100644 index 4379a53b1..000000000 --- a/src/dyncall/include/dyncall_args.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args.h - Description: Callback's Arguments VM - Interface - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_ARGS_H -#define DYNCALL_ARGS_H - -/* - * dyncall args C API - * - * dyncall args provides serialized access to arguments of a function call. - * related concepts: callback - * - */ - -#include "dyncall.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct DCArgs DCArgs; - -DC_API DCbool dcbArgBool (DCArgs*); -DC_API DCchar dcbArgChar (DCArgs*); -DC_API DCshort dcbArgShort (DCArgs*); -DC_API DCint dcbArgInt (DCArgs*); -DC_API DClong dcbArgLong (DCArgs*); -DC_API DClonglong dcbArgLongLong (DCArgs*); -DC_API DCuchar dcbArgUChar (DCArgs*); -DC_API DCushort dcbArgUShort (DCArgs*); -DC_API DCuint dcbArgUInt (DCArgs*); -DC_API DCulong dcbArgULong (DCArgs*); -DC_API DCulonglong dcbArgULongLong(DCArgs*); -DC_API DCfloat dcbArgFloat (DCArgs*); -DC_API DCdouble dcbArgDouble (DCArgs*); -DC_API DCpointer dcbArgPointer (DCArgs*); - -#ifdef __cplusplus -} -#endif - -#endif /* DYNCALL_ARGS_H */ diff --git a/src/dyncall/include/dyncall_args_arm32_arm.h b/src/dyncall/include/dyncall_args_arm32_arm.h deleted file mode 100644 index 92fbd9099..000000000 --- a/src/dyncall/include/dyncall_args_arm32_arm.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_arm32_arm.h - Description: Callback's Arguments VM - Header for ARM32 (ARM mode) - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALLBACK_ARGS_ARM32_ARM_H -#define DYNCALLBACK_ARGS_ARM32_ARM_H - -#include "dyncall_args.h" - -struct DCArgs -{ - /* Don't change order! */ - long reg_data[4]; - int reg_count; - long* stack_ptr; -#if defined(DC__ABI_ARM_HF) - DCfloat f[16]; - int freg_count; - int dreg_count; -#endif -}; - -#endif /* DYNCALLBACK_ARGS_ARM32_ARM_H */ - diff --git a/src/dyncall/include/dyncall_args_arm32_thumb.h b/src/dyncall/include/dyncall_args_arm32_thumb.h deleted file mode 100644 index 07b6d39ce..000000000 --- a/src/dyncall/include/dyncall_args_arm32_thumb.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_arm32_thumb.h - Description: Callback's Arguments VM - Header for ARM32 (THUMB mode) - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALLBACK_ARGS_ARM32_THUMB_H -#define DYNCALLBACK_ARGS_ARM32_THUMB_H - -#include "dyncall_args_arm32_arm.h" /* Uses same code as ARM mode. */ - -#endif /* DYNCALLBACK_ARGS_ARM32_THUMB_H */ - diff --git a/src/dyncall/include/dyncall_args_mips.h b/src/dyncall/include/dyncall_args_mips.h deleted file mode 100644 index 4cb0220ea..000000000 --- a/src/dyncall/include/dyncall_args_mips.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_mips.h - Description: Callback's Arguments VM - Header for MIPS - License: - - Copyright (c) 2013-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALLBACK_ARGS_MIPS_H -#define DYNCALLBACK_ARGS_MIPS_H - -#include "dyncall_args.h" - -struct DCArgs -{ - int ireg_data[8]; - float freg_data[8]; - int ireg_count; - int freg_count; - unsigned char* stackptr; -}; - -#endif /* DYNCALLBACK_ARGS_MIPS_H */ - diff --git a/src/dyncall/include/dyncall_args_ppc32.h b/src/dyncall/include/dyncall_args_ppc32.h deleted file mode 100644 index 46319ec28..000000000 --- a/src/dyncall/include/dyncall_args_ppc32.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_ppc32.h - Description: Callback's Arguments VM - Header for ppc32 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALLBACK_ARGS_PPC32_H -#define DYNCALLBACK_ARGS_PPC32_H - -#include "dyncall_args.h" - -/* Common Args iterator for Apple and System V ABI. */ - -struct DCArgs -{ - int ireg_data[8]; /* offset: 0 size: 4*8 = 32 */ - double freg_data[13]; /* offset: 32 size: 8*13= 104 */ - unsigned char* stackptr; /* offset: 136 size: 4 */ - int ireg_count; /* offset: 140 size: 4 */ - int freg_count; /* offset: 144 size: 4 */ -}; /* total size: 148 */ - -#endif /* DYNCALLBACK_ARGS_PPC32_H */ - diff --git a/src/dyncall/include/dyncall_args_ppc64.h b/src/dyncall/include/dyncall_args_ppc64.h deleted file mode 100644 index 208e2c65d..000000000 --- a/src/dyncall/include/dyncall_args_ppc64.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_ppc64.h - Description: Callback's Arguments VM - Header for ppc64 - License: - - Copyright (c) 2014-2015 Masanori Mitsugi - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALLBACK_ARGS_PPC64_H -#define DYNCALLBACK_ARGS_PPC64_H - -#include "dyncall_args.h" - -struct DCArgs -{ - long long ireg_data[8]; - double freg_data[13]; - unsigned char* stackptr; - int ireg_count; - int freg_count; -}; - -#endif /* DYNCALLBACK_ARGS_PPC64_H */ - diff --git a/src/dyncall/include/dyncall_args_sparc32.h b/src/dyncall/include/dyncall_args_sparc32.h deleted file mode 100644 index d7e42581c..000000000 --- a/src/dyncall/include/dyncall_args_sparc32.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_sparc32.h - Description: Callback's Arguments VM - Header for sparc32 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALLBACK_ARGS_SPARC32_H -#define DYNCALLBACK_ARGS_SPARC32_H - -#include "dyncall_args.h" - -struct DCArgs -{ - int dummy; -}; - -#endif /* DYNCALLBACK_ARGS_SPARC32_H */ - diff --git a/src/dyncall/include/dyncall_args_sparc64.h b/src/dyncall/include/dyncall_args_sparc64.h deleted file mode 100644 index d238d09cb..000000000 --- a/src/dyncall/include/dyncall_args_sparc64.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_sparc64.h - Description: Callback's Arguments VM - Header for sparc32 - not yet - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALLBACK_ARGS_SPARC64_H -#define DYNCALLBACK_ARGS_SPARC64_H - -#include "dyncall_args.h" - -struct DCArgs -{ - int dummy; -}; - -#endif /* DYNCALLBACK_ARGS_SPARC64_H */ - diff --git a/src/dyncall/include/dyncall_args_x64.h b/src/dyncall/include/dyncall_args_x64.h deleted file mode 100644 index cc10f6bed..000000000 --- a/src/dyncall/include/dyncall_args_x64.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_x64.h - Description: Callback's Arguments VM - Header for x64 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALLBACK_ARGS_X64_H -#define DYNCALLBACK_ARGS_X64_H - -#include "dyncall_args.h" -#include "dyncall_callvm_x64.h" /* reuse structures */ - - -struct DCArgs -{ - /* state */ - int64* stack_ptr; - DCRegCount_x64 reg_count; /* @@@ win64 version should maybe force alignment to 8 in order to be secure */ - - /* reg data */ - DCRegData_x64_s reg_data; -}; - -#endif /* DYNCALLBACK_ARGS_X64_H */ - diff --git a/src/dyncall/include/dyncall_args_x86.h b/src/dyncall/include/dyncall_args_x86.h deleted file mode 100644 index d679dcee3..000000000 --- a/src/dyncall/include/dyncall_args_x86.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_args_x86.h - Description: Callback's Arguments VM - Header for x86 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -#ifndef DYNCALL_ARGS_X86_H_ -#define DYNCALL_ARGS_X86_H_ - -#include "dyncall_args.h" - -typedef struct -{ - DCint (*i32)(DCArgs*); - DClonglong (*i64)(DCArgs*); - DCfloat (*f32)(DCArgs*); - DCdouble (*f64)(DCArgs*); -} DCArgsVT; - -extern DCArgsVT dcArgsVT_default; -extern DCArgsVT dcArgsVT_this_ms; -extern DCArgsVT dcArgsVT_fast_ms; -extern DCArgsVT dcArgsVT_fast_gnu; - -struct DCArgs -{ - /* callmode */ - DCArgsVT* vt; - - /* state */ - int* stack_ptr; - - /* fast data / 'this-ptr' info */ - int fast_data[2]; - int fast_count; -}; - -#endif /* DYNCALL_ARGS_X86_H_ */ diff --git a/src/dyncall/include/dyncall_callback.h b/src/dyncall/include/dyncall_callback.h deleted file mode 100644 index 6d599df61..000000000 --- a/src/dyncall/include/dyncall_callback.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback.h - Description: Callback - Interface - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALL_CALLBACK_H -#define DYNCALL_CALLBACK_H - -#include "dyncall_args.h" -#include "dyncall_signature.h" -#include "dyncall_value.h" - -typedef struct DCCallback DCCallback; - -// TODO: return value is the type encoded as a signature char (character of the set [vBcCsSiIjJlLfd]). - -typedef char (DCCallbackHandler)(DCCallback* pcb, DCArgs* args, DCValue* result, void* userdata); - -#ifdef __cplusplus -extern "C" { -#endif - -DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* funcptr, void* userdata); -void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata); -void dcbFreeCallback(DCCallback* pcb); -void* dcbGetUserData (DCCallback* pcb); - - -#ifdef __cplusplus -} -#endif - -#endif /* DYNCALL_CALLBACK_H */ diff --git a/src/dyncall/include/dyncall_callback_arm32_arm.h b/src/dyncall/include/dyncall_callback_arm32_arm.h deleted file mode 100644 index b463549e3..000000000 --- a/src/dyncall/include/dyncall_callback_arm32_arm.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_arm32_arm.h - Description: Callback - Header for ARM32 (ARM mode) - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -#ifndef DYNCALL_CALLBACK_ARM32_ARM_H_ -#define DYNCALL_CALLBACK_ARM32_ARM_H_ - -#include "dyncall_callback.h" - -#include "dyncall_thunk.h" -#include "dyncall_args_arm32_arm.h" - - -struct DCCallback -{ - DCThunk thunk; // offset 0 - DCCallbackHandler* handler; // offset 12 - void* userdata; // offset 16 -}; - - -#endif /* DYNCALL_CALLBACK_ARM32_ARM_H_ */ - diff --git a/src/dyncall/include/dyncall_callback_arm32_thumb.h b/src/dyncall/include/dyncall_callback_arm32_thumb.h deleted file mode 100644 index 1e4651f37..000000000 --- a/src/dyncall/include/dyncall_callback_arm32_thumb.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_arm32_thumb.h - Description: Callback - Header for ARM32 (THUMB mode) - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -#ifndef DYNCALL_CALLBACK_ARM32_THUMB_H_ -#define DYNCALL_CALLBACK_ARM32_THUMB_H_ - -#include "dyncall_callback_arm32_arm.h" /* Uses same code as ARM mode. */ - -#endif /* DYNCALL_CALLBACK_ARM32_THUMB_H_ */ - diff --git a/src/dyncall/include/dyncall_callback_mips.h b/src/dyncall/include/dyncall_callback_mips.h deleted file mode 100644 index 7814638f0..000000000 --- a/src/dyncall/include/dyncall_callback_mips.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_mips.h - Description: Callback - Header for MIPS - License: - - Copyright (c) 2013-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_CALLBACK_MIPS_H -#define DYNCALL_CALLBACK_MIPS_H - -#include "dyncall_callback.h" - -#include "dyncall_thunk.h" -#include "dyncall_args_mips.h" - -struct DCCallback -{ - DCThunk thunk; /* offset 0, size 20 */ - DCCallbackHandler* handler; /* offset 20, size 4 */ - void* userdata; /* offset 24, size 4 */ -}; - -#endif /* DYNCALL_CALLBACK_MIPS_H */ - diff --git a/src/dyncall/include/dyncall_callback_ppc32.h b/src/dyncall/include/dyncall_callback_ppc32.h deleted file mode 100644 index a252b1a12..000000000 --- a/src/dyncall/include/dyncall_callback_ppc32.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_ppc32.h - Description: Callback - Header for ppc32 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALL_CALLBACK_PPC32_H -#define DYNCALL_CALLBACK_PPC32_H - -#include "dyncall_callback.h" - -#include "dyncall_thunk.h" -#include "dyncall_args_ppc32.h" - -struct DCCallback -{ - DCThunk thunk; /* offset 0, size 24 */ - DCCallbackHandler* handler; /* offset 24, size 4 */ - size_t stack_cleanup; /* offset 28, size 4 */ - void* userdata; /* offset 32, size 4 */ -}; /* total size 36 */ - -#endif /* DYNCALL_CALLBACK_PPC32_H */ - diff --git a/src/dyncall/include/dyncall_callback_ppc64.h b/src/dyncall/include/dyncall_callback_ppc64.h deleted file mode 100644 index 81fdefa2f..000000000 --- a/src/dyncall/include/dyncall_callback_ppc64.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_ppc64.h - Description: Callback - Header for ppc64 - License: - - Copyright (c) 2014-2015 Masanori Mitsugi - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALL_CALLBACK_PPC64_H -#define DYNCALL_CALLBACK_PPC64_H - -#include "dyncall_callback.h" - -#include "dyncall_thunk.h" -#include "dyncall_args_ppc64.h" - -/* - ELF v2 - thunk : offset 0, size 48 - handler : offset 48, size 8 - stack_cleanup : offset 56, size 8 - userdata : offset 64, size 8 - - ELF v1 - thunk : offset 0, size 64 - handler : offset 64, size 8 - stack_cleanup : offset 72, size 8 - userdata : offset 80, size 8 -*/ - -struct DCCallback -{ - DCThunk thunk; - DCCallbackHandler* handler; - size_t stack_cleanup; - void* userdata; -}; - -#endif /* DYNCALL_CALLBACK_PPC64_H */ - diff --git a/src/dyncall/include/dyncall_callback_sparc32.h b/src/dyncall/include/dyncall_callback_sparc32.h deleted file mode 100644 index a9cf762ef..000000000 --- a/src/dyncall/include/dyncall_callback_sparc32.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_sparc32.h - Description: Callback - Header for sparc32 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_CALLBACK_SPARC32_H -#define DYNCALL_CALLBACK_SPARC32_H - -#include "dyncall_callback.h" - -#include "dyncall_thunk.h" -#include "dyncall_args_sparc32.h" - -struct DCCallback -{ - DCThunk thunk; /* offset 0, size ?? */ - DCCallbackHandler* handler; /* offset ??, size 4 */ - size_t stack_cleanup; /* offset ??, size 4 */ - void* userdata; /* offset ??, size 4 */ -}; - -#endif /* DYNCALL_CALLBACK_SPARC32_H */ - diff --git a/src/dyncall/include/dyncall_callback_x64.h b/src/dyncall/include/dyncall_callback_x64.h deleted file mode 100644 index 6517ad21e..000000000 --- a/src/dyncall/include/dyncall_callback_x64.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_x64.h - Description: Callback - Header for x64 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -#ifndef DYNCALL_CALLBACK_X64_H_ -#define DYNCALL_CALLBACK_X64_H_ - -#include "dyncall_callback.h" - -#include "dyncall_thunk.h" -#include "dyncall_args_x64.h" - - -struct DCCallback -{ - DCThunk thunk; // offset 0, size 24 - DCCallbackHandler* handler; // offset 24 - void* userdata; // offset 32 -}; - -#endif /* DYNCALL_CALLBACK_X64_H_ */ - diff --git a/src/dyncall/include/dyncall_callback_x86.h b/src/dyncall/include/dyncall_callback_x86.h deleted file mode 100644 index d2e6f7288..000000000 --- a/src/dyncall/include/dyncall_callback_x86.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_callback_x86.h - Description: Callback - Header for x86 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -#ifndef DYNCALL_CALLBACK_X86_H_ -#define DYNCALL_CALLBACK_X86_H_ - -#include "dyncall_callback.h" - -#include "dyncall_thunk.h" -#include "dyncall_args_x86.h" - -struct DCCallback -{ - DCThunk thunk; /* offset 0, size 16 */ - DCCallbackHandler* handler; /* offset 16 */ - DCArgsVT* args_vt; /* offset 20 */ - size_t stack_cleanup; /* offset 24 */ - void* userdata; /* offset 28 */ -}; - -int dcCleanupSize_x86_cdecl (const char* args_signature); -int dcCleanupSize_x86_std (const char* args_signature); -int dcCleanupSize_x86_fast_ms (const char* args_signature); -int dcCleanupSize_x86_fast_gnu(const char* args_signature); - -#endif /* DYNCALL_CALLBACK_X86_H_ */ diff --git a/src/dyncall/include/dyncall_callf.h b/src/dyncall/include/dyncall_callf.h deleted file mode 100644 index 0a8108834..000000000 --- a/src/dyncall/include/dyncall_callf.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - - Package: dyncall - Library: dyncall - File: dyncall/dyncall_callf.h - Description: formatted call interface to dyncall - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -/* - - dyncall formatted calls C API - - REVISION - 2007/12/11 initial - -*/ - - -#ifndef DYNCALL_CALLF_H -#define DYNCALL_CALLF_H - -/* dyncall formatted calls */ - -#include "dyncall.h" -#include "dyncall_signature.h" -#include "dyncall_value.h" - -#include - -void dcArgF (DCCallVM* vm, const DCsigchar* signature, ...); -void dcVArgF(DCCallVM* vm, const DCsigchar* signature, va_list args); - -void dcCallF (DCCallVM* vm, DCValue* result, DCpointer funcptr, const DCsigchar* signature, ...); -void dcVCallF(DCCallVM* vm, DCValue* result, DCpointer funcptr, const DCsigchar* signature, va_list args); - -#endif /* DYNCALL_CALLF_H */ - diff --git a/src/dyncall/include/dyncall_config.h b/src/dyncall/include/dyncall_config.h deleted file mode 100644 index 4f3588878..000000000 --- a/src/dyncall/include/dyncall_config.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - - Package: dyncall - Library: dyncall - File: dyncall/dyncall_config.h - Description: Macro configuration file for non-standard C types - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -/* - - dyncall type configuration - - REVISION - 2007/12/11 initial - -*/ - -#ifndef DYNCALL_CONFIG_H -#define DYNCALL_CONFIG_H - -#include "dyncall_macros.h" - -#define DC_BOOL int -#define DC_LONG_LONG long long -#define DC_POINTER void* - -#endif /* DYNCALL_CONFIG_H */ - diff --git a/src/dyncall/include/dyncall_macros.h b/src/dyncall/include/dyncall_macros.h deleted file mode 100644 index 7731f50a8..000000000 --- a/src/dyncall/include/dyncall_macros.h +++ /dev/null @@ -1,289 +0,0 @@ -/* - - Package: dyncall - Library: dyncall - File: dyncall/dyncall_macros.h - Description: Platform detection macros - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -/* - - dyncall macros - - Platform detection, specific defines and configuration. - The purpose of this file is to provide coherent platform and compiler - specific defines. So instead of defines like WIN32, _OpenBSD_ or - __GNUC__, one should use DC__OS_Win32, DC__OS_OpenBSD or DC__C_GNU, - respectively. - - REVISION - 2007/12/11 initial - -*/ - - -#ifndef DYNCALL_MACROS_H -#define DYNCALL_MACROS_H - - -/* Platform specific defines. */ - -/* MS Windows XP x64/Vista64 or later. */ -#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) -#define DC__OS_Win64 - -/* MS Windows NT/95/98/ME/2000/XP/Vista32. */ -#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__WINDOWS__) || defined(_WINDOWS) -#define DC__OS_Win32 - -/* All the OS' based on Darwin OS (MacOS X, OpenDarwin). Note that '__APPLE__' may be defined for classic MacOS, too. */ -/* __MACOSX__ is not defined in gcc assembler mode (switch: -S) */ -/* @@@ TODO: Check for Classic OS */ - -#elif defined(__APPLE__) || defined(__Darwin__) -# define DC__OS_Darwin -# if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) -# define DC__OS_IPhone -# else /* defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) */ -# define DC__OS_MacOSX -# endif - -/* The most popular open source Unix-like OS - Linux. */ -#elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__) -#define DC__OS_Linux - -/* The most powerful open source Unix-like OS - FreeBSD. */ -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#define DC__OS_FreeBSD - -/* The most secure open source Unix-like OS - OpenBSD. */ -#elif defined(__OpenBSD__) -#define DC__OS_OpenBSD - -/* The most portable open source Unix-like OS - NetBSD. */ -#elif defined(__NetBSD__) -#define DC__OS_NetBSD - -/* The FreeBSD fork having heavy clusterization in mind - DragonFlyBSD. */ -#elif defined(__DragonFly__) -#define DC__OS_DragonFlyBSD - -/* Sun's Unix-like OS - SunOS / Solaris. */ -#elif defined(__sun__) || defined(__sun) || defined(sun) -#define DC__OS_SunOS - -/* The "Linux-like environment for Windows" - Cygwin. */ -#elif defined(__CYGWIN__) -#define DC__OS_Cygwin - -/* The "Minimalist GNU for Windows" - MinGW. */ -#elif defined(__MINGW__)/*@@@*/ -#define DC__OS_MinGW - -/* The Nintendo DS (homebrew) using devkitpro. */ -#elif defined(__nds__) -#define DC__OS_NDS - -/* The PlayStation Portable (homebrew) SDK. */ -#elif defined(__psp__) || defined(PSP) -#define DC__OS_PSP - -/* Haiku (BeOS alike). */ -#elif defined(__HAIKU__) -#define DC__OS_BeOS - -/* The Unix successor - Plan9 from Bell Labs */ -#elif defined(Plan9) || defined(__Plan9__) -#define DC__OS_Plan9 - -/* Digital's Unix-like OS - VMS */ -#elif defined(__vms) -#define DC__OS_VMS - -#elif defined(__minix) -#define DC__OS_Minix - -#else - #error Unsupported OS. -#endif - - - -/* Compiler specific defines. Do not change the order, because */ -/* some of the compilers define flags for compatible ones, too. */ - -/* Intel's C/C++ compiler. */ -#if defined(__INTEL_COMPILER) -#define DC__C_Intel - -/* MS C/C++ compiler. */ -#elif defined(_MSC_VER) -#define DC__C_MSVC - -/* LLVM clang. */ -#elif defined(__clang__) -#define DC__C_CLANG - -/* The GNU Compiler Collection - GCC. */ -#elif defined(__GNUC__) -#define DC__C_GNU - -/* Watcom compiler. */ -#elif defined(__WATCOMC__) -#define DC__C_WATCOM - -/* Portable C Compiler. */ -#elif defined(__PCC__) -#define DC__C_PCC - -/* Sun Pro C. */ -#elif defined(__SUNPRO_C) -#define DC__C_SUNPRO - -/* Undetected C Compiler. */ -#else -#define DC__C_UNKNOWN -#endif - - - -/* Architecture. */ - -/* Check architecture. */ -#if defined(_M_X64_) || defined(_M_AMD64) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) -# define DC__Arch_AMD64 -#elif defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__386__) || defined(__i386) -# define DC__Arch_Intel_x86 -#elif defined(_M_IA64) || defined(__ia64__) -# define DC__Arch_Itanium -#elif defined(_M_PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__power__) -# if defined(__ppc64__) || defined(_ARCH_PPC64) || defined(__power64__) || defined(__powerpc64__) -# define DC__Arch_PPC64 -# else -# define DC__Arch_PPC32 -# endif -#elif defined(__mips64__) || defined(__mips64) -# define DC__Arch_MIPS64 -#elif defined(_M_MRX000) || defined(__mips__) || defined(__mips) || defined(_mips) -# define DC__Arch_MIPS -#elif defined(__arm__) -# define DC__Arch_ARM -#elif defined(__aarch64__) -# define DC__Arch_ARM64 -#elif defined(__sh__) -# define DC__Arch_SuperH -#elif defined(__sparcv9) || defined(__sparc64__) || ( defined(__sparc) && defined(__arch64__) ) -/* this could be needed on Linux/GNU sparc64 in the future: || ( defined(__sparc) && defined(__arch64__) ) */ -# define DC__Arch_Sparcv9 -#elif defined(__sparc) -# define DC__Arch_Sparc -#endif - - - -/* Rough OS classification. */ - -#if defined(DC__OS_Win32) || defined(DC__OS_Win64) -# define DC_WINDOWS -#elif defined(DC__OS_Plan9) -# define DC_PLAN9 -#elif defined(DC__OS_NDS) || defined(DC__OS_PSP) -# define DC_OTHER -#else -# define DC_UNIX -#endif - - - -/* Misc machine-dependent modes, ABIs, etc.. */ - -#if defined(__arm__) && !defined(__thumb__) -# define DC__Arch_ARM_ARM -#elif defined(__arm__) && defined(__thumb__) -# define DC__Arch_ARM_THUMB -#endif - -#if defined(DC__Arch_ARM_ARM) || defined(DC__Arch_ARM_THUMB) -# if defined(__ARM_EABI__) || defined(DC__OS_NDS) -# if defined (__ARM_PCS_VFP) && (__ARM_PCS_VFP == 1) -# define DC__ABI_ARM_HF -# else -# define DC__ABI_ARM_EABI -# endif -# elif defined(__APCS_32__) -# define DC__ABI_ARM_OABI -# endif -#endif /* ARM */ - -#if defined(DC__Arch_MIPS) || defined(DC__Arch_MIPS64) -# if defined(_ABIO32) || defined(_MIPS_ARCH_MIPS1) || defined(_MIPS_ARCH_MIPS2) -# define DC__ABI_MIPS_O32 -# elif defined(_ABIN32) -# define DC__ABI_MIPS_N32 -# elif defined(_ABI64) -# define DC__ABI_MIPS_N64 -# else -# define DC__ABI_MIPS_EABI -# endif -#endif /* MIPS */ - -#if defined(DC__Arch_PPC64) -# if defined(_CALL_ELF) -# define DC__ABI_PPC64_ELF_V _CALL_ELF -# else -# define DC__ABI_PPC64_ELF_V 0 /* 0 means not explicitly set, otherwise this is 1 (big endian) and 2 (little endian) */ -# endif -#endif /* MIPS */ - - -/* Endian detection. */ -#if defined(DC__Arch_Intel_x86) || defined(DC__Arch_AMD64) /* always little */ -# define DC__Endian_LITTLE -#elif defined(DC__Arch_Sparc) /*always big until v9*/ -# define DC__Endian_BIG -#else /* all others are bi-endian */ -/* @@@check flags used on following bi-endianness archs: -DC__Arch_ARM -DC__Arch_ARM64 -DC__Arch_Itanium -DC__Arch_MIPS -DC__Arch_MIPS64 -DC__Arch_PPC32 -DC__Arch_PPC64 -DC__Arch_Sparcv9 -DC__Arch_SuperH -*/ -# if (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 1)) || defined(_BIG_ENDIAN) || defined(MIPSEB) -# define DC__Endian_BIG -# elif (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 2)) || defined(_LITTLE_ENDIAN) || defined(MIPSEL) -# define DC__Endian_LITTLE -# endif /* no else, leave unset if not sure */ -#endif - - -/* Internal macro/tag. */ -#if !defined(DC_API) -#define DC_API -#endif - -#endif /* DYNCALL_MACROS_H */ - diff --git a/src/dyncall/include/dyncall_signature.h b/src/dyncall/include/dyncall_signature.h deleted file mode 100644 index 385dec67a..000000000 --- a/src/dyncall/include/dyncall_signature.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - - Package: dyncall - Library: dyncall - File: dyncall/dyncall_signature.h - Description: Type and calling-convention signature character defines - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -/* - - dyncall signature characters - - REVISION - 2007/12/11 initial - -*/ - - -#ifndef DYNCALL_SIGNATURE_H -#define DYNCALL_SIGNATURE_H - -typedef char DCsigchar; - -#define DC_SIGCHAR_VOID 'v' -#define DC_SIGCHAR_BOOL 'B' -#define DC_SIGCHAR_CHAR 'c' -#define DC_SIGCHAR_UCHAR 'C' -#define DC_SIGCHAR_SHORT 's' -#define DC_SIGCHAR_USHORT 'S' -#define DC_SIGCHAR_INT 'i' -#define DC_SIGCHAR_UINT 'I' -#define DC_SIGCHAR_LONG 'j' -#define DC_SIGCHAR_ULONG 'J' -#define DC_SIGCHAR_LONGLONG 'l' -#define DC_SIGCHAR_ULONGLONG 'L' -#define DC_SIGCHAR_FLOAT 'f' -#define DC_SIGCHAR_DOUBLE 'd' -#define DC_SIGCHAR_POINTER 'p' -#define DC_SIGCHAR_STRING 'Z' -#define DC_SIGCHAR_STRUCT 'T' -#define DC_SIGCHAR_ENDARG ')' /* also works for end struct */ - -/* callback signatures */ - -#define DC_SIGCHAR_CC_PREFIX '_' -#define DC_SIGCHAR_CC_ELLIPSIS 'e' -#define DC_SIGCHAR_CC_STDCALL 's' -#define DC_SIGCHAR_CC_FASTCALL_GNU 'f' -#define DC_SIGCHAR_CC_FASTCALL_MS 'F' -#define DC_SIGCHAR_CC_THISCALL_MS '+' - -#endif /* DYNCALL_SIGNATURE_H */ - diff --git a/src/dyncall/include/dyncall_thunk.h b/src/dyncall/include/dyncall_thunk.h deleted file mode 100644 index 87b05d1d2..000000000 --- a/src/dyncall/include/dyncall_thunk.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk.h - Description: Thunk - Interface - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_H -#define DYNCALL_THUNK_H - -/** - ** dyncall thunks - ** - ** thunks are small-size hybrid code/data objects, created at run-time to - ** be used as function pointers with associated data and entry functions. - ** - ** The header contains code, that does load its address into a designated scratch - ** register and will jump to a thunk function. - ** - ** Thunk entry procedures are compiled functions, that are called as a result of - ** a thunk function. - ** There is one thunk entry currently for supporting callbacks. - ** - ** Thunk context register ( ::= an available scratch register in the calling convention): - ** - ** x86: eax - ** x64: rax - ** ppc: r2 - ** arm: r12 - ** arm64: x9 - ** - **/ - -#include "dyncall_macros.h" - -typedef struct DCThunk_ DCThunk; - -#ifdef __cplusplus -extern "C" { -#endif - -void dcbInitThunk(DCThunk* p, void (*entry)()); - -#if defined(DC__Arch_Intel_x86) -#include "dyncall_thunk_x86.h" -#elif defined (DC__Arch_AMD64) -#include "dyncall_thunk_x64.h" -#elif defined (DC__Arch_PPC32) -#include "dyncall_thunk_ppc32.h" -#elif defined (DC__Arch_PPC64) -#include "dyncall_thunk_ppc64.h" -#elif defined (DC__Arch_ARM_ARM) -#include "dyncall_thunk_arm32_arm.h" -#elif defined (DC__Arch_ARM_THUMB) -#include "dyncall_thunk_arm32_thumb.h" -#elif defined (DC__Arch_MIPS) -#include "dyncall_thunk_mips.h" -#elif defined (DC__Arch_Sparc) -#include "dyncall_thunk_sparc32.h" -#elif defined (DC__Arch_Sparcv9) -#include "dyncall_thunk_sparc64.h" -#elif defined (DC__Arch_ARM64) -#include "dyncall_thunk_arm64.h" -#endif - -#ifdef __cplusplus -} -#endif - - -#endif /* DYNCALL_THUNK_H */ diff --git a/src/dyncall/include/dyncall_thunk_arm32_arm.h b/src/dyncall/include/dyncall_thunk_arm32_arm.h deleted file mode 100644 index 12ffb3305..000000000 --- a/src/dyncall/include/dyncall_thunk_arm32_arm.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_arm32_arm.h - Description: Thunk - Header for ARM32 (ARM mode) - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_ARM32_ARM_H -#define DYNCALL_THUNK_ARM32_ARM_H - - -struct DCThunk_ -{ - unsigned int code[2]; - void (*entry)(); -}; - -#define DCTHUNK_ARM32_ARM_SIZE 12 - - -#endif /* DYNCALL_THUNK_ARM32_ARM_H */ - diff --git a/src/dyncall/include/dyncall_thunk_arm32_thumb.h b/src/dyncall/include/dyncall_thunk_arm32_thumb.h deleted file mode 100644 index 832484c11..000000000 --- a/src/dyncall/include/dyncall_thunk_arm32_thumb.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_arm32_thumb.h - Description: Thunk - Header for ARM32 (THUMB mode) - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_ARM32_THUMB_H -#define DYNCALL_THUNK_ARM32_THUMB_H - -#include "dyncall_thunk_arm32_arm.h" /* Uses same code as ARM mode. */ - -#define DCTHUNK_ARM32_THUMB_SIZE 12 - - -#endif /* DYNCALL_THUNK_ARM32_THUMB_H */ - diff --git a/src/dyncall/include/dyncall_thunk_arm64.h b/src/dyncall/include/dyncall_thunk_arm64.h deleted file mode 100644 index baa5127cf..000000000 --- a/src/dyncall/include/dyncall_thunk_arm64.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_arm64.h - Description: Thunk - Header for ARM64 / ARMv8 / AAPCS64 - License: - - Copyright (c) 2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALL_THUNK_ARM64_H -#define DYNCALL_THUNK_ARM64_H - -struct DCThunk_ -{ - // off size - //-----|---------- - unsigned int code[4]; // 0 16 - void (*entry)(); // 16 8 - void* reserved; // 24 8 - - // 32 total size - -}; - -#endif /* DYNCALL_THUNK_ARM64_H */ - diff --git a/src/dyncall/include/dyncall_thunk_mips.h b/src/dyncall/include/dyncall_thunk_mips.h deleted file mode 100644 index b6acffd53..000000000 --- a/src/dyncall/include/dyncall_thunk_mips.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_mips.h - Description: Thunk - Header for MIPS - License: - - Copyright (c) 2013-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_MIPS_H -#define DYNCALL_THUNK_MIPS_H - -struct DCThunk_ -{ - unsigned short data[6]; - unsigned int jump; - unsigned short bddt[2]; -}; - -#endif /* DYNCALL_THUNK_MIPS_H */ - diff --git a/src/dyncall/include/dyncall_thunk_ppc32.h b/src/dyncall/include/dyncall_thunk_ppc32.h deleted file mode 100644 index 42bce8091..000000000 --- a/src/dyncall/include/dyncall_thunk_ppc32.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_ppc32.h - Description: Thunk - Header for ppc32 (darwin/sysv) - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALL_THUNK_PPC32_H -#define DYNCALL_THUNK_PPC32_H - -struct DCThunk_ -{ - unsigned short code_load_hi, addr_self_hi; /* offset: 0 size: 4 */ - unsigned short code_load_lo, addr_self_lo; /* offset: 4 size: 4 */ - unsigned int code_jump[3]; /* offset: 8 size: 12 */ - void (*addr_entry)(); /* offset: 20 size: 4 */ -}; /* total size: 24 */ - -#define DCTHUNK_SIZE_PPC32 24 - -#endif /* DYNCALL_THUNK_PPC32_H */ - diff --git a/src/dyncall/include/dyncall_thunk_ppc64.h b/src/dyncall/include/dyncall_thunk_ppc64.h deleted file mode 100644 index 2a7e88ea4..000000000 --- a/src/dyncall/include/dyncall_thunk_ppc64.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_ppc64.h - Description: Thunk - Header for ppc64 - License: - - Copyright (c) 2014-2015 Masanori Mitsugi - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifndef DYNCALL_THUNK_PPC64_H -#define DYNCALL_THUNK_PPC64_H - -#if DC__ABI_PPC64_ELF_V != 2 -struct DCThunk_ /* v1 */ -{ - void (*thunk_entry)(); /* offset: 0 */ - long toc_thunk; /* offset: 8 */ - unsigned short code_load_hi, addr_self_hi; /* offset: 16 */ - unsigned short code_load_lo, addr_self_lo; /* offset: 20 */ - unsigned int code_jump[6]; /* offset: 24 */ - void (*addr_entry)(); /* offset: 48 */ - long toc_entry; /* offset: 56 */ -}; -#define DCTHUNK_SIZE_PPC64 64 -#else -struct DCThunk_ /* v2 */ -{ - unsigned short addr_self_hist, code_load_hist; /* offset: 0 */ - unsigned short addr_self_hier, code_load_hier; /* offset: 4 */ - unsigned int code_rot; /* offset: 8 */ - unsigned short addr_self_hi, code_load_hi; /* offset: 12 */ - unsigned short addr_self_lo, code_load_lo; /* offset: 16 */ - unsigned int code_jump[5]; /* offset: 20 */ - void (*addr_entry)(); /* offset: 40 */ -}; -#define DCTHUNK_SIZE_PPC64 48 -#endif - -#endif /* DYNCALL_THUNK_PPC64_H */ - diff --git a/src/dyncall/include/dyncall_thunk_sparc32.h b/src/dyncall/include/dyncall_thunk_sparc32.h deleted file mode 100644 index 456e13e3d..000000000 --- a/src/dyncall/include/dyncall_thunk_sparc32.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_sparc32.h - Description: Thunk - Header for sparc32 - not yet implemented - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_SPARC32_H -#define DYNCALL_THUNK_SPARC32_H - -struct DCThunk_ -{ - int x[4]; /* dummy */ -}; - -#define DCTHUNK_SIZE_SPARC32 32 - -#endif /* DYNCALL_THUNK_SPARC32_H */ diff --git a/src/dyncall/include/dyncall_thunk_sparc64.h b/src/dyncall/include/dyncall_thunk_sparc64.h deleted file mode 100644 index c8eb90d13..000000000 --- a/src/dyncall/include/dyncall_thunk_sparc64.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_sparc64.h - Description: Thunk - Header for sparc64 - not yet implemented - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_SPARC64_H -#define DYNCALL_THUNK_SPARC64_H - -struct DCThunk_ -{ - int x[4]; /* dummy */ -}; - -#define DCTHUNK_SIZE_SPARC64 32 - -#endif /* DYNCALL_THUNK_SPARC32_H */ diff --git a/src/dyncall/include/dyncall_thunk_x64.h b/src/dyncall/include/dyncall_thunk_x64.h deleted file mode 100644 index 5e60d4f87..000000000 --- a/src/dyncall/include/dyncall_thunk_x64.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_x64.h - Description: Thunk - Header for x64 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_X64_H -#define DYNCALL_THUNK_X64_H - -struct DCThunk_ -{ - unsigned long long code[2]; - void (*entry)(); -}; - -#define DCTHUNK_X64_SIZE 24 - - -#endif /* DYNCALL_THUNK_X64_H */ - diff --git a/src/dyncall/include/dyncall_thunk_x86.h b/src/dyncall/include/dyncall_thunk_x86.h deleted file mode 100644 index 29b7ca81d..000000000 --- a/src/dyncall/include/dyncall_thunk_x86.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - - Package: dyncall - Library: dyncallback - File: dyncallback/dyncall_thunk_x86.h - Description: Thunk - Header for x86 - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -#ifndef DYNCALL_THUNK_X86_H -#define DYNCALL_THUNK_X86_H - -struct DCThunk_ -{ - unsigned int code_load; - void* addr_self; - unsigned int code_jump; - void (*addr_entry)(); -}; - -#define DCTHUNK_X86_SIZE 16 - -#endif /* DYNCALL_THUNK_X86_H */ diff --git a/src/dyncall/include/dyncall_types.h b/src/dyncall/include/dyncall_types.h deleted file mode 100644 index 1831eb744..000000000 --- a/src/dyncall/include/dyncall_types.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - - Package: dyncall - Library: dyncall - File: dyncall/dyncall_types.h - Description: Typedefs - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -/* - - dyncall argument- and return-types - - REVISION - 2007/12/11 initial - -*/ - -#ifndef DYNCALL_TYPES_H -#define DYNCALL_TYPES_H - -#include - -#include "dyncall_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void DCvoid; -typedef DC_BOOL DCbool; -typedef char DCchar; -typedef unsigned char DCuchar; -typedef short DCshort; -typedef unsigned short DCushort; -typedef int DCint; -typedef unsigned int DCuint; -typedef long DClong; -typedef unsigned long DCulong; -typedef DC_LONG_LONG DClonglong; -typedef unsigned DC_LONG_LONG DCulonglong; -typedef float DCfloat; -typedef double DCdouble; -typedef DC_POINTER DCpointer; -typedef const char* DCstring; - -typedef size_t DCsize; - -#define DC_TRUE 1 -#define DC_FALSE 0 - -#ifdef __cplusplus -} -#endif - -#endif /* DYNCALL_TYPES_H */ - diff --git a/src/dyncall/include/dyncall_value.h b/src/dyncall/include/dyncall_value.h deleted file mode 100644 index 69068f0a2..000000000 --- a/src/dyncall/include/dyncall_value.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - - Package: dyncall - Library: dyncall - File: dyncall/dyncall_value.h - Description: Value variant type - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - -/* - - dyncall value variant - - a value variant union-type that carries all supported dyncall types. - - REVISION - 2007/12/11 initial - -*/ - -#ifndef DYNCALL_VALUE_H -#define DYNCALL_VALUE_H - -#include "dyncall_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef union DCValue_ DCValue; - -union DCValue_ -{ -#if defined (DC__Arch_PPC32) && defined(DC__Endian_BIG) - DCbool B; - struct { DCchar c_pad[3]; DCchar c; }; - struct { DCuchar C_pad[3]; DCuchar C; }; - struct { DCshort s_pad; DCshort s; }; - struct { DCshort S_pad; DCshort S; }; - DCint i; - DCuint I; -#elif defined (DC__Arch_PPC64) && defined(DC__Endian_BIG) - struct { DCbool B_pad; DCbool B; }; - struct { DCchar c_pad[7]; DCchar c; }; - struct { DCuchar C_pad[7]; DCuchar C; }; - struct { DCshort s_pad[3]; DCshort s; }; - struct { DCshort S_pad[3]; DCshort S; }; - struct { DCint i_pad; DCint i; }; - struct { DCint I_pad; DCuint I; }; -#else - DCbool B; - DCchar c; - DCuchar C; - DCshort s; - DCushort S; - DCint i; - DCuint I; -#endif - DClong j; - DCulong J; - DClonglong l; - DCulonglong L; - DCfloat f; - DCdouble d; - DCpointer p; - DCstring Z; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* DYNCALL_VALUE_H */ - diff --git a/src/dyncall/include/dynload.h b/src/dyncall/include/dynload.h deleted file mode 100644 index df9fe4141..000000000 --- a/src/dyncall/include/dynload.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - - Package: dyncall - Library: dynload - File: dynload/dynload.h - Description: public header for library dynload - License: - - Copyright (c) 2007-2015 Daniel Adler , - Tassilo Philipp - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - - - -#ifndef DYNLOAD_H -#define DYNLOAD_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef DL_API -#define DL_API -#endif - -/* --- public api ---------------------------------------------------------- */ - -/* shared library loading and explicit symbol resolving */ - -typedef struct DLLib_ DLLib; - -DL_API DLLib* dlLoadLibrary(const char* libpath); -DL_API void dlFreeLibrary(DLLib* pLib); -DL_API void* dlFindSymbol(DLLib* pLib, const char* pSymbolName); - -/* symbol table enumeration - only for symbol lookup, not resolve */ - -typedef struct DLSyms_ DLSyms; - -DL_API DLSyms* dlSymsInit (const char* libPath); -DL_API void dlSymsCleanup(DLSyms* pSyms); - -DL_API int dlSymsCount (DLSyms* pSyms); -DL_API const char* dlSymsName (DLSyms* pSyms, int index); -DL_API const char* dlSymsNameFromValue(DLSyms* pSyms, void* value); /* symbol must be loaded */ - - -#ifdef __cplusplus -} -#endif - -#endif /* DYNLOAD_H */ - diff --git a/src/dyncall/lib/libdyncall_s.lib b/src/dyncall/lib/libdyncall_s.lib deleted file mode 100644 index e36ce7c23..000000000 Binary files a/src/dyncall/lib/libdyncall_s.lib and /dev/null differ diff --git a/src/dyncall/lib/libdyncallback_s.lib b/src/dyncall/lib/libdyncallback_s.lib deleted file mode 100644 index dae008de5..000000000 Binary files a/src/dyncall/lib/libdyncallback_s.lib and /dev/null differ diff --git a/src/dyncall/lib/libdynload_s.lib b/src/dyncall/lib/libdynload_s.lib deleted file mode 100644 index 80fc28d06..000000000 Binary files a/src/dyncall/lib/libdynload_s.lib and /dev/null differ diff --git a/src/exact_value.cpp b/src/exact_value.cpp index c1666cafd..ed181b9d0 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -46,7 +46,31 @@ struct ExactValue { gb_global ExactValue const empty_exact_value = {}; HashKey hash_exact_value(ExactValue v) { + switch (v.kind) { + case ExactValue_Invalid: + return HashKey{}; + case ExactValue_Bool: + return hash_integer(u64(v.value_bool)); + case ExactValue_String: + return hash_string(v.value_string); + case ExactValue_Integer: + return hash_integer(u64(v.value_integer)); + case ExactValue_Float: + return hash_f64(v.value_float); + case ExactValue_Pointer: + return hash_integer(v.value_pointer); + case ExactValue_Complex: + return hashing_proc(&v.value_complex, gb_size_of(Complex128)); + + case ExactValue_Compound: + return hash_pointer(v.value_compound); + case ExactValue_Procedure: + return hash_pointer(v.value_procedure); + case ExactValue_Type: + return hash_pointer(v.value_type); + } return hashing_proc(&v, gb_size_of(ExactValue)); + } diff --git a/src/ir.cpp b/src/ir.cpp index a28d28739..2fb398273 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -6925,7 +6925,7 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) { Type *enum_ptr = make_type_pointer(a, t); t = base_type(t); Type *core_elem = core_type(t); - i64 enum_count = t->Enum.field_count; + i64 enum_count = t->Enum.fields.count; irValue *max_count = ir_const_int(a, enum_count); irValue *ti = ir_type_info(proc, t); @@ -8039,12 +8039,11 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info // is_export ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), ir_const_bool(a, t->Enum.is_export)); - if (t->Enum.field_count > 0) { - Entity **fields = t->Enum.fields; - isize count = t->Enum.field_count; - irValue *name_array = ir_generate_array(m, t_string, count, + if (t->Enum.fields.count > 0) { + auto fields = t->Enum.fields; + irValue *name_array = ir_generate_array(m, t_string, fields.count, str_lit("__$enum_names"), cast(i64)entry_index); - irValue *value_array = ir_generate_array(m, t_type_info_enum_value, count, + irValue *value_array = ir_generate_array(m, t_type_info_enum_value, fields.count, str_lit("__$enum_values"), cast(i64)entry_index); bool is_value_int = is_type_integer(t->Enum.base_type); @@ -8052,7 +8051,7 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info GB_ASSERT(is_type_float(t->Enum.base_type)); } - for (isize i = 0; i < count; i++) { + for_array(i, fields) { irValue *name_ep = ir_emit_array_epi(proc, name_array, cast(i32)i); irValue *value_ep = ir_emit_array_epi(proc, value_array, cast(i32)i); @@ -8063,7 +8062,7 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info ir_emit_store(proc, name_ep, ir_const_string(a, fields[i]->token.string)); } - irValue *v_count = ir_const_int(a, count); + irValue *v_count = ir_const_int(a, fields.count); irValue *names = ir_emit_struct_ep(proc, tag, 1); irValue *name_array_elem = ir_array_elem(proc, name_array); diff --git a/src/map.cpp b/src/map.cpp index 08a059d56..a08070656 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -30,8 +30,8 @@ struct HashKey { // u128 key; u64 key; union { - String string; // if String, s.len > 0 - void * ptr; + String string; // if String, s.len > 0 + void * ptr; PtrAndId ptr_and_id; }; }; @@ -65,6 +65,16 @@ gb_inline HashKey hash_ptr_and_id(void *ptr, u32 id) { h.ptr_and_id.id = id; return h; } +gb_inline HashKey hash_integer(u64 u) { + HashKey h = {HashKey_Default}; + h.key = u; + return h; +} +gb_inline HashKey hash_f64(f64 f) { + HashKey h = {HashKey_Default}; + h.key = *cast(u64 *)&f; + return h; +} bool hash_key_equal(HashKey a, HashKey b) { if (a.key == b.key) { diff --git a/src/parser.cpp b/src/parser.cpp index 8dd5d6d30..2643fb2b3 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -375,6 +375,17 @@ void error(AstNode *node, char *fmt, ...) { va_end(va); } +void error_no_newline(AstNode *node, char *fmt, ...) { + Token token = {}; + if (node != nullptr) { + token = ast_node_token(node); + } + va_list va; + va_start(va, fmt); + error_no_newline_va(token, fmt, va); + va_end(va); +} + void warning(AstNode *node, char *fmt, ...) { va_list va; va_start(va, fmt); @@ -3700,6 +3711,20 @@ AstNode *parse_stmt(AstFile *f) { syntax_error(token, "#bounds_check and #no_bounds_check cannot be applied together"); } return s; + } else if (tag == "complete") { + s = parse_stmt(f); + switch (s->kind) { + case AstNode_SwitchStmt: + s->SwitchStmt.complete = true; + break; + case AstNode_TypeSwitchStmt: + s->TypeSwitchStmt.complete = true; + break; + default: + syntax_error(token, "#complete can only be applied to a switch statement"); + break; + } + return s; } if (tag == "include") { diff --git a/src/parser.hpp b/src/parser.hpp index 8d15f3128..d641e8a97 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -286,17 +286,19 @@ AST_NODE_KIND(_ComplexStmtBegin, "", struct {}) \ Entity *implicit_entity; \ }) \ AST_NODE_KIND(SwitchStmt, "switch statement", struct { \ - Token token; \ - AstNode *label; \ - AstNode *init; \ - AstNode *tag; \ - AstNode *body; \ + Token token; \ + AstNode *label; \ + AstNode *init; \ + AstNode *tag; \ + AstNode *body; \ + bool complete; \ }) \ AST_NODE_KIND(TypeSwitchStmt, "type switch statement", struct { \ - Token token; \ - AstNode *label; \ - AstNode *tag; \ - AstNode *body; \ + Token token; \ + AstNode *label; \ + AstNode *tag; \ + AstNode *body; \ + bool complete; \ }) \ AST_NODE_KIND(DeferStmt, "defer statement", struct { Token token; AstNode *stmt; }) \ AST_NODE_KIND(BranchStmt, "branch statement", struct { Token token; AstNode *label; }) \ diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 404b4cea6..6b7a50638 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -227,6 +227,22 @@ void error_va(Token token, char *fmt, va_list va) { gb_mutex_unlock(&global_error_collector.mutex); } +void error_no_newline_va(Token token, char *fmt, va_list va) { + gb_mutex_lock(&global_error_collector.mutex); + global_error_collector.count++; + // NOTE(bill): Duplicate error, skip it + if (token.pos.line == 0) { + gb_printf_err("Error: %s", gb_bprintf_va(fmt, va)); + } else if (global_error_collector.prev != token.pos) { + global_error_collector.prev = token.pos; + gb_printf_err("%.*s(%td:%td) %s", + LIT(token.pos.file), token.pos.line, token.pos.column, + gb_bprintf_va(fmt, va)); + } + gb_mutex_unlock(&global_error_collector.mutex); +} + + void syntax_error_va(Token token, char *fmt, va_list va) { gb_mutex_lock(&global_error_collector.mutex); global_error_collector.count++; diff --git a/src/types.cpp b/src/types.cpp index 2dcd05361..dadbe0a62 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -126,8 +126,7 @@ struct TypeStruct { }) \ TYPE_KIND(Struct, TypeStruct) \ TYPE_KIND(Enum, struct { \ - Entity **fields; \ - i32 field_count; \ + Array fields; \ AstNode *node; \ Scope * scope; \ Entity * names; \ @@ -1657,7 +1656,7 @@ Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_n } } - for (isize i = 0; i < type->Enum.field_count; i++) { + for_array(i, type->Enum.fields) { Entity *f = type->Enum.fields[i]; GB_ASSERT(f->kind == Entity_Constant); String str = f->token.string; @@ -2330,7 +2329,7 @@ gbString write_type_to_string(gbString str, Type *type) { str = write_type_to_string(str, type->Enum.base_type); } str = gb_string_appendc(str, " {"); - for (isize i = 0; i < type->Enum.field_count; i++) { + for_array(i, type->Enum.fields) { Entity *f = type->Enum.fields[i]; GB_ASSERT(f->kind == Entity_Constant); if (i > 0) {