From e98a19404627c21c8bd889309268a427cd947ab4 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 16 Sep 2009 14:23:16 -0700 Subject: [PATCH] Port shm_setup to QNX --- source3/torture/torture.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/source3/torture/torture.c b/source3/torture/torture.c index ed592f1..7ad8f95 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -76,6 +76,7 @@ void *shm_setup(int size) int shmid; void *ret; +#ifndef __QNXNTO__ shmid = shmget(IPC_PRIVATE, size, S_IRUSR | S_IWUSR); if (shmid == -1) { printf("can't get shared memory\n"); @@ -94,6 +95,23 @@ void *shm_setup(int size) See Stevens "advanced programming in unix env" for details */ shmctl(shmid, IPC_RMID, 0); +#else + 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); + } +#endif return ret; } -- 1.6.4.2