Skip to content

Commit bb125d2

Browse files
committed
gcc weirdness
1 parent b940fae commit bb125d2

22 files changed

Lines changed: 262 additions & 48 deletions

File tree

dll/shellext/shellbtrfs/shellext.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,13 @@ class ntstatus_error : public exception {
388388
string msg;
389389
};
390390

391-
#ifdef __REACTOS__
392-
inline wstring to_wstring(uint8_t a) { WCHAR buffer[16]; swprintf(buffer, L"%d", a); return wstring(buffer); }
391+
#if defined(__REACTOS__) && !defined(__GNUC__)
392+
/* Older/MSVC standard libraries shipped no wchar_t to_wstring overloads, so
393+
ReactOS provided its own. A modern libstdc++ (GCC) already declares the full
394+
set of std::to_wstring overloads, and with the 'using namespace std' above
395+
these local shims tie with them and make calls ambiguous; only define them
396+
where the standard library does not. */
397+
inline wstring to_wstring(uint8_t a) { WCHAR buffer[16]; swprintf(buffer, L"%d", a); return wstring(buffer); }
393398
inline wstring to_wstring(uint16_t a) { WCHAR buffer[16]; swprintf(buffer, L"%d", a); return wstring(buffer); }
394399
inline wstring to_wstring(uint32_t a) { WCHAR buffer[32]; swprintf(buffer, L"%ld", a); return wstring(buffer); }
395400
inline wstring to_wstring(uint64_t a) { WCHAR buffer[64]; swprintf(buffer, L"%I64d", a); return wstring(buffer); }

dll/win32/msvcrt/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ list(APPEND MSVCRT_SOURCE
126126
${SHARED_SOURCE}
127127
${msvcrt_shared_asm}
128128
reactos/misc.c
129+
reactos/mingw_compat.c
129130
reactos/system.cpp
130131
concurrency.c
131132
console.c

dll/win32/msvcrt/exit.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,18 @@ void DECLSPEC_NORETURN CDECL _assert(const char* str, const char* file, unsigned
321321
_wassert(strW, fileW, line);
322322
}
323323

324+
/*********************************************************************
325+
* __msvcrt_assert (MSVCRT.@)
326+
*
327+
* A modern mingw-w64 libstdc++/libmingwex calls __msvcrt_assert (imported from
328+
* msvcrt.dll) from its assert() path. Real msvcrt exports it; ReactOS only
329+
* shipped _assert, so forward to it here.
330+
*/
331+
void DECLSPEC_NORETURN CDECL __msvcrt_assert(const char* str, const char* file, unsigned int line)
332+
{
333+
_assert(str, file, line);
334+
}
335+
324336
/*********************************************************************
325337
* _c_exit (MSVCRT.@)
326338
*/

dll/win32/msvcrt/msvcrt.spec

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@
331331
# stub -version=0x600+ _aligned_realloc_dbg(ptr long long str long)
332332
@ cdecl _amsg_exit(long)
333333
@ cdecl _assert(str str long)
334+
@ cdecl __msvcrt_assert(str str long)
335+
@ cdecl -ret64 lseek64(long int64 long)
336+
@ cdecl fstat64(long ptr)
337+
@ cdecl fseeko64(ptr int64 long)
338+
@ cdecl -ret64 ftello64(ptr)
339+
@ cdecl wctype(str)
334340
@ cdecl _atodbl(ptr str)
335341
@ cdecl -version=0x600+ _atodbl_l(ptr str ptr)
336342
@ cdecl -version=0x600+ _atof_l(str ptr)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* PROJECT: ReactOS msvcrt.dll
3+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4+
* PURPOSE: POSIX/large-file CRT names expected by a modern mingw-w64
5+
* libstdc++ (e.g. GCC 16). The real mingw CRT (msvcrt/ucrt)
6+
* exports these; ReactOS only shipped the _-prefixed Win32
7+
* variants, so provide thin forwarders here. Consumed by C++
8+
* modules that link the real libstdc++ (e.g. its std::basic_file).
9+
*/
10+
11+
#include <stdio.h>
12+
#include <io.h>
13+
#include <string.h>
14+
#include <ctype.h>
15+
#include <sys/stat.h>
16+
#include <msvcrt.h>
17+
18+
__int64 __cdecl lseek64(int _FileHandle, __int64 _Offset, int _Origin)
19+
{
20+
return _lseeki64(_FileHandle, _Offset, _Origin);
21+
}
22+
23+
int __cdecl fstat64(int _FileHandle, struct _stat64 *_Stat)
24+
{
25+
return _fstat64(_FileHandle, _Stat);
26+
}
27+
28+
int __cdecl fseeko64(FILE *_File, __int64 _Offset, int _Origin)
29+
{
30+
return _fseeki64(_File, _Offset, _Origin);
31+
}
32+
33+
__int64 __cdecl ftello64(FILE *_File)
34+
{
35+
return _ftelli64(_File);
36+
}
37+
38+
/*
39+
* wctype() maps a character-class name to a mask usable with iswctype().
40+
* msvcrt's ctype.c only compiles it for _MSVCR_VER >= 120, but a modern
41+
* libstdc++ imports it from msvcrt.dll, so provide it here for plain msvcrt.
42+
*/
43+
#if _MSVCR_VER < 120
44+
unsigned short __cdecl wctype(const char *_Property)
45+
{
46+
static const struct { const char *name; unsigned short mask; } properties[] =
47+
{
48+
{ "alnum", _DIGIT | _ALPHA },
49+
{ "alpha", _ALPHA },
50+
{ "cntrl", _CONTROL },
51+
{ "digit", _DIGIT },
52+
{ "graph", _DIGIT | _PUNCT | _ALPHA },
53+
{ "lower", _LOWER },
54+
{ "print", _DIGIT | _PUNCT | _BLANK | _ALPHA },
55+
{ "punct", _PUNCT },
56+
{ "space", _SPACE },
57+
{ "upper", _UPPER },
58+
{ "xdigit", _HEX },
59+
};
60+
unsigned int i;
61+
62+
for (i = 0; i < sizeof(properties) / sizeof(properties[0]); i++)
63+
{
64+
if (strcmp(_Property, properties[i].name) == 0)
65+
return properties[i].mask;
66+
}
67+
68+
return 0;
69+
}
70+
#endif /* _MSVCR_VER < 120 */

dll/win32/urlmon/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ add_definitions(
55
-DPROXY_DELEGATION
66
-DWINE_REGISTER_DLL
77
-D_CRT_NON_CONFORMING_SWPRINTFS
8-
-DPROXY_CLSID_IS={0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}})
8+
# NOTE: the spaces and quoting below are intentional. They force CMake to
9+
# shell-quote this argument in the generated command, preventing bash (which
10+
# is /bin/sh on some distros and is used by Ninja) from brace-expanding the
11+
# unquoted "{a,b,c}" GUID initializer into multiple conflicting
12+
# -DPROXY_CLSID_IS definitions ("'PROXY_CLSID_IS' redefined").
13+
"-DPROXY_CLSID_IS={0x79EAC9F1, 0xBAF9, 0x11CE, {0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B}}")
914

