Merge branch 'alignment' of https://github.com/omor1/fio
authorJens Axboe <axboe@fb.com>
Mon, 22 May 2017 14:44:29 +0000 (08:44 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 22 May 2017 14:44:29 +0000 (08:44 -0600)
1  2 
os/os-android.h

diff --cc os/os-android.h
index acb19a8adea70d9c150a4554a83d1bcd1ee7e6f9,f371116f8f6a9a45a37372b3044f71c77f88f368..c8c6cb85fce1a45ff9bf8bb95e604afdad32f53e
@@@ -107,12 -110,14 +108,14 @@@ error
        return ret;
  }
  
 -static inline void *shmat (int __shmid, const void *__shmaddr, int __shmflg)
 +static inline void *shmat(int __shmid, const void *__shmaddr, int __shmflg)
  {
-       size_t *ptr, size = ioctl(__shmid, ASHMEM_GET_SIZE, NULL);
-       ptr = mmap(NULL, size + sizeof(size_t), PROT_READ | PROT_WRITE, MAP_SHARED, __shmid, 0);
-       *ptr = size;    //save size at beginning of buffer, for use with munmap
-       return &ptr[1];
+       size_t size = ioctl(__shmid, ASHMEM_GET_SIZE, NULL);
+       /* Needs to be 8-byte aligned to prevent SIGBUS on 32-bit ARM */
+       uint64_t *ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, __shmid, 0);
+       /* Save size at beginning of buffer, for use with munmap */
+       *ptr = size;
+       return ptr + 1;
  }
  
  static inline int shmdt (const void *__shmaddr)