Skip to content

Commit

Permalink
Fix for Watcom C compiler "long long" -> "__int64". Fix cast warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Oct 23, 2024
1 parent b5cc863 commit 194e26b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -5926,8 +5926,8 @@ static int X509PrintDirType(char * dst, int max_len, const DNS_entry * entry)
/* Copy it in, decrement available space. */
XSTRNCPY(dst, pfx, bytes_left);
dst += XSTRLEN(pfx);
total_len += XSTRLEN(pfx);
bytes_left -= XSTRLEN(pfx);
total_len += (int)XSTRLEN(pfx);
bytes_left -= (int)XSTRLEN(pfx);

if (fld_len > bytes_left) {
/* Not enough space left. */
Expand Down
15 changes: 11 additions & 4 deletions wolfssl/wolfcrypt/sp_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,17 @@ extern "C" {
#error "Size of unsigned long long not detected"
#endif
#elif (SP_ULONG_BITS == 32) && !defined(NO_64BIT)
/* Speculatively use long long as the 64-bit type as we don't have one
* otherwise. */
typedef unsigned long long sp_uint64;
typedef long long sp_int64;
#define SP_ULLONG_BITS 64
#if defined(__WATCOMC__) && defined(__WATCOM_INT64__)
/* for watcomc compiler long long is not available, use __int64 */
typedef unsigned __int64 sp_uint64;
typedef __int64 sp_int64;
#else
/* Speculatively use long long as the 64-bit type as we don't have one
* otherwise. */
typedef unsigned long long sp_uint64;
typedef long long sp_int64;
#endif
#else
#define SP_ULLONG_BITS 0
#endif
Expand Down
20 changes: 14 additions & 6 deletions wolfssl/wolfcrypt/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,27 @@ decouple library dependencies with standard string, memory and so on.
#endif
#endif

#if (defined(_MSC_VER) && !defined(WOLFSSL_NOT_WINDOWS_API)) || \
defined(__BCPLUSPLUS__)
#if defined(__WATCOMC__) && defined(__WATCOM_INT64__)
/* for watcomc compiler long long is not available, use __int64 */
#define WORD64_AVAILABLE
#define W64LIT(x) x##UL
#define SW64LIT(x) x##L
typedef __int64 sword64;
typedef unsigned __int64 word64;
#elif (defined(_MSC_VER) && !defined(WOLFSSL_NOT_WINDOWS_API)) || \
defined(__BCPLUSPLUS__)
/* windows types */
#define WORD64_AVAILABLE
#define W64LIT(x) x##ui64
#define SW64LIT(x) x##i64
typedef __int64 sword64;
typedef unsigned __int64 word64;
typedef unsigned __int64 word64;
#elif defined(__EMSCRIPTEN__)
#define WORD64_AVAILABLE
#define W64LIT(x) x##ull
#define SW64LIT(x) x##ll
typedef long long sword64;
typedef unsigned long long word64;
typedef unsigned long long word64;
#elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
#define WORD64_AVAILABLE
#ifdef WOLF_C89
Expand All @@ -216,7 +224,7 @@ decouple library dependencies with standard string, memory and so on.
#define SW64LIT(x) x##LL
#endif
typedef long long sword64;
typedef unsigned long long word64;
typedef unsigned long long word64;
#elif defined(__SIZEOF_LONG_LONG__) && __SIZEOF_LONG_LONG__ == 8
#define WORD64_AVAILABLE
#ifdef WOLF_C89
Expand All @@ -227,7 +235,7 @@ decouple library dependencies with standard string, memory and so on.
#define SW64LIT(x) x##LL
#endif
typedef long long sword64;
typedef unsigned long long word64;
typedef unsigned long long word64;
#endif

#if defined(WORD64_AVAILABLE) && !defined(WC_16BIT_CPU)
Expand Down

0 comments on commit 194e26b

Please sign in to comment.