]>
git.saurik.com Git - apple/libc.git/blob - sys/shmctl.c
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 #include <sys/syscall.h>
28 * Stub function to account for the differences in the ipc_perm structure,
29 * while maintaining binary backward compatibility.
32 shmctl(int shmid
, int cmd
, struct shmid_ds
*ds
)
34 #ifdef __DARWIN_UNIX03
35 return syscall(SYS_shmctl
, shmid
, cmd
, ds
);
36 #else /* !__DARWIN_UNIX03 */
37 struct __shmid_ds_old
*ds_old
= ds
;
38 struct __shmid_ds_new ds2
;
39 struct __shmid_ds_new
*ds_new
= &ds2
;
42 #define _UP_CVT(x) ds_new-> x = ds_old-> x
43 #define _DN_CVT(x) ds_old-> x = ds_new-> x
46 /* convert before call */
47 _UP_CVT(shm_perm
.uid
);
48 _UP_CVT(shm_perm
.gid
);
49 _UP_CVT(shm_perm
.cuid
);
50 _UP_CVT(shm_perm
.cgid
);
51 _UP_CVT(shm_perm
.mode
);
52 ds_new
->shm_perm
._seq
= ds_old
->shm_perm
.seq
;
53 ds_new
->shm_perm
._key
= ds_old
->shm_perm
.key
;
61 _UP_CVT(shm_internal
);
64 rv
= syscall(SYS_shmctl
, shmid
, cmd
, ds_new
);
66 if (cmd
== IPC_STAT
) {
67 /* convert after call */
68 _DN_CVT(shm_perm
.uid
); /* warning! precision loss! */
69 _DN_CVT(shm_perm
.gid
); /* warning! precision loss! */
70 _DN_CVT(shm_perm
.cuid
); /* warning! precision loss! */
71 _DN_CVT(shm_perm
.cgid
); /* warning! precision loss! */
72 _DN_CVT(shm_perm
.mode
);
73 ds_new
->shm_perm
.seq
= ds_old
->shm_perm
._seq
;
74 ds_new
->shm_perm
.key
= ds_old
->shm_perm
._key
;
82 _UP_CVT(shm_internal
);
86 #endif /* !__DARWIN_UNIX03 */