Skip to content

Commit 294362a

Browse files
committed
Fixes for building x86 in Visual Studio for non-windows OS.
1 parent 1190d1b commit 294362a

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

wolfcrypt/src/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4055,7 +4055,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
40554055
{
40564056
word32 i;
40574057
for (i = 0; i < sz; i++ )
4058-
output[i] = i;
4058+
output[i] = (byte)i;
40594059

40604060
(void)os;
40614061

wolfssl/wolfcrypt/types.h

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,13 @@ typedef struct w64wrapper {
420420
#define FALL_THROUGH
421421
#endif
422422

423-
/* Micrium will use Visual Studio for compilation but not the Win32 API */
423+
/* For platforms where the target OS is not Windows, but compilation is
424+
* done on Windows/Visual Studio, enable a way to disable USE_WINDOWS_API.
425+
* Examples: Micrium, TenAsus INtime, uTasker, FreeRTOS simulator */
424426
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
425427
!defined(FREERTOS_TCP) && !defined(EBSNET) && \
426-
!defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
428+
!defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS) && \
429+
!defined(WOLFSSL_NOT_WINDOWS_API)
427430
#define USE_WINDOWS_API
428431
#endif
429432

@@ -717,10 +720,10 @@ typedef struct w64wrapper {
717720
#include <string.h>
718721
#endif
719722

720-
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
721-
#define XMEMSET(b,c,l) memset((b),(c),(l))
722-
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
723-
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
723+
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
724+
#define XMEMSET(b,c,l) memset((b),(c),(l))
725+
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
726+
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
724727

725728
#define XSTRLEN(s1) strlen((s1))
726729
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
@@ -746,7 +749,6 @@ typedef struct w64wrapper {
746749
defined(WOLFSSL_ZEPHYR) || defined(MICROCHIP_PIC24)
747750
/* XC32 version < 1.0 does not support strcasecmp. */
748751
#define USE_WOLF_STRCASECMP
749-
#define XSTRCASECMP(s1,s2) wc_strcasecmp(s1,s2)
750752
#elif defined(USE_WINDOWS_API) || defined(FREERTOS_TCP_WINSIM)
751753
#define XSTRCASECMP(s1,s2) _stricmp((s1),(s2))
752754
#else
@@ -759,13 +761,16 @@ typedef struct w64wrapper {
759761
#elif defined(WOLFSSL_CMSIS_RTOSv2) || defined(WOLFSSL_AZSPHERE) \
760762
|| defined(WOLF_C89)
761763
#define USE_WOLF_STRCASECMP
762-
#define XSTRCASECMP(s1,s2) wc_strcasecmp(s1, s2)
763764
#elif defined(WOLF_C89)
764765
#define XSTRCASECMP(s1,s2) strcmp((s1),(s2))
765766
#else
766767
#define XSTRCASECMP(s1,s2) strcasecmp((s1),(s2))
767768
#endif
768769
#endif
770+
#ifdef USE_WOLF_STRCASECMP
771+
#undef XSTRCASECMP
772+
#define XSTRCASECMP(s1,s2) wc_strcasecmp((s1), (s2))
773+
#endif
769774
#endif /* !XSTRCASECMP */
770775

771776
#ifndef XSTRNCASECMP
@@ -776,7 +781,6 @@ typedef struct w64wrapper {
776781
defined(WOLFSSL_ZEPHYR) || defined(MICROCHIP_PIC24)
777782
/* XC32 version < 1.0 does not support strncasecmp. */
778783
#define USE_WOLF_STRNCASECMP
779-
#define XSTRNCASECMP(s1,s2,n) wc_strncasecmp((s1),(s2),(n))
780784
#elif defined(USE_WINDOWS_API) || defined(FREERTOS_TCP_WINSIM)
781785
#define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
782786
#else
@@ -789,13 +793,16 @@ typedef struct w64wrapper {
789793
#elif defined(WOLFSSL_CMSIS_RTOSv2) || defined(WOLFSSL_AZSPHERE) \
790794
|| defined(WOLF_C89)
791795
#define USE_WOLF_STRNCASECMP
792-
#define XSTRNCASECMP(s1,s2,n) wc_strncasecmp(s1, s2 ,n)
793796
#elif defined(WOLF_C89)
794797
#define XSTRNCASECMP(s1,s2,n) strncmp((s1),(s2),(n))
795798
#else
796799
#define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
797800
#endif
798801
#endif
802+
#ifdef USE_WOLF_STRNCASECMP
803+
#undef XSTRNCASECMP
804+
#define XSTRNCASECMP(s1,s2,n) wc_strncasecmp((s1),(s2),(n))
805+
#endif
799806
#endif /* !XSTRNCASECMP */
800807

801808
/* snprintf is used in asn.c for GetTimeString, PKCS7 test, and when

0 commit comments

Comments
 (0)