1015
spec2def(urlmon.dll urlmon.spec ADD_IMPORTLIB)
1116
add_rpcproxy_files(urlmon_urlmon.idl)

drivers/base/kdnet/kdnet_init.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static ULONGLONG KdNetBase36ToU64(const char* s, const char** end)
4848
static BOOLEAN KdNetReadTokenCI(const char* opts, const char* key, char* out, SIZE_T outChars);
4949
static BOOLEAN KdNetParseIpv4(const char* s, ULONG* outHostOrder);
5050
static BOOLEAN KdNetParseUlongDec(const char* s, ULONG* out);
51-
static __forceinline BOOLEAN KdNetHasFlagCI(const char* opts, const char* key);
51+
static __inline BOOLEAN KdNetHasFlagCI(const char* opts, const char* key);
5252
static KDNET_SHARED_DATA g_KdNetSharedData;
5353

5454
static VOID KdNetWireRuntimeParameters(_In_opt_ PCHAR LoaderOptions)
@@ -127,12 +127,12 @@ static VOID KdNetWireRuntimeParameters(_In_opt_ PCHAR LoaderOptions)
127127
}
128128
}
129129

130-
static __forceinline int KdNetIsSpace(char c)
130+
static __inline int KdNetIsSpace(char c)
131131
{
132132
return (c == ' ' || c == '\t' || c == '\r' || c == '\n');
133133
}
134134

135-
static __forceinline char KdNetToUpper(char c)
135+
static __inline char KdNetToUpper(char c)
136136
{
137137
if (c >= 'a' && c <= 'z') return (char)(c - ('a' - 'A'));
138138
return c;
@@ -249,7 +249,7 @@ static BOOLEAN KdNetParseIpv4(const char* s, ULONG* outHostOrder)
249249
return TRUE;
250250
}
251251

