From 4b63cd1614669240fd3ac8aa215ab428d17f9df7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Oct 2015 17:41:16 +0200 Subject: [PATCH 1/2] Libsodium does not compile for Solaris CC compiler #308 --- .../crypto_generichash/blake2/ref/blake2.h | 19 +++++++++++++++++- .../sodium/crypto_generichash_blake2b.h | 20 ++++++++++++++++++- src/libsodium/include/sodium/export.h | 8 ++++++-- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/libsodium/crypto_generichash/blake2/ref/blake2.h b/src/libsodium/crypto_generichash/blake2/ref/blake2.h index e44aac66..be42f335 100644 --- a/src/libsodium/crypto_generichash/blake2/ref/blake2.h +++ b/src/libsodium/crypto_generichash/blake2/ref/blake2.h @@ -57,7 +57,16 @@ extern "C" { BLAKE2B_PERSONALBYTES = 16 }; +#ifndef __sun #pragma pack(push, 1) +#else +# ifndef __GNU_C__ +#pragma pack(1) +# else +#pragma pack(push, 1) +# endif +#endif + typedef struct blake2s_param_ { uint8_t digest_length; // 1 @@ -127,7 +136,16 @@ typedef crypto_generichash_blake2b_state blake2b_state; uint8_t buf[4 * BLAKE2B_BLOCKBYTES]; size_t buflen; } blake2bp_state; + +#ifndef __sun #pragma pack(pop) +#else +# ifndef __GNU_C__ +# pragma pack() +# else +# pragma pack(pop) +# endif +#endif // Streaming API int blake2s_init( blake2s_state *S, const uint8_t outlen ); @@ -174,4 +192,3 @@ typedef crypto_generichash_blake2b_state blake2b_state; #endif #endif - diff --git a/src/libsodium/include/sodium/crypto_generichash_blake2b.h b/src/libsodium/include/sodium/crypto_generichash_blake2b.h index a88a59ec..75c14cb0 100644 --- a/src/libsodium/include/sodium/crypto_generichash_blake2b.h +++ b/src/libsodium/include/sodium/crypto_generichash_blake2b.h @@ -14,7 +14,16 @@ extern "C" { #endif +#ifndef __sun #pragma pack(push, 1) +#else +# ifndef __GNU_C__ +#pragma pack(1) +# else +#pragma pack(push, 1) +# endif +#endif + typedef CRYPTO_ALIGN(64) struct crypto_generichash_blake2b_state { uint64_t h[8]; uint64_t t[2]; @@ -23,7 +32,16 @@ typedef CRYPTO_ALIGN(64) struct crypto_generichash_blake2b_state { size_t buflen; uint8_t last_node; } crypto_generichash_blake2b_state; + +#ifndef __sun #pragma pack(pop) +#else +# ifndef __GNU_C__ +#pragma pack() +# else +#pragma pack(pop) +# endif +#endif #define crypto_generichash_blake2b_BYTES_MIN 16U SODIUM_EXPORT @@ -98,4 +116,4 @@ int crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state, } #endif -#endif +#endif \ No newline at end of file diff --git a/src/libsodium/include/sodium/export.h b/src/libsodium/include/sodium/export.h index 89f10fe9..cfe29590 100644 --- a/src/libsodium/include/sodium/export.h +++ b/src/libsodium/include/sodium/export.h @@ -20,7 +20,11 @@ # endif # else # if defined(__SUNPRO_C) -# define SODIUM_EXPORT __attribute__ __global +# ifndef __GNU_C__ +# define SODIUM_EXPORT __attribute__(visibility(__global)) +# else +# define SODIUM_EXPORT __attribute__ __global +# endif # elif defined(_MSG_VER) # define SODIUM_EXPORT extern __declspec(dllexport) # else @@ -37,4 +41,4 @@ # endif #endif -#endif +#endif \ No newline at end of file From 0814537aea4864e5a1b35d1548d417e266694a5e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Oct 2015 18:13:34 +0200 Subject: [PATCH 2/2] Replace __sun and __GNU_C by __SUNPRO_C to simplify logic regarding @jedisct1 comments --- .../crypto_generichash/blake2/ref/blake2.h | 20 ++++++------------- .../sodium/crypto_generichash_blake2b.h | 20 ++++++------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/libsodium/crypto_generichash/blake2/ref/blake2.h b/src/libsodium/crypto_generichash/blake2/ref/blake2.h index be42f335..d11fa27a 100644 --- a/src/libsodium/crypto_generichash/blake2/ref/blake2.h +++ b/src/libsodium/crypto_generichash/blake2/ref/blake2.h @@ -57,14 +57,10 @@ extern "C" { BLAKE2B_PERSONALBYTES = 16 }; -#ifndef __sun -#pragma pack(push, 1) +#ifdef __SUNPRO_C +# pragma pack(1) #else -# ifndef __GNU_C__ -#pragma pack(1) -# else -#pragma pack(push, 1) -# endif +# pragma pack(push, 1) #endif typedef struct blake2s_param_ @@ -137,14 +133,10 @@ typedef crypto_generichash_blake2b_state blake2b_state; size_t buflen; } blake2bp_state; -#ifndef __sun -#pragma pack(pop) +#ifdef __SUNPRO_C +# pragma pack() #else -# ifndef __GNU_C__ -# pragma pack() -# else -# pragma pack(pop) -# endif +# pragma pack(pop) #endif // Streaming API diff --git a/src/libsodium/include/sodium/crypto_generichash_blake2b.h b/src/libsodium/include/sodium/crypto_generichash_blake2b.h index 75c14cb0..3a6a8efc 100644 --- a/src/libsodium/include/sodium/crypto_generichash_blake2b.h +++ b/src/libsodium/include/sodium/crypto_generichash_blake2b.h @@ -14,14 +14,10 @@ extern "C" { #endif -#ifndef __sun -#pragma pack(push, 1) +#ifdef __SUNPRO_C +# pragma pack(1) #else -# ifndef __GNU_C__ -#pragma pack(1) -# else -#pragma pack(push, 1) -# endif +# pragma pack(push, 1) #endif typedef CRYPTO_ALIGN(64) struct crypto_generichash_blake2b_state { @@ -33,14 +29,10 @@ typedef CRYPTO_ALIGN(64) struct crypto_generichash_blake2b_state { uint8_t last_node; } crypto_generichash_blake2b_state; -#ifndef __sun -#pragma pack(pop) +#ifdef __SUNPRO_C +# pragma pack() #else -# ifndef __GNU_C__ -#pragma pack() -# else -#pragma pack(pop) -# endif +# pragma pack(pop) #endif #define crypto_generichash_blake2b_BYTES_MIN 16U