From a01c0e89bf336b165cf3f981a232ba2f09341764 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 14 Jul 2016 22:47:17 +0000 Subject: alignof handling git-svn-id: svn://tug.org/texlive/trunk@41705 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/gregorio/ChangeLog | 7 + Build/source/texk/gregorio/config_.h.in | 3 + Build/source/texk/gregorio/configure | 219 +++++++++++++++++++++ Build/source/texk/gregorio/configure.ac | 2 + .../texk/gregorio/gregorio-PATCHES/ChangeLog | 4 + .../gregorio/gregorio-PATCHES/patch-04-alignof | 42 ++++ Build/source/texk/gregorio/gregorio-src/src/sha1.c | 11 +- 7 files changed, 278 insertions(+), 10 deletions(-) create mode 100644 Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof (limited to 'Build/source') diff --git a/Build/source/texk/gregorio/ChangeLog b/Build/source/texk/gregorio/ChangeLog index d7e47b960da..dbb97499c1e 100644 --- a/Build/source/texk/gregorio/ChangeLog +++ b/Build/source/texk/gregorio/ChangeLog @@ -1,3 +1,10 @@ +2016-07-15 Karl Berry + + * configure.ac (AC_CHECK_ALIGNOF): add. + * gregorio-src/src/sha1.c (UNALIGNED_P): handle differently. + For Mojca, 14 Jul 2016 13:35:25, + https://github.com/gregorio-project/gregorio/pull/1186. + 2016-05-30 Akira Kakuto Import gregorio-4.1.4. diff --git a/Build/source/texk/gregorio/config_.h.in b/Build/source/texk/gregorio/config_.h.in index ff001294621..3f8ed63e3b1 100644 --- a/Build/source/texk/gregorio/config_.h.in +++ b/Build/source/texk/gregorio/config_.h.in @@ -3,6 +3,9 @@ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD +/* The normal alignment of `uint32_t', in bytes. */ +#undef ALIGNOF_UINT32_T + /* Define to 1 if the `closedir' function returns void instead of `int'. */ #undef CLOSEDIR_VOID diff --git a/Build/source/texk/gregorio/configure b/Build/source/texk/gregorio/configure index 61f3ff9c2b3..7ab4fa3d9cc 100755 --- a/Build/source/texk/gregorio/configure +++ b/Build/source/texk/gregorio/configure @@ -2174,6 +2174,189 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -13611,6 +13794,42 @@ fi done +# The cast to long int works around a bug in the HP C Compiler, +# see AC_CHECK_SIZEOF for more information. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of uint32_t" >&5 +$as_echo_n "checking alignment of uint32_t... " >&6; } +if ${ac_cv_alignof_uint32_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_uint32_t" "$ac_includes_default +#ifndef offsetof +# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) +#endif +typedef struct { char x; uint32_t y; } ac__type_alignof_;"; then : + +else + if test "$ac_cv_type_uint32_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute alignment of uint32_t +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_alignof_uint32_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_uint32_t" >&5 +$as_echo "$ac_cv_alignof_uint32_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define ALIGNOF_UINT32_T $ac_cv_alignof_uint32_t +_ACEOF + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : diff --git a/Build/source/texk/gregorio/configure.ac b/Build/source/texk/gregorio/configure.ac index ca5c099e1ee..587b2b12795 100644 --- a/Build/source/texk/gregorio/configure.ac +++ b/Build/source/texk/gregorio/configure.ac @@ -97,6 +97,8 @@ dnl Checks for header files. AC_CHECK_HEADERS([stdint.h]) AC_CHECK_HEADERS([stdalign.h]) +AC_CHECK_ALIGNOF(uint32_t) + AC_C_BIGENDIAN AC_SUBST([GREGORIO_TREE], [gregorio-src]) diff --git a/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog b/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog index 32d2a875654..75e04c1382f 100644 --- a/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog +++ b/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog @@ -1,3 +1,7 @@ +2016-07-15 Karl Berry + + * patch-04-alignof: add. + 2016-05-30 Akira Kakuto Import gregorio-4.1.4. diff --git a/Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof b/Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof new file mode 100644 index 00000000000..d1a1fe86dea --- /dev/null +++ b/Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof @@ -0,0 +1,42 @@ +Index: configure.ac +=================================================================== +--- configure.ac (revision 41690) ++++ configure.ac (working copy) +@@ -97,6 +97,8 @@ + AC_CHECK_HEADERS([stdint.h]) + AC_CHECK_HEADERS([stdalign.h]) + ++AC_CHECK_ALIGNOF(uint32_t) ++ + AC_C_BIGENDIAN + + AC_SUBST([GREGORIO_TREE], [gregorio-src]) +Index: gregorio-src/src/sha1.c +=================================================================== +--- gregorio-src/src/sha1.c (revision 41690) ++++ gregorio-src/src/sha1.c (working copy) +@@ -37,15 +37,6 @@ + #include + #include + +-#ifdef HAVE_STDALIGN_H +-#include +-#ifdef __clang__ +-#pragma clang diagnostic ignored "-Wc11-extensions" +-#endif +-#else +-#define alignof(x) sizeof(x) +-#endif +- + #ifdef WORDS_BIGENDIAN + #define SWAP(n) (n) + #else +@@ -167,7 +158,7 @@ + if (len >= 64) { + /* architecture and data-specific; LCOV_EXCL_START */ + #if !_STRING_ARCH_unaligned +-#define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) ++#define UNALIGNED_P(p) ((uintptr_t) (p) % ALIGNOF_UINT32_T != 0) + if (UNALIGNED_P(buffer)) { + while (len > 64) { + sha1_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx); diff --git a/Build/source/texk/gregorio/gregorio-src/src/sha1.c b/Build/source/texk/gregorio/gregorio-src/src/sha1.c index 15433d9076b..9ebd6d28c8a 100644 --- a/Build/source/texk/gregorio/gregorio-src/src/sha1.c +++ b/Build/source/texk/gregorio/gregorio-src/src/sha1.c @@ -37,15 +37,6 @@ #include #include -#ifdef HAVE_STDALIGN_H -#include -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wc11-extensions" -#endif -#else -#define alignof(x) sizeof(x) -#endif - #ifdef WORDS_BIGENDIAN #define SWAP(n) (n) #else @@ -167,7 +158,7 @@ void sha1_process_bytes(const void *buffer, size_t len, struct sha1_ctx *ctx) if (len >= 64) { /* architecture and data-specific; LCOV_EXCL_START */ #if !_STRING_ARCH_unaligned -#define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) +#define UNALIGNED_P(p) ((uintptr_t) (p) % ALIGNOF_UINT32_T != 0) if (UNALIGNED_P(buffer)) { while (len > 64) { sha1_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx); -- cgit v1.2.3