Fossil SCM
Add parameters to declarations for dynamically loaded functions, to fix builds with latest GCC on Windows. Reported in [forum:3b3b741661|forum post 3b3b741661].
Commit
51ac554e3577ec246fc8230efbe1b88a531f400cc81ccf0a5d492c19a4b9e019
Parent
1205ec86cb5508e…
1 file changed
+34
-19
+34
-19
| --- src/winfile.c | ||
| +++ src/winfile.c | ||
| @@ -304,39 +304,47 @@ | ||
| 304 | 304 | */ |
| 305 | 305 | int win32_filenames_equal_nocase( |
| 306 | 306 | const wchar_t *fn1, |
| 307 | 307 | const wchar_t *fn2 |
| 308 | 308 | ){ |
| 309 | - static FARPROC fnCompareStringOrdinal; | |
| 310 | - static FARPROC fnRtlInitUnicodeString; | |
| 311 | - static FARPROC fnRtlEqualUnicodeString; | |
| 309 | + /* ---- Data types used by dynamically loaded API functions. -------------- */ | |
| 310 | + typedef struct { /* UNICODE_STRING from <ntdef.h> */ | |
| 311 | + USHORT Length; | |
| 312 | + USHORT MaximumLength; | |
| 313 | + PWSTR Buffer; | |
| 314 | + } MY_UNICODE_STRING; | |
| 315 | + /* ---- Prototypes for dynamically loaded API functions. ------------------ */ | |
| 316 | + typedef int (WINAPI *FNCOMPARESTRINGORDINAL)(LPCWCH,int,LPCWCH,int,BOOL); | |
| 317 | + typedef VOID (NTAPI *FNRTLINITUNICODESTRING)(MY_UNICODE_STRING*,PCWSTR); | |
| 318 | + typedef BOOLEAN (NTAPI *FNRTLEQUALUNICODESTRING) | |
| 319 | + (MY_UNICODE_STRING*,MY_UNICODE_STRING*,BOOLEAN); | |
| 320 | + /* ------------------------------------------------------------------------ */ | |
| 321 | + static FNCOMPARESTRINGORDINAL fnCompareStringOrdinal; | |
| 322 | + static FNRTLINITUNICODESTRING fnRtlInitUnicodeString; | |
| 323 | + static FNRTLEQUALUNICODESTRING fnRtlEqualUnicodeString; | |
| 312 | 324 | static int loaded_CompareStringOrdinal; |
| 313 | 325 | static int loaded_RtlUnicodeStringAPIs; |
| 314 | 326 | if( !loaded_CompareStringOrdinal ){ |
| 315 | - fnCompareStringOrdinal = | |
| 327 | + fnCompareStringOrdinal = (FNCOMPARESTRINGORDINAL) | |
| 316 | 328 | GetProcAddress(GetModuleHandleA("kernel32"),"CompareStringOrdinal"); |
| 317 | 329 | loaded_CompareStringOrdinal = 1; |
| 318 | 330 | } |
| 319 | 331 | if( fnCompareStringOrdinal ){ |
| 320 | 332 | return fnCompareStringOrdinal(fn1,-1,fn2,-1,1)-2==0; |
| 321 | 333 | } |
| 322 | 334 | if( !loaded_RtlUnicodeStringAPIs ){ |
| 323 | - fnRtlInitUnicodeString = | |
| 335 | + fnRtlInitUnicodeString = (FNRTLINITUNICODESTRING) | |
| 324 | 336 | GetProcAddress(GetModuleHandleA("ntdll"),"RtlInitUnicodeString"); |
| 325 | - fnRtlEqualUnicodeString = | |
| 337 | + fnRtlEqualUnicodeString = (FNRTLEQUALUNICODESTRING) | |
| 326 | 338 | GetProcAddress(GetModuleHandleA("ntdll"),"RtlEqualUnicodeString"); |
| 327 | 339 | loaded_RtlUnicodeStringAPIs = 1; |
| 328 | 340 | } |
| 329 | 341 | if( fnRtlInitUnicodeString && fnRtlEqualUnicodeString ){ |
| 330 | - struct { /* UNICODE_STRING from <ntdef.h> */ | |
| 331 | - unsigned short Length; | |
| 332 | - unsigned short MaximumLength; | |
| 333 | - wchar_t *Buffer; | |
| 334 | - } u1, u2; | |
| 342 | + MY_UNICODE_STRING u1, u2; | |
| 335 | 343 | fnRtlInitUnicodeString(&u1,fn1); |
| 336 | 344 | fnRtlInitUnicodeString(&u2,fn2); |
| 337 | - return (unsigned char)fnRtlEqualUnicodeString(&u1,&u2,1); | |
| 345 | + return (BOOLEAN/*unsigned char*/)fnRtlEqualUnicodeString(&u1,&u2,1); | |
| 338 | 346 | } |
| 339 | 347 | /* In what kind of strange parallel universe are we? */ |
| 340 | 348 | return lstrcmpiW(fn1,fn2)==0; |
| 341 | 349 | } |
| 342 | 350 | |
| @@ -461,11 +469,20 @@ | ||
| 461 | 469 | ** is allocated by mprintf(), or NULL on failure. |
| 462 | 470 | */ |
| 463 | 471 | char *win32_file_id( |
| 464 | 472 | const char *zFileName |
| 465 | 473 | ){ |
| 466 | - static FARPROC fnGetFileInformationByHandleEx; | |
| 474 | + /* ---- Data types used by dynamically loaded API functions. -------------- */ | |
| 475 | + typedef struct { /* FILE_ID_INFO from <winbase.h> */ | |
| 476 | + ULONGLONG VolumeSerialNumber; | |
| 477 | + BYTE FileId[16]; | |
| 478 | + } MY_FILE_ID_INFO; | |
| 479 | + /* ---- Prototypes for dynamically loaded API functions. ------------------ */ | |
| 480 | + typedef int (WINAPI *FNGETFILEINFORMATIONBYHANDLEEX) | |
| 481 | + (HANDLE,int/*enum*/,MY_FILE_ID_INFO*,DWORD); | |
| 482 | + /* ------------------------------------------------------------------------ */ | |
| 483 | + static FNGETFILEINFORMATIONBYHANDLEEX fnGetFileInformationByHandleEx; | |
| 467 | 484 | static int loaded_fnGetFileInformationByHandleEx; |
| 468 | 485 | wchar_t *wzFileName = fossil_utf8_to_path(zFileName,0); |
| 469 | 486 | HANDLE hFile; |
| 470 | 487 | char *zFileId = 0; |
| 471 | 488 | hFile = CreateFileW( |
| @@ -476,17 +493,15 @@ | ||
| 476 | 493 | OPEN_EXISTING, |
| 477 | 494 | FILE_FLAG_BACKUP_SEMANTICS, |
| 478 | 495 | NULL); |
| 479 | 496 | if( hFile!=INVALID_HANDLE_VALUE ){ |
| 480 | 497 | BY_HANDLE_FILE_INFORMATION fi; |
| 481 | - struct { /* FILE_ID_INFO from <winbase.h> */ | |
| 482 | - u64 VolumeSerialNumber; | |
| 483 | - unsigned char FileId[16]; | |
| 484 | - } fi2; | |
| 498 | + MY_FILE_ID_INFO fi2; | |
| 485 | 499 | if( !loaded_fnGetFileInformationByHandleEx ){ |
| 486 | - fnGetFileInformationByHandleEx = GetProcAddress( | |
| 487 | - GetModuleHandleA("kernel32"),"GetFileInformationByHandleEx"); | |
| 500 | + fnGetFileInformationByHandleEx = (FNGETFILEINFORMATIONBYHANDLEEX) | |
| 501 | + GetProcAddress( | |
| 502 | + GetModuleHandleA("kernel32"),"GetFileInformationByHandleEx"); | |
| 488 | 503 | loaded_fnGetFileInformationByHandleEx = 1; |
| 489 | 504 | } |
| 490 | 505 | if( fnGetFileInformationByHandleEx ){ |
| 491 | 506 | if( fnGetFileInformationByHandleEx( |
| 492 | 507 | hFile,/*FileIdInfo*/0x12,&fi2,sizeof(fi2)) ){ |
| 493 | 508 |
| --- src/winfile.c | |
| +++ src/winfile.c | |
| @@ -304,39 +304,47 @@ | |
| 304 | */ |
| 305 | int win32_filenames_equal_nocase( |
| 306 | const wchar_t *fn1, |
| 307 | const wchar_t *fn2 |
| 308 | ){ |
| 309 | static FARPROC fnCompareStringOrdinal; |
| 310 | static FARPROC fnRtlInitUnicodeString; |
| 311 | static FARPROC fnRtlEqualUnicodeString; |
| 312 | static int loaded_CompareStringOrdinal; |
| 313 | static int loaded_RtlUnicodeStringAPIs; |
| 314 | if( !loaded_CompareStringOrdinal ){ |
| 315 | fnCompareStringOrdinal = |
| 316 | GetProcAddress(GetModuleHandleA("kernel32"),"CompareStringOrdinal"); |
| 317 | loaded_CompareStringOrdinal = 1; |
| 318 | } |
| 319 | if( fnCompareStringOrdinal ){ |
| 320 | return fnCompareStringOrdinal(fn1,-1,fn2,-1,1)-2==0; |
| 321 | } |
| 322 | if( !loaded_RtlUnicodeStringAPIs ){ |
| 323 | fnRtlInitUnicodeString = |
| 324 | GetProcAddress(GetModuleHandleA("ntdll"),"RtlInitUnicodeString"); |
| 325 | fnRtlEqualUnicodeString = |
| 326 | GetProcAddress(GetModuleHandleA("ntdll"),"RtlEqualUnicodeString"); |
| 327 | loaded_RtlUnicodeStringAPIs = 1; |
| 328 | } |
| 329 | if( fnRtlInitUnicodeString && fnRtlEqualUnicodeString ){ |
| 330 | struct { /* UNICODE_STRING from <ntdef.h> */ |
| 331 | unsigned short Length; |
| 332 | unsigned short MaximumLength; |
| 333 | wchar_t *Buffer; |
| 334 | } u1, u2; |
| 335 | fnRtlInitUnicodeString(&u1,fn1); |
| 336 | fnRtlInitUnicodeString(&u2,fn2); |
| 337 | return (unsigned char)fnRtlEqualUnicodeString(&u1,&u2,1); |
| 338 | } |
| 339 | /* In what kind of strange parallel universe are we? */ |
| 340 | return lstrcmpiW(fn1,fn2)==0; |
| 341 | } |
| 342 | |
| @@ -461,11 +469,20 @@ | |
| 461 | ** is allocated by mprintf(), or NULL on failure. |
| 462 | */ |
| 463 | char *win32_file_id( |
| 464 | const char *zFileName |
| 465 | ){ |
| 466 | static FARPROC fnGetFileInformationByHandleEx; |
| 467 | static int loaded_fnGetFileInformationByHandleEx; |
| 468 | wchar_t *wzFileName = fossil_utf8_to_path(zFileName,0); |
| 469 | HANDLE hFile; |
| 470 | char *zFileId = 0; |
| 471 | hFile = CreateFileW( |
| @@ -476,17 +493,15 @@ | |
| 476 | OPEN_EXISTING, |
| 477 | FILE_FLAG_BACKUP_SEMANTICS, |
| 478 | NULL); |
| 479 | if( hFile!=INVALID_HANDLE_VALUE ){ |
| 480 | BY_HANDLE_FILE_INFORMATION fi; |
| 481 | struct { /* FILE_ID_INFO from <winbase.h> */ |
| 482 | u64 VolumeSerialNumber; |
| 483 | unsigned char FileId[16]; |
| 484 | } fi2; |
| 485 | if( !loaded_fnGetFileInformationByHandleEx ){ |
| 486 | fnGetFileInformationByHandleEx = GetProcAddress( |
| 487 | GetModuleHandleA("kernel32"),"GetFileInformationByHandleEx"); |
| 488 | loaded_fnGetFileInformationByHandleEx = 1; |
| 489 | } |
| 490 | if( fnGetFileInformationByHandleEx ){ |
| 491 | if( fnGetFileInformationByHandleEx( |
| 492 | hFile,/*FileIdInfo*/0x12,&fi2,sizeof(fi2)) ){ |
| 493 |
| --- src/winfile.c | |
| +++ src/winfile.c | |
| @@ -304,39 +304,47 @@ | |
| 304 | */ |
| 305 | int win32_filenames_equal_nocase( |
| 306 | const wchar_t *fn1, |
| 307 | const wchar_t *fn2 |
| 308 | ){ |
| 309 | /* ---- Data types used by dynamically loaded API functions. -------------- */ |
| 310 | typedef struct { /* UNICODE_STRING from <ntdef.h> */ |
| 311 | USHORT Length; |
| 312 | USHORT MaximumLength; |
| 313 | PWSTR Buffer; |
| 314 | } MY_UNICODE_STRING; |
| 315 | /* ---- Prototypes for dynamically loaded API functions. ------------------ */ |
| 316 | typedef int (WINAPI *FNCOMPARESTRINGORDINAL)(LPCWCH,int,LPCWCH,int,BOOL); |
| 317 | typedef VOID (NTAPI *FNRTLINITUNICODESTRING)(MY_UNICODE_STRING*,PCWSTR); |
| 318 | typedef BOOLEAN (NTAPI *FNRTLEQUALUNICODESTRING) |
| 319 | (MY_UNICODE_STRING*,MY_UNICODE_STRING*,BOOLEAN); |
| 320 | /* ------------------------------------------------------------------------ */ |
| 321 | static FNCOMPARESTRINGORDINAL fnCompareStringOrdinal; |
| 322 | static FNRTLINITUNICODESTRING fnRtlInitUnicodeString; |
| 323 | static FNRTLEQUALUNICODESTRING fnRtlEqualUnicodeString; |
| 324 | static int loaded_CompareStringOrdinal; |
| 325 | static int loaded_RtlUnicodeStringAPIs; |
| 326 | if( !loaded_CompareStringOrdinal ){ |
| 327 | fnCompareStringOrdinal = (FNCOMPARESTRINGORDINAL) |
| 328 | GetProcAddress(GetModuleHandleA("kernel32"),"CompareStringOrdinal"); |
| 329 | loaded_CompareStringOrdinal = 1; |
| 330 | } |
| 331 | if( fnCompareStringOrdinal ){ |
| 332 | return fnCompareStringOrdinal(fn1,-1,fn2,-1,1)-2==0; |
| 333 | } |
| 334 | if( !loaded_RtlUnicodeStringAPIs ){ |
| 335 | fnRtlInitUnicodeString = (FNRTLINITUNICODESTRING) |
| 336 | GetProcAddress(GetModuleHandleA("ntdll"),"RtlInitUnicodeString"); |
| 337 | fnRtlEqualUnicodeString = (FNRTLEQUALUNICODESTRING) |
| 338 | GetProcAddress(GetModuleHandleA("ntdll"),"RtlEqualUnicodeString"); |
| 339 | loaded_RtlUnicodeStringAPIs = 1; |
| 340 | } |
| 341 | if( fnRtlInitUnicodeString && fnRtlEqualUnicodeString ){ |
| 342 | MY_UNICODE_STRING u1, u2; |
| 343 | fnRtlInitUnicodeString(&u1,fn1); |
| 344 | fnRtlInitUnicodeString(&u2,fn2); |
| 345 | return (BOOLEAN/*unsigned char*/)fnRtlEqualUnicodeString(&u1,&u2,1); |
| 346 | } |
| 347 | /* In what kind of strange parallel universe are we? */ |
| 348 | return lstrcmpiW(fn1,fn2)==0; |
| 349 | } |
| 350 | |
| @@ -461,11 +469,20 @@ | |
| 469 | ** is allocated by mprintf(), or NULL on failure. |
| 470 | */ |
| 471 | char *win32_file_id( |
| 472 | const char *zFileName |
| 473 | ){ |
| 474 | /* ---- Data types used by dynamically loaded API functions. -------------- */ |
| 475 | typedef struct { /* FILE_ID_INFO from <winbase.h> */ |
| 476 | ULONGLONG VolumeSerialNumber; |
| 477 | BYTE FileId[16]; |
| 478 | } MY_FILE_ID_INFO; |
| 479 | /* ---- Prototypes for dynamically loaded API functions. ------------------ */ |
| 480 | typedef int (WINAPI *FNGETFILEINFORMATIONBYHANDLEEX) |
| 481 | (HANDLE,int/*enum*/,MY_FILE_ID_INFO*,DWORD); |
| 482 | /* ------------------------------------------------------------------------ */ |
| 483 | static FNGETFILEINFORMATIONBYHANDLEEX fnGetFileInformationByHandleEx; |
| 484 | static int loaded_fnGetFileInformationByHandleEx; |
| 485 | wchar_t *wzFileName = fossil_utf8_to_path(zFileName,0); |
| 486 | HANDLE hFile; |
| 487 | char *zFileId = 0; |
| 488 | hFile = CreateFileW( |
| @@ -476,17 +493,15 @@ | |
| 493 | OPEN_EXISTING, |
| 494 | FILE_FLAG_BACKUP_SEMANTICS, |
| 495 | NULL); |
| 496 | if( hFile!=INVALID_HANDLE_VALUE ){ |
| 497 | BY_HANDLE_FILE_INFORMATION fi; |
| 498 | MY_FILE_ID_INFO fi2; |
| 499 | if( !loaded_fnGetFileInformationByHandleEx ){ |
| 500 | fnGetFileInformationByHandleEx = (FNGETFILEINFORMATIONBYHANDLEEX) |
| 501 | GetProcAddress( |
| 502 | GetModuleHandleA("kernel32"),"GetFileInformationByHandleEx"); |
| 503 | loaded_fnGetFileInformationByHandleEx = 1; |
| 504 | } |
| 505 | if( fnGetFileInformationByHandleEx ){ |
| 506 | if( fnGetFileInformationByHandleEx( |
| 507 | hFile,/*FileIdInfo*/0x12,&fi2,sizeof(fi2)) ){ |
| 508 |