summaryrefslogtreecommitdiffstats
path: root/recipes/glibc/glibc-2.5/nios2-ld-collate.patch
blob: abdc7d96679f67f967386bb13527b7b2f8e75f15 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
*** glibc-2.5/./locale/programs/ld-collate.c-	2006-09-21 05:57:30.000000000 +0200
--- glibc-2.5/./locale/programs/ld-collate.c	2010-06-01 10:00:50.000000000 +0200
***************
*** 1934,1945 ****
    return retval | ((elem->section->ruleidx & 0x7f) << 24);
  }
  
  
  void
  collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
  		const char *output_path)
  {
-   struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
    const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE);
    struct iovec iov[2 + nelems];
    struct locale_file data;
--- 1934,2066 ----
    return retval | ((elem->section->ruleidx & 0x7f) << 24);
  }
  
+ /* If localedef is every threaded, these would need to be __thread var.  */
+ struct obstack weightpool;
+ struct obstack extrapool;
+ struct obstack indirectpool;
+ struct collidx_table tablewc;
+ struct locale_collate_t *collate;
+ 
+ static void
+ add_to_tablewc (uint32_t ch, struct element_t *runp)
+ {
+   if (runp->wcnext == NULL && runp->nwcs == 1)
+   {
+     int32_t weigthidx = output_weightwc (&weightpool, collate, runp);
+     collidx_table_add (&tablewc, ch, weigthidx);
+   }
+   else
+   {
+     /* As for the singlebyte table, we recognize sequences and
+        compress them.  */
+     struct element_t *lastp;
+ 
+     collidx_table_add (&tablewc, ch,
+ 		       -(obstack_object_size (&extrapool) / sizeof (uint32_t)));
+ 
+     do
+       {
+ 	/* Store the current index in the weight table.  We know that
+ 	   the current position in the `extrapool' is aligned on a
+ 	   32-bit address.  */
+ 	int32_t weightidx;
+ 	int added;
+ 
+ 	/* Find out wether this is a single entry or we have more than
+ 	   one consecutive entry.  */
+ 	if (runp->wcnext != NULL
+ 	    && runp->nwcs == runp->wcnext->nwcs
+ 	    && wmemcmp ((wchar_t *) runp->wcs,
+ 			(wchar_t *)runp->wcnext->wcs,
+ 			runp->nwcs - 1) == 0
+ 	    && (runp->wcs[runp->nwcs - 1]
+ 		== runp->wcnext->wcs[runp->nwcs - 1] + 1))
+ 	  {
+ 	    int i;
+ 	    struct element_t *series_startp = runp;
+ 	    struct element_t *curp;
+ 
+ 	    /* Now add first the initial byte sequence.  */
+ 	    added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t);
+ 	    if (sizeof (int32_t) == sizeof (int))
+ 	      obstack_make_room (&extrapool, added);
+ 
+ 	    /* More than one consecutive entry.  We mark this by having
+ 	       a negative index into the indirect table.  */
+ 	    obstack_int32_grow_fast (&extrapool,
+ 				     -(obstack_object_size (&indirectpool)
+ 				       / sizeof (int32_t)));
+ 	    obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
+ 
+ 	    do
+ 	      runp = runp->wcnext;
+ 	    while (runp->wcnext != NULL
+ 		   && runp->nwcs == runp->wcnext->nwcs
+ 		   && wmemcmp ((wchar_t *) runp->wcs,
+ 			       (wchar_t *)runp->wcnext->wcs,
+ 			       runp->nwcs - 1) == 0
+ 		   && (runp->wcs[runp->nwcs - 1]
+ 		       == runp->wcnext->wcs[runp->nwcs - 1] + 1));
+ 
+ 	    /* Now walk backward from here to the beginning.  */
+ 	    curp = runp;
+ 
+ 	    for (i = 1; i < runp->nwcs; ++i)
+ 	      obstack_int32_grow_fast (&extrapool, curp->wcs[i]);
+ 
+ 	    /* Now find the end of the consecutive sequence and
+ 	       add all the indeces in the indirect pool.  */
+ 	    do
+ 	      {
+ 		weightidx = output_weightwc (&weightpool, collate,
+ 					     curp);
+ 		obstack_int32_grow (&indirectpool, weightidx);
+ 
+ 		curp = curp->wclast;
+ 	      }
+ 	    while (curp != series_startp);
+ 
+ 	    /* Add the final weight.  */
+ 	    weightidx = output_weightwc (&weightpool, collate, curp);
+ 	    obstack_int32_grow (&indirectpool, weightidx);
+ 
+ 	    /* And add the end byte sequence.  Without length this
+ 	       time.  */
+ 	    for (i = 1; i < curp->nwcs; ++i)
+ 	      obstack_int32_grow (&extrapool, curp->wcs[i]);
+ 	  }
+ 	else
+ 	  {
+ 	    /* A single entry.  Simply add the index and the length and
+ 	       string (except for the first character which is already
+ 	       tested for).  */
+ 	    int i;
+ 
+ 	    /* Output the weight info.  */
+ 	    weightidx = output_weightwc (&weightpool, collate, runp);
+ 
+ 	    added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t);
+ 	    if (sizeof (int) == sizeof (int32_t))
+ 	      obstack_make_room (&extrapool, added);
+ 
+ 	    obstack_int32_grow_fast (&extrapool, weightidx);
+ 	    obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
+ 	    for (i = 1; i < runp->nwcs; ++i)
+ 	      obstack_int32_grow_fast (&extrapool, runp->wcs[i]);
+ 	  }
+ 
+ 	/* Next entry.  */
+ 	lastp = runp;
+ 	runp = runp->wcnext;
+       }
+     while (runp != NULL);
+   }
+ }
  
  void
  collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
  		const char *output_path)
  {
    const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE);
    struct iovec iov[2 + nelems];
    struct locale_file data;
