+ +
a18b27f fix(windows): resolve Win32 Winsock, signal, and CLI test compatibility
saifmukhtar · 2026-11-24
1 /*
2 * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0
3 * Copyright (c) 2026 Saif Mukhtar
4 *
5 * OpenAVX - Open Audio-Video eXchange
6 * include/compat/win32/dlfcn.h - Win32 emulation of dlfcn.h
7 */
8  
9 #ifndef OPENAVX_COMPAT_WIN32_DLFCN_H
10 #define OPENAVX_COMPAT_WIN32_DLFCN_H
11  
12 #if defined(_WIN32) || defined(_MSC_VER)
13  
14 #ifndef WIN32_LEAN_AND_MEAN
15 #define WIN32_LEAN_AND_MEAN
16 #endif
17 #include <windows.h>
18  
19 #ifndef RTLD_LAZY
20 #define RTLD_LAZY 0x0001
21 #endif
22 #ifndef RTLD_NOW
23 #define RTLD_NOW 0x0002
24 #endif
25 #ifndef RTLD_GLOBAL
26 #define RTLD_GLOBAL 0x0100
27 #endif
28 #ifndef RTLD_LOCAL
29 #define RTLD_LOCAL 0x0000
30 #endif
31  
32 static inline void* dlopen(const char* filename, int flags) {
33 (void)flags;
34 if (!filename) return NULL;
35 return (void*)LoadLibraryA(filename);
36 }
37  
38 static inline void* dlsym(void* handle, const char* symbol) {
39 if (!handle || !symbol) return NULL;
40 return (void*)GetProcAddress((HMODULE)handle, symbol);
41 }
42  
43 static inline int dlclose(void* handle) {
44 if (!handle) return -1;
45 return FreeLibrary((HMODULE)handle) ? 0 : -1;
46 }
47  
48 static inline const char* dlerror(void) {
49 return "Dynamic load error";
50 }
51  
52 #endif /* __MINGW32__ vs _MSC_VER */
53  
54 #endif /* OPENAVX_COMPAT_WIN32_DLFCN_H */