1  /* Test built-in string functions with large sizes.  PR 78460.  */
       2  
       3  typedef __SIZE_TYPE__ size_t;
       4  
       5  #define SIZE1 ((size_t) -1)
       6  #define SIZE2 (SIZE1 >> 1)
       7  #define SIZE3 ((unsigned int) -1)
       8  #define SIZE4 (SIZE3 >> 1)
       9  
      10  volatile int v1, v2, v3, v4;
      11  void *volatile vp1, *volatile vp2, *volatile vp3, *volatile vp4;
      12  
      13  void
      14  test_memchr (const void *a, int b)
      15  {
      16    vp1 = __builtin_memchr (a, b, SIZE1);
      17    vp2 = __builtin_memchr (a, b, SIZE2);
      18    vp3 = __builtin_memchr (a, b, SIZE3);
      19    vp4 = __builtin_memchr (a, b, SIZE4);
      20  }
      21  
      22  void
      23  test_memcmp (const void *a, const void *b)
      24  {
      25    v1 = __builtin_memcmp (a, b, SIZE1);
      26    v2 = __builtin_memcmp (a, b, SIZE2);
      27    v3 = __builtin_memcmp (a, b, SIZE3);
      28    v4 = __builtin_memcmp (a, b, SIZE4);
      29  }
      30  
      31  void
      32  test_memcpy (void *a, const void *b)
      33  {
      34    vp1 = __builtin_memcpy (a, b, SIZE1);
      35    vp2 = __builtin_memcpy (a, b, SIZE2);
      36    vp3 = __builtin_memcpy (a, b, SIZE3);
      37    vp4 = __builtin_memcpy (a, b, SIZE4);
      38  }
      39  
      40  void
      41  test_memmove (void *a, const void *b)
      42  {
      43    vp1 = __builtin_memmove (a, b, SIZE1);
      44    vp2 = __builtin_memmove (a, b, SIZE2);
      45    vp3 = __builtin_memmove (a, b, SIZE3);
      46    vp4 = __builtin_memmove (a, b, SIZE4);
      47  }
      48  
      49  void
      50  test_mempcpy (void *a, const void *b)
      51  {
      52    vp1 = __builtin_mempcpy (a, b, SIZE1);
      53    vp2 = __builtin_mempcpy (a, b, SIZE2);
      54    vp3 = __builtin_mempcpy (a, b, SIZE3);
      55    vp4 = __builtin_mempcpy (a, b, SIZE4);
      56  }
      57  
      58  void
      59  test_memset (void *a, int b)
      60  {
      61    vp1 = __builtin_memset (a, b, SIZE1);
      62    vp2 = __builtin_memset (a, b, SIZE2);
      63    vp3 = __builtin_memset (a, b, SIZE3);
      64    vp4 = __builtin_memset (a, b, SIZE4);
      65  }
      66  
      67  void
      68  test_stpncpy (char *a, const char *b)
      69  {
      70    vp1 = __builtin_stpncpy (a, b, SIZE1);
      71    vp2 = __builtin_stpncpy (a, b, SIZE2);
      72    vp3 = __builtin_stpncpy (a, b, SIZE3);
      73    vp4 = __builtin_stpncpy (a, b, SIZE4);
      74  }
      75  
      76  void
      77  test_strndup (const char *a)
      78  {
      79    vp1 = __builtin_strndup (a, SIZE1);
      80    vp2 = __builtin_strndup (a, SIZE2);
      81    vp3 = __builtin_strndup (a, SIZE3);
      82    vp4 = __builtin_strndup (a, SIZE4);
      83  }
      84  
      85  void
      86  test_strncasecmp (const char *a, const char *b)
      87  {
      88    v1 = __builtin_strncasecmp (a, b, SIZE1);
      89    v2 = __builtin_strncasecmp (a, b, SIZE2);
      90    v3 = __builtin_strncasecmp (a, b, SIZE3);
      91    v4 = __builtin_strncasecmp (a, b, SIZE4);
      92  }
      93  
      94  void
      95  test_strncat (char *a, const char *b)
      96  {
      97    vp1 = __builtin_strncat (a, b, SIZE1);
      98    vp2 = __builtin_strncat (a, b, SIZE2);
      99    vp3 = __builtin_strncat (a, b, SIZE3);
     100    vp4 = __builtin_strncat (a, b, SIZE4);
     101  }
     102  
     103  void
     104  test_strncmp (const char *a, const char *b)
     105  {
     106    v1 = __builtin_strncmp (a, b, SIZE1);
     107    v2 = __builtin_strncmp (a, b, SIZE2);
     108    v3 = __builtin_strncmp (a, b, SIZE3);
     109    v4 = __builtin_strncmp (a, b, SIZE4);
     110  }
     111  
     112  void
     113  test_strncpy (char *a, const char *b)
     114  {
     115    vp1 = __builtin_strncpy (a, b, SIZE1);
     116    vp2 = __builtin_strncpy (a, b, SIZE2);
     117    vp3 = __builtin_strncpy (a, b, SIZE3);
     118    vp4 = __builtin_strncpy (a, b, SIZE4);
     119  }