1 |
786 |
skrzyp |
#ifndef CYGONCE_POSIX_MUTTYPES_H
|
2 |
|
|
#define CYGONCE_POSIX_MUTTYPES_H
|
3 |
|
|
//=============================================================================
|
4 |
|
|
//
|
5 |
|
|
// muttypes.h
|
6 |
|
|
//
|
7 |
|
|
// POSIX mutex types 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,jlarmour
|
46 |
|
|
// Date: 2000-03-17
|
47 |
|
|
// Purpose: POSIX types header
|
48 |
|
|
// Description: This header contains POSIX type definitions for mutexes
|
49 |
|
|
// and cond vars. These types are implementation defined.
|
50 |
|
|
//
|
51 |
|
|
// Usage: #include <sys/types.h>
|
52 |
|
|
//
|
53 |
|
|
//
|
54 |
|
|
//####DESCRIPTIONEND####
|
55 |
|
|
//
|
56 |
|
|
//=============================================================================
|
57 |
|
|
|
58 |
|
|
#include <pkgconf/posix.h>
|
59 |
|
|
#include <pkgconf/kernel.h>
|
60 |
|
|
|
61 |
|
|
#include <cyg/infra/cyg_type.h>
|
62 |
|
|
|
63 |
|
|
//-----------------------------------------------------------------------------
|
64 |
|
|
// Mutex object
|
65 |
|
|
// This structure must exactly correspond in size and layout to the underlying
|
66 |
|
|
// eCos C++ class that implements this object. Because we have to support
|
67 |
|
|
// PTHREAD_MUTEX_INITIALIZER we cannot abstract this object very easily.
|
68 |
|
|
|
69 |
|
|
typedef struct
|
70 |
|
|
{
|
71 |
|
|
CYG_WORD32 locked;
|
72 |
|
|
CYG_ADDRESS owner;
|
73 |
|
|
CYG_ADDRESS queue;
|
74 |
|
|
|
75 |
|
|
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
|
76 |
|
|
CYG_WORD32 protocol; // this mutex's protocol
|
77 |
|
|
#endif
|
78 |
|
|
|
79 |
|
|
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING
|
80 |
|
|
CYG_WORD32 ceiling; // mutex priority ceiling
|
81 |
|
|
#endif
|
82 |
|
|
|
83 |
|
|
} pthread_mutex_t;
|
84 |
|
|
|
85 |
|
|
#if defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC) &&\
|
86 |
|
|
defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING)
|
87 |
|
|
#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0, 0, 0 }
|
88 |
|
|
#elif defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC) ||\
|
89 |
|
|
defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING)
|
90 |
|
|
#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0, 0 }
|
91 |
|
|
#else
|
92 |
|
|
#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0 }
|
93 |
|
|
#endif
|
94 |
|
|
|
95 |
|
|
//-----------------------------------------------------------------------------
|
96 |
|
|
// Mutex attributes structure
|
97 |
|
|
|
98 |
|
|
typedef struct
|
99 |
|
|
{
|
100 |
|
|
int protocol;
|
101 |
|
|
#ifdef _POSIX_THREAD_PRIO_PROTECT
|
102 |
|
|
int prioceiling;
|
103 |
|
|
#endif
|
104 |
|
|
} pthread_mutexattr_t;
|
105 |
|
|
|
106 |
|
|
// Values for protocol
|
107 |
|
|
#define PTHREAD_PRIO_NONE 1
|
108 |
|
|
#if defined(_POSIX_THREAD_PRIO_INHERIT)
|
109 |
|
|
#define PTHREAD_PRIO_INHERIT 2
|
110 |
|
|
#endif
|
111 |
|
|
#if defined(_POSIX_THREAD_PRIO_PROTECT)
|
112 |
|
|
#define PTHREAD_PRIO_PROTECT 3
|
113 |
|
|
#endif
|
114 |
|
|
|
115 |
|
|
//-----------------------------------------------------------------------------
|
116 |
|
|
// Condition Variable structure.
|
117 |
|
|
// Like mutexes, this must match the underlying eCos implementation class.
|
118 |
|
|
|
119 |
|
|
typedef struct
|
120 |
|
|
{
|
121 |
|
|
CYG_ADDRESS mutex;
|
122 |
|
|
CYG_ADDRESS queue;
|
123 |
|
|
} pthread_cond_t;
|
124 |
|
|
|
125 |
|
|
#define PTHREAD_COND_INITIALIZER { 0, 0 }
|
126 |
|
|
|
127 |
|
|
//-----------------------------------------------------------------------------
|
128 |
|
|
// Condition variable attributes structure
|
129 |
|
|
|
130 |
|
|
typedef struct
|
131 |
|
|
{
|
132 |
|
|
int dummy;
|
133 |
|
|
} pthread_condattr_t;
|
134 |
|
|
|
135 |
|
|
//-----------------------------------------------------------------------------
|
136 |
|
|
#endif // ifndef CYGONCE_POSIX_MUTTYPES_H
|
137 |
|
|
// End of muttypes.h
|