252-
static __forceinline BOOLEAN KdNetHasFlagCI(const char* opts, const char* key)
252+
static __inline BOOLEAN KdNetHasFlagCI(const char* opts, const char* key)
253253
{
254254
return (KdNetFindKeyCI(opts, key) != NULL);
255255
}

drivers/base/kdnet/kdnet_net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PDEBUG_NET_DATA KdNetData = NULL;
99

1010
/* ----------------------------------------------------------- tiny utils ---*/
1111

12-
static __forceinline USHORT KdNetSwap16(USHORT v)
12+
static __inline USHORT KdNetSwap16(USHORT v)
1313
{
1414
return (USHORT)((v >> 8) | (v << 8));
1515
}

drivers/bus/acpi_new/acpi_new.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ typedef struct _ACPI_NEW_CONTROL_EXTENSION
8585
ACPI_NEW_COMMON_EXTENSION Common;
8686
} ACPI_NEW_CONTROL_EXTENSION, *PACPI_NEW_CONTROL_EXTENSION;
8787

88-
static __forceinline BOOLEAN AcpiNewIsFdo(_In_ PDEVICE_OBJECT DeviceObject)
88+
static __inline BOOLEAN AcpiNewIsFdo(_In_ PDEVICE_OBJECT DeviceObject)
8989
{
9090
PACPI_NEW_COMMON_EXTENSION common = (PACPI_NEW_COMMON_EXTENSION)DeviceObject->DeviceExtension;
9191
return common && (common->Type == AcpiNewDeviceFdo);
9292
}
9393

94-
static __forceinline BOOLEAN AcpiNewIsPdo(_In_ PDEVICE_OBJECT DeviceObject)
94+
static __inline BOOLEAN AcpiNewIsPdo(_In_ PDEVICE_OBJECT DeviceObject)
9595
{
9696
PACPI_NEW_COMMON_EXTENSION common = (PACPI_NEW_COMMON_EXTENSION)DeviceObject->DeviceExtension;
9797
return common && (common->Type == AcpiNewDevicePdo);
9898
}
9999

100-
static __forceinline BOOLEAN AcpiNewIsControl(_In_ PDEVICE_OBJECT DeviceObject)
100+
static __inline BOOLEAN AcpiNewIsControl(_In_ PDEVICE_OBJECT DeviceObject)
101101
{
102102
PACPI_NEW_COMMON_EXTENSION common = (PACPI_NEW_COMMON_EXTENSION)DeviceObject->DeviceExtension;
103103
return common && (common->Type == AcpiNewDeviceControl);

drivers/bus/acpi_new/ec.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ typedef struct _ACPI_NEW_EC_CONTEXT
3232

3333
static ACPI_NEW_EC_CONTEXT g_Ec;
3434

35-
static __forceinline UCHAR EcReadStatus(_In_ PACPI_NEW_EC_CONTEXT Ec)
35+
static __inline UCHAR EcReadStatus(_In_ PACPI_NEW_EC_CONTEXT Ec)
3636
{
3737
return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)Ec->CmdPort);
3838
}
3939

40-
static __forceinline UCHAR EcReadData(_In_ PACPI_NEW_EC_CONTEXT Ec)
40+
static __inline UCHAR EcReadData(_In_ PACPI_NEW_EC_CONTEXT Ec)
4141
{
4242
return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)Ec->DataPort);
4343
}
4444

45-
static __forceinline VOID EcWriteCmd(_In_ PACPI_NEW_EC_CONTEXT Ec, _In_ UCHAR Value)
45+
static __inline VOID EcWriteCmd(_In_ PACPI_NEW_EC_CONTEXT Ec, _In_ UCHAR Value)
4646
{
4747
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)Ec->CmdPort, Value);
4848
}
4949

50-
static __forceinline VOID EcWriteData(_In_ PACPI_NEW_EC_CONTEXT Ec, _In_ UCHAR Value)
50+
static __inline VOID EcWriteData(_In_ PACPI_NEW_EC_CONTEXT Ec, _In_ UCHAR Value)
5151
{
5252
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)Ec->DataPort, Value);
5353
}
@@ -165,7 +165,7 @@ static BOOLEAN EcQuery(_In_ PACPI_NEW_EC_CONTEXT Ec, _Out_ UCHAR *Query)
165165
return FALSE;
166166
}
167167

168-
static __forceinline CHAR AcpiNewHexDigit(_In_ UCHAR N)
168+
static __inline CHAR AcpiNewHexDigit(_In_ UCHAR N)
169169
{
170170
N &= 0xF;
171171
return (N < 10) ? (CHAR)('0' + N) : (CHAR)('A' + (N - 10));

0 commit comments

Comments
 (0)