Create a prototype for OPENSSL_rdtsc
authorKurt Roeckx <kurt@roeckx.be>
Sun, 19 Nov 2017 16:40:56 +0000 (17:40 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Sat, 25 Nov 2017 13:30:11 +0000 (14:30 +0100)
Switch to make it return an uint32_t instead of the various different
types it returns now.

Fixes: #3125
Reviewed-by: Andy Polyakov <appro@openssl.org>
GH: #4757

crypto/armcap.c
crypto/sparcv9cap.c
include/internal/cryptlib.h
test/modes_internal_test.c
test/poly1305_internal_test.c
test/siphash_internal_test.c

index b55a71ee78d45905a8c4895f5d78413c6245914d..a1f77fa2fcf3a28d2b3a2c54f935f0711531e013 100644 (file)
@@ -13,6 +13,7 @@
 #include <setjmp.h>
 #include <signal.h>
 #include <openssl/crypto.h>
 #include <setjmp.h>
 #include <signal.h>
 #include <openssl/crypto.h>
+#include "internal/cryptlib.h"
 
 #include "arm_arch.h"
 
 
 #include "arm_arch.h"
 
@@ -23,7 +24,7 @@ void OPENSSL_cpuid_setup(void)
 {
 }
 
 {
 }
 
-unsigned long OPENSSL_rdtsc(void)
+uint32_t OPENSSL_rdtsc(void)
 {
     return 0;
 }
 {
     return 0;
 }
@@ -45,9 +46,9 @@ void _armv8_aes_probe(void);
 void _armv8_sha1_probe(void);
 void _armv8_sha256_probe(void);
 void _armv8_pmull_probe(void);
 void _armv8_sha1_probe(void);
 void _armv8_sha256_probe(void);
 void _armv8_pmull_probe(void);
-unsigned long _armv7_tick(void);
+uint32_t _armv7_tick(void);
 
 
-unsigned long OPENSSL_rdtsc(void)
+uint32_t OPENSSL_rdtsc(void)
 {
     if (OPENSSL_armcap_P & ARMV7_TICK)
         return _armv7_tick();
 {
     if (OPENSSL_armcap_P & ARMV7_TICK)
         return _armv7_tick();
index 61d0334ee4213dcacaf230436e702632df7c570f..c8c567536b33d78cedf4c650cebc64b84ee62b05 100644 (file)
@@ -15,6 +15,7 @@
 #include <sys/time.h>
 #include <unistd.h>
 #include <openssl/bn.h>
 #include <sys/time.h>
 #include <unistd.h>
 #include <openssl/bn.h>
+#include "internal/cryptlib.h"
 
 #include "sparc_arch.h"
 
 
 #include "sparc_arch.h"
 
@@ -98,7 +99,7 @@ unsigned long _sparcv9_random(void);
 size_t _sparcv9_vis1_instrument_bus(unsigned int *, size_t);
 size_t _sparcv9_vis1_instrument_bus2(unsigned int *, size_t, size_t);
 
 size_t _sparcv9_vis1_instrument_bus(unsigned int *, size_t);
 size_t _sparcv9_vis1_instrument_bus2(unsigned int *, size_t, size_t);
 
-unsigned long OPENSSL_rdtsc(void)
+uint32_t OPENSSL_rdtsc(void)
 {
     if (OPENSSL_sparcv9cap_P[0] & SPARCV9_TICK_PRIVILEGED)
 #if defined(__sun) && defined(__SVR4)
 {
     if (OPENSSL_sparcv9cap_P[0] & SPARCV9_TICK_PRIVILEGED)
 #if defined(__sun) && defined(__SVR4)
index 4280185ab464482424683ab8965516f0cc44da9e..25ccdb1001a835b0de6a5025d0ac045f3908aae4 100644 (file)
@@ -94,6 +94,10 @@ FILE *openssl_fopen(const char *filename, const char *mode);
 void *openssl_fopen(const char *filename, const char *mode);
 # endif
 
 void *openssl_fopen(const char *filename, const char *mode);
 # endif
 
+#ifdef OPENSSL_CPUID_OBJ
+uint32_t OPENSSL_rdtsc();
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
 #ifdef  __cplusplus
 }
 #endif
index f3e46fed80a1d98dded4f7a1386395bd9d1bf9e7..6b02fd014861ab8d79305215d01134b376b7bfd6 100644 (file)
@@ -17,6 +17,7 @@
 #include "../crypto/modes/modes_lcl.h"
 #include "testutil.h"
 #include "internal/nelem.h"
 #include "../crypto/modes/modes_lcl.h"
 #include "testutil.h"
 #include "internal/nelem.h"
+#include "internal/cryptlib.h"
 
 typedef struct {
     size_t size;
 
 typedef struct {
     size_t size;
@@ -889,7 +890,7 @@ static void benchmark_gcm128(const unsigned char *K, size_t Klen,
 #ifdef OPENSSL_CPUID_OBJ
     GCM128_CONTEXT ctx;
     AES_KEY key;
 #ifdef OPENSSL_CPUID_OBJ
     GCM128_CONTEXT ctx;
     AES_KEY key;
-    size_t start, gcm_t, ctr_t, OPENSSL_rdtsc();
+    uint32_t start, gcm_t, ctr_t;
     union {
         u64 u;
         u8 c[1024];
     union {
         u64 u;
         u8 c[1024];
index d1d71c92ee75f1b1a8d88117cd9fe1efdf8ca7d4..3631f3488a0c872a5f8e90f5ef25256aa6d29088 100644 (file)
@@ -16,6 +16,7 @@
 #include "internal/poly1305.h"
 #include "../crypto/poly1305/poly1305_local.h"
 #include "internal/nelem.h"
 #include "internal/poly1305.h"
 #include "../crypto/poly1305/poly1305_local.h"
 #include "internal/nelem.h"
+#include "internal/cryptlib.h"
 
 typedef struct {
     size_t size;
 
 typedef struct {
     size_t size;
@@ -40,8 +41,7 @@ static void benchmark_poly1305()
     POLY1305 poly1305;
     unsigned char key[32];
     unsigned char buf[8192];
     POLY1305 poly1305;
     unsigned char key[32];
     unsigned char buf[8192];
-    unsigned long long stopwatch;
-    unsigned long long OPENSSL_rdtsc();
+    uint32_t stopwatch;
     unsigned int i;
 
     memset (buf,0x55,sizeof(buf));
     unsigned int i;
 
     memset (buf,0x55,sizeof(buf));
index d832aab6607aa325be016d0189233c20e1d51bf4..fe207620c700d32173f42c1f9ab7c7b114a812b1 100644 (file)
@@ -17,6 +17,7 @@
 #include "internal/siphash.h"
 #include "../crypto/siphash/siphash_local.h"
 #include "internal/nelem.h"
 #include "internal/siphash.h"
 #include "../crypto/siphash/siphash_local.h"
 #include "internal/nelem.h"
+#include "internal/cryptlib.h"
 
 static BIO* b_stderr = NULL;
 static BIO* b_stdout = NULL;
 
 static BIO* b_stderr = NULL;
 static BIO* b_stdout = NULL;
@@ -43,8 +44,7 @@ static int benchmark_siphash(void)
     SIPHASH siphash;
     unsigned char key[SIPHASH_KEY_SIZE];
     unsigned char buf[8192];
     SIPHASH siphash;
     unsigned char key[SIPHASH_KEY_SIZE];
     unsigned char buf[8192];
-    unsigned long long stopwatch;
-    unsigned long long OPENSSL_rdtsc();
+    uint32_t stopwatch;
     unsigned int i;
 
     memset (buf,0x55,sizeof(buf));
     unsigned int i;
 
     memset (buf,0x55,sizeof(buf));