texlive[41705] Build/source/texk/gregorio: alignof handling

commits+karl at tug.org commits+karl at tug.org
Fri Jul 15 00:47:17 CEST 2016


Revision: 41705
          http://tug.org/svn/texlive?view=revision&revision=41705
Author:   karl
Date:     2016-07-15 00:47:17 +0200 (Fri, 15 Jul 2016)
Log Message:
-----------
alignof handling

Modified Paths:
--------------
    trunk/Build/source/texk/gregorio/ChangeLog
    trunk/Build/source/texk/gregorio/config_.h.in
    trunk/Build/source/texk/gregorio/configure
    trunk/Build/source/texk/gregorio/configure.ac
    trunk/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog
    trunk/Build/source/texk/gregorio/gregorio-src/src/sha1.c

Added Paths:
-----------
    trunk/Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof

Modified: trunk/Build/source/texk/gregorio/ChangeLog
===================================================================
--- trunk/Build/source/texk/gregorio/ChangeLog	2016-07-14 22:33:33 UTC (rev 41704)
+++ trunk/Build/source/texk/gregorio/ChangeLog	2016-07-14 22:47:17 UTC (rev 41705)
@@ -1,3 +1,10 @@
+2016-07-15  Karl Berry  <karl at tug.org>
+
+	* 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  <kakuto at fuk.kindai.ac.jp>
 
 	Import gregorio-4.1.4.

Modified: trunk/Build/source/texk/gregorio/config_.h.in
===================================================================
--- trunk/Build/source/texk/gregorio/config_.h.in	2016-07-14 22:33:33 UTC (rev 41704)
+++ trunk/Build/source/texk/gregorio/config_.h.in	2016-07-14 22:47:17 UTC (rev 41705)
@@ -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
 

Modified: trunk/Build/source/texk/gregorio/configure
===================================================================
--- trunk/Build/source/texk/gregorio/configure	2016-07-14 22:33:33 UTC (rev 41704)
+++ trunk/Build/source/texk/gregorio/configure	2016-07-14 22:47:17 UTC (rev 41705)
@@ -2174,6 +2174,189 @@
   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 <stdio.h>
+#include <stdlib.h>
+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 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
 cat >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 @@
 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 :

Modified: trunk/Build/source/texk/gregorio/configure.ac
===================================================================
--- trunk/Build/source/texk/gregorio/configure.ac	2016-07-14 22:33:33 UTC (rev 41704)
+++ trunk/Build/source/texk/gregorio/configure.ac	2016-07-14 22:47:17 UTC (rev 41705)
@@ -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])

Modified: trunk/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog
===================================================================
--- trunk/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog	2016-07-14 22:33:33 UTC (rev 41704)
+++ trunk/Build/source/texk/gregorio/gregorio-PATCHES/ChangeLog	2016-07-14 22:47:17 UTC (rev 41705)
@@ -1,3 +1,7 @@
+2016-07-15  Karl Berry  <karl at tug.org>
+
+	* patch-04-alignof: add.
+
 2016-05-30  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 
 	Import gregorio-4.1.4.

Added: trunk/Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof
===================================================================
--- trunk/Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof	                        (rev 0)
+++ trunk/Build/source/texk/gregorio/gregorio-PATCHES/patch-04-alignof	2016-07-14 22:47:17 UTC (rev 41705)
@@ -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 <stdlib.h>
+ #include <string.h>
+ 
+-#ifdef HAVE_STDALIGN_H
+-#include <stdalign.h>
+-#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);

Modified: trunk/Build/source/texk/gregorio/gregorio-src/src/sha1.c
===================================================================
--- trunk/Build/source/texk/gregorio/gregorio-src/src/sha1.c	2016-07-14 22:33:33 UTC (rev 41704)
+++ trunk/Build/source/texk/gregorio/gregorio-src/src/sha1.c	2016-07-14 22:47:17 UTC (rev 41705)
@@ -37,15 +37,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_STDALIGN_H
-#include <stdalign.h>
-#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);



More information about the tex-live-commits mailing list