mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-15 00:01:37 -04:00
refactored if defined WINDOWS to if defined _WIN32
This commit is contained in:
parent
c2e7d637ef
commit
ab5185239e
@ -4,12 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
void OQS_MEM_cleanse(void *ptr, size_t len) {
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
SecureZeroMemory(ptr, len);
|
||||
#elif defined(HAVE_MEMSET_S)
|
||||
if (0U < len && memset_s(ptr, (rsize_t) len, 0, (rsize_t) len) != 0) {
|
||||
|
@ -24,7 +24,7 @@ void OQS_MEM_secure_free(void *ptr, size_t len);
|
||||
#define eprintf(...) fprintf(stderr, __VA_ARGS__);
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define UNUSED
|
||||
// __attribute__ not supported in VS
|
||||
#else
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <oqs/sha3.h>
|
||||
#include <oqs/sig.h>
|
||||
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <oqs/config.h>
|
||||
#endif
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <Wincrypt.h>
|
||||
#else
|
||||
@ -50,7 +50,7 @@ void OQS_RAND_free(OQS_RAND *r) {
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
/* For some reason specifying inline results in a build error */
|
||||
inline
|
||||
#endif
|
||||
@ -147,7 +147,7 @@ void OQS_RAND_report_statistics(const unsigned long occurrences[256], const char
|
||||
OQS_STATUS OQS_RAND_get_system_entropy(uint8_t *buf, size_t n) {
|
||||
OQS_STATUS result = OQS_ERROR;
|
||||
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
int fd = 0;
|
||||
#endif
|
||||
|
||||
@ -155,7 +155,7 @@ OQS_STATUS OQS_RAND_get_system_entropy(uint8_t *buf, size_t n) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
HCRYPTPROV hCryptProv;
|
||||
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) ||
|
||||
!CryptGenRandom(hCryptProv, (DWORD) n, buf)) {
|
||||
@ -174,7 +174,7 @@ OQS_STATUS OQS_RAND_get_system_entropy(uint8_t *buf, size_t n) {
|
||||
result = OQS_SUCCESS;
|
||||
|
||||
err:
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
if (fd > 0) {
|
||||
close(fd);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <sys/types.h>
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <Wincrypt.h>
|
||||
#else
|
||||
@ -18,7 +18,7 @@
|
||||
#include <oqs/rand.h>
|
||||
#include <oqs/rand_urandom_aesctr.h>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#pragma warning(disable : 4267)
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <Wincrypt.h>
|
||||
#else
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include "external/chacha20.c"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* from https://twitter.com/tweetfips202
|
||||
* by Gilles Van Assche, Daniel J. Bernstein, and Peter Schwabe */
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
|
@ -86,13 +86,13 @@ PRINT_TIMER_FOOTER
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
|
||||
int gettimeofday(struct timeval *tp, struct timezone *tzp) {
|
||||
@ -114,7 +114,7 @@ int gettimeofday(struct timeval *tp, struct timezone *tzp) {
|
||||
#endif
|
||||
|
||||
static uint64_t rdtsc(void) {
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
return __rdtsc();
|
||||
#elif defined(__aarch64__)
|
||||
uint64_t x;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <oqs/common.h>
|
||||
#include <oqs/rand.h>
|
||||
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <oqs/config.h>
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#pragma warning(disable : 4244 4293)
|
||||
#endif
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -14,7 +14,7 @@
|
||||
#include "kex_code_mcbits.h"
|
||||
#include "mcbits.h"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#define RECOMMENDED_N_ARRAY_SIZE (752 * 8)
|
||||
#define RECOMMENDED_CDF_TABLE_LEN 6
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
// VS complains about arrays initialized with const param. On Windows,
|
||||
// we use directly the recommended value passed down from calling functions.
|
||||
// Currently there is only one set of params, so that works. Need to fix this
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef DISABLE_NTRU_ON_WINDOWS_BY_DEFAULT
|
||||
|
||||
#include <fcntl.h>
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <Wincrypt.h>
|
||||
#else
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include <ntru_crypto.h>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
#include "rlwe_a.h"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* See LICENSE for complete information.
|
||||
*/
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#pragma warning(disable : 4146 4244 4267)
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -13,7 +13,7 @@
|
||||
#include "LatticeCrypto_priv.h"
|
||||
#include "kex_rlwe_msrln16.h"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -13,7 +13,7 @@
|
||||
#include "newhope.c"
|
||||
#include "params.h"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -21,7 +21,7 @@ extern uint16_t omegas_inv_montgomery[];
|
||||
extern uint16_t psis_inv_montgomery[];
|
||||
extern uint16_t psis_bitrev_montgomery[];
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
typedef unsigned __int16 uint16_t;
|
||||
#endif
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
typedef struct {
|
||||
uint16_t coeffs[PARAM_N];
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
} poly;
|
||||
#else
|
||||
} poly __attribute__((aligned(32)));
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <oqs/rand.h>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include "../windows_undef.h"
|
||||
#endif
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <oqs/rand.h>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#include "../windows_undef.h"
|
||||
#endif
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define OS_WIN 1
|
||||
#define OS_LINUX 2
|
||||
/*
|
||||
#if defined(__WINDOWS__) // Microsoft Windows OS
|
||||
#if defined(_WIN32) // Microsoft Windows OS
|
||||
#define OS_TARGET OS_WIN
|
||||
#elif defined(__LINUX__) // Linux OS
|
||||
#define OS_TARGET OS_LINUX
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#pragma warning(disable : 4047 4090)
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define UNUSED
|
||||
#else
|
||||
#define UNUSED __attribute__((unused))
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(WINDOWS)
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -22,7 +22,7 @@
|
||||
#include "P751/P751_api.h"
|
||||
#include "kex_sidh_msr.h"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#define strdup _strdup // for strdup deprecation warning
|
||||
#endif
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* to avoid Visual Studio errors
|
||||
*/
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#undef OQS_SIDH_MSR_CRYPTO_SECRETKEYBYTES
|
||||
#undef OQS_SIDH_MSR_CRYPTO_PUBLICKEYBYTES
|
||||
#undef OQS_SIDH_MSR_CRYPTO_BYTES
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if defined(WINDOWS)
|
||||
#if defined(_WIN32)
|
||||
#pragma warning(disable : 4244 4293)
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user