forked from oneclick/rubyinstaller2-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patch to avoid compiler error on mingw32
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
mingw-w64-ruby-head/0010-Windows-Use-ATOMIC_PTR-functions-to-avoid-compiler-w.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
From ffb58ea8b401e85474972cdba5be036c12b1fe2f Mon Sep 17 00:00:00 2001 | ||
From: Lars Kanis <lars@greiz-reinsdorf.de> | ||
Date: Mon, 20 May 2024 14:54:44 +0200 | ||
Subject: [PATCH] Windows: Use ATOMIC_PTR functions to avoid compiler warnings | ||
due to incompatible types | ||
|
||
HCRYPTPROV can be casted to pointer without warning but not to size_t. | ||
Avoids the following warning/error: | ||
|
||
../snapshot-master/random.c: In function 'fill_random_bytes_crypt': | ||
../snapshot-master/include/ruby/atomic.h:246:28: warning: passing argument 1 of 'rbimpl_atomic_size_cas' from incompatible pointer type [-Wincompatible-pointer-types] | ||
246 | rbimpl_atomic_size_cas(&(var), (oldval), (newval)) | ||
| ^~~~~~ | ||
| | | ||
| HCRYPTPROV * {aka long unsigned int *} | ||
../snapshot-master/ruby_atomic.h:16:46: note: in expansion of macro 'RUBY_ATOMIC_SIZE_CAS' | ||
16 | #define ATOMIC_SIZE_CAS(var, oldval, newval) RUBY_ATOMIC_SIZE_CAS(var, oldval, newval) | ||
| ^~~~~~~~~~~~~~~~~~~~ | ||
../snapshot-master/random.c:594:32: note: in expansion of macro 'ATOMIC_SIZE_CAS' | ||
594 | old_prov = (HCRYPTPROV)ATOMIC_SIZE_CAS(perm_prov, 0, prov); | ||
compiling ../snapshot-master/range.c | ||
| ^~~~~~~~~~~~~~~ | ||
../snapshot-master/include/ruby/atomic.h:853:41: note: expected 'volatile size_t *' {aka 'volatile unsigned int *'} but argument is of type 'HCRYPTPROV *' {aka 'long unsigned int *'} | ||
853 | rbimpl_atomic_size_cas(volatile size_t *ptr, size_t oldval, size_t newval) | ||
| ~~~~~~~~~~~~~~~~~^~~ | ||
--- | ||
random.c | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/random.c b/random.c | ||
index ea76ea656f..1986cf5f20 100644 | ||
--- a/random.c | ||
+++ b/random.c | ||
@@ -576,7 +576,7 @@ static void | ||
release_crypt(void *p) | ||
{ | ||
HCRYPTPROV *ptr = p; | ||
- HCRYPTPROV prov = (HCRYPTPROV)ATOMIC_SIZE_EXCHANGE(*ptr, INVALID_HCRYPTPROV); | ||
+ HCRYPTPROV prov = (HCRYPTPROV)ATOMIC_PTR_EXCHANGE(*((char *)ptr), (char *)INVALID_HCRYPTPROV); | ||
if (prov && prov != INVALID_HCRYPTPROV) { | ||
CryptReleaseContext(prov, 0); | ||
} | ||
@@ -591,7 +591,7 @@ fill_random_bytes_crypt(void *seed, size_t size) | ||
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { | ||
prov = INVALID_HCRYPTPROV; | ||
} | ||
- old_prov = (HCRYPTPROV)ATOMIC_SIZE_CAS(perm_prov, 0, prov); | ||
+ old_prov = (HCRYPTPROV)ATOMIC_PTR_CAS(*((char *)&perm_prov), 0, (char *)prov); | ||
if (LIKELY(!old_prov)) { /* no other threads acquired */ | ||
if (prov != INVALID_HCRYPTPROV) { | ||
#undef RUBY_UNTYPED_DATA_WARNING | ||
-- | ||
2.26.0.windows.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters