Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes for building x86 in Visual Studio for non-windows OS #8098

Merged
merged 4 commits into from
Nov 5, 2024

Conversation

dgarske
Copy link
Contributor

@dgarske dgarske commented Oct 22, 2024

Description

More fixes for building x86 in Visual Studio for non-windows OS (Watcom C compiler). Followup to PR #7884. Fixes ZD 18465

  • Consolidate the USE_WINDOWS_API to a single place.
  • Expand the WOLFSSL_NOT_WINDOWS_API improvement for intrinsics and word sizes.
  • Fix for macro variadic ... when no variables are used (some compilers like Watcom C have issue with this).
  • Fix for Watcom C compiler "long long" -> "__int64".
  • Fix a couple of minor cast warnings reported from VS.
  • Fixes for consistency in SAVE_VECTOR_REGISTERS , ASSERT_SAVED_VECTOR_REGISTERS and RESTORE_VECTOR_REGISTERS.

Testing

Worked with customer

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@dgarske dgarske self-assigned this Oct 22, 2024
@dgarske dgarske changed the title More fixes for building x86 in Visual Studio for non-windows OS. Foll… More fixes for building x86 in Visual Studio for non-windows OS Oct 22, 2024
@dgarske
Copy link
Contributor Author

dgarske commented Oct 23, 2024

Stage 'PRB-medium-runtime.txt_4'
--enable-all --enable-asn=template --enable-dtls-mtu 
FAIL: scripts/openssl.test

@dgarske
Copy link
Contributor Author

dgarske commented Oct 23, 2024

socat Tests:

FAILED: 146 216 309 310 326 386 399 402 459 460 467 468 478 492 528 530
FAILED unexpected: 326

…om C compiler). Followup to PR wolfSSL#7884. Fixes ZD 18465

* Consolidate the USE_WINDOWS_API to a single place.
* Expand the `WOLFSSL_NOT_WINDOWS_API` improvement for intrinsics and word sizes.
* Fix for macro variadic `...` when no variables are used (some compilers like Watcom C have issue with this).
* Fix for Watcom C compiler "long long" -> "__int64".
* Fix a couple of minor cast warnings reported from VS.
Comment on lines 1753 to 1754
#ifdef __WATCOMC__
#define SAVE_VECTOR_REGISTERS() WC_DO_NOTHING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out there's a fallthrough definition that works for both:

