]> git.pld-linux.org Git - packages/glibc.git/blob - glibc-divdi3.patch
- tool to be included in glibc, to run both ldconfig and telinit in post
[packages/glibc.git] / glibc-divdi3.patch
1 Index: libc/sysdeps/i386/Makefile
2 ===================================================================
3 RCS file: /cvs/glibc/libc/sysdeps/i386/Makefile,v
4 retrieving revision 1.11
5 retrieving revision 1.11.2.1
6 diff -u -r1.11 -r1.11.2.1
7 --- libc/sysdeps/i386/Makefile  17 Sep 1999 16:59:13 -0000      1.11
8 +++ libc/sysdeps/i386/Makefile  28 Feb 2002 19:39:16 -0000      1.11.2.1
9 @@ -9,6 +9,12 @@
10  # On i686 we must avoid generating the trampoline functions generated
11  # to get the GOT pointer.
12  CFLAGS-initfini.s += -march=i386 -mcpu=i386
13 +
14 +ifeq (yes,$(build-shared))
15 +# Compatibility
16 +sysdep_routines += divdi3
17 +shared-only-routines += divdi3
18 +endif
19  endif
20  
21  ifeq ($(subdir),db2)
22 Index: libc/sysdeps/m68k/Makefile
23 ===================================================================
24 RCS file: /cvs/glibc/libc/sysdeps/m68k/Makefile,v
25 retrieving revision 1.20
26 retrieving revision 1.20.2.1
27 diff -u -r1.20 -r1.20.2.1
28 --- libc/sysdeps/m68k/Makefile  6 Jul 2001 04:55:55 -0000       1.20
29 +++ libc/sysdeps/m68k/Makefile  28 Feb 2002 19:39:18 -0000      1.20.2.1
30 @@ -33,6 +33,14 @@
31  # The 68k `long double' is a distinct type we support.
32  long-double-fcts = yes
33  
34 +ifeq ($(subdir),csu)
35 +ifeq (yes,$(build-shared))
36 +# Compatibility
37 +sysdep_routines += divdi3
38 +shared-only-routines += divdi3
39 +endif
40 +endif
41 +
42  ifeq ($(subdir),elf)
43  CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
44  endif
45 Index: libc/sysdeps/s390/s390-32/Makefile
46 ===================================================================
47 RCS file: /cvs/glibc/libc/sysdeps/s390/s390-32/Makefile,v
48 retrieving revision 1.1
49 retrieving revision 1.1.2.1
50 diff -u -r1.1 -r1.1.2.1
51 --- libc/sysdeps/s390/s390-32/Makefile  16 Mar 2001 08:59:44 -0000      1.1
52 +++ libc/sysdeps/s390/s390-32/Makefile  28 Feb 2002 19:39:19 -0000      1.1.2.1
53 @@ -1,5 +1,13 @@
54  pic-ccflag = -fpic
55  
56 +ifeq ($(subdir),csu)
57 +ifeq (yes,$(build-shared))
58 +# Compatibility
59 +sysdep_routines += divdi3
60 +shared-only-routines += divdi3
61 +endif
62 +endif
63 +
64  ifeq ($(subdir),gmon)
65  sysdep_routines += s390-mcount
66  endif
67 Index: libc/sysdeps/wordsize-32/divdi3.c
68 ===================================================================
69 RCS file: sysdeps/wordsize-32/divdi3.c
70 diff -N sysdeps/wordsize-32/divdi3.c
71 --- /dev/null   1 Jan 1970 00:00:00 -0000
72 +++ libc/sysdeps/wordsize-32/divdi3.c   28 Feb 2002 19:38:59 -0000      1.1.2.1
73 @@ -0,0 +1,327 @@
74 +/* 64-bit multiplication and division
75 +   Copyright (C) 1989, 1992-1999, 2000, 2001, 2002
76 +   Free Software Foundation, Inc.
77 +   This file is part of the GNU C Library.
78 +
79 +   The GNU C Library is free software; you can redistribute it and/or
80 +   modify it under the terms of the GNU Lesser General Public
81 +   License as published by the Free Software Foundation; either
82 +   version 2.1 of the License, or (at your option) any later version.
83 +
84 +   The GNU C Library is distributed in the hope that it will be useful,
85 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
86 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
87 +   Lesser General Public License for more details.
88 +
89 +   You should have received a copy of the GNU Lesser General Public
90 +   License along with the GNU C Library; if not, write to the Free
91 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
92 +   02111-1307 USA.  */
93 +
94 +#include <endian.h>
95 +#include <stdlib.h>
96 +#include <bits/wordsize.h>
97 +
98 +#if __WORDSIZE != 32
99 +#error This is for 32-bit targets only
100 +#endif
101 +
102 +typedef unsigned int UQItype   __attribute__ ((mode (QI)));
103 +typedef          int SItype    __attribute__ ((mode (SI)));
104 +typedef unsigned int USItype   __attribute__ ((mode (SI)));
105 +typedef          int DItype    __attribute__ ((mode (DI)));
106 +typedef unsigned int UDItype   __attribute__ ((mode (DI)));
107 +#define Wtype SItype
108 +#define HWtype SItype
109 +#define DWtype DItype
110 +#define UWtype USItype
111 +#define UHWtype USItype
112 +#define UDWtype UDItype
113 +#define W_TYPE_SIZE 32
114 +
115 +#include <stdlib/longlong.h>
116 +
117 +#if __BYTE_ORDER == __BIG_ENDIAN
118 +struct DWstruct { Wtype high, low;};
119 +#elif __BYTE_ORDER == __LITTLE_ENDIAN
120 +struct DWstruct { Wtype low, high;};
121 +#else
122 +#error Unhandled endianity
123 +#endif
124 +typedef union { struct DWstruct s; DWtype ll; } DWunion;
125 +
126 +static UDWtype
127 +__udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
128 +{
129 +  DWunion ww;
130 +  DWunion nn, dd;
131 +  DWunion rr;
132 +  UWtype d0, d1, n0, n1, n2;
133 +  UWtype q0, q1;
134 +  UWtype b, bm;
135 +
136 +  nn.ll = n;
137 +  dd.ll = d;
138 +
139 +  d0 = dd.s.low;
140 +  d1 = dd.s.high;
141 +  n0 = nn.s.low;
142 +  n1 = nn.s.high;
143 +
144 +#if !UDIV_NEEDS_NORMALIZATION
145 +  if (d1 == 0)
146 +    {
147 +      if (d0 > n1)
148 +       {
149 +         /* 0q = nn / 0D */
150 +
151 +         udiv_qrnnd (q0, n0, n1, n0, d0);
152 +         q1 = 0;
153 +
154 +         /* Remainder in n0.  */
155 +       }
156 +      else
157 +       {
158 +         /* qq = NN / 0d */
159 +
160 +         if (d0 == 0)
161 +           d0 = 1 / d0;        /* Divide intentionally by zero.  */
162 +
163 +         udiv_qrnnd (q1, n1, 0, n1, d0);
164 +         udiv_qrnnd (q0, n0, n1, n0, d0);
165 +
166 +         /* Remainder in n0.  */
167 +       }
168 +
169 +      if (rp != 0)
170 +       {
171 +         rr.s.low = n0;
172 +         rr.s.high = 0;
173 +         *rp = rr.ll;
174 +       }
175 +    }
176 +
177 +#else /* UDIV_NEEDS_NORMALIZATION */
178 +
179 +  if (d1 == 0)
180 +    {
181 +      if (d0 > n1)
182 +       {
183 +         /* 0q = nn / 0D */
184 +
185 +         count_leading_zeros (bm, d0);
186 +
187 +         if (bm != 0)
188 +           {
189 +             /* Normalize, i.e. make the most significant bit of the
190 +                denominator set.  */
191 +
192 +             d0 = d0 << bm;
193 +             n1 = (n1 << bm) | (n0 >> (W_TYPE_SIZE - bm));
194 +             n0 = n0 << bm;
195 +           }
196 +
197 +         udiv_qrnnd (q0, n0, n1, n0, d0);
198 +         q1 = 0;
199 +
200 +         /* Remainder in n0 >> bm.  */
201 +       }
202 +      else
203 +       {
204 +         /* qq = NN / 0d */
205 +
206 +         if (d0 == 0)
207 +           d0 = 1 / d0;        /* Divide intentionally by zero.  */
208 +
209 +         count_leading_zeros (bm, d0);
210 +
211 +         if (bm == 0)
212 +           {
213 +             /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
214 +                conclude (the most significant bit of n1 is set) /\ (the
215 +                leading quotient digit q1 = 1).
216 +
217 +                This special case is necessary, not an optimization.
218 +                (Shifts counts of W_TYPE_SIZE are undefined.)  */
219 +
220 +             n1 -= d0;
221 +             q1 = 1;
222 +           }
223 +         else
224 +           {
225 +             /* Normalize.  */
226 +
227 +             b = W_TYPE_SIZE - bm;
228 +
229 +             d0 = d0 << bm;
230 +             n2 = n1 >> b;
231 +             n1 = (n1 << bm) | (n0 >> b);
232 +             n0 = n0 << bm;
233 +
234 +             udiv_qrnnd (q1, n1, n2, n1, d0);
235 +           }
236 +
237 +         /* n1 != d0...  */
238 +
239 +         udiv_qrnnd (q0, n0, n1, n0, d0);
240 +
241 +         /* Remainder in n0 >> bm.  */
242 +       }
243 +
244 +      if (rp != 0)
245 +       {
246 +         rr.s.low = n0 >> bm;
247 +         rr.s.high = 0;
248 +         *rp = rr.ll;
249 +       }
250 +    }
251 +#endif /* UDIV_NEEDS_NORMALIZATION */
252 +
253 +  else
254 +    {
255 +      if (d1 > n1)
256 +       {
257 +         /* 00 = nn / DD */
258 +
259 +         q0 = 0;
260 +         q1 = 0;
261 +
262 +         /* Remainder in n1n0.  */
263 +         if (rp != 0)
264 +           {
265 +             rr.s.low = n0;
266 +             rr.s.high = n1;
267 +             *rp = rr.ll;
268 +           }
269 +       }
270 +      else
271 +       {
272 +         /* 0q = NN / dd */
273 +
274 +         count_leading_zeros (bm, d1);
275 +         if (bm == 0)
276 +           {
277 +             /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
278 +                conclude (the most significant bit of n1 is set) /\ (the
279 +                quotient digit q0 = 0 or 1).
280 +
281 +                This special case is necessary, not an optimization.  */
282 +
283 +             /* The condition on the next line takes advantage of that
284 +                n1 >= d1 (true due to program flow).  */
285 +             if (n1 > d1 || n0 >= d0)
286 +               {
287 +                 q0 = 1;
288 +                 sub_ddmmss (n1, n0, n1, n0, d1, d0);
289 +               }
290 +             else
291 +               q0 = 0;
292 +
293 +             q1 = 0;
294 +
295 +             if (rp != 0)
296 +               {
297 +                 rr.s.low = n0;
298 +                 rr.s.high = n1;
299 +                 *rp = rr.ll;
300 +               }
301 +           }
302 +         else
303 +           {
304 +             UWtype m1, m0;
305 +             /* Normalize.  */
306 +
307 +             b = W_TYPE_SIZE - bm;
308 +
309 +             d1 = (d1 << bm) | (d0 >> b);
310 +             d0 = d0 << bm;
311 +             n2 = n1 >> b;
312 +             n1 = (n1 << bm) | (n0 >> b);
313 +             n0 = n0 << bm;
314 +
315 +             udiv_qrnnd (q0, n1, n2, n1, d1);
316 +             umul_ppmm (m1, m0, q0, d0);
317 +
318 +             if (m1 > n1 || (m1 == n1 && m0 > n0))
319 +               {
320 +                 q0--;
321 +                 sub_ddmmss (m1, m0, m1, m0, d1, d0);
322 +               }
323 +
324 +             q1 = 0;
325 +
326 +             /* Remainder in (n1n0 - m1m0) >> bm.  */
327 +             if (rp != 0)
328 +               {
329 +                 sub_ddmmss (n1, n0, n1, n0, m1, m0);
330 +                 rr.s.low = (n1 << b) | (n0 >> bm);
331 +                 rr.s.high = n1 >> bm;
332 +                 *rp = rr.ll;
333 +               }
334 +           }
335 +       }
336 +    }
337 +
338 +  ww.s.low = q0;
339 +  ww.s.high = q1;
340 +  return ww.ll;
341 +}
342 +
343 +DWtype
344 +__divdi3 (DWtype u, DWtype v)
345 +{
346 +  Wtype c = 0;
347 +  DWtype w;
348 +
349 +  if (u < 0)
350 +    {
351 +      c = ~c;
352 +      u = -u;
353 +    }
354 +  if (v < 0)
355 +    {
356 +      c = ~c;
357 +      v = -v;
358 +    }
359 +  w = __udivmoddi4 (u, v, NULL);
360 +  if (c)
361 +    w = -w;
362 +  return w;
363 +}
364 +
365 +DWtype
366 +__moddi3 (DWtype u, DWtype v)
367 +{
368 +  Wtype c = 0;
369 +  DWtype w;
370 +
371 +  if (u < 0)
372 +    {
373 +      c = ~c;
374 +      u = -u;
375 +    }
376 +  if (v < 0)
377 +    {
378 +      c = ~c;
379 +      v = -v;
380 +    }
381 +  __udivmoddi4 (u, v, &w);
382 +  if (c)
383 +    w = -w;
384 +  return w;
385 +}
386 +
387 +UDWtype
388 +__udivdi3 (UDWtype u, UDWtype v)
389 +{
390 +  return __udivmoddi4 (u, v, NULL);
391 +}
392 +
393 +UDWtype
394 +__umoddi3 (UDWtype u, UDWtype v)
395 +{
396 +  UDWtype w;
397 +
398 +  __udivmoddi4 (u, v, &w);
399 +  return w;
400 +}
This page took 0.058338 seconds and 3 git commands to generate.