Skip to content

Commit d963b6c

Browse files
committed
Various GCC 4.7 regenerations
1 parent 0dbfde7 commit d963b6c

File tree

4 files changed

+361
-6
lines changed

4 files changed

+361
-6
lines changed

steps/SHA256SUMS.pkgs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ c99d080cf17ac3f75cbae67095cb76220a92d96d877c92c896a7f05c9c94e92d gcc-10.4.0_0.t
5555
e0c9e7f4f0cd0d5027f2a38eb262f883133c31ac9ec93ee6afa5abc028096bc0 gcc-13.1.0_0.tar.bz2
5656
27bb77077559b6c0f8dd7b8790ac48f70410ecc8816b5c493988ad5556da65e2 gcc-4.0.4_0.tar.bz2
5757
c1bf792e90df13bf7a24d3f8ce3939fd96ff61b8117e4dcef75605974f3fcf25 gcc-4.0.4_1.tar.bz2
58-
7ac087bf006188154c28401d0c875ede56076c19d41bc54ffa0d7cc18ce40800 gcc-4.7.4_0.tar.bz2
58+
73d27741e882a1eecdfeb36e51d08152fb5359d116b8d489eadb62ef2c36d5bc gcc-4.7.4_0.tar.bz2
5959
dc67fc1b132fa3945349efe74c5b2197bd0b6babf4d29d2deddd04f09d9af680 gettext-0.21_0.tar.bz2
6060
309282ba840f80b5e10897b1221f3ff3329b9e05b982c788d03652f411974524 gmp-6.2.1_0.tar.bz2
6161
62edfa633f64202b2d29199d11d56a897654a441c7ae39a4d59ca5fe75199f61 gperf-3.1_0.tar.bz2
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* Conversion lookup tables for the decNumber C Library.
2+
Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3+
Contributed by IBM Corporation. Author Mike Cowlishaw.
4+
5+
This file is part of GCC.
6+
7+
GCC is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License as published by the Free
9+
Software Foundation; either version 3, or (at your option) any later
10+
version.
11+
12+
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
for more details.
16+
17+
Under Section 7 of GPL version 3, you are granted additional
18+
permissions described in the GCC Runtime Library Exception, version
19+
3.1, as published by the Free Software Foundation.
20+
21+
You should have received a copy of the GNU General Public License and
22+
a copy of the GCC Runtime Library Exception along with this program;
23+
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24+
<http://www.gnu.org/licenses/>. */
25+
26+
/* ------------------------------------------------------------------------ */
27+
/* Binary Coded Decimal and Densely Packed Decimal conversion lookup tables */
28+
/* [Automatically generated -- do not edit. 2008.06.21] */
29+
/* ------------------------------------------------------------------------ */
30+
/* For details, see DPDecimal.html on the General Decimal Arithmetic page. */
31+
32+
#include "decDPDSymbols.h"
33+
34+
/* This include file defines several DPD and BCD conversion tables: */
35+
/* */
36+
/* uint16_t BCD2DPD[2458]; -- BCD -> DPD (0x999 => 2457) */
37+
/* uint16_t BIN2DPD[1000]; -- Bin -> DPD (999 => 2457) */
38+
/* uint8_t BIN2CHAR[4001]; -- Bin -> CHAR (999 => '\3' '9' '9' '9') */
39+
/* uint8_t BIN2BCD8[4000]; -- Bin -> bytes (999 => 9 9 9 3) */
40+
/* uint16_t DPD2BCD[1024]; -- DPD -> BCD (0x3FF => 0x999) */
41+
/* uint16_t DPD2BIN[1024]; -- DPD -> BIN (0x3FF => 999) */
42+
/* uint32_t DPD2BINK[1024]; -- DPD -> BIN * 1000 (0x3FF => 999000) */
43+
/* uint32_t DPD2BINM[1024]; -- DPD -> BIN * 1E+6 (0x3FF => 999000000) */
44+
/* uint8_t DPD2BCD8[4096]; -- DPD -> bytes (x3FF => 9 9 9 3) */
45+
/* */
46+
/* In all cases the result (10 bits or 12 bits, or binary) is right-aligned */
47+
/* in the table entry. BIN2CHAR entries are a single byte length (0 for */
48+
/* value 0) followed by three digit characters; a trailing terminator is */
49+
/* included to allow 4-char moves always. BIN2BCD8 and DPD2BCD8 entries */
50+
/* are similar with the three BCD8 digits followed by a one-byte length */
51+
/* (again, length=0 for value 0). */
52+
/* */
53+
/* To use a table, its name, prefixed with DEC_, must be defined with a */
54+
/* value of 1 before this header file is included. For example: */
55+
/* #define DEC_BCD2DPD 1 */
56+
/* This mechanism allows software to only include tables that are needed. */
57+
/* ------------------------------------------------------------------------ */
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
#include <stdio.h>
2+
#include <stdint.h>
3+
#include <stdbool.h>
4+
5+
/*
6+
* Creates decDPD.h.
7+
* Based upon the algorithm given on;
8+
* https://web.archive.org/web/20080308073422/http://www2.hursley.ibm.com/decimal/DPDecimal.html
9+
* originally written in the (obselete) language Rexx.
10+
*
11+
* Is not bit-for-bit identical to the original decDPD.h, as we don't bother
12+
* to follow the same formatting.
13+
*
14+
* The original Rexx code follows;
15+
*/
16+
17+
// /* dpdGenerate.rex -- display Densely Packed Decimal table */
18+
// /* mfc 2000.10.03; Rexx version with new equations 2007.02.01 */
19+
//
20+
// do i=0 to 999
21+
// bcd=right(i, 3, 0) -- make three-digit hexadecimal string
22+
// bit10=bcd2dpd(x2b(bcd)) -- compress
23+
// bit12=dpd2bcd(bit10) -- expand
24+
// say bcd bit10 bit12 -- display
25+
// end i
26+
// exit
27+
//
28+
// /* bcd2dpd -- Compress BCD to Densely Packed Decimal
29+
// argument is a string of 12 characters, each 0 or 1, being 3 digits
30+
// of 4 bits, each being a valid BCD digit (0000-1001)
31+
// (for example, 923 is 100100100011)
32+
// result is a string of 10 characters, each 0 or 1
33+
// (for the example, this would be 1001010011)
34+
// */
35+
// bcd2dpd: procedure
36+
// -- assign each bit to a variable, named as in the description
37+
// parse arg a +1 b +1 c +1 d +1 e +1 f +1 g +1 h +1 i +1 j +1 k +1 m +1
38+
//
39+
// -- derive the result bits, using boolean expressions only
40+
// -- [the operators are: '&'=AND, '|'=OR, '\'=NOT.]
41+
// p=b | (a & j) | (a & f & i)
42+
// q=c | (a & k) | (a & g & i)
43+
// r=d
44+
// s=(f & (\a | \i)) | (\a & e & j) | (e & i)
45+
// t=g | (\a & e &k;) | (a & i)
46+
// u=h
47+
// v=a | e | i
48+
// w=a | (e & i) | (\e & j)
49+
// x=e | (a & i) | (\a & k)
50+
// y=m
51+
// -- concatenate the bits and return
52+
// return p||q||r||s||t||u||v||w||x||y
53+
//
54+
// /* dpd2bcd -- Expand Densely Packed Decimal to BCD
55+
// argument is a string of 10 characters, each 0 or 1; all 1024
56+
// possibilities are accepted (non-canonicals -> 999)
57+
// (for example, 1001010011)
58+
// result is a string of 12 characters, each 0 or 1
59+
// (for the example, 100100100011 -- 923)
60+
// */
61+
// dpd2bcd: procedure
62+
// -- assign each bit to a variable, named as in the description
63+
// parse arg p +1 q +1 r +1 s +1 t +1 u +1 v +1 w +1 x +1 y +1
64+
//
65+
// -- derive the result bits, using boolean expressions only
66+
// a= (v & w) & (\s | t | \x)
67+
// b=p & (\v | \w | (s & \t & x))
68+
// c=q & (\v | \w | (s & \t & x))
69+
// d=r
70+
// e=v & ((\w & x) | (\t & x) | (s & x))
71+
// f=(s & (\v | \x)) | (p & \s & t & v & w & x)
72+
// g=(t & (\v | \x)) | (q & \s & t & w)
73+
// h=u
74+
// i=v & ((\w & \x) | (w & x & (s | t)))
75+
// j=(\v & w) | (s & v & \w & x) | (p & w & (\x | (\s & \t)))
76+
// k=(\v & x) | (t & \w & x) | (q & v & w & (\x | (\s & \t)))
77+
// m=y
78+
// -- concatenate the bits and return
79+
// return a||b||c||d||e||f||g||h||i||j||k||m
80+
81+
void int2boolarr(uint32_t num, bool *arr, int bits) {
82+
int j = 0;
83+
for (int i = bits - 1; i >= 0; i--) {
84+
arr[j++] = (num >> i) & 0x1;
85+
}
86+
}
87+
88+
uint32_t boolarr2int(bool *dpd, int bits) {
89+
uint32_t num = 0;
90+
int j = 0;
91+
for (int i = bits - 1; i >= 0; i--) {
92+
num |= dpd[j++] << i;
93+
}
94+
return num;
95+
}
96+
97+
uint32_t bcd2dpd(uint16_t ibcd) {
98+
bool bcd[12];
99+
int2boolarr(ibcd, bcd, 12);
100+
101+
bool dpd[10];
102+
dpd[0] = bcd[1] | (bcd[0] & bcd[9]) | (bcd[0] & bcd[5] & bcd[8]);
103+
dpd[1] = bcd[2] | (bcd[0] & bcd[10]) | (bcd[0] & bcd[6] & bcd[8]);
104+
dpd[2] = bcd[3];
105+
dpd[3] = (bcd[5] & (~bcd[0] | ~bcd[8])) | (~bcd[0] & bcd[4] & bcd[9]) | (bcd[4] & bcd[8]);
106+
dpd[4] = bcd[6] | (~bcd[0] & bcd[4] & bcd[10]) | (bcd[0] & bcd[8]);
107+
dpd[5] = bcd[7];
108+
dpd[6] = bcd[0] | bcd[4] | bcd[8];
109+
dpd[7] = bcd[0] | (bcd[4] & bcd[8]) | (~bcd[4] & bcd[9]);
110+
dpd[8] = bcd[4] | (bcd[0] & bcd[8]) | (~bcd[0] & bcd[10]);
111+
dpd[9] = bcd[11];
112+
113+
return boolarr2int(dpd, 10);
114+
}
115+
116+
uint32_t dpd2bcd(uint32_t idpd) {
117+
bool dpd[10];
118+
int2boolarr(idpd, dpd, 10);
119+
120+
bool bcd[12];
121+
bcd[0] = (dpd[6] & dpd[7]) & (~dpd[3] | dpd[4] | ~dpd[8]);
122+
bcd[1] = dpd[0] & (~dpd[6] | ~dpd[7] | (dpd[3] & ~dpd[4] & dpd[8]));
123+
bcd[2] = dpd[1] & (~dpd[6] | ~dpd[7] | (dpd[3] & ~dpd[4] & dpd[8]));
124+
bcd[3] = dpd[2];
125+
bcd[4] = dpd[6] & ((~dpd[7] & dpd[8]) | (~dpd[4] & dpd[8]) | (dpd[3] & dpd[8]));
126+
bcd[5] = (dpd[3] & (~dpd[6] | ~dpd[8])) | (dpd[0] & ~dpd[3] & dpd[4] & dpd[6] & dpd[7] & dpd[8]);
127+
bcd[6] = (dpd[4] & (~dpd[6] | ~dpd[8])) | (dpd[1] & ~dpd[3] & dpd[4] & dpd[7]);
128+
bcd[7] = dpd[5];
129+
bcd[8] = dpd[6] & ((~dpd[7] & ~dpd[8]) | (dpd[7] & dpd[8] & (dpd[3] | dpd[4])));
130+
bcd[9] = (~dpd[6] & dpd[7]) | (dpd[3] & dpd[6] & ~dpd[7] & dpd[8]) | (dpd[0] & dpd[7] & (~dpd[8] | (~dpd[3] & ~dpd[4])));
131+
bcd[10] = (~dpd[6] & dpd[8]) | (dpd[4] & ~dpd[7] & dpd[8]) | (dpd[1] & dpd[6] & dpd[7] & (~dpd[8] | (~dpd[3] & ~dpd[4])));
132+
bcd[11] = dpd[9];
133+
134+
return boolarr2int(bcd, 12);
135+
}
136+
137+
uint8_t get_cntrl_char(uint8_t num) {
138+
if (num == 0) {
139+
return 0;
140+
} else if (num < 10) {
141+
return 1;
142+
} else if (num < 100) {
143+
return 2;
144+
} else {
145+
return 3;
146+
}
147+
}
148+
149+
void bin2char(uint8_t num, uint32_t str[4]) {
150+
str[0] = get_cntrl_char(num);
151+
str[1] = num / 100 + '0';
152+
str[2] = (num % 100) / 10 + '0';
153+
str[3] = num % 10 + '0';
154+
}
155+
156+
void bin2bcd8(uint8_t num, char digit[4], uint32_t arr[4]) {
157+
for (int i = 0; i < 3; i++) {
158+
arr[i] = digit[i] - '0';
159+
}
160+
arr[3] = get_cntrl_char(num);
161+
}
162+
163+
#define TABLES_COUNT 9
164+
165+
int main(void) {
166+
uint32_t BCD2DPD[2458] = {0};
167+
uint32_t BIN2DPD[1000] = {0};
168+
uint32_t BIN2BCD8[4000];
169+
uint32_t BIN2CHAR[4001];
170+
uint32_t DPD2BCD[1024] = {0};
171+
uint32_t DPD2BIN[1024] = {0};
172+
uint32_t DPD2BINK[1024] = {0};
173+
uint32_t DPD2BINM[1024] = {0};
174+
uint32_t DPD2BCD8[4096];
175+
176+
for (int i = 0; i < 1000; i++) {
177+
char digit[4];
178+
snprintf(digit, 4, "%03d", i);
179+
uint32_t bcd = 0;
180+
for (int j = 0; j < 3; j++) {
181+
bcd |= (digit[j] - '0') << (4 * (2 - j));
182+
}
183+
184+
uint32_t dpd = bcd2dpd(bcd);
185+
BCD2DPD[bcd] = dpd;
186+
DPD2BCD[dpd] = bcd;
187+
BIN2DPD[i] = dpd;
188+
DPD2BIN[dpd] = i;
189+
DPD2BINK[dpd] = i * 1000;
190+
DPD2BINM[dpd] = i * 1E+6;
191+
192+
bin2char(i, BIN2CHAR + (4 * i));
193+
bin2bcd8(i, digit, BIN2BCD8 + (4 * i));
194+
bin2bcd8(i, digit, DPD2BCD8 + (4 * dpd));
195+
}
196+
BIN2CHAR[4000] = '\0';
197+
198+
char *names[] = {
199+
"BCD2DPD", "BIN2DPD", "BIN2CHAR", "BIN2BCD8", "DPD2BCD", "DPD2BIN",
200+
"DPD2BINK", "DPD2BINM", "DPD2BCD8",
201+
};
202+
char *types[] = {
203+
"uint16_t", "uint16_t", "uint8_t", "uint8_t", "uint16_t", "uint16_t",
204+
"uint32_t", "uint32_t", "uint8_t",
205+
};
206+
uint32_t *data[] = {
207+
BCD2DPD, BIN2DPD, BIN2CHAR, BIN2BCD8, DPD2BCD, DPD2BIN,
208+
DPD2BINK, DPD2BINM, DPD2BCD8,
209+
};
210+
int lengths[] = {2458, 1000, 4001, 4000, 1024, 1024, 1024, 1024, 4096};
211+
212+
for (int i = 0; i < TABLES_COUNT; i++) {
213+
printf("#if defined(DEC_%s) && DEC_%s==1 && !defined(DEC%s)\n", names[i], names[i], names[i]);
214+
printf("#define DEC%s\n", names[i]);
215+
printf("const %s %s[%d] = {\n", types[i], names[i], lengths[i]);
216+
for (int j = 0; j < lengths[i] / 16; j++) {
217+
for (int k = j * 16; k < (j + 1) * 16 && k < lengths[i]; k++) {
218+
printf("%s%d,", k == j * 16 ? "" : " ", data[i][k]);
219+
}
220+
printf("\n");
221+
}
222+
printf("};\n");
223+
printf("#endif\n\n");
224+
}
225+
}

0 commit comments

Comments
 (0)