@@ -1758,7 +1758,7 @@ typedef struct w64wrapper {
     #endif
 
     #ifndef SAVE_VECTOR_REGISTERS
-        #define SAVE_VECTOR_REGISTERS(...) WC_DO_NOTHING
+        #define SAVE_VECTOR_REGISTERS(fail_clause) WC_DO_NOTHING
     #endif
     #ifndef SAVE_VECTOR_REGISTERS2
         #define SAVE_VECTOR_REGISTERS2() 0
@@ -1772,10 +1772,10 @@ typedef struct w64wrapper {
         #define WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(x) WC_DO_NOTHING
     #endif
     #ifndef ASSERT_SAVED_VECTOR_REGISTERS
-        #define ASSERT_SAVED_VECTOR_REGISTERS(...) WC_DO_NOTHING
+        #define ASSERT_SAVED_VECTOR_REGISTERS(fail_clause) WC_DO_NOTHING
     #endif
     #ifndef ASSERT_RESTORED_VECTOR_REGISTERS
-        #define ASSERT_RESTORED_VECTOR_REGISTERS(...) WC_DO_NOTHING
+        #define ASSERT_RESTORED_VECTOR_REGISTERS(fail_clause) WC_DO_NOTHING
     #endif
     #ifndef RESTORE_VECTOR_REGISTERS
         #define RESTORE_VECTOR_REGISTERS() WC_DO_NOTHING

on the other hand, defining it to take no args doesn't work on C99, for example:

wolfcrypt/src/sp_int.c:19625:5: error: 'SAVE_VECTOR_REGISTERS' undeclared (first use in this function)
19625 |     SAVE_VECTOR_REGISTERS(err = _svr_ret;);
      |     ^~~~~~~~~~~~~~~~~~~~~
wolfcrypt/src/rsa.c:4754:46: error: macro "SAVE_VECTOR_REGISTERS" passed 1 arguments, but takes just 0
 4754 |         SAVE_VECTOR_REGISTERS(ret = _svr_ret;);
      |                                              ^

The reason the always-expect-one-arg works even when some invocations pass no args is that (I've just learned from research) invoking a cpp macro with () for args actually passes a single no-tokens arg implicitly. wild stuff.

src/tls.c Outdated
Comment on lines 7177 to 7179
#define CAN_GET_SIZE() 0
#define CAN_WRITE() 0
#define CAN_PARSE() 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be defined to take one dummy arg, as explained in my comment below.

@dgarske dgarske requested a review from douzzer November 1, 2024 21:02
@douzzer
Copy link
Contributor

douzzer commented Nov 1, 2024

retest this please ("FAIL: scripts/external.test")

src/ocsp.c Outdated
@@ -1634,7 +1634,8 @@ int wolfSSL_OCSP_REQ_CTX_nbio(WOLFSSL_OCSP_REQ_CTX *ctx)
case ORIOS_WRITE:
{
const unsigned char *req;
int reqLen = wolfSSL_BIO_get_mem_data(ctx->reqResp, &req);
int reqLen = wolfSSL_BIO_get_mem_data(ctx->reqResp,
(unsigned char*)&req);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

req should be cast to (void *) here.

src/ocsp.c Outdated
@@ -1710,7 +1711,8 @@ int wolfSSL_OCSP_sendreq_nbio(OcspResponse **presp, WOLFSSL_OCSP_REQ_CTX *ctx)
if (ret != WOLFSSL_SUCCESS)
return ret;

len = wolfSSL_BIO_get_mem_data(ctx->reqResp, &resp);
len = wolfSSL_BIO_get_mem_data(ctx->reqResp,
(unsigned char*)&resp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for resp here.

src/tls.c Outdated
@@ -14764,7 +14764,7 @@ static word16 TLSX_GetMinSize_Client(word16* type)
}
#define TLSX_GET_MIN_SIZE_CLIENT TLSX_GetMinSize_Client
#else
#define TLSX_GET_MIN_SIZE_CLIENT(...) 0
#define TLSX_GET_MIN_SIZE_CLIENT() 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also take one dummy arg.

src/tls.c Outdated
@@ -14833,7 +14833,7 @@ static word16 TLSX_GetMinSize_Server(const word16 *type)
}
#define TLSX_GET_MIN_SIZE_SERVER TLSX_GetMinSize_Server
#else
#define TLSX_GET_MIN_SIZE_SERVER(...) 0
#define TLSX_GET_MIN_SIZE_SERVER() 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this.

@@ -178,7 +178,7 @@ WOLFSSL_API void wolfSSL_SetLoggingPrefix(const char* prefix);
WOLFSSL_API void WOLFSSL_MSG_EX(const char* fmt, ...);
#define HAVE_WOLFSSL_MSG_EX
#else
#define WOLFSSL_MSG_EX(...) WC_DO_NOTHING
#define WOLFSSL_MSG_EX() WC_DO_NOTHING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is going to cause problems, given that WOLFSSL_MSG_EX() always has at least 1 arg, and sometimes has more than 1.

can we gate the WOLFSSL_MSG_EX() definition in some way, so that WOLFSSL_MSG_EX(...) is kept on targets that support variadic macros?

@dgarske dgarske requested a review from douzzer November 4, 2024 19:15
@dgarske dgarske removed their assignment Nov 4, 2024
@douzzer douzzer merged commit 8ecf064 into wolfSSL:master Nov 5, 2024
143 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants