1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-01 04:58:35 +03:00

Port the Samba 4 shm_setup to QNX.

This commit is contained in:
Matt Kraai 2009-09-16 16:04:02 -07:00 committed by Matthias Dieter Wallnöfer
parent aa7aa664dc
commit cce3e66665

18
source4/torture/util_smb.c Normal file → Executable file
View File

@ -257,6 +257,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, SHM_R | SHM_W);
if (shmid == -1) {
printf("can't get shared memory\n");
@ -275,6 +292,7 @@ void *shm_setup(int size)
See Stevens "advanced programming in unix env" for details
*/
shmctl(shmid, IPC_RMID, 0);
#endif
return ret;
}