***************
*** 1947,1962 ****
    size_t cnt;
    size_t ch;
    int32_t tablemb[256];
-   struct obstack weightpool;
-   struct obstack extrapool;
-   struct obstack indirectpool;
    struct section_list *sect;
-   struct collidx_table tablewc;
    uint32_t elem_size;
    uint32_t *elem_table;
    int i;
    struct element_t *runp;
  
    data.magic = LIMAGIC (LC_COLLATE);
    data.n = nelems;
    iov[0].iov_base = (void *) &data;
--- 2068,2080 ----
    size_t cnt;
    size_t ch;
    int32_t tablemb[256];
    struct section_list *sect;
    uint32_t elem_size;
    uint32_t *elem_table;
    int i;
    struct element_t *runp;
  
+   collate = locale->categories[LC_COLLATE].collate;
    data.magic = LIMAGIC (LC_COLLATE);
    data.n = nelems;
    iov[0].iov_base = (void *) &data;
***************
*** 2292,2414 ****
       the table.  In case we have more than one sequence starting with
       the same byte we have to use extra indirection.  */
    {
-     auto void add_to_tablewc (uint32_t ch, struct element_t *runp);
- 
-     void add_to_tablewc (uint32_t ch, struct element_t *runp)
-       {
- 	if (runp->wcnext == NULL && runp->nwcs == 1)
- 	  {
- 	    int32_t weigthidx = output_weightwc (&weightpool, collate, runp);
- 	    collidx_table_add (&tablewc, ch, weigthidx);
- 	  }
- 	else
- 	  {
- 	    /* As for the singlebyte table, we recognize sequences and
- 	       compress them.  */
- 	    struct element_t *lastp;
- 
- 	    collidx_table_add (&tablewc, ch,
- 			       -(obstack_object_size (&extrapool) / sizeof (uint32_t)));
- 
- 	    do
- 	      {
- 		/* Store the current index in the weight table.  We know that
- 		   the current position in the `extrapool' is aligned on a
- 		   32-bit address.  */
- 		int32_t weightidx;
- 		int added;
- 
- 		/* Find out wether this is a single entry or we have more than
- 		   one consecutive entry.  */
- 		if (runp->wcnext != NULL
- 		    && runp->nwcs == runp->wcnext->nwcs
- 		    && wmemcmp ((wchar_t *) runp->wcs,
- 				(wchar_t *)runp->wcnext->wcs,
- 				runp->nwcs - 1) == 0
- 		    && (runp->wcs[runp->nwcs - 1]
- 			== runp->wcnext->wcs[runp->nwcs - 1] + 1))
- 		  {
- 		    int i;
- 		    struct element_t *series_startp = runp;
- 		    struct element_t *curp;
- 
- 		    /* Now add first the initial byte sequence.  */
- 		    added = (1 + 1 + 2 * (runp->nwcs - 1)) * sizeof (int32_t);
- 		    if (sizeof (int32_t) == sizeof (int))
- 		      obstack_make_room (&extrapool, added);
- 
- 		    /* More than one consecutive entry.  We mark this by having
- 		       a negative index into the indirect table.  */
- 		    obstack_int32_grow_fast (&extrapool,
- 					     -(obstack_object_size (&indirectpool)
- 					       / sizeof (int32_t)));
- 		    obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
- 
- 		    do
- 		      runp = runp->wcnext;
- 		    while (runp->wcnext != NULL
- 			   && runp->nwcs == runp->wcnext->nwcs
- 			   && wmemcmp ((wchar_t *) runp->wcs,
- 				       (wchar_t *)runp->wcnext->wcs,
- 				       runp->nwcs - 1) == 0
- 			   && (runp->wcs[runp->nwcs - 1]
- 			       == runp->wcnext->wcs[runp->nwcs - 1] + 1));
- 
- 		    /* Now walk backward from here to the beginning.  */
- 		    curp = runp;
- 
- 		    for (i = 1; i < runp->nwcs; ++i)
- 		      obstack_int32_grow_fast (&extrapool, curp->wcs[i]);
- 
- 		    /* Now find the end of the consecutive sequence and
- 		       add all the indeces in the indirect pool.  */
- 		    do
- 		      {
- 			weightidx = output_weightwc (&weightpool, collate,
- 						     curp);
- 			obstack_int32_grow (&indirectpool, weightidx);
- 
- 			curp = curp->wclast;
- 		      }
- 		    while (curp != series_startp);
- 
- 		    /* Add the final weight.  */
- 		    weightidx = output_weightwc (&weightpool, collate, curp);
- 		    obstack_int32_grow (&indirectpool, weightidx);
- 
- 		    /* And add the end byte sequence.  Without length this
- 		       time.  */
- 		    for (i = 1; i < curp->nwcs; ++i)
- 		      obstack_int32_grow (&extrapool, curp->wcs[i]);
- 		  }
- 		else
- 		  {
- 		    /* A single entry.  Simply add the index and the length and
- 		       string (except for the first character which is already
- 		       tested for).  */
- 		    int i;
- 
- 		    /* Output the weight info.  */
- 		    weightidx = output_weightwc (&weightpool, collate, runp);
- 
- 		    added = (1 + 1 + runp->nwcs - 1) * sizeof (int32_t);
- 		    if (sizeof (int) == sizeof (int32_t))
- 		      obstack_make_room (&extrapool, added);
- 
- 		    obstack_int32_grow_fast (&extrapool, weightidx);
- 		    obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
- 		    for (i = 1; i < runp->nwcs; ++i)
- 		      obstack_int32_grow_fast (&extrapool, runp->wcs[i]);
- 		  }
- 
- 		/* Next entry.  */
- 		lastp = runp;
- 		runp = runp->wcnext;
- 	      }
- 	    while (runp != NULL);
- 	  }
-       }
- 
      tablewc.p = 6;
      tablewc.q = 10;
      collidx_table_init (&tablewc);
--- 2410,2415 ----