diff --git a/.gitignore b/.gitignore index 4e0b267df..102c414e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.swp *.lo *.la *.o diff --git a/commit-tests.sh b/commit-tests.sh index c9aff4d51..469eacd1f 100755 --- a/commit-tests.sh +++ b/commit-tests.sh @@ -5,7 +5,7 @@ # make sure current config is ok echo -e "\n\nTesting current config...\n\n" -make -j 8 test; +make clean; make -j 8 test; RESULT=$? [ $RESULT -ne 0 ] && echo -e "\n\nCurrent config make test failed" && exit 1 diff --git a/configure.ac b/configure.ac index 87da15f0a..9c3a56097 100644 --- a/configure.ac +++ b/configure.ac @@ -49,6 +49,8 @@ gl_VISIBILITY m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) +AX_CXX_COMPILER_VERSION + AC_CHECK_FUNCS([gethostbyname]) AC_CHECK_FUNCS([gettimeofday]) AC_CHECK_FUNCS([inet_ntoa]) @@ -698,12 +700,6 @@ GCCWARNINGS="$GCCWARNINGS -Warray-bounds" ;; esac -AC_ARG_ENABLE(gcc-lots-o-warnings, -AS_HELP_STRING(--enable-gcc-lots-o-warnings, Enable lots of gcc warnings (default: disabled)), -[if test x$enableval = xyes; then - AM_CFLAGS="$AM_CFLAGS $GCCWARNINGS" -fi]) - AC_ARG_ENABLE(gcc-hardening, AS_HELP_STRING(--enable-gcc-hardening, Enable compiler security checks (default: disabled)), [if test x$enableval = xyes; then @@ -713,13 +709,7 @@ AS_HELP_STRING(--enable-gcc-hardening, Enable compiler security checks (default: LDFLAGS="$LDFLAGS -pie" fi]) -dnl Linker hardening options -dnl Currently these options are ELF specific - you can't use this with MacOSX -AC_ARG_ENABLE(linker-hardening, -AS_HELP_STRING(--enable-linker-hardening, Enable linker security fixups (default: disabled)), -[if test x$enableval = xyes; then - LDFLAGS="$LDFLAGS -z relro -z now" -fi]) +AX_HARDEN_CC_COMPILER_FLAGS CREATE_HEX_VERSION AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY" @@ -734,3 +724,20 @@ AC_CONFIG_FILES([support/libcyassl.pc]) AC_OUTPUT +echo "---" +echo "Configuration summary for $PACKAGE_NAME version $VERSION" +echo "" +echo " * Installation prefix: $prefix" +echo " * System type: $host_vendor-$host_os" +echo " * Host CPU: $host_cpu" +echo " * C Compiler: $CC_VERSION" +echo " * C Flags: $CFLAGS" +echo " * C++ Compiler: $CXX_VERSION" +echo " * C++ Flags: $CXXFLAGS" +echo " * CPP Flags: $CPPFLAGS" +echo " * Assertions enabled: $ac_cv_assert" +echo " * Debug enabled: $with_debug" +echo " * Warnings as failure: $ac_cv_warnings_as_errors" +echo " * SASL support: $ac_enable_sasl" +echo "" +echo "---" diff --git a/ctaocrypt/benchmark/benchmark.c b/ctaocrypt/benchmark/benchmark.c index b1e662034..c344868b3 100644 --- a/ctaocrypt/benchmark/benchmark.c +++ b/ctaocrypt/benchmark/benchmark.c @@ -49,33 +49,35 @@ #pragma warning(disable: 4996) #endif -void bench_des(); -void bench_arc4(); -void bench_hc128(); -void bench_rabbit(); +void bench_des(void); +void bench_arc4(void); +void bench_hc128(void); +void bench_rabbit(void); void bench_aes(int); -void bench_aesgcm(); +void bench_aesgcm(void); -void bench_md5(); -void bench_sha(); -void bench_sha256(); -void bench_sha512(); -void bench_ripemd(); +void bench_md5(void); +void bench_sha(void); +void bench_sha256(void); +void bench_sha512(void); +void bench_ripemd(void); -void bench_rsa(); -void bench_rsaKeyGen(); -void bench_dh(); +void bench_rsa(void); +void bench_rsaKeyGen(void); +void bench_dh(void); #ifdef HAVE_ECC -void bench_eccKeyGen(); -void bench_eccKeyAgree(); +void bench_eccKeyGen(void); +void bench_eccKeyAgree(void); #endif -double current_time(); +double current_time(void); int main(int argc, char** argv) { + (void)argc; + (void)argv; #ifndef NO_AES bench_aes(0); bench_aes(1); @@ -180,7 +182,7 @@ byte tag[16]; #ifdef HAVE_AESGCM -void bench_aesgcm() +void bench_aesgcm(void) { Aes enc; double start, total, persec; @@ -204,7 +206,7 @@ void bench_aesgcm() #ifndef NO_DES3 -void bench_des() +void bench_des(void) { Des3 enc; double start, total, persec; @@ -226,7 +228,7 @@ void bench_des() #endif -void bench_arc4() +void bench_arc4(void) { Arc4 enc; double start, total, persec; @@ -247,7 +249,7 @@ void bench_arc4() #ifdef HAVE_HC128 -void bench_hc128() +void bench_hc128(void) { HC128 enc; double start, total, persec; @@ -269,7 +271,7 @@ void bench_hc128() #ifndef NO_RABBIT -void bench_rabbit() +void bench_rabbit(void) { Rabbit enc; double start, total, persec; @@ -290,7 +292,7 @@ void bench_rabbit() #endif /* NO_RABBIT */ -void bench_md5() +void bench_md5(void) { Md5 hash; byte digest[MD5_DIGEST_SIZE]; @@ -313,7 +315,7 @@ void bench_md5() } -void bench_sha() +void bench_sha(void) { Sha hash; byte digest[SHA_DIGEST_SIZE]; @@ -337,7 +339,7 @@ void bench_sha() #ifndef NO_SHA256 -void bench_sha256() +void bench_sha256(void) { Sha256 hash; byte digest[SHA256_DIGEST_SIZE]; @@ -361,7 +363,7 @@ void bench_sha256() #endif #ifdef CYASSL_SHA512 -void bench_sha512() +void bench_sha512(void) { Sha512 hash; byte digest[SHA512_DIGEST_SIZE]; @@ -385,7 +387,7 @@ void bench_sha512() #endif #ifdef CYASSL_RIPEMD -void bench_ripemd() +void bench_ripemd(void) { RipeMd hash; byte digest[RIPEMD_DIGEST_SIZE]; @@ -411,7 +413,7 @@ void bench_ripemd() RNG rng; -void bench_rsa() +void bench_rsa(void) { int i; byte tmp[4096]; @@ -468,7 +470,7 @@ void bench_rsa() #ifndef NO_DH -void bench_dh() +void bench_dh(void) { int i; byte tmp[1024]; @@ -526,7 +528,7 @@ void bench_dh() #endif #ifdef CYASSL_KEY_GEN -void bench_rsaKeyGen() +void bench_rsaKeyGen(void) { RsaKey genKey; double start, total, each, milliEach; @@ -567,7 +569,7 @@ void bench_rsaKeyGen() #endif /* CYASSL_KEY_GEN */ #ifdef HAVE_ECC -void bench_eccKeyGen() +void bench_eccKeyGen(void) { ecc_key genKey; double start, total, each, milliEach; @@ -591,7 +593,7 @@ void bench_eccKeyGen() } -void bench_eccKeyAgree() +void bench_eccKeyAgree(void) { ecc_key genKey, genKey2; double start, total, each, milliEach; @@ -669,7 +671,7 @@ void bench_eccKeyAgree() #include - double current_time() + double current_time(void) { struct timeval tv; gettimeofday(&tv, 0); diff --git a/ctaocrypt/src/asm.c b/ctaocrypt/src/asm.c index 008322e90..d33418afe 100644 --- a/ctaocrypt/src/asm.c +++ b/ctaocrypt/src/asm.c @@ -41,7 +41,7 @@ mu = c[x] * mp #define INNERMUL \ -asm( \ +__asm__( \ "movl %5,%%eax \n\t" \ "mull %4 \n\t" \ "addl %1,%%eax \n\t" \ @@ -54,7 +54,7 @@ asm( \ : "%eax", "%edx", "%cc") #define PROPCARRY \ -asm( \ +__asm__( \ "addl %1,%0 \n\t" \ "setb %%al \n\t" \ "movzbl %%al,%1 \n\t" \ @@ -73,7 +73,7 @@ asm( \ mu = c[x] * mp #define INNERMUL \ -asm( \ +__asm__( \ "movq %5,%%rax \n\t" \ "mulq %4 \n\t" \ "addq %1,%%rax \n\t" \ @@ -86,7 +86,7 @@ asm( \ : "%rax", "%rdx", "%cc") #define INNERMUL8 \ - asm( \ + __asm__( \ "movq 0(%5),%%rax \n\t" \ "movq 0(%2),%%r10 \n\t" \ "movq 0x8(%5),%%r11 \n\t" \ @@ -180,7 +180,7 @@ asm( \ #define PROPCARRY \ -asm( \ +__asm__( \ "addq %1,%0 \n\t" \ "setb %%al \n\t" \ "movzbq %%al,%1 \n\t" \ @@ -200,13 +200,13 @@ asm( \ */ #define MONT_START \ - asm("movd %0,%%mm2"::"g"(mp)) + __asm__("movd %0,%%mm2"::"g"(mp)) #define MONT_FINI \ - asm("emms") + __asm__("emms") #define LOOP_START \ -asm( \ +__asm__( \ "movd %0,%%mm1 \n\t" \ "pxor %%mm3,%%mm3 \n\t" \ "pmuludq %%mm2,%%mm1 \n\t" \ @@ -214,7 +214,7 @@ asm( \ /* pmuludq on mmx registers does a 32x32->64 multiply. */ #define INNERMUL \ -asm( \ +__asm__( \ "movd %1,%%mm4 \n\t" \ "movd %2,%%mm0 \n\t" \ "paddq %%mm4,%%mm3 \n\t" \ @@ -225,7 +225,7 @@ asm( \ :"=g"(_c[LO]) : "0"(_c[LO]), "g"(*tmpm++) ); #define INNERMUL8 \ -asm( \ +__asm__( \ "movd 0(%1),%%mm4 \n\t" \ "movd 0(%2),%%mm0 \n\t" \ "paddq %%mm4,%%mm3 \n\t" \ @@ -295,10 +295,10 @@ asm( \ pointer */ #define LOOP_END \ -asm( "movd %%mm3,%0 \n" :"=r"(cy)) +__asm__( "movd %%mm3,%0 \n" :"=r"(cy)) #define PROPCARRY \ -asm( \ +__asm__( \ "addl %1,%0 \n\t" \ "setb %%al \n\t" \ "movzbl %%al,%1 \n\t" \ @@ -317,7 +317,7 @@ asm( \ mu = c[x] * mp #define INNERMUL \ -asm( \ +__asm__( \ " LDR r0,%1 \n\t" \ " ADDS r0,r0,%0 \n\t" \ " MOVCS %0,#1 \n\t" \ @@ -327,7 +327,7 @@ asm( \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c[0]):"r0","%cc"); #define PROPCARRY \ -asm( \ +__asm__( \ " LDR r0,%1 \n\t" \ " ADDS r0,r0,%0 \n\t" \ " STR r0,%1 \n\t" \ @@ -345,7 +345,7 @@ asm( \ mu = c[x] * mp #define INNERMUL \ -asm( \ +__asm__( \ " mullw 16,%3,%4 \n\t" \ " mulhwu 17,%3,%4 \n\t" \ " addc 16,16,%0 \n\t" \ @@ -357,7 +357,7 @@ asm( \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"16", "17", "18","%cc"); ++tmpm; #define PROPCARRY \ -asm( \ +__asm__( \ " lwz 16,%1 \n\t" \ " addc 16,16,%0 \n\t" \ " stw 16,%1 \n\t" \ @@ -375,7 +375,7 @@ asm( \ mu = c[x] * mp #define INNERMUL \ -asm( \ +__asm__( \ " mulld 16,%3,%4 \n\t" \ " mulhdu 17,%3,%4 \n\t" \ " addc 16,16,%0 \n\t" \ @@ -387,7 +387,7 @@ asm( \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"16", "17", "18","%cc"); ++tmpm; #define PROPCARRY \ -asm( \ +__asm__( \ " ldx 16,0,%1 \n\t" \ " addc 16,16,%0 \n\t" \ " sdx 16,0,%1 \n\t" \ @@ -407,7 +407,7 @@ asm( \ mu = c[x] * mp #define INNERMUL \ -asm( \ +__asm__( \ " ld.w r2,%1 \n\t" \ " add r2,%0 \n\t" \ " eor r3,r3 \n\t" \ @@ -418,7 +418,7 @@ asm( \ :"=r"(cy),"=r"(_c):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c):"r2","r3"); #define PROPCARRY \ -asm( \ +__asm__( \ " ld.w r2,%1 \n\t" \ " add r2,%0 \n\t" \ " st.w %1,r2 \n\t" \ @@ -475,7 +475,7 @@ asm( \ #define COMBA_FINI #define SQRADD(i, j) \ -asm( \ +__asm__( \ "movl %6,%%eax \n\t" \ "mull %%eax \n\t" \ "addl %%eax,%0 \n\t" \ @@ -484,7 +484,7 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i) :"%eax","%edx","%cc"); #define SQRADD2(i, j) \ -asm( \ +__asm__( \ "movl %6,%%eax \n\t" \ "mull %7 \n\t" \ "addl %%eax,%0 \n\t" \ @@ -496,7 +496,7 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j) :"%eax","%edx", "%cc"); #define SQRADDSC(i, j) \ -asm( \ +__asm__( \ "movl %3,%%eax \n\t" \ "mull %4 \n\t" \ "movl %%eax,%0 \n\t" \ @@ -507,7 +507,7 @@ asm( \ /* TAO removed sc0,1,2 as input to remove warning so %6,%7 become %3,%4 */ #define SQRADDAC(i, j) \ -asm( \ +__asm__( \ "movl %6,%%eax \n\t" \ "mull %7 \n\t" \ "addl %%eax,%0 \n\t" \ @@ -516,7 +516,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%eax","%edx","%cc"); #define SQRADDDB \ -asm( \ +__asm__( \ "addl %6,%0 \n\t" \ "adcl %7,%1 \n\t" \ "adcl %8,%2 \n\t" \ @@ -545,7 +545,7 @@ asm( \ #define COMBA_FINI #define SQRADD(i, j) \ -asm( \ +__asm__( \ "movq %6,%%rax \n\t" \ "mulq %%rax \n\t" \ "addq %%rax,%0 \n\t" \ @@ -554,7 +554,7 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i) :"%rax","%rdx","%cc"); #define SQRADD2(i, j) \ -asm( \ +__asm__( \ "movq %6,%%rax \n\t" \ "mulq %7 \n\t" \ "addq %%rax,%0 \n\t" \ @@ -566,7 +566,7 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i), "g"(j) :"%rax","%rdx","%cc"); #define SQRADDSC(i, j) \ -asm( \ +__asm__( \ "movq %3,%%rax \n\t" \ "mulq %4 \n\t" \ "movq %%rax,%0 \n\t" \ @@ -577,7 +577,7 @@ asm( \ /* TAO removed sc0,1,2 as input to remove warning so %6,%7 become %3,%4 */ #define SQRADDAC(i, j) \ -asm( \ +__asm__( \ "movq %6,%%rax \n\t" \ "mulq %7 \n\t" \ "addq %%rax,%0 \n\t" \ @@ -586,7 +586,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%rax","%rdx","%cc"); #define SQRADDDB \ -asm( \ +__asm__( \ "addq %6,%0 \n\t" \ "adcq %7,%1 \n\t" \ "adcq %8,%2 \n\t" \ @@ -613,10 +613,10 @@ asm( \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI \ - asm("emms"); + __asm__("emms"); #define SQRADD(i, j) \ -asm( \ +__asm__( \ "movd %6,%%mm0 \n\t" \ "pmuludq %%mm0,%%mm0\n\t" \ "movd %%mm0,%%eax \n\t" \ @@ -628,7 +628,7 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i) :"%eax","%cc"); #define SQRADD2(i, j) \ -asm( \ +__asm__( \ "movd %6,%%mm0 \n\t" \ "movd %7,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ @@ -644,7 +644,7 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j) :"%eax","%edx","%cc"); #define SQRADDSC(i, j) \ -asm( \ +__asm__( \ "movd %3,%%mm0 \n\t" \ "movd %4,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ @@ -657,7 +657,7 @@ asm( \ /* TAO removed sc0,1,2 as input to remove warning so %6,%7 become %3,%4 */ #define SQRADDAC(i, j) \ -asm( \ +__asm__( \ "movd %6,%%mm0 \n\t" \ "movd %7,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ @@ -670,7 +670,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "m"(i), "m"(j) :"%eax","%edx","%cc"); #define SQRADDDB \ -asm( \ +__asm__( \ "addl %6,%0 \n\t" \ "adcl %7,%1 \n\t" \ "adcl %8,%2 \n\t" \ @@ -701,7 +701,7 @@ asm( \ /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ -asm( \ +__asm__( \ " UMULL r0,r1,%6,%6 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ @@ -710,7 +710,7 @@ asm( \ /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ -asm( \ +__asm__( \ " UMULL r0,r1,%6,%7 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ @@ -721,13 +721,13 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j) : "r0", "r1", "%cc"); #define SQRADDSC(i, j) \ -asm( \ +__asm__( \ " UMULL %0,%1,%6,%7 \n\t" \ " SUB %2,%2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2) : "0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j) : "%cc"); #define SQRADDAC(i, j) \ -asm( \ +__asm__( \ " UMULL r0,r1,%6,%7 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ @@ -735,7 +735,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2) : "0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j) : "r0", "r1", "%cc"); #define SQRADDDB \ -asm( \ +__asm__( \ " ADDS %0,%0,%3 \n\t" \ " ADCS %1,%1,%4 \n\t" \ " ADC %2,%2,%5 \n\t" \ @@ -766,7 +766,7 @@ asm( \ /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ -asm( \ +__asm__( \ " mullw 16,%6,%6 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhwu 16,%6,%6 \n\t" \ @@ -776,7 +776,7 @@ asm( \ /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ -asm( \ +__asm__( \ " mullw 16,%6,%7 \n\t" \ " mulhwu 17,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ @@ -788,14 +788,14 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16", "17","%cc"); #define SQRADDSC(i, j) \ -asm( \ +__asm__( \ " mullw %0,%6,%7 \n\t" \ " mulhwu %1,%6,%7 \n\t" \ " xor %2,%2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "%cc"); #define SQRADDAC(i, j) \ -asm( \ +__asm__( \ " mullw 16,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhwu 16,%6,%7 \n\t" \ @@ -804,7 +804,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"16", "%cc"); #define SQRADDDB \ -asm( \ +__asm__( \ " addc %0,%0,%3 \n\t" \ " adde %1,%1,%4 \n\t" \ " adde %2,%2,%5 \n\t" \ @@ -834,7 +834,7 @@ asm( \ /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ -asm( \ +__asm__( \ " mulld 16,%6,%6 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhdu 16,%6,%6 \n\t" \ @@ -844,7 +844,7 @@ asm( \ /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ -asm( \ +__asm__( \ " mulld 16,%6,%7 \n\t" \ " mulhdu 17,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ @@ -856,14 +856,14 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16", "17","%cc"); #define SQRADDSC(i, j) \ -asm( \ +__asm__( \ " mulld %0,%6,%7 \n\t" \ " mulhdu %1,%6,%7 \n\t" \ " xor %2,%2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "%cc"); #define SQRADDAC(i, j) \ -asm( \ +__asm__( \ " mulld 16,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhdu 16,%6,%7 \n\t" \ @@ -872,7 +872,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"16", "%cc"); #define SQRADDDB \ -asm( \ +__asm__( \ " addc %0,%0,%3 \n\t" \ " adde %1,%1,%4 \n\t" \ " adde %2,%2,%5 \n\t" \ @@ -904,7 +904,7 @@ asm( \ /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ -asm( \ +__asm__( \ " mulu.d r2,%6,%6 \n\t" \ " add %0,%0,r2 \n\t" \ " adc %1,%1,r3 \n\t" \ @@ -913,7 +913,7 @@ asm( \ /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ -asm( \ +__asm__( \ " mulu.d r2,%6,%7 \n\t" \ " add %0,%0,r2 \n\t" \ " adc %1,%1,r3 \n\t" \ @@ -924,7 +924,7 @@ asm( \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"r2", "r3"); #define SQRADDSC(i, j) \ -asm( \ +__asm__( \ " mulu.d r2,%6,%7 \n\t" \ " mov %0,r2 \n\t" \ " mov %1,r3 \n\t" \ @@ -932,7 +932,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "r2", "r3"); #define SQRADDAC(i, j) \ -asm( \ +__asm__( \ " mulu.d r2,%6,%7 \n\t" \ " add %0,%0,r2 \n\t" \ " adc %1,%1,r3 \n\t" \ @@ -940,7 +940,7 @@ asm( \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"r2", "r3"); #define SQRADDDB \ -asm( \ +__asm__( \ " add %0,%0,%3 \n\t" \ " adc %1,%1,%4 \n\t" \ " adc %2,%2,%5 \n\t" \ @@ -1059,7 +1059,7 @@ asm( \ /* this should multiply i and j */ #define MULADD(i, j) \ -asm( \ +__asm__( \ "movl %6,%%eax \n\t" \ "mull %7 \n\t" \ "addl %%eax,%0 \n\t" \ @@ -1094,7 +1094,7 @@ asm( \ /* this should multiply i and j */ #define MULADD(i, j) \ -asm ( \ +__asm__ ( \ "movq %6,%%rax \n\t" \ "mulq %7 \n\t" \ "addq %%rax,%0 \n\t" \ @@ -1126,11 +1126,11 @@ asm ( \ /* anything you need at the end */ #define COMBA_FINI \ - asm("emms"); + __asm__("emms"); /* this should multiply i and j */ #define MULADD(i, j) \ -asm( \ +__asm__( \ "movd %6,%%mm0 \n\t" \ "movd %7,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ @@ -1162,7 +1162,7 @@ asm( \ #define COMBA_FINI #define MULADD(i, j) \ -asm( \ +__asm__( \ " UMULL r0,r1,%6,%7 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ @@ -1190,7 +1190,7 @@ asm( \ /* untested: will mulhwu change the flags? Docs say no */ #define MULADD(i, j) \ -asm( \ +__asm__( \ " mullw 16,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhwu 16,%6,%7 \n\t" \ @@ -1219,7 +1219,7 @@ asm( \ /* untested: will mulhwu change the flags? Docs say no */ #define MULADD(i, j) \ -asm( \ +____asm__( \ " mulld 16,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhdu 16,%6,%7 \n\t" \ @@ -1248,7 +1248,7 @@ asm( \ #define COMBA_FINI #define MULADD(i, j) \ -asm( \ +____asm__( \ " mulu.d r2,%6,%7 \n\t"\ " add %0,r2 \n\t"\ " adc %1,%1,r3 \n\t"\ diff --git a/ctaocrypt/src/coding.c b/ctaocrypt/src/coding.c index 63edc6a66..063656ca4 100644 --- a/ctaocrypt/src/coding.c +++ b/ctaocrypt/src/coding.c @@ -262,4 +262,4 @@ int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen) } -#endif /* OPENSSL_EXTRA */ +#endif /* defined(OPENSSL_EXTRA) || defined (SESSION_CERTS) || defined(CYASSL_KEY_GEN) || defined(CYASSL_CERT_GEN) || defined(HAVE_WEBSERVER) */ diff --git a/ctaocrypt/test/include.am b/ctaocrypt/test/include.am index 9c876c939..b1b8de3ed 100644 --- a/ctaocrypt/test/include.am +++ b/ctaocrypt/test/include.am @@ -5,5 +5,6 @@ noinst_PROGRAMS+= ctaocrypt/test/testctaocrypt ctaocrypt_test_testctaocrypt_SOURCES = ctaocrypt/test/test.c ctaocrypt_test_testctaocrypt_LDADD = src/libcyassl.la ctaocrypt_test_testctaocrypt_DEPENDENCIES = src/libcyassl.la +noinst_HEADERS += ctaocrypt/test/test.h EXTRA_DIST += ctaocrypt/test/test.sln EXTRA_DIST += ctaocrypt/test/test.vcproj diff --git a/ctaocrypt/test/test.c b/ctaocrypt/test/test.c index ddb3e0149..c8180253b 100644 --- a/ctaocrypt/test/test.c +++ b/ctaocrypt/test/test.c @@ -79,6 +79,8 @@ #define printf dc_log_printf #endif +#include "ctaocrypt/test/test.h" + typedef struct testVector { char* input; @@ -87,36 +89,39 @@ typedef struct testVector { size_t outLen; } testVector; -int md2_test(); -int md5_test(); -int md4_test(); -int sha_test(); -int sha256_test(); -int sha512_test(); -int sha384_test(); -int hmac_test(); -int arc4_test(); -int hc128_test(); -int rabbit_test(); -int des_test(); -int des3_test(); -int aes_test(); -int aesgcm_test(); -int rsa_test(); -int dh_test(); -int dsa_test(); -int random_test(); -int pwdbased_test(); -int ripemd_test(); -int openssl_test(); /* test mini api */ +int md2_test(void); +int md5_test(void); +int md4_test(void); +int sha_test(void); +int sha256_test(void); +int sha512_test(void); +int sha384_test(void); +int hmac_test(void); +int arc4_test(void); +int hc128_test(void); +int rabbit_test(void); +int des_test(void); +int des3_test(void); +int aes_test(void); +int aesgcm_test(void); +int rsa_test(void); +int dh_test(void); +int dsa_test(void); +int random_test(void); +int pwdbased_test(void); +int ripemd_test(void); +int openssl_test(void); /* test mini api */ +int pbkdf1_test(void); +int pkcs12_test(void); +int pbkdf2_test(void); #ifdef HAVE_ECC - int ecc_test(); + int ecc_test(void); #endif int PemToDer(const char* inName, const char* outName); -void err_sys(const char* msg, int es) +static void err_sys(const char* msg, int es) { printf("%s error = %d\n", msg, es); #ifndef THREADX @@ -395,7 +400,7 @@ int md2_test() #endif -int md5_test() +int md5_test(void) { Md5 md5; byte hash[MD5_DIGEST_SIZE]; @@ -458,7 +463,7 @@ int md5_test() #ifndef NO_MD4 -int md4_test() +int md4_test(void) { Md4 md4; byte hash[MD4_DIGEST_SIZE]; @@ -2088,7 +2093,7 @@ int openssl_test() #ifndef NO_PWDBASED -int pkcs12_test() +int pkcs12_test(void) { const byte passwd[] = { 0x00, 0x73, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x67, 0x00, 0x00 }; @@ -2130,7 +2135,7 @@ int pkcs12_test() } -int pbkdf2_test() +int pbkdf2_test(void) { char passwd[] = "password"; const byte salt[] = { 0x78, 0x57, 0x8E, 0x5a, 0x5d, 0x63, 0xcb, 0x06 }; @@ -2154,7 +2159,7 @@ int pbkdf2_test() } -int pbkdf1_test() +int pbkdf1_test(void) { char passwd[] = "password"; const byte salt[] = { 0x78, 0x57, 0x8E, 0x5a, 0x5d, 0x63, 0xcb, 0x06 }; @@ -2177,7 +2182,7 @@ int pbkdf1_test() } -int pwdbased_test() +int pwdbased_test(void) { int ret = pbkdf1_test(); ret += pbkdf2_test(); @@ -2190,7 +2195,7 @@ int pwdbased_test() #ifdef HAVE_ECC -int ecc_test() +int ecc_test(void) { RNG rng; byte sharedA[1024]; diff --git a/ctaocrypt/test/test.h b/ctaocrypt/test/test.h new file mode 100644 index 000000000..82ffdf7f4 --- /dev/null +++ b/ctaocrypt/test/test.h @@ -0,0 +1,25 @@ +/* test.c + * + * Copyright (C) 2006-2012 Sawtooth Consulting Ltd. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#pragma once; + +void ctaocrypt_test(void* args); + diff --git a/cyassl/test.h b/cyassl/test.h index 59788dc2d..63471a2ce 100644 --- a/cyassl/test.h +++ b/cyassl/test.h @@ -227,6 +227,8 @@ static INLINE int mygetopt(int argc, char** argv, char* optstring) static INLINE int PasswordCallBack(char* passwd, int sz, int rw, void* userdata) { + (void)rw; + (void)userdata; strncpy(passwd, "yassl123", sz); return 8; } @@ -236,6 +238,7 @@ static INLINE int PasswordCallBack(char* passwd, int sz, int rw, void* userdata) static INLINE void showPeer(CYASSL* ssl) { + (void)ssl; #ifdef OPENSSL_EXTRA CYASSL_CIPHER* cipher; @@ -429,6 +432,7 @@ static INLINE int udp_read_connect(SOCKET_T sockfd) static INLINE void udp_accept(SOCKET_T* sockfd, int* clientfd, func_args* args) { + (void)args; SOCKADDR_IN_T addr; tcp_socket(sockfd, &addr, yasslIP, yasslPort, 1); @@ -492,6 +496,7 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, int* clientfd, func_args* args, static INLINE void tcp_set_nonblocking(SOCKET_T* sockfd) { + (void)sockfd; #ifdef NON_BLOCKING #ifdef USE_WINDOWS_API unsigned long blocking = 1; @@ -672,6 +677,7 @@ static void INLINE CRL_CallBack(const char* url) static INLINE void CaCb(unsigned char* der, int sz, int type) { + (void)der; printf("Got CA cache add callback, derSz = %d, type = %d\n", sz, type); } diff --git a/examples/client/client.c b/examples/client/client.c index 3ed70b481..d74d82672 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -26,6 +26,8 @@ #include #include +#include "examples/client/client.h" + /* #define TEST_RESUME */ diff --git a/examples/client/client.h b/examples/client/client.h new file mode 100644 index 000000000..d4f33df55 --- /dev/null +++ b/examples/client/client.h @@ -0,0 +1,25 @@ +/* client.h + * + * Copyright (C) 2006-2012 Sawtooth Consulting Ltd. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#pragma once + +void client_test(void* args); + diff --git a/examples/client/include.am b/examples/client/include.am index 0b900c221..4773cc8a1 100644 --- a/examples/client/include.am +++ b/examples/client/include.am @@ -2,6 +2,7 @@ # All paths should be given relative to the root noinst_PROGRAMS += examples/client/client +noinst_HEADERS += examples/client/client.h examples_client_client_SOURCES = examples/client/client.c examples_client_client_LDADD = src/libcyassl.la examples_client_client_DEPENDENCIES = src/libcyassl.la diff --git a/examples/echoclient/echoclient.c b/examples/echoclient/echoclient.c index d93ca3fe2..ff61635ab 100644 --- a/examples/echoclient/echoclient.c +++ b/examples/echoclient/echoclient.c @@ -26,6 +26,7 @@ #include #include +#include "examples/echoclient/echoclient.h" void echoclient_test(void* args) { diff --git a/examples/echoclient/echoclient.h b/examples/echoclient/echoclient.h new file mode 100644 index 000000000..37e6c0929 --- /dev/null +++ b/examples/echoclient/echoclient.h @@ -0,0 +1,23 @@ +/* echoclient.h + * + * Copyright (C) 2006-2012 Sawtooth Consulting Ltd. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#pragma once +void echoclient_test(void* args); diff --git a/examples/echoclient/include.am b/examples/echoclient/include.am index 8f09c24d3..37592d158 100644 --- a/examples/echoclient/include.am +++ b/examples/echoclient/include.am @@ -4,6 +4,7 @@ noinst_PROGRAMS += examples/echoclient/echoclient +noinst_HEADERS += examples/echoclient/echoclient.h examples_echoclient_echoclient_SOURCES = examples/echoclient/echoclient.c examples_echoclient_echoclient_LDADD = src/libcyassl.la examples_echoclient_echoclient_DEPENDENCIES = src/libcyassl.la diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index 3bf51bc9f..49dd7f266 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -30,6 +30,8 @@ #define ECHO_OUT #endif +#include "examples/echoserver/echoserver.h" + #ifdef SESSION_STATS CYASSL_API void PrintSessionStats(void); @@ -38,6 +40,7 @@ static void SignalReady(void* args) { + (void)args; #if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) /* signal ready to tcp_accept */ func_args* server_args = (func_args*)args; @@ -58,10 +61,13 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args) int doDTLS = 0; int outCreated = 0; + (void)outCreated; int shutdown = 0; int useAnyAddr = 0; int argc = ((func_args*)args)->argc; + (void)argc; char** argv = ((func_args*)args)->argv; + (void)argv; #ifdef ECHO_OUT FILE* fout = stdout; diff --git a/examples/echoserver/echoserver.h b/examples/echoserver/echoserver.h new file mode 100644 index 000000000..20f7b52e2 --- /dev/null +++ b/examples/echoserver/echoserver.h @@ -0,0 +1,24 @@ +/* echoserver.h + * + * Copyright (C) 2006-2012 Sawtooth Consulting Ltd. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#pragma once + +THREAD_RETURN CYASSL_THREAD echoserver_test(void* args); diff --git a/examples/echoserver/include.am b/examples/echoserver/include.am index c998c56ef..6e031e063 100644 --- a/examples/echoserver/include.am +++ b/examples/echoserver/include.am @@ -4,6 +4,7 @@ noinst_PROGRAMS += examples/echoserver/echoserver +noinst_HEADERS += examples/echoserver/echoserver.h examples_echoserver_echoserver_SOURCES = examples/echoserver/echoserver.c examples_echoserver_echoserver_LDADD = src/libcyassl.la examples_echoserver_echoserver_DEPENDENCIES = src/libcyassl.la diff --git a/examples/server/include.am b/examples/server/include.am index fab37fd0f..c54eb9135 100644 --- a/examples/server/include.am +++ b/examples/server/include.am @@ -4,6 +4,7 @@ noinst_PROGRAMS += examples/server/server +noinst_HEADERS += examples/server/server.h examples_server_server_SOURCES = examples/server/server.c examples_server_server_LDADD = src/libcyassl.la examples_server_server_DEPENDENCIES = src/libcyassl.la diff --git a/examples/server/server.c b/examples/server/server.c index 2df2d99a5..4a7f05edc 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -26,6 +26,8 @@ #include #include +#include "examples/server/server.h" + #ifdef CYASSL_CALLBACKS int srvHandShakeCB(HandShakeInfo*); diff --git a/examples/server/server.h b/examples/server/server.h new file mode 100644 index 000000000..658c4007b --- /dev/null +++ b/examples/server/server.h @@ -0,0 +1,24 @@ +/* server.c + * + * Copyright (C) 2006-2012 Sawtooth Consulting Ltd. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#pragma once + +THREAD_RETURN CYASSL_THREAD server_test(void* args); diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4 new file mode 100644 index 000000000..1f8e70845 --- /dev/null +++ b/m4/ax_append_compile_flags.m4 @@ -0,0 +1,65 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the compiler works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. During the check the flag is always added to the +# current language's flags. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and +# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with +# AX_APPEND_LINK_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 3 + +AC_DEFUN([AX_APPEND_COMPILE_FLAGS], +[AC_REQUIRE([AX_CHECK_COMPILE_FLAG]) +AC_REQUIRE([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3]) +done +])dnl AX_APPEND_COMPILE_FLAGS diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 new file mode 100644 index 000000000..1d38b76fb --- /dev/null +++ b/m4/ax_append_flag.m4 @@ -0,0 +1,69 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) +# +# DESCRIPTION +# +# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space +# added in between. +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains +# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly +# FLAG. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + +AC_DEFUN([AX_APPEND_FLAG], +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX +AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl +AS_VAR_SET_IF(FLAGS, + [case " AS_VAR_GET(FLAGS) " in + *" $1 "*) + AC_RUN_LOG([: FLAGS already contains $1]) + ;; + *) + AC_RUN_LOG([: FLAGS="$FLAGS $1"]) + AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) + ;; + esac], + [AS_VAR_SET(FLAGS,["$1"])]) +AS_VAR_POPDEF([FLAGS])dnl +])dnl AX_APPEND_FLAG diff --git a/m4/ax_append_link_flags.m4 b/m4/ax_append_link_flags.m4 new file mode 100644 index 000000000..48cbd4bb1 --- /dev/null +++ b/m4/ax_append_link_flags.m4 @@ -0,0 +1,63 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the linker works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is +# used. During the check the flag is always added to the linker's flags. +# +# If EXTRA-FLAGS is defined, it is added to the linker's default flags +# when the check is done. The check is thus made with the flags: "LDFLAGS +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to +# issue an error when a bad flag is given. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG. +# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 3 + +AC_DEFUN([AX_APPEND_LINK_FLAGS], +[AC_REQUIRE([AX_CHECK_LINK_FLAG]) +AC_REQUIRE([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3]) +done +])dnl AX_APPEND_LINK_FLAGS diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 000000000..c3a8d695a --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,72 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4 new file mode 100644 index 000000000..e2d0d363e --- /dev/null +++ b/m4/ax_check_link_flag.m4 @@ -0,0 +1,71 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the linker or gives an error. +# (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the linker's default flags +# when the check is done. The check is thus made with the flags: "LDFLAGS +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to +# issue an error when a bad flag is given. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + +AC_DEFUN([AX_CHECK_LINK_FLAG], +[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl +AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS $4 $1" + AC_LINK_IFELSE([AC_LANG_PROGRAM()], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + LDFLAGS=$ax_check_save_flags]) +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_LINK_FLAGS diff --git a/m4/ax_compiler_version.m4 b/m4/ax_compiler_version.m4 new file mode 100644 index 000000000..7f6708d5d --- /dev/null +++ b/m4/ax_compiler_version.m4 @@ -0,0 +1,36 @@ +AC_DEFUN([AX_C_COMPILER_VERSION],[ + + dnl Print version of C compiler + AC_MSG_CHECKING("C Compiler version--$GCC") + AS_IF([test "$GCC" = "yes"],[ + CC_VERSION=`$CC --version | sed 1q` ],[ + test "$SUNCC" = "yes"],[ + CC_VERSION=`$CC -V 2>&1 | sed 1q` ],[ + test "$CLANG" = "yes"],[ + CC_VERSION=`$CC --version 2>&1 | sed 1q` ],[ + CC_VERSION="" + ]) + AC_MSG_RESULT("$CC_VERSION") + AC_SUBST(CC_VERSION) + ]) + + +AC_DEFUN([AX_CXX_COMPILER_VERSION], [ + + dnl Check C version while at it + AC_REQUIRE([AX_C_COMPILER_VERSION]) + + dnl Print version of CXX compiler + AC_MSG_CHECKING("C++ Compiler version") + AS_IF([test "$GCC" = "yes"],[ + CXX_VERSION=`$CXX --version | sed 1q` ],[ + test "$SUNCC" = "yes"],[ + CXX_VERSION=`$CXX -V 2>&1 | sed 1q` ],[ + test "$CLANG" = "yes"],[ + CXX_VERSION=`$CXX --version 2>&1 | sed 1q` ],[ + CXX_VERSION="" + ]) + AC_MSG_RESULT("$CXX_VERSION") + AC_SUBST(CXX_VERSION) + ]) + diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4 new file mode 100644 index 000000000..1490819d4 --- /dev/null +++ b/m4/ax_harden_compiler_flags.m4 @@ -0,0 +1,145 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_HARDEN_COMPILER_FLAGS +# +# DESCRIPTION +# +# Any compiler flag that "hardens" or tests code. C99 is assumed. +# +# NOTE: Implementation based on AX_APPEND_FLAG. +# +# LICENSE +# +# Copyright (C) 2012 Brian Aker +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# +# * The names of its contributors may not be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# The Following flags are not checked for +# -Wdeclaration-after-statement is counter to C99 +# AX_APPEND_COMPILE_FLAGS([-std=c++11]) -- Not ready yet +# AX_APPEND_COMPILE_FLAGS([-pedantic]) -- ? +# AX_APPEND_COMPILE_FLAGS([-Wstack-protector]) -- Issues on 32bit compile +# AX_APPEND_COMPILE_FLAGS([-fstack-protector-all]) -- Issues on 32bit compile +# AX_APPEND_COMPILE_FLAGS([-Wlong-long]) -- Don't turn on for compatibility issues memcached_stat_st + +#serial 2 + AC_DEFUN([AX_HARDEN_LINKER_FLAGS], [ + AC_REQUIRE([AX_CHECK_LINK_FLAG]) + AC_REQUIRE([AX_VCS_CHECKOUT]) + AC_REQUIRE([AX_DEBUG]) + + AS_IF([test "$ac_cv_vcs_checkout" = yes], [ + AX_CHECK_LINK_FLAG([-Werror]) + ]) + AX_CHECK_LINK_FLAG([-z relro -z now]) + ]) + + AC_DEFUN([AX_HARDEN_C_COMPILER_FLAGS], [ + AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) + AC_REQUIRE([AX_HARDEN_LINKER_FLAGS]) + + AC_LANG_PUSH([C]) + AS_IF([test "$ax_with_debug" = yes], [ + AX_APPEND_COMPILE_FLAGS([-O0])],[ + AX_APPEND_COMPILE_FLAGS([-O2]) + ]) + + ac_cv_warnings_as_errors=no + AS_IF([test "$ac_cv_vcs_checkout" = yes], [ + AX_APPEND_COMPILE_FLAGS([-Werror]) + ac_cv_warnings_as_errors=yes + ]) + + AX_APPEND_COMPILE_FLAGS([-Wall]) + AX_APPEND_COMPILE_FLAGS([-Wextra]) + AX_APPEND_COMPILE_FLAGS([-std=c99]) + AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes]) + AX_APPEND_COMPILE_FLAGS([-Wnested-externs]) + AX_APPEND_COMPILE_FLAGS([-Wold-style-definition]) + AX_APPEND_COMPILE_FLAGS([-Woverride-init]) + AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes]) + AX_APPEND_COMPILE_FLAGS([-Wlogical-op]) + AC_LANG_POP + + ]) + + AC_DEFUN([AX_HARDEN_CC_COMPILER_FLAGS], [ + AC_REQUIRE([AX_HARDEN_C_COMPILER_FLAGS]) + AC_LANG_PUSH([C++]) + + AS_IF([test "$ax_with_debug" = yes], [ + AX_APPEND_COMPILE_FLAGS([-O0])],[ + AX_APPEND_COMPILE_FLAGS([-O2]) + AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2]) + ]) + + AS_IF([test "$ac_cv_vcs_checkout" = yes], [ + AX_APPEND_COMPILE_FLAGS([-Werror]) + ]) + + AX_APPEND_COMPILE_FLAGS([-Wall]) + AX_APPEND_COMPILE_FLAGS([-Wextra]) + AX_APPEND_COMPILE_FLAGS([-Wpragmas]) + AX_APPEND_COMPILE_FLAGS([--paramssp-buffer-size=1]) + AX_APPEND_COMPILE_FLAGS([-Waddress]) + AX_APPEND_COMPILE_FLAGS([-Warray-bounds]) + AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts]) + AX_APPEND_COMPILE_FLAGS([-Wcomment]) + AX_APPEND_COMPILE_FLAGS([-Wctor-dtor-privacy]) + AX_APPEND_COMPILE_FLAGS([-Wfloat-equal]) + AX_APPEND_COMPILE_FLAGS([-Wformat=2]) + AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn]) + AX_APPEND_COMPILE_FLAGS([-Wlogical-op]) + AX_APPEND_COMPILE_FLAGS([-Wnon-virtual-dtor]) + AX_APPEND_COMPILE_FLAGS([-Wnormalized=id]) + AX_APPEND_COMPILE_FLAGS([-Woverloaded-virtual]) + AX_APPEND_COMPILE_FLAGS([-Wpointer-arith]) + AX_APPEND_COMPILE_FLAGS([-Wredundant-decls]) + AX_APPEND_COMPILE_FLAGS([-Wshadow]) + AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32]) + AX_APPEND_COMPILE_FLAGS([-Wsign-compare]) + AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1]) + AX_APPEND_COMPILE_FLAGS([-Wswitch-enum]) + AX_APPEND_COMPILE_FLAGS([-Wundef]) + AX_APPEND_COMPILE_FLAGS([-Wunused-result]) + AX_APPEND_COMPILE_FLAGS([-Wunused-variable]) + AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) + AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all]) + AX_APPEND_COMPILE_FLAGS([-fwrapv]) + AX_APPEND_COMPILE_FLAGS([-ggdb]) + AC_LANG_POP + ]) diff --git a/m4/ax_vcs_checkout.m4 b/m4/ax_vcs_checkout.m4 new file mode 100644 index 000000000..e354470ed --- /dev/null +++ b/m4/ax_vcs_checkout.m4 @@ -0,0 +1,60 @@ +# =========================================================================== +# http:// +# =========================================================================== +# +# SYNOPSIS +# +# AX_VCS_CHECKOUT +# +# DESCRIPTION +# +# Discover whether or not we are operating with a tree which +# has been checked out of a version control system. +# +# +# LICENSE +# +# Copyright (C) 2012 Brian Aker +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# +# * The names of its contributors may not be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#serial 1 + +AC_DEFUN([AX_VCS_CHECKOUT],[ + AC_CACHE_CHECK([for vcs checkout], [ac_cv_vcs_checkout], [ + AS_IF([test -d ".bzr"],[ac_cv_vcs_checkout=yes]) + AS_IF([test -d ".svn"],[ac_cv_vcs_checkout=yes]) + AS_IF([test -d ".hg"], [ac_cv_vcs_checkout=yes]) + AS_IF([test -d ".git"],[ac_cv_vcs_checkout=yes]) + ]) + + AS_IF([test "$ac_cv_vcs_checkout" = yes], [ + ]) + ]) diff --git a/m4/debug.m4 b/m4/debug.m4 new file mode 100644 index 000000000..7bdbeba09 --- /dev/null +++ b/m4/debug.m4 @@ -0,0 +1,18 @@ +AC_DEFUN([AX_DEBUG],[ + AC_ARG_WITH([debug], + [AS_HELP_STRING([--with-debug], + [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])], + [ax_with_debug=$withval], + [ax_with_debug=no]) + AS_IF([test "$ax_with_debug" = "yes"],[ + # Debugging. No optimization. + AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG" + AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG" + AC_DEFINE(DEBUG, [ 1 ], [Define to 1 to enable debugging code.]) + ],[ + # Optimized version. No debug + AM_CFLAGS="${AM_CFLAGS} ${OPTIMIZE_CFLAGS}" + AM_CXXFLAGS="${AM_CXXFLAGS} ${OPTIMIZE_CXXFLAGS}" + AC_DEFINE(DEBUG, [ 0 ], [Define to 1 to enable debugging code.]) + ]) +]) diff --git a/m4/visibility.m4 b/m4/visibility.m4 index 077c4765e..75c34b6e1 100644 --- a/m4/visibility.m4 +++ b/m4/visibility.m4 @@ -1,5 +1,5 @@ -# visibility.m4 serial 3 (gettext-0.18) -dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc. +# visibility.m4 serial 4 (gettext-0.18.2) +dnl Copyright (C) 2005, 2008, 2010-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -33,7 +33,8 @@ AC_DEFUN([gl_VISIBILITY], AC_CACHE_VAL([gl_cv_cc_vis_werror], [ gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" - AC_TRY_COMPILE([], [], + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], [gl_cv_cc_vis_werror=yes], [gl_cv_cc_vis_werror=no]) CFLAGS="$gl_save_CFLAGS"]) @@ -51,13 +52,15 @@ AC_DEFUN([gl_VISIBILITY], if test $gl_cv_cc_vis_werror = yes; then CFLAGS="$CFLAGS -Werror" fi - AC_TRY_COMPILE( - [extern __attribute__((__visibility__("hidden"))) int hiddenvar; - extern __attribute__((__visibility__("default"))) int exportedvar; - extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); - extern __attribute__((__visibility__("default"))) int exportedfunc (void); - void dummyfunc (void) {}], - [], + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void) {} + ]], + [[]])], [gl_cv_cc_visibility=yes], [gl_cv_cc_visibility=no]) CFLAGS="$gl_save_CFLAGS"]) diff --git a/tests/api.c b/tests/api.c index 102dc09a5..d476d06c5 100644 --- a/tests/api.c +++ b/tests/api.c @@ -42,7 +42,9 @@ static int test_CyaSSL_read_write(void); /* test function helpers */ static int test_method(CYASSL_METHOD *method, const char *name); +#ifdef OPENSSL_EXTRA static int test_method2(CYASSL_METHOD *method, const char *name); +#endif #ifndef NO_FILESYSTEM static int test_ucf(CYASSL_CTX *ctx, const char* file, int type, int cond, const char* name); @@ -120,6 +122,7 @@ int test_method(CYASSL_METHOD *method, const char *name) return TEST_SUCCESS; } +#ifdef OPENSSL_EXTRA int test_method2(CYASSL_METHOD *method, const char *name) { printf(testingFmt, name); @@ -132,6 +135,7 @@ int test_method2(CYASSL_METHOD *method, const char *name) printf(resultFmt, passed); return TEST_SUCCESS; } +#endif int test_CyaSSL_Method_Allocators(void) { @@ -657,7 +661,9 @@ void test_client_nofail(void* args) int msgSz = strlen(msg); int argc = ((func_args*)args)->argc; + (void)argc; char** argv = ((func_args*)args)->argv; + (void)argv; ((func_args*)args)->return_code = TEST_FAIL; method = CyaSSLv23_client_method(); diff --git a/tests/suites.c b/tests/suites.c index 6e59ed8af..6702a3de9 100644 --- a/tests/suites.c +++ b/tests/suites.c @@ -28,10 +28,8 @@ #define MAX_ARGS 40 #define MAX_COMMAND_SZ 240 - -void client_test(void*); -THREAD_RETURN CYASSL_THREAD server_test(void*); - +#include "examples/client/client.h" +#include "examples/server/server.h" static void execute_test_case(int svr_argc, char** svr_argv, int cli_argc, char** cli_argv) @@ -85,7 +83,7 @@ static void execute_test_case(int svr_argc, char** svr_argv, } -void test_harness(void* vargs) +static void test_harness(void* vargs) { func_args* args = (func_args*)vargs; char* script; diff --git a/tests/unit.c b/tests/unit.c index 1fbcc9cb5..f84fc1dc5 100644 --- a/tests/unit.c +++ b/tests/unit.c @@ -9,6 +9,8 @@ char* myoptarg = NULL; int main(int argc, char** argv) { + (void)argc; + (void)argv; int ret; printf("staring unit tests...\n"); @@ -86,4 +88,4 @@ void FreeTcpReady(tcp_ready* ready) pthread_mutex_destroy(&ready->mutex); pthread_cond_destroy(&ready->cond); #endif -} \ No newline at end of file +} diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index ebcb0c28f..091f512ae 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -27,18 +27,19 @@ #include #include +#include "ctaocrypt/test/test.h" + #ifdef SINGLE_THREADED #error testsuite needs threads to run, please run ctaocrypt/test, \ and the examples/ individually #endif -void ctaocrypt_test(void*); +#include "examples/echoclient/echoclient.h" +#include "examples/echoserver/echoserver.h" +#include "examples/server/server.h" +#include "ctaocrypt/test/test.h" void client_test(void*); -void echoclient_test(void*); - -THREAD_RETURN CYASSL_THREAD server_test(void*); -THREAD_RETURN CYASSL_THREAD echoserver_test(void*); void file_test(char* file, byte* hash);