OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [misc/] [sysvipc/] [sem.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
4
 
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Library General Public License as
7
   published by the Free Software Foundation; either version 2 of the
8
   License, or (at your option) any later version.
9
 
10
   The GNU C Library is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
 
15
   You should have received a copy of the GNU Library General Public
16
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
17
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
   Boston, MA 02111-1307, USA.  */
19
 
20
#include <errno.h>
21
#include <sys/sem.h>
22
#include "ipc.h"
23
 
24
 
25
#ifdef L_semctl
26
/* Return identifier for array of NSEMS semaphores associated with
27
   KEY.  */
28
#include <stdarg.h>
29
/* arg for semctl system calls. */
30
union semun {
31
    int val;                    /* value for SETVAL */
32
    struct semid_ds *buf;               /* buffer for IPC_STAT & IPC_SET */
33
    unsigned short *array;              /* array for GETALL & SETALL */
34
    struct seminfo *__buf;              /* buffer for IPC_INFO */
35
    void *__pad;
36
};
37
 
38
 
39
#ifdef __NR_semctl
40
#define __NR___semctl __NR_semctl
41
static inline _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, union semun *, arg);
42
#endif
43
 
44
int semctl(int semid, int semnum, int cmd, ...)
45
{
46
    union semun arg;
47
    va_list ap;
48
 
49
    /* Get the argument.  */
50
    va_start (ap, cmd);
51
    arg = va_arg (ap, union semun);
52
    va_end (ap);
53
#ifdef __NR_semctl
54
    return __semctl(semid, semnum, cmd, &arg);
55
#else
56
    return __ipc(IPCOP_semctl, semid, semnum, cmd, &arg);
57
#endif
58
}
59
#endif
60
 
61
#ifdef L_semget
62
/* for definition of NULL */
63
#include <stdlib.h>             
64
 
65
#ifdef __NR_semget
66
_syscall3(int, semget, key_t, key, int, nsems, int, semflg);
67
 
68
#else
69
/* Return identifier for array of NSEMS semaphores associated
70
 * with KEY.  */
71
int semget (key_t key, int nsems, int semflg)
72
{
73
    return __ipc(IPCOP_semget, key, nsems, semflg, NULL);
74
}
75
#endif
76
#endif
77
 
78
#ifdef L_semop
79
 
80
#ifdef __NR_semop
81
_syscall3(int, semop, int, semid, struct sembuf *, sops, size_t, nsops);
82
 
83
#else
84
/* Perform user-defined atomical operation of array of semaphores.  */
85
int semop (int semid, struct sembuf *sops, size_t nsops)
86
{
87
    return __ipc(IPCOP_semop, semid, (int) nsops, 0, sops);
88
}
89
#endif
90
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.