Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / regression / tcc / 119_random_stuff.c
blob95097b82d165be7a8c01b8a77c2174ba6328c475
1 #include <stdio.h>
3 struct big_struct { char a[262144]; };
5 static const char str[] = "abcdefghijklmnopqrstuvwxyz";
7 void tst_branch(void)
9 printf("tst_branch --");
10 goto *&&a;
11 printf (" dummy");
12 a: ;
13 printf(" --\n");
16 void tst_void_ptr(void *pv, int i)
18 i ? *pv : *pv; // dr106
21 void tst_shift(void)
23 int i = 1;
24 long long l = 1;
25 i = i << 32; // illegal. just test
26 l = l << 64; // illegal. just test
29 #if !defined(_WIN32)
30 #include <sys/mman.h>
32 void tst_const_addr(void)
34 void *addr = mmap ((void *)0x20000000, 4096, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS, -1, 0);
35 if (addr != (void *) -1) {
36 *(int *)0x20000000 += 42;
37 munmap (addr, 4096);
40 #endif
42 struct zero_struct {};
44 struct zero_struct tst_zero_struct(void)
46 struct zero_struct ret;
47 return ret;
50 struct big_struct tst_big(struct big_struct tst)
52 return tst;
55 void tst_adr (int (*fp)(char *, const char *, ...))
57 char buf[10];
58 (*fp)(buf, "%.0f", 5.0);
59 printf("tst_adr %s\n", buf);
62 int tst(void)
64 long long value = 3;
65 return -value;
68 void tst_compare(void)
70 /* This failed on risc64 */
71 printf ("tst_compare: %s\n", tst() > 0 ? "error" : "ok");
74 #pragma pack(1)
75 struct S { int d:24; int f:14; } i, j;
76 #pragma pack()
78 void tst_pack (void)
80 i.f = 5; j.f = 5;
81 printf("tst_pack: j.f = %d, i.f = %d\n", j.f, i.f);
84 void tst_cast(void)
86 signed char c = (signed char) 0xaaaaaaaa;
87 int r = (unsigned short) c ^ (signed char) 0x99999999;
88 printf ("schar to ushort cast: %x\n", r);
91 int
92 main (void)
94 struct big_struct big;
96 tst_branch();
97 tst_shift();
98 tst_void_ptr(&big.a[0], 0);
99 #if !defined(_WIN32)
100 tst_const_addr();
101 #endif
102 tst_zero_struct();
103 tst_big(big);
104 tst_adr(&sprintf);
105 tst_compare();
106 tst_pack();
107 tst_cast();