aboutsummaryrefslogtreecommitdiff
path: root/core/runtime/entry_windows.odin
blob: 2f323cb41003c7717aa760104eb89426ca3a5266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//+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 == .i386 || 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 {
			args__ = argv[:argc]
			context = default_context()
			#force_no_inline _startup_runtime()
			intrinsics.__entry_point()
			#force_no_inline _cleanup_runtime()
			return 0
		}
	}
}