Skip to content

Commit

Permalink
Further fixes for Watcom C compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Oct 28, 2024
1 parent 08502ce commit 7f0d820
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
34 changes: 20 additions & 14 deletions wolfssl/wolfcrypt/sp_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ This library provides single precision (SP) integer math functions.
#ifndef WOLFSSL_LINUXKM
#include <limits.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/hash.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/hash.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -100,6 +101,15 @@ extern "C" {
#error "Size of unsigned int not detected"
#endif

#if defined(__WATCOMC__) && defined(__WATCOM_INT64__)
/* For older Watcom C compiler force types */
#define SP_ULLONG_BITS 64
typedef unsigned __int64 sp_uint64;
typedef __int64 sp_int64;

#else

/* 32-bit type */
#if defined(WOLF_C89) && !defined(NO_64BIT) && \
ULONG_MAX == 18446744073709551615UL
#define SP_ULONG_BITS 64
Expand All @@ -108,8 +118,8 @@ extern "C" {
typedef long sp_int64;
#elif !defined(WOLF_C89) && !defined(NO_64BIT) && \
ULONG_MAX == 18446744073709551615ULL && \
4294967295UL != 18446744073709551615ULL /* verify pre-processor supports
* 64-bit ULL types */
/* sanity check pre-processor supports 64-bit ULL types */ \
4294967295UL != 18446744073709551615ULL
#define SP_ULONG_BITS 64

typedef unsigned long sp_uint64;
Expand All @@ -132,6 +142,7 @@ extern "C" {
#error "Size of unsigned long not detected"
#endif

/* 64-bit type */
#ifdef ULLONG_MAX
#if defined(WOLF_C89) && ULLONG_MAX == 18446744073709551615UL
#define SP_ULLONG_BITS 64
Expand Down Expand Up @@ -166,20 +177,15 @@ extern "C" {
#endif
#elif (SP_ULONG_BITS == 32) && !defined(NO_64BIT)
#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
/* 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;
#else
#define SP_ULLONG_BITS 0
#endif

#endif /* __WATCOMC__ */

#ifdef WOLFSSL_SP_DIV_32
#define WOLFSSL_SP_DIV_WORD_HALF
Expand Down
16 changes: 7 additions & 9 deletions wolfssl/wolfcrypt/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,9 @@ decouple library dependencies with standard string, memory and so on.
#endif
#endif

#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__)
#if (defined(_MSC_VER) && !defined(WOLFSSL_NOT_WINDOWS_API)) || \
defined(__BCPLUSPLUS__) || \
(defined(__WATCOMC__) && defined(__WATCOM_INT64__))
/* windows types */
#define WORD64_AVAILABLE
#define W64LIT(x) x##ui64
Expand Down Expand Up @@ -1756,7 +1750,11 @@ typedef struct w64wrapper {
#endif

#ifndef SAVE_VECTOR_REGISTERS
#ifdef __WATCOMC__
#define SAVE_VECTOR_REGISTERS() WC_DO_NOTHING
#else
#define SAVE_VECTOR_REGISTERS(...) WC_DO_NOTHING
#endif
#endif
#ifndef SAVE_VECTOR_REGISTERS2
#define SAVE_VECTOR_REGISTERS2() 0
Expand Down

0 comments on commit 7f0d820

Please sign in to comment.