]>
git.saurik.com Git - apple/libc.git/blob - sys/msgctl.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@ 
  28  * Stub function to account for the differences in the ipc_perm structure, 
  29  * while maintaining binary backward compatibility. 
  31  * This is only the legacy behavior. 
  33 extern int __msgctl(int, int, struct msqid_ds 
*); 
  36 msgctl(int msqid
, int cmd
, struct msqid_ds 
*ds
) 
  38         struct __msqid_ds_old   
*ds_old 
= (struct __msqid_ds_old 
*)ds
; 
  39         struct __msqid_ds_new   ds2
; 
  40         struct __msqid_ds_new   
*ds_new 
= &ds2
; 
  43 #define _UP_CVT(x)      ds_new-> x = ds_old-> x 
  44 #define _DN_CVT(x)      ds_old-> x = ds_new-> x 
  47                 /* convert before call */ 
  48                 _UP_CVT(msg_perm
.uid
); 
  49                 _UP_CVT(msg_perm
.gid
); 
  50                 _UP_CVT(msg_perm
.cuid
); 
  51                 _UP_CVT(msg_perm
.cgid
); 
  52                 _UP_CVT(msg_perm
.mode
); 
  53                 ds_new
->msg_perm
._seq 
= ds_old
->msg_perm
.seq
; 
  54                 ds_new
->msg_perm
._key 
= ds_old
->msg_perm
.key
; 
  63                 _UP_CVT(msg_pad1
);      /* binary compatibility */ 
  65                 _UP_CVT(msg_pad2
);      /* binary compatibility */ 
  67                 _UP_CVT(msg_pad3
);      /* binary compatibility */ 
  68                 _UP_CVT(msg_pad4
[0]);   /* binary compatibility */ 
  69                 _UP_CVT(msg_pad4
[1]);   /* binary compatibility */ 
  70                 _UP_CVT(msg_pad4
[2]);   /* binary compatibility */ 
  71                 _UP_CVT(msg_pad4
[3]);   /* binary compatibility */ 
  74         rv 
= __msgctl(msqid
, cmd
, ds_new
); 
  76         if (cmd 
== IPC_STAT
) { 
  77                 /* convert after call */ 
  78                 _DN_CVT(msg_perm
.uid
);  /* warning!  precision loss! */ 
  79                 _DN_CVT(msg_perm
.gid
);  /* warning!  precision loss! */ 
  80                 _DN_CVT(msg_perm
.cuid
); /* warning!  precision loss! */ 
  81                 _DN_CVT(msg_perm
.cgid
); /* warning!  precision loss! */ 
  82                 _DN_CVT(msg_perm
.mode
); 
  83                 ds_old
->msg_perm
.seq 
= ds_new
->msg_perm
._seq
; 
  84                 ds_old
->msg_perm
.key 
= ds_new
->msg_perm
._key
; 
  93                 _DN_CVT(msg_pad1
);      /* binary compatibility */ 
  95                 _DN_CVT(msg_pad2
);      /* binary compatibility */ 
  97                 _DN_CVT(msg_pad3
);      /* binary compatibility */ 
  98                 _DN_CVT(msg_pad4
[0]);   /* binary compatibility */ 
  99                 _DN_CVT(msg_pad4
[1]);   /* binary compatibility */ 
 100                 _DN_CVT(msg_pad4
[2]);   /* binary compatibility */ 
 101                 _DN_CVT(msg_pad4
[3]);   /* binary compatibility */