Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / regression / tcc / 117_builtins.c
blob4da28ff58e7c85ae7c422042ebc4bea8116a3ae0
1 #include <stdio.h>
3 struct big_struct { char a[262144]; };
5 static const char str[] = "abcdefghijklmnopqrstuvwxyz";
7 int
8 main (void)
10 char *p;
11 char tmp[100];
12 int r = 0;
14 #if defined __BOUNDS_CHECKING_ON || defined BC_ON
15 printf("BOUNDS ON:\n");
16 #else
17 printf("BOUNDS OFF:\n");
18 #endif
20 if (r != 0)
21 __builtin_abort();
23 r = (__builtin_offsetof(struct big_struct, a) != 0);
24 printf(" 1:%d", !r);
26 p = __builtin_memcpy (tmp, str, sizeof(str));
27 r = (p != tmp);
28 printf(" 2:%d", !r);
30 r = __builtin_memcmp (p, str, sizeof(str));
31 printf(" 3:%d", !r);
33 p = __builtin_memmove(tmp, str, sizeof(str));
34 r = (__builtin_memcmp (p, str, sizeof(str)));
35 printf(" 4:%d", !r);
37 p = __builtin_memset(tmp, 0, sizeof (tmp));
38 r = (p != tmp || tmp[0] != 0 || tmp[99] != 0);
39 printf(" 5:%d", !r);
41 r = (__builtin_strlen(str) != sizeof(str) - 1);
42 printf(" 6:%d", !r);
44 p = __builtin_strcpy(tmp, str);
45 r = (__builtin_memcmp (p, str, sizeof(str)));
46 printf(" 7:%d", !r);
48 p = __builtin_strncpy(tmp, str, sizeof(str));
49 r = (__builtin_memcmp (p, str, sizeof(str)));
50 printf(" 8:%d", !r);
52 r = (__builtin_strcmp (p, str));
53 printf(" 9:%d", !r);
55 r = (__builtin_strncmp (p, str, sizeof(str)));
56 printf(" 10:%d", !r);
58 tmp[0] = '\0';
59 p = __builtin_strcat(tmp, str);
60 r = (__builtin_memcmp (p, str, sizeof(str)));
61 printf(" 11:%d", !r);
63 r = (__builtin_strchr(p, 'z') != &p[25]);
64 printf(" 12:%d", !r);
66 p = __builtin_strdup (str);
67 r = (__builtin_memcmp (p, str, sizeof(str)));
68 printf(" 13:%d", !r);
69 __builtin_free(p);
71 p = __builtin_malloc (100);
72 __builtin_memset(p, 0, 100);
73 p = __builtin_realloc (p, 1000);
74 __builtin_memset(p, 0, 1000);
75 __builtin_free(p);
77 p = __builtin_calloc(10, 10);
78 __builtin_memset(p, 0, 100);
79 __builtin_free(p);
81 #if defined(__i386__) || defined(__x86_64__)
82 p = __builtin_alloca(100);
83 __builtin_memset(p, 0, 100);
84 #endif
85 printf("\n");