10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
56812Sraf * Common Development and Distribution License (the "License").
66812Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
216812Sraf
220Sstevel@tonic-gate /*
239170SRoger.Faulkner@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
280Sstevel@tonic-gate /* All Rights Reserved */
290Sstevel@tonic-gate
306812Sraf #pragma weak _shmat = shmat
316812Sraf #pragma weak _shmctl = shmctl
326812Sraf #pragma weak _shmctl64 = shmctl64
336812Sraf #pragma weak _shmdt = shmdt
346812Sraf #pragma weak _shmget = shmget
356812Sraf #pragma weak _shmids = shmids
360Sstevel@tonic-gate
376812Sraf #include "lint.h"
380Sstevel@tonic-gate #include <sys/types.h>
390Sstevel@tonic-gate #include <sys/ipc.h>
400Sstevel@tonic-gate #include <sys/ipc_impl.h>
410Sstevel@tonic-gate #include <sys/shm.h>
420Sstevel@tonic-gate #include <sys/shm_impl.h>
430Sstevel@tonic-gate #include <sys/syscall.h>
440Sstevel@tonic-gate #include <errno.h>
450Sstevel@tonic-gate
460Sstevel@tonic-gate void *
shmat(int shmid,const void * shmaddr,int shmflg)470Sstevel@tonic-gate shmat(int shmid, const void *shmaddr, int shmflg)
480Sstevel@tonic-gate {
490Sstevel@tonic-gate sysret_t rval;
500Sstevel@tonic-gate int error;
510Sstevel@tonic-gate
520Sstevel@tonic-gate error = __systemcall(&rval, SYS_shmsys, SHMAT, shmid, shmaddr, shmflg);
53*9264SRoger.Faulkner@Sun.COM if (error)
540Sstevel@tonic-gate (void) __set_errno(error);
55*9264SRoger.Faulkner@Sun.COM return ((void *)rval.sys_rval1);
560Sstevel@tonic-gate }
570Sstevel@tonic-gate
580Sstevel@tonic-gate int
shmctl(int shmid,int cmd,struct shmid_ds * buf)590Sstevel@tonic-gate shmctl(int shmid, int cmd, struct shmid_ds *buf)
600Sstevel@tonic-gate {
610Sstevel@tonic-gate if (cmd == IPC_SET64 || cmd == IPC_STAT64) {
620Sstevel@tonic-gate (void) __set_errno(EINVAL);
630Sstevel@tonic-gate return (-1);
640Sstevel@tonic-gate }
650Sstevel@tonic-gate return (syscall(SYS_shmsys, SHMCTL, shmid, cmd, buf));
660Sstevel@tonic-gate }
670Sstevel@tonic-gate
680Sstevel@tonic-gate int
shmctl64(int shmid,int cmd,struct shmid_ds64 * buf)690Sstevel@tonic-gate shmctl64(int shmid, int cmd, struct shmid_ds64 *buf)
700Sstevel@tonic-gate {
710Sstevel@tonic-gate if (cmd != IPC_SET64 && cmd != IPC_STAT64) {
720Sstevel@tonic-gate (void) __set_errno(EINVAL);
730Sstevel@tonic-gate return (-1);
740Sstevel@tonic-gate }
750Sstevel@tonic-gate return (syscall(SYS_shmsys, SHMCTL, shmid, cmd, buf));
760Sstevel@tonic-gate }
770Sstevel@tonic-gate
780Sstevel@tonic-gate int
shmdt(char * shmaddr)790Sstevel@tonic-gate shmdt(char *shmaddr)
800Sstevel@tonic-gate {
81*9264SRoger.Faulkner@Sun.COM return (syscall(SYS_shmsys, SHMDT, shmaddr));
820Sstevel@tonic-gate }
830Sstevel@tonic-gate
840Sstevel@tonic-gate int
shmget(key_t key,size_t size,int shmflg)850Sstevel@tonic-gate shmget(key_t key, size_t size, int shmflg)
860Sstevel@tonic-gate {
870Sstevel@tonic-gate return (syscall(SYS_shmsys, SHMGET, key, size, shmflg));
880Sstevel@tonic-gate }
890Sstevel@tonic-gate
900Sstevel@tonic-gate int
shmids(int * buf,uint_t nids,uint_t * pnids)910Sstevel@tonic-gate shmids(int *buf, uint_t nids, uint_t *pnids)
920Sstevel@tonic-gate {
930Sstevel@tonic-gate return (syscall(SYS_shmsys, SHMIDS, buf, nids, pnids));
940Sstevel@tonic-gate }
95