patches/glibc/ports-2.12.1/170-localedef-fix-trampoline.patch
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Wed Dec 14 16:55:22 2011 +0100 (2011-12-14)
branch1.13
changeset 2848 1ff89596dab0
permissions -rw-r--r--
libc/eglibc: fix localedef 2.14 build

The localedef of eglibc 2.14 requires NOT_IN_libc to be defined in order to
compile intl/l10nflist.c.

This is because localedef is built separately from eglibc and uses some parts of
eglibc that don't compile in standalone without this preprocessor definition.

This fixes the following error:

[ALL ] gcc -g -O2 -DNO_SYSCONF -DNO_UNCOMPRESS
-DLOCALE_PATH='"/usr/lib/locale:/usr/share/i18n"'
-DLOCALEDIR='"/usr/lib/locale"' -DLOCALE_ALIAS_PATH='"/usr/share/locale"'
-DCHARMAP_PATH='"/usr/share/i18n/charmaps"'
-DREPERTOIREMAP_PATH='"/usr/share/i18n/repertoiremaps"'
-DLOCSRCDIR='"/usr/share/i18n/locales"' -Iglibc/locale/programs -Iglibc/locale
-I/<snip>/.build/src/eglibc-localedef-2_14/include
-I/<snip>/.build/src/eglibc-localedef-2_14 -I.
-include /<snip>/.build/src/eglibc-localedef-2_14/include/always.h -Wall
-Wno-format -c -o locarchive.o glibc/locale/programs/locarchive.c
[ALL ] glibc/locale/programs/locarchive.c: In function 'enlarge_archive':
[ALL ] glibc/locale/programs/locarchive.c:303:21: warning: variable
'oldlocrectab' set but not used [-Wunused-but-set-variable]
[ALL ] In file included from glibc/locale/programs/locarchive.c:651:0:
[ALL ] glibc/locale/programs/../../intl/l10nflist.c: In function
'_nl_normalize_codeset':
[ERROR] glibc/locale/programs/../../intl/l10nflist.c:342:9: error:
'_nl_C_locobj_ptr' undeclared (first use in this function)
[ALL ] glibc/locale/programs/../../intl/l10nflist.c:342:9: note: each
undeclared identifier is reported only once for each function it appears in
[ALL ] glibc/locale/programs/locarchive.c: In function
'add_locales_to_archive':
[ALL ] glibc/locale/programs/locarchive.c:1450:7: warning: passing argument
1 of '__xpg_basename' discards 'const' qualifier from pointer target type
[enabled by default]
[ALL ] /usr/include/libgen.h:35:14: note: expected 'char *' but argument is
of type 'const char *'
[ERROR] make[1]: *** [locarchive.o] Error 1

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
(transplanted from 4cd9134739b594451794cf61a6e1b137422cdafd)
yann@2437
     1
#! /bin/sh -e
yann@2437
     2
yann@2437
     3
# DP: Description: Fix localedef segfault when run under exec-shield,
yann@2437
     4
#        PaX or similar. (#231438, #198099)
yann@2437
     5
# DP: Dpatch Author: James Troup <james@nocrew.org>
yann@2437
     6
# DP: Patch Author: (probably) Jakub Jelinek <jakub@redhat.com>
yann@2437
     7
# DP: Upstream status: Unknown
yann@2437
     8
# DP: Status Details: Unknown
yann@2437
     9
# DP: Date: 2004-03-16
yann@2437
    10
yann@2437
    11
if [ $# -ne 2 ]; then
yann@2437
    12
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
yann@2437
    13
    exit 1
yann@2437
    14
fi
yann@2437
    15
case "$1" in
yann@2437
    16
    -patch) patch -d "$2" -f --no-backup-if-mismatch -p1 < $0;;
yann@2437
    17
    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p1 < $0;;
yann@2437
    18
    *)
yann@2437
    19
	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
yann@2437
    20
	exit 1
yann@2437
    21
esac
yann@2437
    22
exit 0
yann@2437
    23
yann@2437
    24
diff -durN glibc-2.12.1.orig/locale/programs/3level.h glibc-2.12.1/locale/programs/3level.h
yann@2437
    25
--- glibc-2.12.1.orig/locale/programs/3level.h	2007-07-16 02:54:59.000000000 +0200
yann@2437
    26
+++ glibc-2.12.1/locale/programs/3level.h	2009-11-13 00:49:56.000000000 +0100
yann@2437
    27
@@ -203,6 +203,42 @@
yann@2437
    28
 	}
yann@2437
    29
     }
yann@2437
    30
 }
yann@2437
    31
+
yann@2437
    32
+/* GCC ATM seems to do a poor job with pointers to nested functions passed
yann@2437
    33
+   to inlined functions.  Help it a little bit with this hack.  */
yann@2437
    34
+#define wchead_table_iterate(tp, fn) \
yann@2437
    35
+do									      \
yann@2437
    36
+  {									      \
yann@2437
    37
+    struct wchead_table *t = (tp);					      \
yann@2437
    38
+    uint32_t index1;							      \
yann@2437
    39
+    for (index1 = 0; index1 < t->level1_size; index1++)			      \
yann@2437
    40
+      {									      \
yann@2437
    41
+	uint32_t lookup1 = t->level1[index1];				      \
yann@2437
    42
+	if (lookup1 != ((uint32_t) ~0))					      \
yann@2437
    43
+	  {								      \
yann@2437
    44
+	    uint32_t lookup1_shifted = lookup1 << t->q;			      \
yann@2437
    45
+	    uint32_t index2;						      \
yann@2437
    46
+	    for (index2 = 0; index2 < (1 << t->q); index2++)		      \
yann@2437
    47
+	      {								      \
yann@2437
    48
+		uint32_t lookup2 = t->level2[index2 + lookup1_shifted];	      \
yann@2437
    49
+		if (lookup2 != ((uint32_t) ~0))				      \
yann@2437
    50
+		  {							      \
yann@2437
    51
+		    uint32_t lookup2_shifted = lookup2 << t->p;		      \
yann@2437
    52
+		    uint32_t index3;					      \
yann@2437
    53
+		    for (index3 = 0; index3 < (1 << t->p); index3++)	      \
yann@2437
    54
+		      {							      \
yann@2437
    55
+			struct element_t *lookup3			      \
yann@2437
    56
+			  = t->level3[index3 + lookup2_shifted];	      \
yann@2437
    57
+			if (lookup3 != NULL)				      \
yann@2437
    58
+			  fn ((((index1 << t->q) + index2) << t->p) + index3, \
yann@2437
    59
+			      lookup3);					      \
yann@2437
    60
+		      }							      \
yann@2437
    61
+		  }							      \
yann@2437
    62
+	      }								      \
yann@2437
    63
+	  }								      \
yann@2437
    64
+      }									      \
yann@2437
    65
+  } while (0)
yann@2437
    66
+
yann@2437
    67
 #endif
yann@2437
    68
 
yann@2437
    69
 #ifndef NO_FINALIZE