]> git.ipfire.org Git - thirdparty/openssl.git/commit
threads_win: fix build error with mingw64
authorGeorgi Valkov <gvalkov@gmail.com>
Wed, 10 Jul 2024 14:28:28 +0000 (17:28 +0300)
committerTomas Mraz <tomas@openssl.org>
Wed, 17 Jul 2024 14:37:07 +0000 (16:37 +0200)
commita2c74d7af66e6eff9b4355b27e760e8517746f08
tree87e59a0bf94b0268f7663fa4c45d24dca11d070f
parent29bbe7d0086aec1f0fec1ffc03d05aa4610c4a12
threads_win: fix build error with mingw64

This fixes a build error regression on mingw64 introduced by me in
16beec98d26644b96d57bd8da477166d0bc7d05c

In get_hold_current_qp, uint32_t variables were improperly
used to hold the value of reader_idx, which is defined as long int.
So I used CRYPTO_atomic_load_int, where a comment states
On Windows, LONG is always the same size as int

There is a size confusion, because
Win32 VC x86/x64: LONG, long, long int are 32 bit
MingW-W64: LONG, long, long int are 32 bit
cygwin64: LONG is 32 bit, long, long int are 64 bit

Fix:
- define reader_idx as uint32_t
- edit misleading comment, to clarify:
On Windows, LONG (but not long) is always the same size as int.

Fixes the following build error, reported in [1].
crypto/threads_win.c: In function 'get_hold_current_qp':
crypto/threads_win.c:184:32: error: passing argument 1 of 'CRYPTO_atomic_load_int' from incompatible pointer type [-Wincompatible-pointer-types]
  184 |         CRYPTO_atomic_load_int(&lock->reader_idx, (int *)&qp_idx,
      |                                ^~~~~~~~~~~~~~~~~
      |                                |
      |                                volatile long int *

[1] https://github.com/openssl/openssl/pull/24405#issuecomment-2211602282

Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24803)
crypto/threads_win.c