summaryrefslogtreecommitdiff
path: root/patches/glibc/ports-2.12.1/170-localedef-fix-trampoline.patch
blob: 0e05844160c1818816a060587d42b6bd0f523833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh -e

# DP: Description: Fix localedef segfault when run under exec-shield,
#        PaX or similar. (#231438, #198099)
# DP: Dpatch Author: James Troup <james@nocrew.org>
# DP: Patch Author: (probably) Jakub Jelinek <jakub@redhat.com>
# DP: Upstream status: Unknown
# DP: Status Details: Unknown
# DP: Date: 2004-03-16

if [ $# -ne 2 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch) patch -d "$2" -f --no-backup-if-mismatch -p1 < $0;;
    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p1 < $0;;
    *)
	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
	exit 1
esac
exit 0

diff -durN glibc-2.12.1.orig/locale/programs/3level.h glibc-2.12.1/locale/programs/3level.h
--- glibc-2.12.1.orig/locale/programs/3level.h	2007-07-16 02:54:59.000000000 +0200
+++ glibc-2.12.1/locale/programs/3level.h	2009-11-13 00:49:56.000000000 +0100
@@ -203,6 +203,42 @@
 	}
     }
 }
+
+/* GCC ATM seems to do a poor job with pointers to nested functions passed
+   to inlined functions.  Help it a little bit with this hack.  */
+#define wchead_table_iterate(tp, fn) \
+do									      \
+  {									      \
+    struct wchead_table *t = (tp);					      \
+    uint32_t index1;							      \
+    for (index1 = 0; index1 < t->level1_size; index1++)			      \
+      {									      \
+	uint32_t lookup1 = t->level1[index1];				      \
+	if (lookup1 != ((uint32_t) ~0))					      \
+	  {								      \
+	    uint32_t lookup1_shifted = lookup1 << t->q;			      \
+	    uint32_t index2;						      \
+	    for (index2 = 0; index2 < (1 << t->q); index2++)		      \
+	      {								      \
+		uint32_t lookup2 = t->level2[index2 + lookup1_shifted];	      \
+		if (lookup2 != ((uint32_t) ~0))				      \
+		  {							      \
+		    uint32_t lookup2_shifted = lookup2 << t->p;		      \
+		    uint32_t index3;					      \
+		    for (index3 = 0; index3 < (1 << t->p); index3++)	      \
+		      {							      \
+			struct element_t *lookup3			      \
+			  = t->level3[index3 + lookup2_shifted];	      \
+			if (lookup3 != NULL)				      \
+			  fn ((((index1 << t->q) + index2) << t->p) + index3, \
+			      lookup3);					      \
+		      }							      \
+		  }							      \
+	      }								      \
+	  }								      \
+      }									      \
+  } while (0)
+
 #endif
 
 #ifndef NO_FINALIZE