Rune - Reorder weak bindings
[rune.git] / libruntime / rt_stubs.c
1 /*
2  * STUBS.C
3  *
4  * These stubs exist to allow external APIs to load at run-time without libgen
5  * when used directly in a Rune executable.
6  */
7 #include "defs.h"
8
9 void _GenInternalCallWrapper(void);
10 void _initType(Type *type, typelist_t *list, int op);
11 void _initPtrType(Type *type, Type *ptrto, int sqflags);
12 void _SyscallAdd(Syscall *sc);
13 void _InternalRegisterType(const char *str, const char *linkname, Type *type);
14
15 extern int _LibGenActive;
16 extern Type _Int8Type;
17 extern Type _Int16Type;
18 extern Type _Int32Type;
19 extern Type _Int64Type;
20 extern Type _UInt8Type;
21 extern Type _UInt16Type;
22 extern Type _UInt32Type;
23 extern Type _UInt64Type;
24 extern Type _StrType;
25 extern Type _CharPtrType;
26 extern Type _CharPtrPtrType;
27
28 __weak_reference(_GenInternalCallWrapper, GenInternalCallWrapper);
29 __weak_reference(_initType, initType);
30 __weak_reference(_initPtrType, initPtrType);
31 __weak_reference(_SyscallAdd, SyscallAdd);
32 __weak_reference(_InternalRegisterType, InternalRegisterType);
33
34 void
35 _GenInternalCallWrapper(void)
36 {
37         dpanic("_GenInternalCallWrapper: requires linking against libgen");
38 }
39
40 void
41 _initType(Type *type, typelist_t *list, int op)
42 {
43         dpanic("_initType: requires linking against libgen");
44 }
45
46 void
47 _initPtrType(Type *type, Type *ptrto, int sqflags)
48 {
49         dpanic("_initPtrType: requires linking against libgen");
50 }
51
52 void
53 _SyscallAdd(Syscall *sc)
54 {
55         dpanic("_SyscallAdd: requires linking against libgen");
56 }
57
58 void
59 _InternalRegisterType(const char *str, const char *linkname, Type *type)
60 {
61         dpanic("_InternalRegisterType: requires linking against libgen");
62 }
63
64 int _LibGenActive = 0;
65 Type _Int8Type = { .ty_Flags = 0 };
66 Type _Int16Type = { .ty_Flags = 0 };
67 Type _Int32Type = { .ty_Flags = 0 };
68 Type _Int64Type = { .ty_Flags = 0 };
69 Type _UInt8Type = { .ty_Flags = 0 };
70 Type _UInt16Type = { .ty_Flags = 0 };
71 Type _UInt32Type = { .ty_Flags = 0 };
72 Type _UInt64Type = { .ty_Flags = 0 };
73 Type _SizeType = { .ty_Flags = 0 };
74 Type _OffType = { .ty_Flags = 0 };
75 Type _StrType = { .ty_Flags = 0 };
76 Type _CharPtrType = { .ty_Flags = 0 };
77 Type _CharPtrPtrType = { .ty_Flags = 0 };
78
79 __weak_reference(_LibGenActive, LibGenActive);
80 __weak_reference(_Int8Type, Int8Type);
81 __weak_reference(_Int16Type, Int16Type);
82 __weak_reference(_Int32Type, Int32Type);
83 __weak_reference(_Int64Type, Int64Type);
84 __weak_reference(_UInt8Type, UInt8Type);
85 __weak_reference(_UInt16Type, UInt16Type);
86 __weak_reference(_UInt32Type, UInt32Type);
87 __weak_reference(_UInt64Type, UInt64Type);
88 __weak_reference(_SizeType, SizeType);
89 __weak_reference(_OffType, OffType);
90 __weak_reference(_StrType, StrType);
91 __weak_reference(_CharPtrType, CharPtrType);
92 __weak_reference(_CharPtrPtrType, CharPtrPtrType);
93
94 void _rune_entry_main(void) { }
95 __weak_reference(_rune_entry_main, rune_entry_main);
96
97 static void *Dummy;
98
99 void **_start_runectors = &Dummy;
100 void **_stop_runectors = &Dummy;
101 __weak_reference(_start_runectors, start_runectors);
102 __weak_reference(_stop_runectors, stop_runectors);
103