From f2da43318887ff31031dfa9b2c8f2f0cb1175458 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 30 Apr 2014 22:46:24 +0530 Subject: [PATCH] More portability tweaks. Handle platform specific yasm parameters. Resolve namespace conflict on OSX. Do not build Skein ASM code on OSX. --- Makefile.in | 2 +- config | 22 +++++++++++++++++++--- crypto/sha2/sha512.c | 2 +- crypto/sha2/sha512.h | 2 +- rabin/global/dedupe_config.c | 2 +- utils/sse_level.c | 2 +- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Makefile.in b/Makefile.in index 2deed5f..722492d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -166,7 +166,7 @@ SHA2ASM_SRCS = crypto/sha2/intel/sha512_avx.asm crypto/sha2/intel/sha512_sse4.as SHA2ASM_OBJS = $(SHA2ASM_SRCS:.asm=.o) SHA2_OBJS = $(SHA2_SRCS:.c=.o) -YASM = @YASM@ -f x64 -f elf64 -X gnu -g dwarf2 -D LINUX +YASM = @YASM@ LIBBSCWRAP = libbsc_compress.c LIBBSCWRAPOBJ = libbsc_compress.o LIBBSCDIR = @LIBBSCDIR@ diff --git a/config b/config index acb811c..0ec979c 100755 --- a/config +++ b/config @@ -74,6 +74,8 @@ sha256asmobjs= sha256objs= keylen= yasm=yasm +yasm_params_linux="-f x64 -f elf64 -X gnu -g dwarf2 -D LINUX" +yasm_params_osx="-f macho64 -X gnu -p gas" keccak_srcs= keccak_hdrs= keccak_srcs_asm= @@ -274,7 +276,10 @@ fi echo $plat | egrep 'x86_64|amd64' > /dev/null if [ $? -eq 0 ] then - skeinblock='\$\(SKEIN_BLOCK_ASM\)' + if [ "$OS" != "Darwin" ] + then + skeinblock='\$\(SKEIN_BLOCK_ASM\)' + fi yasm= # @@ -304,6 +309,17 @@ then exit 1 fi + if [ "$OS" = "Linux" ] + then + yasm="${yasm} ${yasm_params_linux}" + elif [ "$OS" = "Darwin" ] + then + yasm="${yasm} ${yasm_params_osx}" + elif [ "$OS" = "SunOS" ] + then + yasm="${yasm} ${yasm_params_linux}" + fi + if [ $debug -eq 1 ] then keccak_srcs='\$\(KECCAK_SRC_OPT64\)' @@ -436,7 +452,7 @@ else echo "Yes." fi -rm -f tst* +rm -rf tst* openssl_libdir="${openssl_libdir},--enable-new-dtags" # Detect other library packages @@ -581,7 +597,7 @@ then echo "Libarchive version 3.0 or newer is required." exit 1 fi -rm -f tst tst.c +rm -rf tst* tst.c echo "Generating Makefile ..." linkvar="LINK" diff --git a/crypto/sha2/sha512.c b/crypto/sha2/sha512.c index c985944..5c2c66c 100644 --- a/crypto/sha2/sha512.c +++ b/crypto/sha2/sha512.c @@ -130,7 +130,7 @@ static const uint64_t iv256[SHA512_HASH_WORDS] = { static update_func_ptr sha512_update_func; int -APS_NAMESPACE(Init_SHA512) (processor_info_t *pc) +APS_NAMESPACE(Init_SHA512) (processor_cap_t *pc) { if (pc->proc_type == PROC_X64_INTEL || pc->proc_type == PROC_X64_AMD) { if (pc->avx_level > 0) { diff --git a/crypto/sha2/sha512.h b/crypto/sha2/sha512.h index 08c24be..b7bbf69 100644 --- a/crypto/sha2/sha512.h +++ b/crypto/sha2/sha512.h @@ -97,7 +97,7 @@ extern "C" { void APS_NAMESPACE(SHA512_Init) (SHA512_Context *sc); void APS_NAMESPACE(SHA512_Update) (SHA512_Context *sc, const void *data, size_t len); void APS_NAMESPACE(SHA512_Final) (SHA512_Context *sc, uint8_t hash[SHA512_HASH_SIZE]); -int APS_NAMESPACE(Init_SHA512) (processor_info_t *pc); +int APS_NAMESPACE(Init_SHA512) (processor_cap_t *pc); /* As are SHA-512/256 and SHA-512/224 */ #define SHA512t256_Context SHA512_Context diff --git a/rabin/global/dedupe_config.c b/rabin/global/dedupe_config.c index 1d93e6a..89b1998 100644 --- a/rabin/global/dedupe_config.c +++ b/rabin/global/dedupe_config.c @@ -247,7 +247,7 @@ read_config(char *configfile, archive_config_t *cfg) } } else if (strncmp(line, "ARCHIVESZ", 9) == 0) { int ovr; - ssize_t arch_sz; + int64_t arch_sz; ovr = parse_numeric(&arch_sz, pos); if (ovr == 1) { log_msg(LOG_ERR, 0, "ARCHIVESZ value too large.\n"); diff --git a/utils/sse_level.c b/utils/sse_level.c index 3ecb9a0..0ddb2e4 100644 --- a/utils/sse_level.c +++ b/utils/sse_level.c @@ -29,7 +29,7 @@ int main(void) { - processor_info_t pc; + processor_cap_t pc; cpuid_basic_identify(&pc); if (pc.sse_level == 3 && pc.sse_sub_level == 1) { printf("ssse%d", pc.sse_level);