From 593d2a3aff3f07e5b32750073bf0229dda8255d1 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 16 Sep 2009 14:23:16 -0700 Subject: [PATCH] Port the Samba 3 shm_setup to QNX. --- source3/torture/torture.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) mode change 100644 => 100755 source3/torture/torture.c diff --git a/source3/torture/torture.c b/source3/torture/torture.c old mode 100644 new mode 100755 index ed592f1..98694ed --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -76,6 +76,23 @@ void *shm_setup(int size) int shmid; void *ret; +#ifdef __QNXNTO__ + shmid = shm_open("private", O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + if (shmid == -1) { + printf("can't get shared memory\n"); + exit(1); + } + shm_unlink("private"); + if (ftruncate(shmid, size) == -1) { + printf("can't set shared memory size\n"); + exit(1); + } + ret = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0); + if (ret == MAP_FAILED) { + printf("can't map shared memory\n"); + exit(1); + } +#else shmid = shmget(IPC_PRIVATE, size, S_IRUSR | S_IWUSR); if (shmid == -1) { printf("can't get shared memory\n"); @@ -94,6 +111,7 @@ void *shm_setup(int size) See Stevens "advanced programming in unix env" for details */ shmctl(shmid, IPC_RMID, 0); +#endif return ret; } -- 1.6.4.2