Home | History | Annotate | Download | only in ld-plugin
      1 #define ASMNAME(cname)  ASMNAME2 (__USER_LABEL_PREFIX__, cname)
      2 #define ASMNAME2(prefix, cname) STRING (prefix) cname
      3 #define STRING(x)    #x
      4 
      5 typedef __SIZE_TYPE__ size_t;
      6 extern void abort (void);
      7 extern void *memcpy (void *, const void *, size_t)
      8   __asm (ASMNAME ("my_memcpy"));
      9 extern void bcopy (const void *, void *, size_t)
     10   __asm (ASMNAME ("my_bcopy"));
     11 extern void *memset (void *, int, size_t)
     12   __asm (ASMNAME ("my_memset"));
     13 extern void bzero (void *, size_t)
     14   __asm (ASMNAME ("my_bzero"));
     15 extern int memcmp (const void *, const void *, size_t);
     16 
     17 struct A { char c[32]; } a = { "foobar" };
     18 char x[64] = "foobar", y[64];
     19 int i = 39, j = 6, k = 4;
     20 
     21 extern int inside_main;
     22 
     23 void
     24 main_test (void)
     25 {
     26   struct A b = a;
     27   struct A c = { { 'x' } };
     28 
     29   inside_main = 1;
     30 
     31   if (memcmp (b.c, x, 32) || c.c[0] != 'x' || memcmp (c.c + 1, x + 32, 31))
     32     abort ();
     33   if (__builtin_memcpy (y, x, i) != y || memcmp (x, y, 64))
     34     abort ();
     35   if (memcpy (y + 6, x, j) != y + 6
     36       || memcmp (x, y, 6) || memcmp (x, y + 6, 58))
     37     abort ();
     38   if (__builtin_memset (y + 2, 'X', k) != y + 2
     39       || memcmp (y, "foXXXXfoobar", 13))
     40     abort ();
     41   bcopy (y + 1, y + 2, 6);
     42   if (memcmp (y, "fooXXXXfobar", 13))
     43     abort ();
     44   __builtin_bzero (y + 4, 2);
     45   if (memcmp (y, "fooX\0\0Xfobar", 13))
     46     abort ();
     47 }
     48