aboutsummaryrefslogtreecommitdiffstats
path: root/gen
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-20 15:54:26 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-20 15:54:26 +0100
commit9dbe6d3478329df159cf402c1812485649741e7c (patch)
treeea618ce99263b478e94083673e5233719b3fd712 /gen
parentm (diff)
downloadslibc-9dbe6d3478329df159cf402c1812485649741e7c.tar.gz
slibc-9dbe6d3478329df159cf402c1812485649741e7c.tar.bz2
slibc-9dbe6d3478329df159cf402c1812485649741e7c.tar.xz
It is of course possible that int is 16 bits, and long is required to get 32 bits
(in this case, assuming 8-, 16-, and 32-bit integers exists) long must be 32 bits. Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r--gen/bits/intconf.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/gen/bits/intconf.c b/gen/bits/intconf.c
index 361dd16..4fe45fd 100644
--- a/gen/bits/intconf.c
+++ b/gen/bits/intconf.c
@@ -173,17 +173,34 @@ static char* byteorder_16(void)
static char* byteorder_32(void)
{
static char buf[32 / 4 + 1];
- union
- {
- int all;
- struct
+ if (8 * sizeof(int) == 32)
{
- char a; char b; char c; char d;
- };
- } test = { .all = 0x01020304 };
+ union
+ {
+ int all;
+ struct
+ {
+ char a; char b; char c; char d;
+ };
+ } test = { .all = 0x01020304 };
- sprintf(buf, "%02i%02i%02i%02i",
- test.a, test.b, test.c, test.d);
+ sprintf(buf, "%02i%02i%02i%02i",
+ test.a, test.b, test.c, test.d);
+ }
+ else
+ {
+ union
+ {
+ long int all;
+ struct
+ {
+ char a; char b; char c; char d;
+ };
+ } test = { .all = 0x01020304L };
+
+ sprintf(buf, "%02i%02i%02i%02i",
+ test.a, test.b, test.c, test.d);
+ }
return buf;
}
@@ -245,7 +262,7 @@ int main(int argc, char* argv[])
/* Print byte orders. */
r |= printf("INT16_BYTEORDER 0x%s\n", byteorder_16());
- r |= printf("INT32_BYTEORDER 0x%s\n", byteorder_32());
+ r |= printf("INT32_BYTEORDER 0x%sL\n", byteorder_32());
r |= printf("INT64_BYTEORDER 0x%sLL\n", byteorder_64());
/* Print the intrinsic type for specific numbers of bits. */