aboutsummaryrefslogtreecommitdiff
path: root/core/runtime
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-01-12 20:10:23 +0000
committergingerBill <bill@gingerbill.org>2022-01-12 20:10:23 +0000
commitf1521aa980da5753a6ba6ea951d1cb2ebfd0e66a (patch)
tree141a8ca43b314a1c66ca7b63746fe43b2677576d /core/runtime
parentfb0a3ab7c14d4bc3b821cef723ec6ea3e956c956 (diff)
Add proc_windows.odin for custom entry points
Diffstat (limited to 'core/runtime')
-rw-r--r--core/runtime/proc_windows.odin44
1 files changed, 44 insertions, 0 deletions
diff --git a/core/runtime/proc_windows.odin b/core/runtime/proc_windows.odin
new file mode 100644
index 000000000..ba3a2b9d8
--- /dev/null
+++ b/core/runtime/proc_windows.odin
@@ -0,0 +1,44 @@
+//+private
+//+build windows
+package runtime
+
+import "core:intrinsics"
+
+when ODIN_BUILD_MODE == "dynamic" {
+ @(link_name="DllMain", linkage="strong", require)
+ DllMain :: proc "stdcall" (hinstDLL: rawptr, fdwReason: u32, lpReserved: rawptr) -> b32 {
+ context = default_context()
+ switch fdwReason {
+ case 1: // DLL_PROCESS_ATTACH
+ #force_no_inline _startup_runtime()
+ intrinsics.__entry_point()
+ case 0: // DLL_PROCESS_DETACH
+ #force_no_inline _cleanup_runtime()
+ case 2: // DLL_THREAD_ATTACH
+ break
+ case 3: // DLL_THREAD_DETACH
+ break
+ }
+ return true
+ }
+} else when !ODIN_TEST && !ODIN_NO_ENTRY_POINT {
+ when ODIN_ARCH == "386" || ODIN_NO_CRT {
+ @(link_name="mainCRTStartup", linkage="strong", require)
+ mainCRTStartup :: proc "stdcall" () -> i32 {
+ context = default_context()
+ #force_no_inline _startup_runtime()
+ intrinsics.__entry_point()
+ #force_no_inline _cleanup_runtime()
+ return 0
+ }
+ } else {
+ @(link_name="main", linkage="strong", require)
+ main :: proc "c" (argc: i32, argv: [^]cstring) -> i32 {
+ context = default_context()
+ #force_no_inline _startup_runtime()
+ intrinsics.__entry_point()
+ #force_no_inline _cleanup_runtime()
+ return 0
+ }
+ }
+} \ No newline at end of file