diff packages/compat/posix/current/include/mutex.h @ 183:9160a8005d76

Merge from eCos master repository on 2001-09-12-03:52:30-BST
author jlarmour
date Wed, 12 Sep 2001 04:21:13 +0000
parents
children e0c0827131d1
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/packages/compat/posix/current/include/mutex.h
@@ -0,0 +1,163 @@
+#ifndef CYGONCE_POSIX_MUTEX_H
+#define CYGONCE_POSIX_MUTEX_H
+//=============================================================================
+//
+//      mutex.h
+//
+//      POSIX mutex and condition variable function definitions
+//
+//=============================================================================
+//####COPYRIGHTBEGIN####
+//                                                                          
+// -------------------------------------------                              
+// The contents of this file are subject to the Red Hat eCos Public License 
+// Version 1.1 (the "License"); you may not use this file except in         
+// compliance with the License.  You may obtain a copy of the License at    
+// http://www.redhat.com/                                                   
+//                                                                          
+// Software distributed under the License is distributed on an "AS IS"      
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the 
+// License for the specific language governing rights and limitations under 
+// the License.                                                             
+//                                                                          
+// The Original Code is eCos - Embedded Configurable Operating System,      
+// released September 30, 1998.                                             
+//                                                                          
+// The Initial Developer of the Original Code is Red Hat.                   
+// Portions created by Red Hat are                                          
+// Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc.               
+// All Rights Reserved.                                                     
+// -------------------------------------------                              
+//                                                                          
+//####COPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     nickg,jlarmour
+// Contributors:  
+// Date:          2001-09-10
+// Purpose:       POSIX mutex and condition variable function definitions
+// Description:   This header contains POSIX API definitions for mutexes
+//                and cond vars.
+//              
+// Usage:         #include <pthread.h>
+//              
+//
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+#include <pkgconf/posix.h>
+
+#include <sys/types.h>   // pthread_* types
+
+//=============================================================================
+// Mutexes
+
+//-----------------------------------------------------------------------------
+// Mutex attributes manipulation functions
+
+// Initialize attribute object
+externC int pthread_mutexattr_init ( pthread_mutexattr_t *attr);
+
+// Destroy attribute object
+externC int pthread_mutexattr_destroy ( pthread_mutexattr_t *attr);
+
+#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT)
+
+// Set priority inversion protection protocol
+externC int pthread_mutexattr_setprotocol ( pthread_mutexattr_t *attr,
+                                            int protocol);
+
+// Get priority inversion protection protocol
+externC int pthread_mutexattr_getprotocol ( pthread_mutexattr_t *attr,
+                                            int *protocol);
+
+#if defined(_POSIX_THREAD_PRIO_PROTECT)
+
+// Set priority for priority ceiling protocol
+externC int pthread_mutexattr_setprioceiling ( pthread_mutexattr_t *attr,
+                                               int prioceiling);
+
+// Get priority for priority ceiling protocol
+externC int pthread_mutexattr_getprioceiling ( pthread_mutexattr_t *attr,
+                                               int *prioceiling);
+
+// Set priority ceiling of given thread, returning old ceiling.
+externC int pthread_mutex_setprioceiling( pthread_mutex_t *mutex,
+                                          int prioceiling,
+                                          int *old_ceiling);
+
+// Get priority ceiling of given thread
+externC int pthread_mutex_getprioceiling( pthread_mutex_t *mutex,
+                                          int *prioceiling);
+#endif
+
+#endif
+
+//-----------------------------------------------------------------------------
+// Mutex functions
+
+// Initialize mutex. If mutex_attr is NULL, use default attributes.
+externC int pthread_mutex_init (pthread_mutex_t *mutex,
+                                const pthread_mutexattr_t *mutex_attr);
+
+// Destroy mutex.
+externC int pthread_mutex_destroy (pthread_mutex_t *mutex);
+
+// Lock mutex, waiting for it if necessary.
+externC int pthread_mutex_lock (pthread_mutex_t *mutex);
+
+// Try to lock mutex.
+externC int pthread_mutex_trylock (pthread_mutex_t *mutex);
+
+
+// Unlock mutex.
+externC int pthread_mutex_unlock (pthread_mutex_t *mutex);
+
+
+
+//=============================================================================
+// Condition Variables
+
+//-----------------------------------------------------------------------------
+// Attribute manipulation functions
+// We do not actually support any attributes at present, so these do nothing.
+
+// Initialize condition variable attributes
+externC int pthread_condattr_init (pthread_condattr_t *attr);
+
+// Destroy condition variable attributes
+externC int pthread_condattr_destroy (pthread_condattr_t *attr);
+
+//-----------------------------------------------------------------------------
+// Condition variable functions
+
+// Initialize condition variable.
+externC int pthread_cond_init (pthread_cond_t *cond,
+                               const pthread_condattr_t *attr);
+
+// Destroy condition variable.
+externC int pthread_cond_destroy (pthread_cond_t *cond);
+
+// Wake up one thread waiting for condition variable
+externC int pthread_cond_signal (pthread_cond_t *cond);
+
+// Wake up all threads waiting for condition variable
+externC int pthread_cond_broadcast (pthread_cond_t *cond);
+
+// Block on condition variable until signalled. The mutex is
+// assumed to be locked before this call, will be unlocked
+// during the wait, and will be re-locked on wakeup.
+externC int pthread_cond_wait (pthread_cond_t *cond,
+                               pthread_mutex_t *mutex);
+
+// Block on condition variable until signalled, or the timeout expires.
+externC int pthread_cond_timedwait (pthread_cond_t *cond,
+                                    pthread_mutex_t *mutex,
+                                    const struct timespec *abstime);
+
+
+//-----------------------------------------------------------------------------
+#endif // ifndef CYGONCE_POSIX_MUTEX_H
+// End of mutex.h