Skip to contentSkip to conversation

Conditionally include <sys/shm.h> based on OS support. Define missing MAP_HUGETLB for Android.

PATCH Applied [email protected] 2 participants 4 messages Mar 12, 2013 – Mar 13, 2013 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Conditionally include <sys/shm.h> based on OS support. Define missing MAP_HUGETLB for Android.

From: Oleg <olegm@olegm-vmware.(none)>

---
 backend.c       |    6 +++---
 init.c          |    7 ++++---
 memory.c        |    6 +++---
 os/os-android.h |    4 ++++
 4 files changed, 14 insertions(+), 9 deletions(-)
backend.c +3 -3
index d1fe964..e482fb8 100644
@@ -34,12 +34,12 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/ipc.h>
-#ifndef FIO_NO_HAVE_SHM_H
-#include <sys/shm.h>
-#endif
 #include <sys/mman.h>
 
 #include "fio.h"
+#ifndef FIO_NO_HAVE_SHM_H
+#include <sys/shm.h>
+#endif
 #include "hash.h"
 #include "smalloc.h"
 #include "verify.h"
init.c +4 -3
index c722688..9d15318 100644
@@ -9,13 +9,14 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/ipc.h>
-#ifndef FIO_NO_HAVE_SHM_H
-#include <sys/shm.h>
-#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #include "fio.h"
+#ifndef FIO_NO_HAVE_SHM_H
+#include <sys/shm.h>
+#endif
+
 #include "parse.h"
 #include "smalloc.h"
 #include "filehash.h"
memory.c +3 -3
index ee5f895..443d71d 100644
@@ -5,12 +5,12 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#ifndef FIO_NO_HAVE_SHM_H
-#include <sys/shm.h>
-#endif
 #include <sys/mman.h>
 
 #include "fio.h"
+#ifndef FIO_NO_HAVE_SHM_H
+#include <sys/shm.h>
+#endif
 
 static void *pinned_mem;
 
os/os-android.h +4 -0
index cedfdaf..3bb44b9 100644
@@ -31,6 +31,7 @@
 #define FIO_HAVE_E4_ENG
 #define FIO_HAVE_BYTEORDER_FUNCS
 #define FIO_HAVE_MMAP_HUGE
+#define FIO_NO_HAVE_SHM_H
 
 #define OS_MAP_ANON		MAP_ANONYMOUS
 
@@ -41,6 +42,9 @@
 #ifdef MADV_REMOVE
 #define FIO_MADV_FREE	MADV_REMOVE
 #endif
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB 0x40000 /* arch specific */
+#endif
 
 
 /*
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 20 lines · On 12 March 2013 18:06, <[email protected]> wrote:

From: Oleg <olegm@olegm-vmware.(none)>

---
 backend.c       |    6 +++---
 init.c          |    7 ++++---
 memory.c        |    6 +++---
 os/os-android.h |    4 ++++
 4 files changed, 14 insertions(+), 9 deletions(-)
backend.c +0 -2
index d1fe964..e482fb8 100644
@@ -34,12 +34,12 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/ipc.h>
-#ifndef FIO_NO_HAVE_SHM_H
-#include <sys/shm.h>

backend.c line 45

Quoted 10 lines
backend.c +3 -1
-#endif
 #include <sys/mman.h>
 
 #include "fio.h"
+#ifndef FIO_NO_HAVE_SHM_H
+#include <sys/shm.h>
+#endif
 #include "hash.h"
 #include "smalloc.h"
 #include "verify.h"

Hmm, well that's broken the build. The following should be applied to avoid double definition.

configure +1 -2
index d1f277d..1827e02 100755
@@ -234,7 +234,7 @@ Android)
   output_sym "CONFIG_CLOCK_GETTIME"
   output_sym "CONFIG_CLOCK_MONOTONIC"
   echo "CC=$cc" >> $config_host_mak
-  echo "EXTFLAGS=$CFLAGS -include config-host.h -DFIO_NO_HAVE_SHM_H
-D_GNU_SOURCE" >> $config_host_mak
+  echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >>

$config_host_mak
exit 0
esac

#2 lore raw
Quoted 11 lines · Aaron Carroll
configure +1 -2
index d1f277d..1827e02 100755
@@ -234,7 +234,7 @@ Android)
   output_sym "CONFIG_CLOCK_GETTIME"
   output_sym "CONFIG_CLOCK_MONOTONIC"
   echo "CC=$cc" >> $config_host_mak
-  echo "EXTFLAGS=$CFLAGS -include config-host.h -DFIO_NO_HAVE_SHM_H
-D_GNU_SOURCE" >> $config_host_mak
+  echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >>
Quoted 3 lines

$config_host_mak
exit 0
esac

And gmail has mangled my diff. Correct version attached.

-- Aaron

configure +1 -1
index d1f277d..1827e02 100755
@@ -234,7 +234,7 @@ Android)
   output_sym "CONFIG_CLOCK_GETTIME"
   output_sym "CONFIG_CLOCK_MONOTONIC"
   echo "CC=$cc" >> $config_host_mak
-  echo "EXTFLAGS=$CFLAGS -include config-host.h -DFIO_NO_HAVE_SHM_H -D_GNU_SOURCE" >> $config_host_mak
+  echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
   exit 0
 esac
 

A message that is not in the archive (sent off-list or not yet received): CAExtNyFN5mOUFgYaki=64Dd=WA6diu5Q_GiXy0-_JE-5k2cgLw@mail.gmail.com

#4 lore raw
Quoted 4 lines · Oleg Matcovsky

Yes, -DFIO_NO_HAVE_SHM_H must be removed from Makefile.

Anyway, I have working Android.mk file and fio builds without any problems. Will post for your review tonight.

That's great. It would be good if you could also test your changes with an NDK build, which is done something like:

make UNAME=Android cross_prefix=~/dev/android-toolchain-r8c/bin/arm-linux-androideabi-

Cheers,
-- Aaron