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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [linuxthreads/] [semaphore.h] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* Linuxthreads - a simple clone()-based implementation of Posix        */
2
/* threads for Linux.                                                   */
3
/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr)              */
4
/*                                                                      */
5
/* This program is free software; you can redistribute it and/or        */
6
/* modify it under the terms of the GNU Library General Public License  */
7
/* as published by the Free Software Foundation; either version 2       */
8
/* of the License, or (at your option) any later version.               */
9
/*                                                                      */
10
/* This program 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        */
13
/* GNU Library General Public License for more details.                 */
14
 
15
#ifndef _SEMAPHORE_H
16
#define _SEMAPHORE_H    1
17
 
18
#include <features.h>
19
#include <sys/types.h>
20
#include <bits/pthreadtypes.h>
21
#ifdef __USE_XOPEN2K
22
# define __need_timespec
23
# include <time.h>
24
#endif
25
 
26
#ifndef _PTHREAD_DESCR_DEFINED
27
/* Thread descriptors.  Needed for `sem_t' definition.  */
28
typedef struct _pthread_descr_struct *_pthread_descr;
29
# define _PTHREAD_DESCR_DEFINED
30
#endif
31
 
32
/* System specific semaphore definition.  */
33
typedef struct
34
{
35
  struct _pthread_fastlock __sem_lock;
36
  int __sem_value;
37
  _pthread_descr __sem_waiting;
38
} sem_t;
39
 
40
 
41
 
42
/* Value returned if `sem_open' failed.  */
43
#define SEM_FAILED      ((sem_t *) 0)
44
 
45
/* Maximum value the semaphore can have.  */
46
#define SEM_VALUE_MAX   ((int) ((~0u) >> 1))
47
 
48
 
49
__BEGIN_DECLS
50
 
51
/* Initialize semaphore object SEM to VALUE.  If PSHARED then share it
52
   with other processes.  */
53
extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) __THROW;
54
 
55
/* Free resources associated with semaphore object SEM.  */
56
extern int sem_destroy (sem_t *__sem) __THROW;
57
 
58
/* Open a named semaphore NAME with open flaot OFLAG.  */
59
extern sem_t *sem_open (__const char *__name, int __oflag, ...) __THROW;
60
 
61
/* Close descriptor for named semaphore SEM.  */
62
extern int sem_close (sem_t *__sem) __THROW;
63
 
64
/* Remove named semaphore NAME.  */
65
extern int sem_unlink (__const char *__name) __THROW;
66
 
67
/* Wait for SEM being posted.  */
68
extern int sem_wait (sem_t *__sem) __THROW;
69
 
70
#ifdef __USE_XOPEN2K
71
/* Similar to `sem_wait' but wait only until ABSTIME.  */
72
extern int sem_timedwait (sem_t *__restrict __sem,
73
                          __const struct timespec *__restrict __abstime)
74
     __THROW;
75
#endif
76
 
77
/* Test whether SEM is posted.  */
78
extern int sem_trywait (sem_t *__sem) __THROW;
79
 
80
/* Post SEM.  */
81
extern int sem_post (sem_t *__sem) __THROW;
82
 
83
/* Get current value of SEM and store it in *SVAL.  */
84
extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
85
     __THROW;
86
 
87
__END_DECLS
88
 
89
#endif  /* semaphore.h */

powered by: WebSVN 2.1.0

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