Fix SIZEOF_LONG and SIZEOF_LONG_LONG logic#3283
Fix SIZEOF_LONG and SIZEOF_LONG_LONG logic#3283RipleyTom wants to merge 1 commit intowolfSSL:masterfrom
Conversation
|
Can one of the admins verify this patch? |
|
I have some more informations, finally setup VM to actually test myself without relying on our CI and our issue specifically happens because curl/libcurl also defines a SIZEOF_LONG ! |
|
Sorry i was getting confused because somehow libcurl decided to name some of its files the same as some wolfssl files. Not sure if the solution I propose is ok though, maybe naming it something that wouldn't lead to name collisions would be better, esp in a header that gets included in other projects for imports but that'd be quite a big change. |
|
From what I can tell the define comes from here in libcurl: It gets defined before the include of wolfssl headers, reaches types.h header, doesn't define SIZEOF_LONG_LONG because SIZEOF_LONG is already defined and can't find a proper setting and crashes on |
|
Hi @RipleyTom , My understanding is that we only require one or the other. So either It looks like Curl is always using 4 for Your patch is good, but I would still want to decouple the We integrate very nice with Curl and the maintainer @bagder is part of wolfSSL, so I am surprised you are experiencing this. Thanks, |
|
Below is the breakdown of the logic that leads to the error: enum {
// SIZEOF_LONG is defined so it's not hit
#if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
CTC_SETTINGS = 0x0
// SIZEOF_LONG is 4 so it's not hit
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
CTC_SETTINGS = 0x1
// SIZEOF_LONG_LONG is not defined so it's not hit
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
CTC_SETTINGS = 0x2
// SIZEOF_LONG_LONG is not defined so it's not hit
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
CTC_SETTINGS = 0x4
// SIZEOF_LONG is defined so it's not hit
#elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
CTC_SETTINGS = 0x8
// SIZEOF_LONG is 4 so it's not hit
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
CTC_SETTINGS = 0x10
// SIZEOF_LONG_LONG is not defined so it's not hit
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
CTC_SETTINGS = 0x20
// SIZEOF_LONG_LONG is not defined so it's not hit
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
CTC_SETTINGS = 0x40
#else
// Error here
#error "bad math long / long long settings"
#endif
};Curl has some special code in the configure part of it that undef both before including WolfSSL: But that code is not part of the vcxproj we use to build curl on windows. As for my patches it defines them only if there are undefined before the inclusion of the header, which wouldn't happen if user declared them already. edit: |
|
@RipleyTom , I like this change. In order to accept a PR we need a signed contributors agreement. Would you mind emailing support@wolfssl.com to request this? Thanks, David Garske |
|
@RipleyTom , checking in to see about the contributor agreement status? Would you mind emailing support@wolfssl.com to request this? Thanks, David Garske |
Hi, @dgarske @RipleyTom @wolfSSL-Bot @bagder |
Somehow we're hitting a case where one is defined but not the other, improved logic so that both are guaranteed to be defined.
To be specific we're hitting an #error below in the same file:
#error "bad math long / long long settings"because SIZEOF_LONG is defined as 4 and SIZEOF_LONG_LONG is undefined so it's hitting none of the cases listed(and on msvc it should hit the SIZEOF_LONG_LONG==8 cases).