Ticket #51779: patch-gregorio-alignof.diff

File patch-gregorio-alignof.diff, 10.8 KB (added by mojca (Mojca Miklavec), 8 years ago)

Backporting upstream patch for alignof for gregorio

  • Portfile

     
    7676
    7777# patches related to changes in install paths
    7878patchfiles-append  patch-texk_chktex_Makefile.in.diff \
     79                   patch-texk_gregorio.diff \
    7980                   patch-texk_kpathsea_Makefile.in.diff \
    8081                   patch-texk_tex4htk_Makefile.in.diff \
    8182                   patch-texk_texlive_linked_scripts_Makefile.in.diff \
  • files/patch-texk_gregorio.diff

     
     1https://trac.macports.org/ticket/51779
     2https://github.com/gregorio-project/gregorio/pull/1186
     3http://tug.org/svn/texlive?view=revision&revision=41705
     4
     5--- texk/gregorio/config_.h.in.orig
     6+++ texk/gregorio/config_.h.in
     7@@ -3,6 +3,9 @@
     8 /* Define if building universal (internal helper macro) */
     9 #undef AC_APPLE_UNIVERSAL_BUILD
     10 
     11+/* The normal alignment of `uint32_t', in bytes. */
     12+#undef ALIGNOF_UINT32_T
     13+
     14 /* Define to 1 if the `closedir' function returns void instead of `int'. */
     15 #undef CLOSEDIR_VOID
     16 
     17--- texk/gregorio/configure.orig
     18+++ texk/gregorio/configure
     19@@ -2186,6 +2186,189 @@ $as_echo "$ac_res" >&6; }
     20   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
     21 
     22 } # ac_fn_c_check_member
     23+
     24+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
     25+# --------------------------------------------
     26+# Tries to find the compile-time value of EXPR in a program that includes
     27+# INCLUDES, setting VAR accordingly. Returns whether the value could be
     28+# computed
     29+ac_fn_c_compute_int ()
     30+{
     31+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
     32+  if test "$cross_compiling" = yes; then
     33+    # Depending upon the size, compute the lo and hi bounds.
     34+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     35+/* end confdefs.h.  */
     36+$4
     37+int
     38+main ()
     39+{
     40+static int test_array [1 - 2 * !(($2) >= 0)];
     41+test_array [0] = 0;
     42+return test_array [0];
     43+
     44+  ;
     45+  return 0;
     46+}
     47+_ACEOF
     48+if ac_fn_c_try_compile "$LINENO"; then :
     49+  ac_lo=0 ac_mid=0
     50+  while :; do
     51+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     52+/* end confdefs.h.  */
     53+$4
     54+int
     55+main ()
     56+{
     57+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
     58+test_array [0] = 0;
     59+return test_array [0];
     60+
     61+  ;
     62+  return 0;
     63+}
     64+_ACEOF
     65+if ac_fn_c_try_compile "$LINENO"; then :
     66+  ac_hi=$ac_mid; break
     67+else
     68+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
     69+                       if test $ac_lo -le $ac_mid; then
     70+                         ac_lo= ac_hi=
     71+                         break
     72+                       fi
     73+                       as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
     74+fi
     75+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     76+  done
     77+else
     78+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     79+/* end confdefs.h.  */
     80+$4
     81+int
     82+main ()
     83+{
     84+static int test_array [1 - 2 * !(($2) < 0)];
     85+test_array [0] = 0;
     86+return test_array [0];
     87+
     88+  ;
     89+  return 0;
     90+}
     91+_ACEOF
     92+if ac_fn_c_try_compile "$LINENO"; then :
     93+  ac_hi=-1 ac_mid=-1
     94+  while :; do
     95+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     96+/* end confdefs.h.  */
     97+$4
     98+int
     99+main ()
     100+{
     101+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
     102+test_array [0] = 0;
     103+return test_array [0];
     104+
     105+  ;
     106+  return 0;
     107+}
     108+_ACEOF
     109+if ac_fn_c_try_compile "$LINENO"; then :
     110+  ac_lo=$ac_mid; break
     111+else
     112+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
     113+                       if test $ac_mid -le $ac_hi; then
     114+                         ac_lo= ac_hi=
     115+                         break
     116+                       fi
     117+                       as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
     118+fi
     119+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     120+  done
     121+else
     122+  ac_lo= ac_hi=
     123+fi
     124+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     125+fi
     126+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     127+# Binary search between lo and hi bounds.
     128+while test "x$ac_lo" != "x$ac_hi"; do
     129+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
     130+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     131+/* end confdefs.h.  */
     132+$4
     133+int
     134+main ()
     135+{
     136+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
     137+test_array [0] = 0;
     138+return test_array [0];
     139+
     140+  ;
     141+  return 0;
     142+}
     143+_ACEOF
     144+if ac_fn_c_try_compile "$LINENO"; then :
     145+  ac_hi=$ac_mid
     146+else
     147+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
     148+fi
     149+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     150+done
     151+case $ac_lo in #((
     152+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
     153+'') ac_retval=1 ;;
     154+esac
     155+  else
     156+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     157+/* end confdefs.h.  */
     158+$4
     159+static long int longval () { return $2; }
     160+static unsigned long int ulongval () { return $2; }
     161+#include <stdio.h>
     162+#include <stdlib.h>
     163+int
     164+main ()
     165+{
     166+
     167+  FILE *f = fopen ("conftest.val", "w");
     168+  if (! f)
     169+    return 1;
     170+  if (($2) < 0)
     171+    {
     172+      long int i = longval ();
     173+      if (i != ($2))
     174+       return 1;
     175+      fprintf (f, "%ld", i);
     176+    }
     177+  else
     178+    {
     179+      unsigned long int i = ulongval ();
     180+      if (i != ($2))
     181+       return 1;
     182+      fprintf (f, "%lu", i);
     183+    }
     184+  /* Do not output a trailing newline, as this causes \r\n confusion
     185+     on some platforms.  */
     186+  return ferror (f) || fclose (f) != 0;
     187+
     188+  ;
     189+  return 0;
     190+}
     191+_ACEOF
     192+if ac_fn_c_try_run "$LINENO"; then :
     193+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
     194+else
     195+  ac_retval=1
     196+fi
     197+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
     198+  conftest.$ac_objext conftest.beam conftest.$ac_ext
     199+rm -f conftest.val
     200+
     201+  fi
     202+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
     203+  as_fn_set_status $ac_retval
     204+
     205+} # ac_fn_c_compute_int
     206 cat >config.log <<_ACEOF
     207 This file contains any messages produced by compilers while
     208 running configure, to aid debugging if configure makes a mistake.
     209@@ -12707,7 +12890,7 @@ else
     210     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     211     since some C++ compilers masquerading as C compilers
     212     incorrectly reject 9223372036854775807.  */
     213-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
     214+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
     215   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
     216                       && LARGE_OFF_T % 2147483647 == 1)
     217                      ? 1 : -1];
     218@@ -12753,7 +12936,7 @@ else
     219     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     220     since some C++ compilers masquerading as C compilers
     221     incorrectly reject 9223372036854775807.  */
     222-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
     223+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
     224   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
     225                       && LARGE_OFF_T % 2147483647 == 1)
     226                      ? 1 : -1];
     227@@ -12777,7 +12960,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     228     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     229     since some C++ compilers masquerading as C compilers
     230     incorrectly reject 9223372036854775807.  */
     231-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
     232+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
     233   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
     234                       && LARGE_OFF_T % 2147483647 == 1)
     235                      ? 1 : -1];
     236@@ -12822,7 +13005,7 @@ else
     237     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     238     since some C++ compilers masquerading as C compilers
     239     incorrectly reject 9223372036854775807.  */
     240-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
     241+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
     242   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
     243                       && LARGE_OFF_T % 2147483647 == 1)
     244                      ? 1 : -1];
     245@@ -12846,7 +13029,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     246     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     247     since some C++ compilers masquerading as C compilers
     248     incorrectly reject 9223372036854775807.  */
     249-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
     250+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
     251   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
     252                       && LARGE_OFF_T % 2147483647 == 1)
     253                      ? 1 : -1];
     254@@ -13623,6 +13806,42 @@ fi
     255 done
     256 
     257 
     258+# The cast to long int works around a bug in the HP C Compiler,
     259+# see AC_CHECK_SIZEOF for more information.
     260+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of uint32_t" >&5
     261+$as_echo_n "checking alignment of uint32_t... " >&6; }
     262+if ${ac_cv_alignof_uint32_t+:} false; then :
     263+  $as_echo_n "(cached) " >&6
     264+else
     265+  if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_uint32_t"        "$ac_includes_default
     266+#ifndef offsetof
     267+# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
     268+#endif
     269+typedef struct { char x; uint32_t y; } ac__type_alignof_;"; then :
     270+
     271+else
     272+  if test "$ac_cv_type_uint32_t" = yes; then
     273+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
     274+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
     275+as_fn_error 77 "cannot compute alignment of uint32_t
     276+See \`config.log' for more details" "$LINENO" 5; }
     277+   else
     278+     ac_cv_alignof_uint32_t=0
     279+   fi
     280+fi
     281+
     282+fi
     283+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_uint32_t" >&5
     284+$as_echo "$ac_cv_alignof_uint32_t" >&6; }
     285+
     286+
     287+
     288+cat >>confdefs.h <<_ACEOF
     289+#define ALIGNOF_UINT32_T $ac_cv_alignof_uint32_t
     290+_ACEOF
     291+
     292+
     293+
     294  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
     295 $as_echo_n "checking whether byte ordering is bigendian... " >&6; }
     296 if ${ac_cv_c_bigendian+:} false; then :
     297# --- texk/gregorio/configure.ac.orig
     298# +++ texk/gregorio/configure.ac
     299# @@ -97,6 +97,8 @@ dnl Checks for header files.
     300#  AC_CHECK_HEADERS([stdint.h])
     301#  AC_CHECK_HEADERS([stdalign.h])
     302
     303# +AC_CHECK_ALIGNOF(uint32_t)
     304# +
     305#  AC_C_BIGENDIAN
     306
     307#  AC_SUBST([GREGORIO_TREE], [gregorio-src])
     308--- texk/gregorio/gregorio-src/src/sha1.c.orig
     309+++ texk/gregorio/gregorio-src/src/sha1.c
     310@@ -37,15 +37,6 @@
     311 #include <stdlib.h>
     312 #include <string.h>
     313 
     314-#ifdef HAVE_STDALIGN_H
     315-#include <stdalign.h>
     316-#ifdef __clang__
     317-#pragma clang diagnostic ignored "-Wc11-extensions"
     318-#endif
     319-#else
     320-#define alignof(x) sizeof(x)
     321-#endif
     322-
     323 #ifdef WORDS_BIGENDIAN
     324 #define SWAP(n) (n)
     325 #else
     326@@ -167,7 +158,7 @@ void sha1_process_bytes(const void *buffer, size_t len, struct sha1_ctx *ctx)
     327     if (len >= 64) {
     328         /* architecture and data-specific; LCOV_EXCL_START */
     329 #if !_STRING_ARCH_unaligned
     330-#define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
     331+#define UNALIGNED_P(p) ((uintptr_t) (p) % ALIGNOF_UINT32_T != 0)
     332         if (UNALIGNED_P(buffer)) {
     333             while (len > 64) {
     334                 sha1_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx);