#!/bin/bash
###SHELLPACK preamble cmattach-test-install 20110718
WEB_LOCATION=http://ozlabs.org/~cyeoh/cma
MIRROR_LOCATION="$WEBROOT/cmattach/"

###SHELLPACK parseargBegin
###SHELLPACK parseargInstall
###SHELLPACK parseargEnd

###SHELLPACK sources_fetch cma-test-${VERSION}.tgz cmattach-test-${VERSION}-installed

# Build
###SHELLPACK build_start cmattach-test-${VERSION}-installed
echo "diff --git a/process_vm.h b/process_vm.h
index bc69e45..d80a245 100755
--- a/process_vm.h
+++ b/process_vm.h
@@ -7,10 +7,13 @@
 #include <sys/syscall.h>
 #include <sys/types.h>
 
-#if defined(i386)
+#if defined(__i386__)
 #define __NR_process_vm_readv 347
 #define __NR_process_vm_writev 348
 
+#elif defined(__x86_64__)
+#define __NR_process_vm_readv 310
+#define __NR_process_vm_writev 311
 
 #elif defined(_ARCH_PPC)
 #define __NR_process_vm_readv 351
diff --git a/setup_process_vm_readv_iovec.c b/setup_process_vm_readv_iovec.c
index 162934f..ec7d1ed 100644
--- a/setup_process_vm_readv_iovec.c
+++ b/setup_process_vm_readv_iovec.c
@@ -82,6 +82,7 @@ int main(int argc, char *argv[])
     printf(\" %p %i\", foo[i], buf_sizes[i]);
   }
   printf(\"\\n\");
+  fflush(NULL);
 
 
 
diff --git a/setup_process_vm_readv_simple.c b/setup_process_vm_readv_simple.c
index 1de1422..b16a331 100644
--- a/setup_process_vm_readv_simple.c
+++ b/setup_process_vm_readv_simple.c
@@ -21,6 +21,7 @@ int main(int argc, char *argv[])
   strcpy(foo, tst_string);
 
   printf(\"Target process is setup\\nRun the following to test:\\n./t_process_vm_readv_simple %i %p %i\\n\", getpid(), foo, strlen(foo));
+  fflush(NULL);
   while (1)
     {
       sleep(100);
diff --git a/setup_process_vm_writev.c b/setup_process_vm_writev.c
index 408e373..16b8e47 100644
--- a/setup_process_vm_writev.c
+++ b/setup_process_vm_writev.c
@@ -42,6 +42,7 @@ int main(int argc, char *argv[])
 
   printf(\"Target process is setup\\nRun the following to test:\\n./t_process_vm_writev \");
   printf(\"%i %p %i\\n\", getpid(), foo, buffer_size);
+  fflush(NULL);
   while (foo[buffer_size-1]==DEFAULT_CHAR)
     {
       sleep(1);
" | patch -p1 || die Failed to patch cma-test

###SHELLPACK make
