Skip to content

Commit 15e4eb6

Browse files
committed
Replace UWP patch for dlfcn-win32 with LF line endings
1 parent f5ac2fa commit 15e4eb6

File tree

1 file changed

+123
-123
lines changed

1 file changed

+123
-123
lines changed

depends/windowsstore/dlfcn-win32/0001-win10-fixed-uwp-build.patch

Lines changed: 123 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -12,138 +12,138 @@ index cb9f9bb..74cac34 100644
1212
--- a/src/dlfcn.c
1313
+++ b/src/dlfcn.c
1414
@@ -24,6 +24,7 @@
15-
* THE SOFTWARE.
16-
*/
17-
18-
+#define _CRT_SECURE_NO_WARNINGS
19-
#ifdef _DEBUG
20-
#define _CRTDBG_MAP_ALLOC
21-
#include <stdlib.h>
15+
* THE SOFTWARE.
16+
*/
17+
18+
+#define _CRT_SECURE_NO_WARNINGS
19+
#ifdef _DEBUG
20+
#define _CRTDBG_MAP_ALLOC
21+
#include <stdlib.h>
2222
@@ -311,6 +312,7 @@ static HMODULE MyGetModuleHandleFromAddress( const void *addr )
23-
/* Load Psapi.dll at runtime, this avoids linking caveat */
24-
static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded )
25-
{
26-
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
27-
static BOOL (WINAPI *EnumProcessModulesPtr)(HANDLE, HMODULE *, DWORD, LPDWORD) = NULL;
28-
static BOOL failed = FALSE;
29-
UINT uMode;
23+
/* Load Psapi.dll at runtime, this avoids linking caveat */
24+
static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded )
25+
{
26+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
27+
static BOOL (WINAPI *EnumProcessModulesPtr)(HANDLE, HMODULE *, DWORD, LPDWORD) = NULL;
28+
static BOOL failed = FALSE;
29+
UINT uMode;
3030
@@ -349,21 +351,27 @@ static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb,
31-
}
32-
33-
return EnumProcessModulesPtr( hProcess, lphModule, cb, lpcbNeeded );
34-
+#else
35-
+ return 0;
36-
+#endif
37-
}
38-
39-
DLFCN_EXPORT
40-
void *dlopen( const char *file, int mode )
41-
{
42-
- HMODULE hModule;
43-
- UINT uMode;
44-
+ HMODULE hModule = NULL;
45-
+ UINT uMode = 0;
46-
47-
error_occurred = FALSE;
48-
49-
/* Do not let Windows display the critical-error-handler message box */
50-
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
51-
uMode = MySetErrorMode( SEM_FAILCRITICALERRORS );
52-
+#endif
53-
54-
if( file == NULL )
55-
{
56-
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) // what is replacement of GMH on UWP?
57-
/* POSIX says that if the value of file is NULL, a handle on a global
58-
* symbol object must be provided. That object must be able to access
59-
* all symbols from the original program file, and any objects loaded
31+
}
32+
33+
return EnumProcessModulesPtr( hProcess, lphModule, cb, lpcbNeeded );
34+
+#else
35+
+ return 0;
36+
+#endif
37+
}
38+
39+
DLFCN_EXPORT
40+
void *dlopen( const char *file, int mode )
41+
{
42+
- HMODULE hModule;
43+
- UINT uMode;
44+
+ HMODULE hModule = NULL;
45+
+ UINT uMode = 0;
46+
47+
error_occurred = FALSE;
48+
49+
/* Do not let Windows display the critical-error-handler message box */
50+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
51+
uMode = MySetErrorMode( SEM_FAILCRITICALERRORS );
52+
+#endif
53+
54+
if( file == NULL )
55+
{
56+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) // what is replacement of GMH on UWP?
57+
/* POSIX says that if the value of file is NULL, a handle on a global
58+
* symbol object must be provided. That object must be able to access
59+
* all symbols from the original program file, and any objects loaded
6060
@@ -378,6 +386,7 @@ void *dlopen( const char *file, int mode )
61-
62-
if( !hModule )
63-
save_err_str( "(null)", GetLastError( ) );
64-
+#endif
65-
}
66-
else
67-
{
61+
62+
if( !hModule )
63+
save_err_str( "(null)", GetLastError( ) );
64+
+#endif
65+
}
66+
else
67+
{
6868
@@ -415,8 +424,25 @@ void *dlopen( const char *file, int mode )
69-
* to UNIX's search paths (start with system folders instead of current
70-
* folder).
71-
*/
72-
- hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
73-
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
74-
+ int result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), NULL, 0);
75-
+ if (result == 0)
76-
+ return NULL;
77-
+
78-
+ wchar_t* newStr = (wchar_t*)malloc(result*sizeof(wchar_t));
79-
+ result = MultiByteToWideChar( CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), newStr, result );
80-
+ if (result == 0)
81-
+ {
82-
+ free( newStr );
83-
+ return NULL;
84-
+ }
85-
86-
+ hModule = LoadPackagedLibrary( newStr, 0 );
87-
+ free( newStr );
88-
+ dwProcModsAfter = 0;
89-
+#else // WINAPI_PARTITION_DESKTOP
90-
+ hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
91-
+#endif
92-
if( !hModule )
93-
{
94-
save_err_str( lpFileName, GetLastError( ) );
69+
* to UNIX's search paths (start with system folders instead of current
70+
* folder).
71+
*/
72+
- hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
73+
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
74+
+ int result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), NULL, 0);
75+
+ if (result == 0)
76+
+ return NULL;
77+
+
78+
+ wchar_t* newStr = (wchar_t*)malloc(result*sizeof(wchar_t));
79+
+ result = MultiByteToWideChar( CP_UTF8, MB_ERR_INVALID_CHARS, lpFileName, strlen(lpFileName), newStr, result );
80+
+ if (result == 0)
81+
+ {
82+
+ free( newStr );
83+
+ return NULL;
84+
+ }
85+
86+
+ hModule = LoadPackagedLibrary( newStr, 0 );
87+
+ free( newStr );
88+
+ dwProcModsAfter = 0;
89+
+#else // WINAPI_PARTITION_DESKTOP
90+
+ hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
91+
+#endif
92+
if( !hModule )
93+
{
94+
save_err_str( lpFileName, GetLastError( ) );
9595
@@ -453,7 +479,9 @@ void *dlopen( const char *file, int mode )
96-
}
97-
98-
/* Return to previous state of the error-mode bit flags. */
99-
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
100-
MySetErrorMode( uMode );
101-
+#endif
102-
103-
return (void *) hModule;
104-
}
96+
}
97+
98+
/* Return to previous state of the error-mode bit flags. */
99+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
100+
MySetErrorMode( uMode );
101+
+#endif
102+
103+
return (void *) hModule;
104+
}
105105
@@ -488,13 +516,15 @@ void *dlsym( void *handle, const char *name )
106-
{
107-
FARPROC symbol;
108-
HMODULE hCaller;
109-
- HMODULE hModule;
110-
- DWORD dwMessageId;
111-
+ HMODULE hModule = 0;
112-
+ DWORD dwMessageId = 0;
113-
114-
error_occurred = FALSE;
115-
116-
symbol = NULL;
117-
hCaller = NULL;
118-
+
119-
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) // what is replacement of GMH on UWP?
120-
hModule = GetModuleHandle( NULL );
121-
dwMessageId = 0;
122-
106+
{
107+
FARPROC symbol;
108+
HMODULE hCaller;
109+
- HMODULE hModule;
110+
- DWORD dwMessageId;
111+
+ HMODULE hModule = 0;
112+
+ DWORD dwMessageId = 0;
113+
114+
error_occurred = FALSE;
115+
116+
symbol = NULL;
117+
hCaller = NULL;
118+
+
119+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP) // what is replacement of GMH on UWP?
120+
hModule = GetModuleHandle( NULL );
121+
dwMessageId = 0;
122+
123123
@@ -525,6 +555,7 @@ void *dlsym( void *handle, const char *name )
124-
goto end;
125-
}
126-
}
127-
+#endif
128-
129-
if( handle != RTLD_NEXT )
130-
{
124+
goto end;
125+
}
126+
}
127+
+#endif
128+
129+
if( handle != RTLD_NEXT )
130+
{
131131
@@ -538,6 +569,7 @@ void *dlsym( void *handle, const char *name )
132-
* in all globally loaded objects.
133-
*/
134-
135-
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
136-
if( hModule == handle || handle == RTLD_NEXT )
137-
{
138-
HANDLE hCurrentProc;
132+
* in all globally loaded objects.
133+
*/
134+
135+
+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
136+
if( hModule == handle || handle == RTLD_NEXT )
137+
{
138+
HANDLE hCurrentProc;
139139
@@ -588,6 +620,7 @@ void *dlsym( void *handle, const char *name )
140-
}
141-
}
142-
}
143-
+#endif
144-
145-
end:
146-
if( symbol == NULL )
140+
}
141+
}
142+
}
143+
+#endif
144+
145+
end:
146+
if( symbol == NULL )
147147
--
148148
2.47.1.windows.1
149149

0 commit comments

Comments
 (0)