]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make this work on platforms where r != x.
authorJulian Seward <jseward@acm.org>
Thu, 15 Dec 2005 16:11:25 +0000 (16:11 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 15 Dec 2005 16:11:25 +0000 (16:11 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5347

perf/bigcode.c

index 0f444e0d6d743b1b671326c0297aea13aaabfec6..2ffc253d5e4c5382238384c806e1695d4d04425b 100644 (file)
@@ -9,6 +9,8 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
+#include <sys/mman.h>
 
 #define FN_SIZE   996      // Must be big enough to hold the compiled f()
 #define N_LOOPS   20000    // Should be divisible by four
@@ -28,13 +30,16 @@ int f(int x, int y)
    return y;
 }
 
-static char a[FN_SIZE * N_LOOPS];
-
 int main(int argc, char* argv[])
 {
    int h, i, sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    int n_fns, n_reps;
 
+   char* a = mmap(0, FN_SIZE * N_LOOPS, 
+                     PROT_EXEC|PROT_WRITE, 
+                     MAP_PRIVATE|MAP_ANONYMOUS, 0,0);
+   assert(a != (char*)MAP_FAILED);
+
    if (argc <= 1) {
       // Mode 1: not so much code
       n_fns  = N_LOOPS / RATIO;