int printf(const char *, ...);
void p(char *str, int x) {
printf("%s: %d\n", str, x);
}
void q(char *str, double x) {
printf("%s: %f\n", str, x);
}
void r(char *str, void *ptr) {
printf("%s: %p\n", str, ptr);
}
int random(void);
int main() {
int N = random();
#define P(n,args) p(#n #args, __builtin_##n args)
#define Q(n,args) q(#n #args, __builtin_##n args)
#define R(n,args) r(#n #args, __builtin_##n args)
#define V(n,args) p(#n #args, (__builtin_##n args, 0))
P(types_compatible_p, (int, float));
P(choose_expr, (0, 10, 20));
P(constant_p, (sizeof(10)));
P(expect, (N == 12, 0));
V(prefetch, (&N));
V(prefetch, (&N, 1));
V(prefetch, (&N, 1, 0));
Q(huge_val, ());
Q(huge_valf, ());
Q(huge_vall, ());
Q(inf, ());
Q(inff, ());
Q(infl, ());
P(fpclassify, (0, 1, 2, 3, 4, 1.0));
P(fpclassify, (0, 1, 2, 3, 4, 1.0f));
P(fpclassify, (0, 1, 2, 3, 4, 1.0l));
Q(nan, (""));
Q(nanf, (""));
Q(nanl, (""));
Q(nans, (""));
Q(nan, ("10"));
Q(nanf, ("10"));
Q(nanl, ("10"));
Q(nans, ("10"));
P(isgreater, (1., 2.));
P(isgreaterequal, (1., 2.));
P(isless, (1., 2.));
P(islessequal, (1., 2.));
P(islessgreater, (1., 2.));
P(isunordered, (1., 2.));
P(isnan, (1.));
P(abs, (N));
P(clz, (N));
P(clzl, (N));
P(clzll, (N));
P(ctz, (N));
P(ctzl, (N));
P(ctzll, (N));
P(ffs, (N));
P(ffsl, (N));
P(ffsll, (N));
P(parity, (N));
P(parityl, (N));
P(parityll, (N));
P(popcount, (N));
P(popcountl, (N));
P(popcountll, (N));
Q(powi, (1.2f, N));
Q(powif, (1.2f, N));
Q(powil, (1.2f, N));
int a, b, n = random(); char s0[10], s1[] = "Hello";
V(strcat, (s0, s1));
V(strcmp, (s0, s1));
V(strncat, (s0, s1, n));
V(strchr, (s0, s1[0]));
V(strrchr, (s0, s1[0]));
V(strcpy, (s0, s1));
V(strncpy, (s0, s1, n));
V(__memset_chk, (s0, 0, sizeof s0, n));
V(__memcpy_chk, (s0, s1, sizeof s0, n));
V(__memmove_chk, (s0, s1, sizeof s0, n));
V(__mempcpy_chk, (s0, s1, sizeof s0, n));
V(__strncpy_chk, (s0, s1, sizeof s0, n));
V(__strcpy_chk, (s0, s1, n));
s0[0] = 0;
V(__strcat_chk, (s0, s1, n));
P(object_size, (s0, 0));
P(object_size, (s0, 1));
P(object_size, (s0, 2));
P(object_size, (s0, 3));
P(bswap32, (N));
P(bswap64, (N));
V(trap, ());
R(extract_return_addr, (&N));
P(signbit, (1.0));
return 0;
}
void foo() {
__builtin_strcat(0, 0);
}
void bar() {
float f;
double d;
long double ld;
f = __builtin_huge_valf(); d = __builtin_huge_val(); ld = __builtin_huge_vall(); f = __builtin_nanf(""); d = __builtin_nan(""); ld = __builtin_nanl(""); f = __builtin_nanf("0xAE98"); d = __builtin_nan("0xAE98"); ld = __builtin_nanl("0xAE98"); f = __builtin_nansf(""); d = __builtin_nans(""); ld = __builtin_nansl(""); f = __builtin_nansf("0xAE98"); d = __builtin_nans("0xAE98"); ld = __builtin_nansl("0xAE98");
}
void test_float_builtins(float F, double D, long double LD) {
volatile int res;
res = __builtin_isinf(F);
res = __builtin_isinf(D);
res = __builtin_isinf(LD);
res = __builtin_isfinite(F);
res = __builtin_isnormal(F);
}
void test_builtin_longjmp(void **buffer) {
__builtin_longjmp(buffer, 1);
}
long long test_builtin_readcyclecounter() {
return __builtin_readcyclecounter();
}