int foo (int *a, char *b, char *c) { int d = __builtin_memcmp (s.a, e, 100); d += __builtin_memcmp (s.a, e, 200); return d; }
/* * @count: number of allocations to perform * @rounded: if true, only do power-of-2-rounded allocs */ void _test_allocs(int count, int rounded) { int i, size; size = (rounded) ? MINALLOC_SZ : 1; for (i = 0; i < count; i++) { _disrupt(size); p[i].p = kmalloc(size); assert(is_aligned((uintptr_t)p[i].p, 16)); p[i].size = size; if (rounded) { memset32(p[i].p, i, size); size *= 2; size = (size > MAXALLOC_SZ) ? MINALLOC_SZ : size; } else { memset(p[i].p, i, size); size++; size = (size > MAXALLOC_SZ) ? 1 : size; } } for (i = 0; i < count; i++) { size = p[i].size; _disrupt(size); (rounded) ? memset32(tmpbuf, i, size) : memset(tmpbuf, i, size); if (__builtin_memcmp(p[i].p, tmpbuf, size)) panic("_Bucket: FAIL: [%d] buffer at 0x%lx, with size " "%d bytes got corrupted", i, p[i].p, size); kfree(p[i].p); size = ((size / 2) > 1) ? size / 2 : MINALLOC_SZ; p[i].p = kmalloc(size); assert(is_aligned((uintptr_t)p[i].p, 16)); p[i].size = size; (rounded) ? memset32(p[i].p, i, size) : memset(p[i].p, i, size); _disrupt(size); } for (i = 0; i < count; i++) { _disrupt(45); size = p[i].size; (rounded) ? memset32(tmpbuf, i, size) : memset(tmpbuf, i, size); if (__builtin_memcmp(p[i].p, tmpbuf, size)) panic("_Bucket: FAIL: [%d] buffer at 0x%lx, with size " "%d bytes got corrupted", i, p[i].p, size); kfree(p[i].p); _disrupt(32); } printk("_Bucket: %s: Success\n", __FUNCTION__); }
__attribute__ ((noinline)) int f6 (char *p) { int result = 0; result += __builtin_memcmp (p, "ab", 2); result += __builtin_memcmp (p, "abc", 3); return result; }
__attribute__ ((noinline)) int f5 (S * s) { int result = 0; result += __builtin_memcmp (s->s, "ab", 2); result += __builtin_memcmp (s->s, "abc", 3); return result; }
int main() { unsigned int a[10] = { 0xFFFFFFFF }; unsigned int b[10] = { 0xFFFFFFFF }; unsigned int c[10] = { 0xFFFFFFFE }; if (__builtin_memcmp(&a, &a, sizeof(a))) { return 1; } if (__builtin_memcmp(&a, &b, sizeof(a))) { return 1; } if (!__builtin_memcmp(&a, &c, sizeof(a))) { return 1; } return 0; }
int foo (int *a, char *b, char *c) { int d = __builtin_memcmp (&s.a, e, 4); /* No check because s.a was instrumented above with access size 4. */ return s.a; }
_Bool Equal (struct __go_open_array a, struct __go_open_array b) { if (a.__count != b.__count) return 0; return __builtin_memcmp (a.__values, b.__values, a.__count) == 0; }
check (struct A * a, int b) { const char *p; switch (b) { case 0: p = "abcdefghi"; break; case 1: p = "j\0\0\0\0\0\0\0\0"; break; case 2: p = "kl\0\0\0\0\0\0\0"; break; case 3: p = "mnop\0\0\0\0\0"; break; case 4: p = "qrstuvwx\0"; break; default: abort (); } if (__builtin_memcmp (a->c, p, 10) != 0) abort (); }
foo (void) { __m128 x = test (1, n1); if (__builtin_memcmp (&x, &n1, sizeof (x)) != 0) abort (); return 0; }
int matherr (struct exception* e) { const char *n; if (e->type != DOMAIN) return 0; n = e->name; if (__builtin_strcmp (n, "acos") == 0 || __builtin_strcmp (n, "asin") == 0) e->retval = __builtin_nan (""); else if (__builtin_strcmp (n, "atan2") == 0) { if (e->arg1 == 0 && e->arg2 == 0) { double nz; nz = -0.0; if (__builtin_memcmp (&e->arg2, &nz, sizeof (double)) != 0) e->retval = e->arg1; else e->retval = copysign (PI, e->arg1); } else return 0; } else if (__builtin_strcmp (n, "log") == 0 || __builtin_strcmp (n, "log10") == 0) e->retval = __builtin_nan (""); else if (__builtin_strcmp (n, "pow") == 0) { if (e->arg1 < 0) e->retval = __builtin_nan (""); else if (e->arg1 == 0 && e->arg2 == 0) e->retval = 1.0; else if (e->arg1 == 0 && e->arg2 < 0) { double i; if (modf (e->arg2, &i) == 0 && ((int64_t) i & 1) == 1) e->retval = copysign (__builtin_inf (), e->arg1); else e->retval = __builtin_inf (); } else return 0; } else if (__builtin_strcmp (n, "sqrt") == 0) { if (e->arg1 < 0) e->retval = __builtin_nan (""); else return 0; } else return 0; return 1; }
int main (void) { if (__builtin_memcmp (s(foo), "//", 3) != 0) __builtin_abort (); return 0; }
int main () { __builtin_init_dwarf_reg_size_table (dwarf_reg_size_table); if (__builtin_memcmp (ref_reg_size_table, dwarf_reg_size_table, DWARF_FRAME_REGISTERS + 1) != 0) __builtin_abort (); return 0; }
void foo () { /* Instrument a with access size 3. */ int d = __builtin_memcmp (&a, "123", 3); /* This should generate a __builtin___asan_report_store4, because the reference to a has been instrumented above with access size 3. */ a = 1; }
void sse2_test (void) { unaligned x; __m128i y = { 0 }; x = y; y = foo (y, y, y, y, y, y, y, y, 1, 2, 3, 4, 5, 6, -1, x); if (__builtin_memcmp (&y, &x, sizeof (y)) != 0) abort (); }
void foo () { /* Instrument a with access size 5. */ int d = __builtin_memcmp (&a, "12345", 4); /* This should not generate a __builtin___asan_report_store4 because the reference to a has been already instrumented above with access size 5. */ a = 1; }
void sse2_test (void) { packed x; __m128d y = { 0 }; x.f = y; y = foo (y, y, y, y, y, y, y, y, 1, 2, 3, 4, 5, 6, -1, x); if (__builtin_memcmp (&y, &x.f, sizeof (y)) != 0) abort (); }
check (char *dest, char *src, size_t len) { char *result; result = my_stpcpy (dest, src); if (result != dest + len) __builtin_abort (); if (__builtin_memcmp (src, dest, len) != 0) __builtin_abort (); }
void sse2_test (void) { packed x; _Decimal128 y = -1; x.f = y; y = foo (0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, -1, x); if (__builtin_memcmp (&y, &x.f, sizeof (y))) abort (); }
int main (void) { struct E e = {.row = 5,.col = 0,.defaults = {6, {-1, -1, -1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}} }; struct C c[4]; struct A a = { c, 4 }; struct B b = { &a, 1 }; struct D d; __builtin_memset (&c, 0, sizeof c); foo (&e, 65, 2, &b); d = e.defaults.attr; d.columns = 2; if (__builtin_memcmp (&d, &c[0].attr, sizeof d)) __builtin_abort (); d.fragment = 1; if (__builtin_memcmp (&d, &c[1].attr, sizeof d)) __builtin_abort (); return 0; }
bool runtime_showframe(String s, bool current) { static int32 traceback = -1; if(current && runtime_m()->throwing > 0) return 1; if(traceback < 0) traceback = runtime_gotraceback(nil); return traceback > 1 || (__builtin_memchr(s.str, '.', s.len) != nil && __builtin_memcmp(s.str, "runtime.", 7) != 0); }
int main () { int a[4][3][2] = {}; static int a2[4][3][2] = {{{ 0, 0 }, { 0, 0 }, { 0, 0 }}, {{ 312, 381 }, { 295, 356 }, { 337, 335 }}, {{ 1041, 975 }, { 1016, 1085 }, { 935, 1060 }}, {{ 0, 0 }, { 0, 0 }, { 0, 0 }}}; int y[5] = { 0, 1, 1, 1, 0 }; int y2[5] = { 0, 6561, 2401, 289, 0 }; char z2[10] = { 48, 49, 50, 51, 0, 0, 0, 0, 0, 0 }; long w[1][2] = { ~0L, ~0L }; foo (&a[1], y + 1, w, 1, 3L, 4L, 3, 4, 2L, 5); if (__builtin_memcmp (a, a2, sizeof (a)) || __builtin_memcmp (y, y2, sizeof (y)) || __builtin_memcmp (z, z2, sizeof (z)) || w[0][0] != ~0x249249L || w[0][1] != ~0x249249L) __builtin_abort (); return 0; }
int main (void) { __m128 x = { 1.0 }; foo (x, x, x, x, 5); if (__builtin_memcmp (&r, &x, sizeof (r))) abort (); return 0; }
int main () { int a[4][3][2] = {}; static int a2[4][3][2] = {{{ 0, 0 }, { 0, 0 }, { 0, 0 }}, {{ 312, 381 }, { 295, 356 }, { 337, 335 }}, {{ 1041, 975 }, { 1016, 1085 }, { 935, 1060 }}, {{ 0, 0 }, { 0, 0 }, { 0, 0 }}}; int (*p)[3][2] = &a[1]; int y[5] = { 0, 1, 1, 1, 0 }; int y2[5] = { 0, 6561, 2401, 289, 0 }; char z2[10] = { 48, 49, 50, 51, 0, 0, 0, 0, 0, 0 }; long w[1][2] = { ~0L, ~0L }; foo (p, y + 1, w, 1, 3L, 4L, 3, 4, 2L, 5); if (__builtin_memcmp (a, a2, sizeof (a)) || __builtin_memcmp (y, y2, sizeof (y)) || __builtin_memcmp (z, z2, sizeof (z)) || w[0][0] != ~0x249249L || w[0][1] != ~0x249249L) __builtin_abort (); S s; s.foo (1, 3L, 4L, 3, 4, 2L, 5); for (int i = 0; i < 9; i++) if (s.a[i] != (i < 4 ? 0x55555555ULL : 0)) __builtin_abort (); if (__builtin_memcmp (a3, a2, sizeof (a3)) || __builtin_memcmp (y3, y2, sizeof (y3)) || __builtin_memcmp (s.z, z2, sizeof (s.z)) || w3[0][0] != ~0x249249L || w3[0][1] != ~0x249249L) __builtin_abort (); if (bb[0] != 78 || bb[1] != 12 || bb[2] != 22 || bb[3] != 84 || bb[4] != 127) __builtin_abort (); }
foo (int i, vector int j) { char *p = __builtin_alloca (64 + i); m += u.k; v.k = m; w.k = j; if (__builtin_memcmp (&v.c, &w.c, 16) != 0) __builtin_abort (); j += u.k; bar (p, j); j += u.k; bar (p, j); return 0; }
void testf (void) { float xxxxx[8]; int i; xxxxx[0] = __builtin_copysignf (1.0, Yf[0]); xxxxx[1] = __builtin_copysignf (1.0, Yf[1]); xxxxx[2] = __builtin_copysignf (-1.0, Yf[2]); xxxxx[3] = __builtin_copysignf (0.0, Yf[3]); xxxxx[4] = __builtin_copysignf (-0.0, Yf[4]); xxxxx[5] = __builtin_copysignf (-0.0, Yf[5]); xxxxx[6] = __builtin_copysignf (__builtin_inff (), Yf[6]); xxxxx[7] = __builtin_copysignf (-__builtin_nanf (""), Yf[7]); for (i = 0; i < 8; ++i) if (__builtin_memcmp (xxxxx+i, Zf+i, sizeof(float)) != 0) abort (); }
int main(void) { char buf[128]; int ab = __builtin_abs(-7) - __builtin_abs(5); printf("Res1: %d\n", ab); __builtin_memcpy(vals1, vals0, sizeof(vals0)); printf("Res2: %d\n", __builtin_memcmp(vals0, vals1, sizeof(vals0))); __builtin_memset(vals0, 0, sizeof(vals0)); printf("Res3: %d %d %d %d %d\n", vals0[0], vals0[1], vals0[2], vals0[3], vals0[4]); printf("Res4: %d\n", (int) __builtin_strlen("Hello World")); printf("Res5: %d\n", __builtin_strcmp(hello, "Hello World") > 0); __builtin_strcpy(buf, hello); printf("Res6: %s\n", buf); return 0; }
int main () { char a[8] = ""; __builtin_strcpy (a, "123"); size_t n0 = __builtin_strlen (a); __builtin_strncat (a + 3, a, n0); /* { dg-warning "specified bound depends on the length" } */ size_t n1 = __builtin_strlen (a); if (n1 == n0) __builtin_abort (); a[6] = '7'; __builtin_strcpy (a, "456"); size_t n2; if (foo (a, a + 3, &n2) != 6 || n2 != 3) __builtin_abort (); if (__builtin_memcmp (a, "456456\0", sizeof "456456\0")) __builtin_abort (); return 0; }
int main (void) { char buf[18]; unsigned short s[18]; unsigned char c[18] = "abcdefghijklmnopq"; int i; for (i = 0; i < 256; i++) { v2[i] = i; v3[i] = i + 1; } for (i = 0; i < 18; i++) s[i] = c[i]; s[5] |= 0x600; s[6] |= 0x500; s[11] |= 0x2000; s[15] |= 0x500; foo (); if (bar (17, s, buf) != 17 || __builtin_memcmp (buf, "abcdeghhijkmmnoqq", 18) != 0) __builtin_abort (); return 0; }
int baz (char *a, char *b) { return __builtin_memcmp (a, b, 30000); }
void foo (struct S s) { if (__builtin_memcmp (s.arr, A, 4)) __builtin_abort (); }