|
From: <sv...@va...> - 2009-04-15 02:39:13
|
Author: njn
Date: 2009-04-15 03:38:41 +0100 (Wed, 15 Apr 2009)
New Revision: 9533
Log:
Create three header files, tests/malloc.h, tests/sys_mman.h, and tests/asm.h
that factor out common platform differences in the tests, and applied them.
This reduces the number of failures by 24, mostly by allowing a number of
tests containing asm code to run again. It also fixes bug #179731.
Added:
branches/DARWIN/tests/asm.h
branches/DARWIN/tests/malloc.h
branches/DARWIN/tests/sys_mman.h
Modified:
branches/DARWIN/Makefile.tool-tests.am
branches/DARWIN/exp-ptrcheck/tests/mm.c
branches/DARWIN/massif/tests/custom_alloc.c
branches/DARWIN/massif/tests/malloc_usable.c
branches/DARWIN/memcheck/tests/addressable.c
branches/DARWIN/memcheck/tests/amd64/sse_memory.c
branches/DARWIN/memcheck/tests/badjump.c
branches/DARWIN/memcheck/tests/custom_alloc.c
branches/DARWIN/memcheck/tests/file_locking.c
branches/DARWIN/memcheck/tests/linux/stack_switch.c
branches/DARWIN/memcheck/tests/mallinfo.c
branches/DARWIN/memcheck/tests/malloc_usable.c
branches/DARWIN/memcheck/tests/memalign2.c
branches/DARWIN/memcheck/tests/mempool.c
branches/DARWIN/memcheck/tests/mmaptest.c
branches/DARWIN/memcheck/tests/origin1-yes.c
branches/DARWIN/memcheck/tests/pointer-trace.c
branches/DARWIN/memcheck/tests/sh-mem-random.c
branches/DARWIN/memcheck/tests/sigaltstack.c
branches/DARWIN/memcheck/tests/signal2.c
branches/DARWIN/memcheck/tests/stack_changes.c
branches/DARWIN/memcheck/tests/str_tester.c
branches/DARWIN/memcheck/tests/x86-linux/bug133694.c
branches/DARWIN/memcheck/tests/x86/Makefile.am
branches/DARWIN/memcheck/tests/x86/fxsave.c
branches/DARWIN/none/tests/amd64/bug137714-amd64.c
branches/DARWIN/none/tests/amd64/faultstatus.c
branches/DARWIN/none/tests/amd64/nibz_bennee_mmap.c
branches/DARWIN/none/tests/amd64/redundantRexW.c
branches/DARWIN/none/tests/amd64/smc1.c
branches/DARWIN/none/tests/amd64/ssse3_misaligned.c
branches/DARWIN/none/tests/faultstatus.c
branches/DARWIN/none/tests/linux/mremap.c
branches/DARWIN/none/tests/linux/mremap2.c
branches/DARWIN/none/tests/map_unaligned.c
branches/DARWIN/none/tests/map_unmap.c
branches/DARWIN/none/tests/munmap_exe.c
branches/DARWIN/none/tests/ppc32/jm-insns.c
branches/DARWIN/none/tests/ppc32/test_fx.c
branches/DARWIN/none/tests/ppc32/test_gx.c
branches/DARWIN/none/tests/susphello.c
branches/DARWIN/none/tests/x86/Makefile.am
branches/DARWIN/none/tests/x86/bug126147-x86.c
branches/DARWIN/none/tests/x86/cmpxchg8b.c
branches/DARWIN/none/tests/x86/faultstatus.c
branches/DARWIN/none/tests/x86/fcmovnu.c
branches/DARWIN/none/tests/x86/fxtract.c
branches/DARWIN/none/tests/x86/incdec_alt.c
branches/DARWIN/none/tests/x86/jcxz.c
branches/DARWIN/none/tests/x86/lahf.c
branches/DARWIN/none/tests/x86/looper.c
branches/DARWIN/none/tests/x86/sbbmisc.c
branches/DARWIN/none/tests/x86/ssse3_misaligned.c
branches/DARWIN/perf/Makefile.am
branches/DARWIN/perf/bigcode.c
branches/DARWIN/perf/bz2.c
branches/DARWIN/tests/Makefile.am
Modified: branches/DARWIN/Makefile.tool-tests.am
===================================================================
--- branches/DARWIN/Makefile.tool-tests.am 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/Makefile.tool-tests.am 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,3 +1,4 @@
+# This file is used for tool tests, and also in perf/Makefile.am.
include $(top_srcdir)/Makefile.flags.am # For AM_FLAG_M3264_PRI
Modified: branches/DARWIN/exp-ptrcheck/tests/mm.c
===================================================================
--- branches/DARWIN/exp-ptrcheck/tests/mm.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/exp-ptrcheck/tests/mm.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,4 @@
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <unistd.h>
#include "arith_include1.c"
@@ -11,10 +11,6 @@
write(-1, buf, len);
}
-#if defined(__APPLE__)
-# define MAP_ANONYMOUS MAP_ANON
-#endif
-
int main(void)
{
struct sigaction sigsegv;
Modified: branches/DARWIN/massif/tests/custom_alloc.c
===================================================================
--- branches/DARWIN/massif/tests/custom_alloc.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/massif/tests/custom_alloc.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,5 +1,5 @@
#include <unistd.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <assert.h>
#include <stdlib.h>
@@ -14,7 +14,7 @@
void* get_superblock(void)
{
void* p = mmap( 0, SUPERBLOCK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANON, -1, 0 );
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
assert(p != ((void*)(-1)));
Modified: branches/DARWIN/massif/tests/malloc_usable.c
===================================================================
--- branches/DARWIN/massif/tests/malloc_usable.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/massif/tests/malloc_usable.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,15 +1,11 @@
#include <assert.h>
-#if defined(__APPLE__)
-#include <malloc/malloc.h>
-#else
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
-# if !defined(_AIX) && !defined(__APPLE__)
+# if !defined(VGO_aix5) && !defined(VGO_darwin)
// Because our allocations are in multiples of 8 or 16, 99 will round up
// to 104 or 112.
int* x = malloc(99);
Modified: branches/DARWIN/memcheck/tests/addressable.c
===================================================================
--- branches/DARWIN/memcheck/tests/addressable.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/addressable.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,6 +1,6 @@
/* Test different kinds of addressability and definedness */
#include "../memcheck.h"
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <stdio.h>
#include <sys/resource.h>
#include <unistd.h>
@@ -14,19 +14,18 @@
static char *mm(char *addr, int size, int prot)
{
- #if defined(__APPLE__)
- # define MAP_ANONYMOUS MAP_ANON
- #endif
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
char *ret;
- if (addr) flags |= MAP_FIXED;
+ if (addr)
+ flags |= MAP_FIXED;
ret = mmap(addr, size, prot, flags, -1, 0);
if (ret == (char *)-1) {
perror("mmap failed");
exit(1);
}
+
return ret;
}
@@ -34,6 +33,7 @@
static void test1()
{
char *m = mm(0, pgsz * 5, PROT_READ);
+
VALGRIND_CHECK_MEM_IS_DEFINED(m, pgsz*5); /* all defined */
}
Modified: branches/DARWIN/memcheck/tests/amd64/sse_memory.c
===================================================================
--- branches/DARWIN/memcheck/tests/amd64/sse_memory.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/amd64/sse_memory.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -6,7 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-#include <malloc.h>
+#include "tests/malloc.h"
#include <string.h>
typedef unsigned char V128[16];
@@ -148,7 +148,7 @@
} \
for (i = 0; i < 5; i++) { \
randRMArgs(&margs); \
- buf = memalign(16,mem_size); \
+ buf = memalign16(mem_size); \
randomise(buf,mem_size); \
r_m_##insn(&margs,buf); \
showRM(#insn, &margs, buf, mem_size, res_mask);\
Modified: branches/DARWIN/memcheck/tests/badjump.c
===================================================================
--- branches/DARWIN/memcheck/tests/badjump.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/badjump.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,5 @@
-char* get_bad_place ( void );
+#include "tests/sys_mman.h"
+
int main ( void )
{
#if defined(__powerpc64__) || defined(_AIX)
@@ -7,32 +8,13 @@
uniform behaviour on all supported targets - a jump to an
unmapped page - the following is needed. */
unsigned long long int fake_fndescr[3];
- fake_fndescr[0] = (unsigned long long int)get_bad_place();
+ fake_fndescr[0] = (unsigned long long int)get_unmapped_page();
fake_fndescr[1] = 0;
fake_fndescr[2] = 0;
return ((int(*)(void)) fake_fndescr) ();
#else
- char* p = get_bad_place();
+ char* p = get_unmapped_page();
return ((int(*)(void)) p) ();
#endif
}
-#include <sys/mman.h>
-#include <assert.h>
-#include <unistd.h>
-
-/* map a page, then unmap it, then return that address. That
- guarantees to give an address which will fault when accessed,
- without making any assumptions about the layout of the address
- space. */
-
-char* get_bad_place ( void )
-{
- long pagesz = sysconf(_SC_PAGE_SIZE);
- assert(pagesz == 4096 || pagesz == 65536);
- void* ptr = mmap(0, pagesz, PROT_READ, MAP_ANON|MAP_PRIVATE, -1, 0);
- assert(ptr != (void*)-1);
- int r = munmap(ptr, pagesz);
- assert(r == 0);
- return ptr;
-}
Modified: branches/DARWIN/memcheck/tests/custom_alloc.c
===================================================================
--- branches/DARWIN/memcheck/tests/custom_alloc.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/custom_alloc.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,5 +1,5 @@
#include <unistd.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <assert.h>
#include <stdlib.h>
@@ -14,7 +14,7 @@
void* get_superblock(void)
{
void* p = mmap( 0, SUPERBLOCK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANON, -1, 0 );
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
assert(p != ((void*)(-1)));
Modified: branches/DARWIN/memcheck/tests/file_locking.c
===================================================================
--- branches/DARWIN/memcheck/tests/file_locking.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/file_locking.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -9,7 +9,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
Modified: branches/DARWIN/memcheck/tests/linux/stack_switch.c
===================================================================
--- branches/DARWIN/memcheck/tests/linux/stack_switch.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/linux/stack_switch.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -6,7 +6,7 @@
#include <sched.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <sys/syscall.h>
#include <sys/wait.h>
#include <unistd.h>
Modified: branches/DARWIN/memcheck/tests/mallinfo.c
===================================================================
--- branches/DARWIN/memcheck/tests/mallinfo.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/mallinfo.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,8 +1,4 @@
-#if defined(__APPLE__)
-#include <malloc/malloc.h>
-#else
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // getopt()
Modified: branches/DARWIN/memcheck/tests/malloc_usable.c
===================================================================
--- branches/DARWIN/memcheck/tests/malloc_usable.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/malloc_usable.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,15 +1,11 @@
#include <assert.h>
-#if defined(__APPLE__)
-#include <malloc/malloc.h>
-#else
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
-# if !defined(_AIX) && !defined(__APPLE__)
+# if !defined(VGO_aix5) && !defined(VGO_darwin)
// Because Memcheck marks any slop as inaccessible, it doesn't round up
// sizes for malloc_usable_size().
int* x = malloc(99);
Modified: branches/DARWIN/memcheck/tests/memalign2.c
===================================================================
--- branches/DARWIN/memcheck/tests/memalign2.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/memalign2.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -14,23 +14,20 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
-#if defined(__APPLE__)
-#include <malloc/malloc.h>
-#else
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
#include <errno.h>
int main ( void )
{
-# if defined(_AIX)
+# if defined(VGO_aix5)
// AIX 5.2 has neither memalign() nor posix_memalign(); do nothing.
-# elif defined(__APPLE__)
+# elif defined(VGO_darwin)
// Likewise for Mac OS X.
# else
// Nb: assuming VG_MIN_MALLOC_SZB is 8!
+ // DDD: (this is no longer true)
// Should work with both 32-bit and 64-bit pointers, though.
int* p;
Modified: branches/DARWIN/memcheck/tests/mempool.c
===================================================================
--- branches/DARWIN/memcheck/tests/mempool.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/mempool.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,18 +1,17 @@
#include <unistd.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <assert.h>
#include <stdlib.h>
+
#include "../memcheck.h"
-#if !defined(MAP_ANONYMOUS)
-#define MAP_ANONYMOUS 0
-#endif
#define SUPERBLOCK_SIZE 100000
#define REDZONE_SIZE 8
static const int USE_MMAP = 0;
-typedef struct _level_list {
+typedef struct _level_list
+{
struct _level_list *next;
char *where;
} level_list;
@@ -27,6 +26,7 @@
pool *make_pool()
{
pool *p;
+
if(USE_MMAP) {
p = (pool *)mmap(0, sizeof(pool), PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
Modified: branches/DARWIN/memcheck/tests/mmaptest.c
===================================================================
--- branches/DARWIN/memcheck/tests/mmaptest.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/mmaptest.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -2,7 +2,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
int main()
{
Modified: branches/DARWIN/memcheck/tests/origin1-yes.c
===================================================================
--- branches/DARWIN/memcheck/tests/origin1-yes.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/origin1-yes.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -13,7 +13,7 @@
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <unistd.h>
#include "../memcheck.h"
@@ -124,9 +124,6 @@
// mmap block, initialised
{
- #if defined(__APPLE__)
- # define MAP_ANONYMOUS MAP_ANON
- #endif
int* ptr_to_def_mmap_int =
mmap(0, 4096, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
int def_mmap_int = *ptr_to_def_mmap_int;
Modified: branches/DARWIN/memcheck/tests/pointer-trace.c
===================================================================
--- branches/DARWIN/memcheck/tests/pointer-trace.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/pointer-trace.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -2,15 +2,14 @@
Make sure that leak-check's pointer tracing avoids traps, i.e. tricky
memory areas where it could crash if not careful.
*/
+
#include <stdio.h>
#include "memcheck/memcheck.h"
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
-#if defined(__APPLE__)
-# define MAP_ANONYMOUS MAP_ANON
-#endif
+
#if !defined(MAP_NORESERVE)
# define MAP_NORESERVE 0
#endif
@@ -21,6 +20,7 @@
int i;
int fd;
char *map;
+
/* I _think_ the point of this is to fill ptrs with a pointer
to every 4th page in the entire address space, hence
guaranteeing that at least one of them points into one of
Modified: branches/DARWIN/memcheck/tests/sh-mem-random.c
===================================================================
--- branches/DARWIN/memcheck/tests/sh-mem-random.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/sh-mem-random.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include "memcheck/memcheck.h"
// All the sizes here are in *bytes*, not bits.
@@ -22,11 +22,7 @@
#define PAGE_SIZE 4096ULL
-#if !defined(MAP_ANONYMOUS)
-#define MAP_ANONYMOUS 0
-#endif
-
// XXX: should check the error cases for SET/GET_VBITS also
// For the byte 'x', build a value of 'size' bytes from that byte, eg:
Modified: branches/DARWIN/memcheck/tests/sigaltstack.c
===================================================================
--- branches/DARWIN/memcheck/tests/sigaltstack.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/sigaltstack.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
void sig_handler(int sig){
int var;
@@ -19,7 +19,7 @@
// ask for an alt stack with EXEC permissions,
// since signal returning requires execution of code on the stack.
char *stk = (char *)mmap(0, size, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_ANON|MAP_PRIVATE, -1, 0);
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
sigstk.ss_sp = stk;
sigstk.ss_size = size;
Modified: branches/DARWIN/memcheck/tests/signal2.c
===================================================================
--- branches/DARWIN/memcheck/tests/signal2.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/signal2.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -2,39 +2,20 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
+#include "tests/sys_mman.h"
void sig_hdlr ( int signo ) {
printf ( "caught sig segv\n" ); exit(1);
}
-char* get_bad_place ( void );
int main ( void ) {
char* badplace;
printf ( "installing sig handler\n" );
signal(SIGSEGV, sig_hdlr);
printf ( "doing bad thing\n" );
- badplace = get_bad_place();
+ badplace = get_unmapped_page();
*(int*)badplace = 0;
printf ( "exited normally ?!\n" );
return 0;
}
-#include <sys/mman.h>
-#include <assert.h>
-#include <unistd.h>
-
-/* map a page, then unmap it, then return that address. That
- guarantees to give an address which will fault when accessed,
- without making any assumptions about the layout of the address
- space. */
-
-char* get_bad_place ( void )
-{
- long pagesz = sysconf(_SC_PAGE_SIZE);
- assert(pagesz == 4096 || pagesz == 65536);
- void* ptr = mmap(0, pagesz, PROT_READ, MAP_ANON|MAP_PRIVATE, -1, 0);
- assert(ptr != (void*)-1);
- int r = munmap(ptr, pagesz);
- assert(r == 0);
- return ptr;
-}
Modified: branches/DARWIN/memcheck/tests/stack_changes.c
===================================================================
--- branches/DARWIN/memcheck/tests/stack_changes.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/stack_changes.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ucontext.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include "valgrind.h"
@@ -39,7 +39,7 @@
}
stack = (void *)mmap(0, STACK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_ANON|MAP_PRIVATE, -1, 0);
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if (stack == (void*)-1) {
perror("mmap");
Modified: branches/DARWIN/memcheck/tests/str_tester.c
===================================================================
--- branches/DARWIN/memcheck/tests/str_tester.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/str_tester.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -264,6 +264,7 @@
SIMPLE_COPY(stpcpy, 16, "6666666666666666", 59);
}
+// DDD: better done by testing for the function.
#if !defined(__APPLE__)
static void
test_stpncpy (void)
@@ -465,6 +466,7 @@
}
}
+// DDD: better done by testing for the function.
#if !defined(_AIX) && !defined(__APPLE__)
static void
test_strchrnul (void)
@@ -501,6 +503,7 @@
}
#endif /* !defined(_AIX) */
+// DDD: better done by testing for the function.
#if !defined(_AIX) && !defined(__APPLE__)
static void
test_rawmemchr (void)
@@ -576,6 +579,7 @@
}
}
+// DDD: better done by testing for the function.
#if !defined(_AIX) && !defined(__APPLE__)
static void
test_memrchr (void)
Modified: branches/DARWIN/memcheck/tests/x86/Makefile.am
===================================================================
--- branches/DARWIN/memcheck/tests/x86/Makefile.am 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/x86/Makefile.am 2009-04-15 02:38:41 UTC (rev 9533)
@@ -29,19 +29,20 @@
bug152022 \
espindola2 \
fpeflags \
+ fprem \
+ fxsave \
pushfw_x86 \
- fprem xor-undef-x86
+ xor-undef-x86 \
+ sse_memory
# DDD: not sure if these ones should work on Darwin or not... if not, should
# be moved into x86-linux/.
if ! VGCONF_OS_IS_DARWIN
check_PROGRAMS += \
- fxsave \
int3-x86 \
more_x86_fp \
pushfpopf \
pushpopmem \
- sse_memory \
tronical
endif
Modified: branches/DARWIN/memcheck/tests/x86/fxsave.c
===================================================================
--- branches/DARWIN/memcheck/tests/x86/fxsave.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/x86/fxsave.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,11 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
-#if defined(__APPLE__)
-# include <malloc/malloc.h>
-#else
-# include <malloc.h>
-#endif
+#include "tests/asm.h"
+#include "tests/malloc.h"
#include <string.h>
const unsigned int vec0[4]
@@ -38,14 +35,14 @@
"fldz\n\t"
"fldz\n\t"
"finit\n");
- asm __volatile__("movups vecZ, %xmm0");
- asm __volatile__("movups vecZ, %xmm1");
- asm __volatile__("movups vecZ, %xmm2");
- asm __volatile__("movups vecZ, %xmm3");
- asm __volatile__("movups vecZ, %xmm4");
- asm __volatile__("movups vecZ, %xmm5");
- asm __volatile__("movups vecZ, %xmm6");
- asm __volatile__("movups vecZ, %xmm7");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm0");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm1");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm2");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm3");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm4");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm5");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm6");
+ asm __volatile__("movups " VG_SYM(vecZ) ", %xmm7");
asm __volatile__(
"pushl $0\n\t"
"ldmxcsr 0(%esp)\n\t"
@@ -62,8 +59,8 @@
asm __volatile__("fldlg2");
asm __volatile__("fld %st(3)");
asm __volatile__("fld %st(3)");
- asm __volatile__("movups vec0, %xmm0");
- asm __volatile__("movups vec1, %xmm1");
+ asm __volatile__("movups " VG_SYM(vec0) ", %xmm0");
+ asm __volatile__("movups " VG_SYM(vec1) ", %xmm1");
asm __volatile__("xorps %xmm2, %xmm2");
asm __volatile__("movaps %xmm2, %xmm3");
asm __volatile__("movaps %xmm2, %xmm4");
@@ -106,9 +103,9 @@
int main ( int argc, char** argv )
{
- unsigned char* buf1 = memalign(16,512);
- unsigned char* buf2 = memalign(16,512);
- unsigned char* buf3 = memalign(16,512);
+ unsigned char* buf1 = memalign16(512);
+ unsigned char* buf2 = memalign16(512);
+ unsigned char* buf3 = memalign16(512);
int xx = argc > 1;
printf("Re-run with any arg to suppress least-significant\n"
" 16 bits of FP numbers\n");
Modified: branches/DARWIN/memcheck/tests/x86-linux/bug133694.c
===================================================================
--- branches/DARWIN/memcheck/tests/x86-linux/bug133694.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/memcheck/tests/x86-linux/bug133694.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
int main(int argc, char **argv)
{
Modified: branches/DARWIN/none/tests/amd64/bug137714-amd64.c
===================================================================
--- branches/DARWIN/none/tests/amd64/bug137714-amd64.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/amd64/bug137714-amd64.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <assert.h>
typedef unsigned char UChar;
Modified: branches/DARWIN/none/tests/amd64/faultstatus.c
===================================================================
--- branches/DARWIN/none/tests/amd64/faultstatus.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/amd64/faultstatus.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <setjmp.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <unistd.h>
struct test {
Modified: branches/DARWIN/none/tests/amd64/nibz_bennee_mmap.c
===================================================================
--- branches/DARWIN/none/tests/amd64/nibz_bennee_mmap.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/amd64/nibz_bennee_mmap.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -27,12 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
-#include <sys/mman.h>
+#include "vgtest_sys_mman.h"
-#if !defined(MAP_ANONYMOUS)
-#define MAP_ANONYMOUS 0
-#endif
-
int main(int argc, char **argv)
{
void *p;
Modified: branches/DARWIN/none/tests/amd64/redundantRexW.c
===================================================================
--- branches/DARWIN/none/tests/amd64/redundantRexW.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/amd64/redundantRexW.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -7,9 +7,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
-#if !defined(__APPLE__)
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
typedef unsigned char UChar;
@@ -170,20 +168,9 @@
{
XMMRegs* regs;
Mem* mem;
- // Darwin lacks memalign, but malloc is always 16-aligned anyway.
- #if defined(__APPLE__)
- regs = malloc(sizeof(XMMRegs) + 16); assert(regs);
- mem = malloc(sizeof(Mem) + 16); assert(mem);
- #else
- regs = memalign(16, sizeof(XMMRegs) + 16); assert(regs);
- mem = memalign(16, sizeof(Mem) + 16); assert(mem);
- #endif
+ regs = memalign16(sizeof(XMMRegs) + 16);
+ mem = memalign16(sizeof(Mem) + 16);
- /* Both have to be 16-aligned so we can do movapd et al. 16-byte
- * alignment is standard on AMD64. */
- assert( 0 == (0xFL & (unsigned long int)regs) );
- assert( 0 == (0xFL & (unsigned long int)mem) );
-
/* addpd mem, reg 66 49 0f 58 48 00 rex.WB addpd 0x0(%r8),%xmm1 */
{
before_test( regs, mem );
Modified: branches/DARWIN/none/tests/amd64/smc1.c
===================================================================
--- branches/DARWIN/none/tests/amd64/smc1.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/amd64/smc1.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <assert.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
typedef unsigned long long int Addr;
typedef unsigned char UChar;
@@ -101,7 +101,7 @@
{
int i;
code = mmap(NULL, 20, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANON, -1, 0);
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
assert(code != MAP_FAILED);
for (i = 0; i < 10; i += 2) {
set_dest ( (Addr)&p );
Modified: branches/DARWIN/none/tests/amd64/ssse3_misaligned.c
===================================================================
--- branches/DARWIN/none/tests/amd64/ssse3_misaligned.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/amd64/ssse3_misaligned.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,8 +1,5 @@
-
-#if !defined(__APPLE__)
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -11,14 +8,7 @@
void maybe_fault ( int delta )
{
- // Darwin lacks memalign, but malloc is always 16-aligned anyway.
- #if defined(__APPLE__)
- char* x = malloc(32/*size*/);
- #else
- char* x = memalign(16/*alignment*/,32/*size*/);
- #endif
- assert(x);
- assert(0 == ((16-1) & (unsigned long)x));
+ char* x = memalign16(32);
memset(x, 0, 32);
__asm__ __volatile__(
"pabsb (%0),%%xmm7"
Modified: branches/DARWIN/none/tests/faultstatus.c
===================================================================
--- branches/DARWIN/none/tests/faultstatus.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/faultstatus.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <setjmp.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <unistd.h>
/*
Modified: branches/DARWIN/none/tests/linux/mremap.c
===================================================================
--- branches/DARWIN/none/tests/linux/mremap.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/linux/mremap.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <stdio.h>
#include <stdlib.h>
Modified: branches/DARWIN/none/tests/linux/mremap2.c
===================================================================
--- branches/DARWIN/none/tests/linux/mremap2.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/linux/mremap2.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -2,7 +2,7 @@
#include <stdio.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <assert.h>
#include <stdlib.h>
#include <sys/types.h>
Modified: branches/DARWIN/none/tests/map_unaligned.c
===================================================================
--- branches/DARWIN/none/tests/map_unaligned.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/map_unaligned.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,11 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
-#if defined(__APPLE__)
-# define MAP_ANONYMOUS MAP_ANON
-#endif
-
int main(int argc, char **argv)
{
void *p1;
Modified: branches/DARWIN/none/tests/map_unmap.c
===================================================================
--- branches/DARWIN/none/tests/map_unmap.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/map_unmap.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,5 +1,5 @@
#include <stdio.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <stdlib.h>
#include <unistd.h>
@@ -10,7 +10,7 @@
static void *domap(void)
{
- void *ret = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
+ void *ret = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (ret == (void *)-1) {
perror("mmap");
Modified: branches/DARWIN/none/tests/munmap_exe.c
===================================================================
--- branches/DARWIN/none/tests/munmap_exe.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/munmap_exe.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,5 +1,5 @@
#include <unistd.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <stdio.h>
#include <stdlib.h>
@@ -11,7 +11,7 @@
{
void* m;
- m = mmap(NULL, 100, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0);
+ m = mmap(NULL, 100, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (m == (void*)-1) {
fprintf(stderr, "error mmapping\n");
Modified: branches/DARWIN/none/tests/ppc32/jm-insns.c
===================================================================
--- branches/DARWIN/none/tests/ppc32/jm-insns.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/ppc32/jm-insns.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -166,7 +166,7 @@
#include <stdint.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
/* Something of the same size as void*, so can be safely be coerced
to/from a pointer type. Also same size as the host's gp registers. */
@@ -229,10 +229,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h> // getopt
-#include <malloc.h>
-
#ifndef __powerpc64__
#define ASSEMBLY_FUNC(__fname, __insn) \
asm(".section \".text\"\n" \
@@ -4403,7 +4401,7 @@
{
#if !defined (ALTIVEC_ARGS_LARGE)
unsigned int i=2;
- viargs = memalign(16, i * sizeof(vector unsigned int));
+ viargs = memalign16(i * sizeof(vector unsigned int));
viargs[0] = (vector unsigned int) { 0x01020304,0x05060708,0x090A0B0C,0x0E0D0E0F };
AB_DPRINTF_VEC32x4( viargs[0] );
viargs[1] = (vector unsigned int) { 0xF1F2F3F4,0xF5F6F7F8,0xF9FAFBFC,0xFEFDFEFF };
@@ -4459,7 +4457,7 @@
#if !defined (ALTIVEC_ARGS_LARGE)
nb_vfargs = 12;
- vfargs = memalign(16, nb_vfargs * sizeof(vector float));
+ vfargs = memalign16(nb_vfargs * sizeof(vector float));
// 4 values:
for (s=0; s<2; s++) {
@@ -4474,7 +4472,7 @@
}
#else
nb_vfargs = 50;
- vfargs = memalign(16, nb_vfargs * sizeof(vector float));
+ vfargs = memalign16(nb_vfargs * sizeof(vector float));
for (s=0; s<2; s++) {
for (_exp=0x0; ; _exp += 0x3F ) {
@@ -6763,7 +6761,7 @@
vector unsigned int* viargs_priv;
// private viargs table to store to
- viargs_priv = memalign(16,(nb_viargs * sizeof(vector unsigned int)));
+ viargs_priv = memalign16(nb_viargs * sizeof(vector unsigned int));
for (i=0; i<nb_viargs; i++)
viargs_priv[i] = (vector unsigned int) { 0,0,0,0 };
Modified: branches/DARWIN/none/tests/ppc32/test_fx.c
===================================================================
--- branches/DARWIN/none/tests/ppc32/test_fx.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/ppc32/test_fx.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include <malloc.h>
+#include <stdlib.h>
double do_fsqrt ( double x )
{
Modified: branches/DARWIN/none/tests/ppc32/test_gx.c
===================================================================
--- branches/DARWIN/none/tests/ppc32/test_gx.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/ppc32/test_gx.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include <malloc.h>
+#include "tests/malloc.h"
/* This is a Marie Celeste instruction. Some IBM documents think it
exists, others don't. The same appears to be true for
Modified: branches/DARWIN/none/tests/susphello.c
===================================================================
--- branches/DARWIN/none/tests/susphello.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/susphello.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -7,6 +7,7 @@
* Author Magnus Ihse, ihse at bea.com
*/
+// DDD: add a comment explaining why it's not tested on Darwin.
#if !defined(__APPLE__)
#include <signal.h>
Modified: branches/DARWIN/none/tests/x86/Makefile.am
===================================================================
--- branches/DARWIN/none/tests/x86/Makefile.am 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/Makefile.am 2009-04-15 02:38:41 UTC (rev 9533)
@@ -58,16 +58,30 @@
yield.stderr.exp yield.stdout.exp yield.disabled
check_PROGRAMS = \
- badseg bt_everything bt_literal \
+ badseg \
+ bt_everything \
+ bt_literal \
+ bug126147-x86 \
bug132813-x86 \
bug135421-x86 \
bug137714-x86 \
+ cmpxchg8b \
cse_fail \
+ fcmovnu \
fpu_lazy_eflags \
+ fxtract \
getseg \
+ incdec_alt \
$(INSN_TESTS) \
- movx int pushpopseg \
- smc1 yield
+ jcxz \
+ lahf \
+ looper \
+ movx \
+ int \
+ pushpopseg \
+ sbbmisc \
+ smc1 \
+ yield
if BUILD_SSSE3_TESTS
check_PROGRAMS += ssse3_misaligned
endif
@@ -77,18 +91,9 @@
if ! VGCONF_OS_IS_DARWIN
check_PROGRAMS += \
bug125959-x86 \
- bug126147-x86 \
bug152818-x86 \
- cmpxchg8b \
cpuid \
faultstatus \
- fcmovnu \
- fxtract \
- incdec_alt \
- jcxz \
- lahf \
- looper \
- sbbmisc \
seg_override \
sigcontext
endif
Modified: branches/DARWIN/none/tests/x86/bug126147-x86.c
===================================================================
--- branches/DARWIN/none/tests/x86/bug126147-x86.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/bug126147-x86.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,4 @@
-
+#include "tests/asm.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -19,10 +19,8 @@
extern char *mystrncpy(char *dest, const char *src, size_t n);
asm(
".text\n"
-".globl mystrncpy\n"
-".type mystrncpy,@function\n"
"\n"
-"mystrncpy:\n"
+VG_SYM(mystrncpy) ":\n"
" pushl %esi\n"
" pushl %edi\n"
" movl %esp, %ecx\n"
@@ -32,20 +30,19 @@
"\n"
" movl %edi, %edx\n"
" cld\n"
-".Lzzloop:\n"
+"0:\n"
" dec %ecx\n"
-" js .Lzzout\n"
+" js 1f\n"
" lodsb\n"
" stosb\n"
" or %al, %al\n"
-" jnz .Lzzloop\n"
+" jnz 0b\n"
" repnz stosb\n"
-".Lzzout:\n"
+"1:\n"
" movl %edx, %eax\n"
" popl %edi\n"
" popl %esi\n"
" ret\n"
-".previous\n"
"\n"
);
@@ -66,8 +63,7 @@
unsigned int base, int UpCase);
asm(
".text\n"
-".globl __ltostr\n"
-"__ltostr:\n"
+VG_SYM(__ltostr) ":\n"
" pushl %esi\n"
" pushl %edi # destination\n"
" pushl %ebp\n"
@@ -79,27 +75,27 @@
" movl 0x1c(%eax), %eax # dividend\n"
" decl %ecx\n"
" movl %ecx, %esi\n"
-" movl $('A'-0xa), %ebp\n"
+" movl $55, %ebp # 55 == char(A)-10\n"
" xorl %edx, %edx # must be 0 -- used by idiv\n"
" cmpl $0x0, 36(%esp) # check for uppercase\n"
-" jnz .Lyynext\n"
+" jnz 0f\n"
" addl $0x20, %ebp # set lowercase\n"
-".Lyynext:\n"
+"0:\n"
" idiv %ebx, %eax\n"
" cmpb $0x9, %dl\n"
-" jg .Lyynext2\n"
-" addb $'0', %dl\n"
-" jmp .Lyystos\n"
-".Lyynext2:\n"
+" jg 1f\n"
+" addb $48, %dl # 48 == '0'\n"
+" jmp 2f\n"
+"1:\n"
" addl %ebp, %edx\n"
-".Lyystos:\n"
+"2:\n"
" movb %dl, (%edi, %ecx)\n"
" xorl %edx, %edx\n"
" decl %ecx\n"
-" jz .Lyyout\n"
+" jz 3f\n"
" orl %eax, %eax\n"
-" jnz .Lyynext\n"
-".Lyyout:\n"
+" jnz 0b\n"
+"3:\n"
" cld\n"
" movl %esi, %ebx\n"
" leal 1(%edi, %ecx), %esi\n"
@@ -113,7 +109,6 @@
" popl %edi\n"
" popl %esi\n"
" ret\n"
-".previous\n"
);
#define STREQ(a, b) (strcmp((a), (b)) == 0)
Modified: branches/DARWIN/none/tests/x86/cmpxchg8b.c
===================================================================
--- branches/DARWIN/none/tests/x86/cmpxchg8b.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/cmpxchg8b.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,4 @@
-
+#include "tests/asm.h"
#include <stdio.h>
typedef unsigned long long int ULong;
@@ -14,7 +14,7 @@
extern void foo ( void );
asm("\n"
- "foo:\n"
+ VG_SYM(foo) ":\n"
"\tpushl %eax\n"
"\tpushl %ebx\n"
"\tpushl %ecx\n"
@@ -22,18 +22,18 @@
"\txorl %eax, %eax\n" // get eflags in a known state
- "\tmovl eax,%eax\n"
- "\tmovl ebx,%ebx\n"
- "\tmovl ecx,%ecx\n"
- "\tmovl edx,%edx\n"
- "\tcmpxchg8b m64\n"
- "\tmovl %eax,eax\n"
- "\tmovl %ebx,ebx\n"
- "\tmovl %ecx,ecx\n"
- "\tmovl %edx,edx\n"
+ "\tmovl " VG_SYM(eax) ",%eax\n"
+ "\tmovl " VG_SYM(ebx) ",%ebx\n"
+ "\tmovl " VG_SYM(ecx) ",%ecx\n"
+ "\tmovl " VG_SYM(edx) ",%edx\n"
+ "\tcmpxchg8b " VG_SYM(m64) "\n"
+ "\tmovl %eax," VG_SYM(eax) "\n"
+ "\tmovl %ebx," VG_SYM(ebx) "\n"
+ "\tmovl %ecx," VG_SYM(ecx) "\n"
+ "\tmovl %edx," VG_SYM(edx) "\n"
"\tpushfl\n"
"\tpopl %eax\n"
- "\tmovl %eax,zout\n"
+ "\tmovl %eax," VG_SYM(zout) "\n"
"\tpopl %edx\n"
"\tpopl %ecx\n"
Modified: branches/DARWIN/none/tests/x86/faultstatus.c
===================================================================
--- branches/DARWIN/none/tests/x86/faultstatus.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/faultstatus.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <setjmp.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
#include <unistd.h>
struct test {
Modified: branches/DARWIN/none/tests/x86/fcmovnu.c
===================================================================
--- branches/DARWIN/none/tests/x86/fcmovnu.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/fcmovnu.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,4 @@
-
+#include "tests/asm.h"
#include <stdio.h>
double zzz;
@@ -15,7 +15,7 @@
"movl $0,%esi\n\t"
"add %esi,%esi\n\t"
"fcmovnu %st(1), %st(0)\n\t"
- "fstl zzz\n\t"
+ "fstl " VG_SYM(zzz) "\n\t"
"finit\n\t"
"popl %esi\n\t"
);
Modified: branches/DARWIN/none/tests/x86/fxtract.c
===================================================================
--- branches/DARWIN/none/tests/x86/fxtract.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/fxtract.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,4 @@
-
+#include "tests/asm.h"
#include <stdio.h>
#include <math.h>
@@ -6,13 +6,12 @@
extern void do_fxtract ( void );
asm("\n"
-".global do_fxtract\n"
-"do_fxtract:\n"
+VG_SYM(do_fxtract) ":\n"
"\tfinit\n"
-"\tfldl arg\n"
+"\tfldl " VG_SYM(arg) "\n"
"\tfxtract\n"
-"\tfstpl res1\n"
-"\tfstpl res2\n"
+"\tfstpl " VG_SYM(res1) "\n"
+"\tfstpl " VG_SYM(res2) "\n"
"\tret"
);
Modified: branches/DARWIN/none/tests/x86/incdec_alt.c
===================================================================
--- branches/DARWIN/none/tests/x86/incdec_alt.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/incdec_alt.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,51 +1,52 @@
/* A test of the alternative (redundant) encodings for {inc,dec}{w,l}. */
+#include "tests/asm.h"
#include <stdio.h>
int r1,r2,r3,r4,r5,r6,r7,r8,a1,a2;
extern void foo ( void );
asm("\n"
-"foo:\n"
+VG_SYM(foo) ":\n"
"\tpushl $0\n"
"\tpopfl\n"
-"\tmovl a1,%eax\n"
-"\tmovl a2,%edx\n"
+"\tmovl " VG_SYM(a1) ",%eax\n"
+"\tmovl " VG_SYM(a2) ",%edx\n"
/* inc %eax */
"\t.byte 0xFF\n"
"\t.byte 0xC0\n"
-"\tmovl %eax,r1\n"
+"\tmovl %eax," VG_SYM(r1) "\n"
"\tpushfl\n"
-"\tpopl r2\n"
+"\tpopl " VG_SYM(r2) "\n"
/* inc %dx */
"\t.byte 0x66\n"
"\t.byte 0xFF\n"
"\t.byte 0xC2\n"
-"\tmovl %edx,r3\n"
+"\tmovl %edx," VG_SYM(r3) "\n"
"\tpushfl\n"
-"\tpopl r4\n"
+"\tpopl " VG_SYM(r4) "\n"
/* dec %edx */
"\t.byte 0xFF\n"
"\t.byte 0xCA\n"
-"\tmovl %edx,r5\n"
+"\tmovl %edx," VG_SYM(r5) "\n"
"\tpushfl\n"
-"\tpopl r6\n"
+"\tpopl " VG_SYM(r6) "\n"
/* dec %ax */
"\t.byte 0x66\n"
"\t.byte 0xFF\n"
"\t.byte 0xC8\n"
-"\tmovl %eax,r7\n"
+"\tmovl %eax," VG_SYM(r7) "\n"
"\tpushfl\n"
-"\tpopl r8\n"
+"\tpopl " VG_SYM(r8) "\n"
"\tret\n"
);
Modified: branches/DARWIN/none/tests/x86/jcxz.c
===================================================================
--- branches/DARWIN/none/tests/x86/jcxz.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/jcxz.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -11,12 +11,12 @@
__asm__ __volatile__(
"movl %0,%%ecx\n\t"
"movl $0,%%eax\n"
- ".Lxyzzy1:\n\t"
- "jcxz .Lfoobar1\n\t"
+ "0:\n\t"
+ "jcxz 1f\n\t"
"addl $1, %%eax\n\t"
"subl $1, %%ecx\n\t"
- "jmp .Lxyzzy1\n"
- ".Lfoobar1:\n\t"
+ "jmp 0b\n"
+ "1:\n\t"
"movl %%eax, %1"
: /*out*/ : /*in*/ "m"(block[0]),
"m"(block[1]) : /*trash*/ "eax","ecx","cc","memory"
@@ -32,12 +32,12 @@
__asm__ __volatile__(
"movl %0,%%ecx\n\t"
"movl $0,%%eax\n"
- ".Lxyzzy2:\n\t"
- "jecxz .Lfoobar2\n\t"
+ "0:\n\t"
+ "jecxz 1f\n\t"
"addl $1, %%eax\n\t"
"subl $1, %%ecx\n\t"
- "jmp .Lxyzzy2\n"
- ".Lfoobar2:\n\t"
+ "jmp 0b\n"
+ "1:\n\t"
"movl %%eax, %1"
: /*out*/ : /*in*/ "m"(block[0]),
"m"(block[1]) : /*trash*/ "eax","ecx","cc","memory"
Modified: branches/DARWIN/none/tests/x86/lahf.c
===================================================================
--- branches/DARWIN/none/tests/x86/lahf.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/lahf.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,9 +1,9 @@
-
+#include "tests/asm.h"
#include <stdio.h>
extern int foo_1 ( void );
asm("\n"
-"foo_1:\n"
+VG_SYM(foo_1) ":\n"
"\tpushl $0\n"
"\tpopfl\n"
"\tmovl $0xFFFFFFFF, %eax\n"
@@ -15,7 +15,7 @@
extern int foo_0 ( void );
asm("\n"
-"foo_0:\n"
+VG_SYM(foo_0) ":\n"
"\tpushl $0\n"
"\tpopfl\n"
"\tmovl $0x0, %eax\n"
Modified: branches/DARWIN/none/tests/x86/looper.c
===================================================================
--- branches/DARWIN/none/tests/x86/looper.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/looper.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,4 @@
-
+#include "tests/asm.h"
#include <stdio.h>
int arg = 0;
@@ -7,19 +7,18 @@
extern void loop_plain ( void );
asm("\n"
".text\n"
-".globl loop_plain\n"
-"loop_plain:\n"
+VG_SYM(loop_plain) ":\n"
"\tpushl %ecx\n"
"\tmovl $999, %eax\n"
-"\tmovl arg, %ecx\n"
+"\tmovl " VG_SYM(arg) ", %ecx\n"
-".Lmn123plain:\n"
+"0:\n"
"\tdecl %eax\n"
"\tdecl %eax\n"
"\tdecl %eax\n"
-"\tloop .Lmn123plain\n"
+"\tloop 0b\n"
-"\tmovl %eax, res\n"
+"\tmovl %eax, " VG_SYM(res) "\n"
"\tpopl %ecx\n"
"\tret\n"
);
@@ -27,19 +26,18 @@
extern void loop_ne ( void );
asm("\n"
".text\n"
-".globl loop_ne\n"
-"loop_ne:\n"
+VG_SYM(loop_ne) ":\n"
"\tpushl %ecx\n"
"\tmovl $999, %eax\n"
-"\tmovl arg, %ecx\n"
+"\tmovl " VG_SYM(arg) ", %ecx\n"
-".Lmn123ne:\n"
+"0:\n"
"\tdecl %eax\n"
"\tdecl %eax\n"
"\tdecl %eax\n"
-"\tloopne .Lmn123ne\n"
+"\tloopne 0b\n"
-"\tmovl %eax, res\n"
+"\tmovl %eax, " VG_SYM(res) "\n"
"\tpopl %ecx\n"
"\tret\n"
);
@@ -47,13 +45,12 @@
extern void loop_e ( void );
asm("\n"
".text\n"
-".globl loop_e\n"
-"loop_e:\n"
+VG_SYM(loop_e) ":\n"
"\tpushl %ecx\n"
"\tmovl $999, %eax\n"
-"\tmovl arg, %ecx\n"
+"\tmovl " VG_SYM(arg) ", %ecx\n"
-".Lmn123e:\n"
+"0:\n"
"\tdecl %eax\n"
"\tdecl %eax\n"
"\tdecl %eax\n"
@@ -61,9 +58,9 @@
"\tpushfl\n"
"\txorl $64, 0(%esp)\n"
"\tpopfl\n"
-"\tloope .Lmn123e\n"
+"\tloope 0b\n"
-"\tmovl %eax, res\n"
+"\tmovl %eax, " VG_SYM(res) "\n"
"\tpopl %ecx\n"
"\tret\n"
);
Modified: branches/DARWIN/none/tests/x86/sbbmisc.c
===================================================================
--- branches/DARWIN/none/tests/x86/sbbmisc.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/sbbmisc.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,4 +1,4 @@
-
+#include "tests/asm.h"
#include <stdio.h>
char in_b, out_b1, out_b2, in_b2;
@@ -9,17 +9,17 @@
extern void sbb_ib_al ( void );
asm("\n"
-"sbb_ib_al:\n"
+VG_SYM(sbb_ib_al) ":\n"
-"\tmovb in_b, %al\n"
+"\tmovb " VG_SYM(in_b) ", %al\n"
"\tclc\n"
"\tsbbb $5, %al\n"
-"\tmovb %al, out_b1\n"
+"\tmovb %al, " VG_SYM(out_b1) "\n"
-"\tmovb in_b, %al\n"
+"\tmovb " VG_SYM(in_b) ", %al\n"
"\tstc\n"
"\tsbbb $5, %al\n"
-"\tmovb %al, out_b2\n"
+"\tmovb %al, " VG_SYM(out_b2) "\n"
"\tret\n"
);
@@ -27,17 +27,17 @@
extern void sbb_iw_ax ( void );
asm("\n"
-"sbb_iw_ax:\n"
+VG_SYM(sbb_iw_ax) ":\n"
-"\tmovw in_w, %ax\n"
+"\tmovw " VG_SYM(in_w) ", %ax\n"
"\tclc\n"
"\tsbbw $555, %ax\n"
-"\tmovw %ax, out_w1\n"
+"\tmovw %ax, " VG_SYM(out_w1) "\n"
-"\tmovw in_w, %ax\n"
+"\tmovw " VG_SYM(in_w) ", %ax\n"
"\tstc\n"
"\tsbbw $555, %ax\n"
-"\tmovw %ax, out_w2\n"
+"\tmovw %ax, " VG_SYM(out_w2) "\n"
"\tret\n"
);
@@ -45,17 +45,17 @@
extern void sbb_il_eax ( void );
asm("\n"
-"sbb_il_eax:\n"
+VG_SYM(sbb_il_eax) ":\n"
-"\tmovl in_l, %eax\n"
+"\tmovl " VG_SYM(in_l) ", %eax\n"
"\tclc\n"
"\tsbbl $555666, %eax\n"
-"\tmovl %eax, out_l1\n"
+"\tmovl %eax, " VG_SYM(out_l1) "\n"
-"\tmovl in_l, %eax\n"
+"\tmovl " VG_SYM(in_l) ", %eax\n"
"\tstc\n"
"\tsbbl $555666, %eax\n"
-"\tmovl %eax, out_l2\n"
+"\tmovl %eax, " VG_SYM(out_l2) "\n"
"\tret\n"
);
@@ -63,17 +63,17 @@
extern void sbb_eb_gb ( void );
asm("\n"
-"sbb_eb_gb:\n"
+VG_SYM(sbb_eb_gb) ":\n"
-"\tmovb in_b, %al\n"
+"\tmovb " VG_SYM(in_b) ", %al\n"
"\tclc\n"
-"\tsbbb in_b2, %al\n"
-"\tmovb %al, out_b1\n"
+"\tsbbb " VG_SYM(in_b2) ", %al\n"
+"\tmovb %al, " VG_SYM(out_b1) "\n"
-"\tmovb in_b, %al\n"
+"\tmovb " VG_SYM(in_b) ", %al\n"
"\tstc\n"
-"\tsbbb in_b2, %al\n"
-"\tmovb %al, out_b2\n"
+"\tsbbb " VG_SYM(in_b2) ", %al\n"
+"\tmovb %al, " VG_SYM(out_b2) "\n"
"\tret\n"
);
@@ -81,20 +81,20 @@
extern void sbb_eb_gb_2 ( void );
asm("\n"
-"sbb_eb_gb_2:\n"
+VG_SYM(sbb_eb_gb_2) ":\n"
"\tpushl %ecx\n"
-"\tmovb in_b, %cl\n"
-"\tmovb in_b2, %dh\n"
+"\tmovb " VG_SYM(in_b) ", %cl\n"
+"\tmovb " VG_SYM(in_b2) ", %dh\n"
"\tclc\n"
"\tsbbb %dh,%cl\n"
-"\tmovb %cl, out_b1\n"
+"\tmovb %cl, " VG_SYM(out_b1) "\n"
-"\tmovb in_b, %cl\n"
-"\tmovb in_b2, %dh\n"
+"\tmovb " VG_SYM(in_b) ", %cl\n"
+"\tmovb " VG_SYM(in_b2) ", %dh\n"
"\tstc\n"
"\tsbbb %dh,%cl\n"
-"\tmovb %cl, out_b2\n"
+"\tmovb %cl, " VG_SYM(out_b2) "\n"
"\tpopl %ecx\n"
"\tret\n"
@@ -103,17 +103,17 @@
extern void adc_eb_gb ( void );
asm("\n"
-"adc_eb_gb:\n"
+VG_SYM(adc_eb_gb) ":\n"
-"\tmovb in_b, %al\n"
+"\tmovb " VG_SYM(in_b) ", %al\n"
"\tclc\n"
-"\tadcb in_b2, %al\n"
-"\tmovb %al, out_b1\n"
+"\tadcb " VG_SYM(in_b2) ", %al\n"
+"\tmovb %al, " VG_SYM(out_b1) "\n"
-"\tmovb in_b, %al\n"
+"\tmovb " VG_SYM(in_b) ", %al\n"
"\tstc\n"
-"\tadcb in_b2, %al\n"
-"\tmovb %al, out_b2\n"
+"\tadcb " VG_SYM(in_b2) ", %al\n"
+"\tmovb %al, " VG_SYM(out_b2) "\n"
"\tret\n"
);
@@ -121,20 +121,20 @@
extern void adc_eb_gb_2 ( void );
asm("\n"
-"adc_eb_gb_2:\n"
+VG_SYM(adc_eb_gb_2) ":\n"
"\tpushl %ecx\n"
-"\tmovb in_b, %cl\n"
-"\tmovb in_b2, %dh\n"
+"\tmovb " VG_SYM(in_b) ", %cl\n"
+"\tmovb " VG_SYM(in_b2) ", %dh\n"
"\tclc\n"
"\tadcb %dh,%cl\n"
-"\tmovb %cl, out_b1\n"
+"\tmovb %cl, " VG_SYM(out_b1) "\n"
-"\tmovb in_b, %cl\n"
-"\tmovb in_b2, %dh\n"
+"\tmovb " VG_SYM(in_b) ", %cl\n"
+"\tmovb " VG_SYM(in_b2) ", %dh\n"
"\tstc\n"
"\tadcb %dh,%cl\n"
-"\tmovb %cl, out_b2\n"
+"\tmovb %cl, " VG_SYM(out_b2) "\n"
"\tpopl %ecx\n"
"\tret\n"
Modified: branches/DARWIN/none/tests/x86/ssse3_misaligned.c
===================================================================
--- branches/DARWIN/none/tests/x86/ssse3_misaligned.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/none/tests/x86/ssse3_misaligned.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,8 +1,5 @@
-
-#if !defined(__APPLE__)
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -11,14 +8,7 @@
void maybe_fault ( int delta )
{
- // Darwin lacks memalign, but malloc is always 16-aligned anyway.
- #if defined(__APPLE__)
- char* x = malloc(32/*size*/);
- #else
- char* x = memalign(16/*alignment*/,32/*size*/);
- #endif
- assert(x);
- assert(0 == ((16-1) & (unsigned long)x));
+ char* x = memalign16(32);
memset(x, 0, 32);
__asm__ __volatile__(
"pabsb (%0),%%xmm7"
Modified: branches/DARWIN/perf/Makefile.am
===================================================================
--- branches/DARWIN/perf/Makefile.am 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/perf/Makefile.am 2009-04-15 02:38:41 UTC (rev 9533)
@@ -1,6 +1,5 @@
-# For AM_FLAG_M3264_PRI
-include $(top_srcdir)/Makefile.flags.am
+include $(top_srcdir)/Makefile.tool-tests.am
noinst_SCRIPTS = vg_perf
@@ -18,10 +17,10 @@
check_PROGRAMS = \
bigcode bz2 fbench ffbench heap sarp tinycc
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_builddir)/include
-AM_CFLAGS = -Winline -Wall -Wshadow -g -O $(AM_FLAG_M3264_PRI)
-AM_CXXFLAGS = $(AM_CFLAGS)
+AM_CFLAGS += -O $(AM_FLAG_M3264_PRI)
+AM_CXXFLAGS += -O $(AM_FLAG_M3264_PRI)
+
# Extra stuff
bz2_CFLAGS = $(AM_CFLAGS) -Wno-inline
Modified: branches/DARWIN/perf/bigcode.c
===================================================================
--- branches/DARWIN/perf/bigcode.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/perf/bigcode.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -10,12 +10,8 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
-#include <sys/mman.h>
+#include "tests/sys_mman.h"
-#ifndef MAP_ANONYMOUS
-#define MAP_ANONYMOUS 0
-#endif /* MAP_ANONYMOUS */
-
#define FN_SIZE 996 // Must be big enough to hold the compiled f()
#define N_LOOPS 20000 // Should be divisible by four
#define RATIO 4 // Ratio of code sizes between the two modes
Modified: branches/DARWIN/perf/bz2.c
===================================================================
--- branches/DARWIN/perf/bz2.c 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/perf/bz2.c 2009-04-15 02:38:41 UTC (rev 9533)
@@ -6412,11 +6412,7 @@
}
#include <stdio.h>
-#ifdef __APPLE__
-#include <malloc/malloc.h>
-#else
-#include <malloc.h>
-#endif
+#include "tests/malloc.h"
#include <assert.h>
/* For providing services. */
Modified: branches/DARWIN/tests/Makefile.am
===================================================================
--- branches/DARWIN/tests/Makefile.am 2009-04-14 23:44:11 UTC (rev 9532)
+++ branches/DARWIN/tests/Makefile.am 2009-04-15 02:38:41 UTC (rev 9533)
@@ -11,6 +11,11 @@
platform_test \
vg_regtest
+noinst_HEADERS = \
+ asm.h \
+ malloc.h \
+ sys_mman.h
+
EXTRA_DIST = $(noinst_SCRIPTS)
check_PROGRAMS = \
Added: branches/DARWIN/tests/asm.h
===================================================================
--- branches/DARWIN/tests/asm.h (rev 0)
+++ branches/DARWIN/tests/asm.h 2009-04-15 02:38:41 UTC (rev 9533)
@@ -0,0 +1,19 @@
+// Header to factor out platform differences in asm code.
+
+// On Darwin, all symbols get an underscore prepended when compiled. If we
+// use any such symbols in asm code, we need to add that underscore. So in
+// general, any symbol named in asm code should be wrapped by VG_SYM.
+
+// This one is for use in inline asm in C files.
+#if defined(VGO_darwin)
+#define VG_SYM(x) "_"#x
+#else
+#define VG_SYM(x) #x
+#endif
+
+// This one is for use in asm files.
+#if defined(VGO_darwin)
+#define VG_SYM_ASM(x) _#x
+#else
+#define VG_SYM_ASM(x) x
+#endif
Added: branches/DARWIN/tests/malloc.h
===================================================================
--- branches/DARWIN/tests/malloc.h (rev 0)
+++ branches/DARWIN/tests/malloc.h 2009-04-15 02:38:41 UTC (rev 9533)
@@ -0,0 +1,27 @@
+// Replacement for malloc.h which factors out platform differences.
+
+#include <stdlib.h>
+#if defined(VGO_darwin)
+# include <malloc/malloc.h>
+#else
+# include <malloc.h>
+#endif
+
+#include <assert.h>
+
+// Allocates a 16-aligned block. Asserts if the allocation fails.
+__attribute__((unused))
+static void* memalign16(size_t szB)
+{
+ void* x;
+#if defined(VGO_darwin)
+ // Darwin lacks memalign, but its malloc is always 16-aligned anyway.
+ x = malloc(szB);
+#else
+ x = memalign(16, szB);
+#endif
+ assert(x);
+ assert(0 == ((16-1) & (unsigned long)x));
+ return x;
+}
+
Added: branches/DARWIN/tests/sys_mman.h
===================================================================
--- branches/DARWIN/tests/sys_mman.h (rev 0)
+++ branches/DARWIN/tests/sys_mman.h 2009-04-15 02:38:41 UTC (rev 9533)
@@ -0,0 +1,31 @@
+// Replacement for sys/mman.h which factors out platform differences.
+
+#include <sys/mman.h>
+
+#if defined(VGO_darwin)
+# define MAP_ANONYMOUS MAP_ANON
+#endif
+
+
+#include <assert.h>
+#include <unistd.h>
+
+// Map a page, then unmap it, then return that address. That
+// guarantees to give an address which will fault when accessed,
+// without making any assumptions about the layout of the address
+// space.
+
+__attribute__((unused))
+static void* get_unmapped_page(void)
+{
+ void* ptr;
+ int r;
+ long pagesz = sysconf(_SC_PAGE_SIZE);
+ assert(pagesz == 4096 || pagesz == 65536);
+ ptr = mmap(0, pagesz, PROT_READ, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ assert(ptr != (void*)-1);
+ r = munmap(ptr, pagesz);
+ assert(r == 0);
+ return ptr;
+}
+
|