posix_memalign is portable to older, non-c11 runtimes.

2017-02-17  Uros Bizjak  <ubiz...@gmail.com>

    * gcc.dg/strncmp-2.c (test_driver_strncmp): Use posix_memalign
    instead of aligned_alloc.

Tested on x86_64-linux-gnu, CentOS 5.11.

OK for mainline?

Uros.
diff --git a/gcc/testsuite/gcc.dg/strncmp-2.c b/gcc/testsuite/gcc.dg/strncmp-2.c
index 0c9a07a..8d799a1 100644
--- a/gcc/testsuite/gcc.dg/strncmp-2.c
+++ b/gcc/testsuite/gcc.dg/strncmp-2.c
@@ -19,10 +19,13 @@ static void test_driver_strncmp (void (test_strncmp)(const 
char *, const char *,
 {
   long pgsz = sysconf(_SC_PAGESIZE);
   char buf1[sz+1];
-  char *buf2 = aligned_alloc(pgsz,2*pgsz);
+  char *buf2;
   char *p2;
   int r,i,e;
 
+  r = posix_memalign ((void **)&buf2,pgsz,2*pgsz);
+  if (r < 0) abort ();
+
   r = mprotect (buf2+pgsz,pgsz,PROT_NONE);
   if (r < 0) abort();
   

Reply via email to