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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [posix/] [current/] [include/] [semaphore.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_SEMAPHORE_H
2
#define CYGONCE_SEMAPHORE_H
3
//=============================================================================
4
//
5
//      semaphore.h
6
//
7
//      POSIX semaphore header
8
//
9
//=============================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
11
// -------------------------------------------                              
12
// This file is part of eCos, the Embedded Configurable Operating System.   
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under    
16
// the terms of the GNU General Public License as published by the Free     
17
// Software Foundation; either version 2 or (at your option) any later      
18
// version.                                                                 
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT      
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
23
// for more details.                                                        
24
//
25
// You should have received a copy of the GNU General Public License        
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
28
//
29
// As a special exception, if other files instantiate templates or use      
30
// macros or inline functions from this file, or you compile this file      
31
// and link it with other works to produce a work based on this file,       
32
// this file does not by itself cause the resulting work to be covered by   
33
// the GNU General Public License. However the source code for this file    
34
// must still be made available in accordance with section (3) of the GNU   
35
// General Public License v2.                                               
36
//
37
// This exception does not invalidate any other reasons why a work based    
38
// on this file might be covered by the GNU General Public License.         
39
// -------------------------------------------                              
40
// ####ECOSGPLCOPYRIGHTEND####                                              
41
//=============================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):     nickg
45
// Contributors:  nickg
46
// Date:          2000-03-17
47
// Purpose:       POSIX semaphore header
48
// Description:   This header contains all the definitions needed to support
49
//                semaphores under eCos. The reader is referred to the POSIX
50
//                standard or equivalent documentation for details of the
51
//                functionality contained herein.
52
//              
53
// Usage:
54
//              #include <semaphore.h>
55
//              ...
56
//              
57
//
58
//####DESCRIPTIONEND####
59
//
60
//=============================================================================
61
 
62
#include <pkgconf/hal.h>
63
#include <pkgconf/kernel.h>
64
#include <pkgconf/posix.h>
65
 
66
#include <stddef.h>             // NULL, size_t
67
 
68
#include <limits.h>
69
 
70
#include <sys/types.h>
71
 
72
//-----------------------------------------------------------------------------
73
// Semaphore object definition
74
 
75
// This structure must exactly correspond in size and layout to the underlying
76
// eCos C++ class that implements this object.
77
 
78
typedef struct
79
{
80
  CYG_WORD32    sem_value;
81
  CYG_ADDRESS   sem_queue;
82
} sem_t;
83
 
84
//-----------------------------------------------------------------------------
85
// Semaphore functions
86
 
87
// Initialize semaphore to value.
88
// pshared is not supported under eCos.
89
externC int sem_init  (sem_t *sem, int pshared, unsigned int value);
90
 
91
// Destroy the semaphore.
92
externC int sem_destroy  (sem_t *sem);
93
 
94
// Decrement value if >0 or wait for a post.
95
externC int sem_wait  (sem_t *sem);
96
 
97
// Decrement value if >0, return -1 if not.
98
externC int sem_trywait  (sem_t *sem);
99
 
100
// Increment value and wake a waiter if one is present.
101
externC int sem_post  (sem_t *sem);
102
 
103
// Get current value
104
externC int sem_getvalue  (sem_t *sem, int *sval);
105
 
106
//-----------------------------------------------------------------------------
107
// Named semaphore functions
108
// These are an optional feature under eCos
109
 
110
// Open an existing named semaphore, or create it.
111
externC sem_t *sem_open  (const char *name, int oflag, ...);
112
 
113
// Close descriptor for semaphore.
114
externC int sem_close  (sem_t *sem);
115
 
116
// Remove named semaphore
117
externC int sem_unlink  (const char *name);
118
 
119
//-----------------------------------------------------------------------------
120
// Special return value for sem_open()
121
 
122
#define SEM_FAILED      ((sem_t *)NULL)
123
 
124
//-----------------------------------------------------------------------------
125
#endif // ifndef CYGONCE_SEMAPHORE_H
126
// End of semaphore.h

powered by: WebSVN 2.1.0

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