⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ithread.h

📁 基于LINUX/UNIX的UPN库,是智能家具的用的底层库.
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************* * * Copyright (c) 2000-2003 Intel Corporation  * All rights reserved.  * * Redistribution and use in source and binary forms, with or without  * modification, are permitted provided that the following conditions are met:  * * * Redistributions of source code must retain the above copyright notice,  * this list of conditions and the following disclaimer.  * * Redistributions in binary form must reproduce the above copyright notice,  * this list of conditions and the following disclaimer in the documentation  * and/or other materials provided with the distribution.  * * Neither name of Intel Corporation nor the names of its contributors  * may be used to endorse or promote products derived from this software  * without specific prior written permission. *  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/#ifndef ITHREADH#define ITHREADH#ifdef __cplusplusextern "C" {#endif#include <pthread.h>#ifndef WIN32	#include <unistd.h>#endif#ifdef __FreeBSD__	#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE#endif#ifdef PTHREAD_MUTEX_RECURSIVE	/* This system has SuS2-compliant mutex attributes.	 * E.g. on Cygwin, where we don't have the old nonportable (NP) symbols	 */	#define ITHREAD_MUTEX_FAST_NP       PTHREAD_MUTEX_NORMAL	#define ITHREAD_MUTEX_RECURSIVE_NP  PTHREAD_MUTEX_RECURSIVE	#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK#else /* PTHREAD_MUTEX_RECURSIVE */	#define ITHREAD_MUTEX_FAST_NP       PTHREAD_MUTEX_FAST_NP	#define ITHREAD_MUTEX_RECURSIVE_NP  PTHREAD_MUTEX_RECURSIVE_NP	#define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK_NP#endif /* PTHREAD_MUTEX_RECURSIVE */#define ITHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE#define ITHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED#define ITHREAD_CANCELED PTHREAD_CANCELED  /*************************************************************************** * Name: ithread_t * *  Description: *      Thread handle. *      typedef to pthread_t. *      Internal Use Only. ***************************************************************************/typedef pthread_t ithread_t;   /**************************************************************************** * Name: ithread_attr_t * *  Description: *      Thread attribute. *      typedef to pthread_attr_t *      Internal Use Only ***************************************************************************/typedef pthread_attr_t ithread_attr_t;	/**************************************************************************** * Name: start_routine * *  Description: *      Thread start routine  *      Internal Use Only. ***************************************************************************/typedef void * (*start_routine) (void *arg);  /**************************************************************************** * Name: ithread_cond_t * *  Description: *      condition variable. *      typedef to pthread_cond_t *      Internal Use Only. ***************************************************************************/typedef pthread_cond_t ithread_cond_t;/**************************************************************************** * Name: ithread_mutexattr_t * *  Description: *      Mutex attribute. *      typedef to pthread_mutexattr_t *      Internal Use Only ***************************************************************************/typedef pthread_mutexattr_t ithread_mutexattr_t;	/**************************************************************************** * Name: ithread_mutex_t * *  Description: *      Mutex. *      typedef to pthread_mutex_t *      Internal Use Only. ***************************************************************************/typedef pthread_mutex_t ithread_mutex_t;/**************************************************************************** * Name: ithread_condattr_t * *  Description: *      Condition attribute. *      typedef to pthread_condattr_t *      NOT USED *      Internal Use Only ***************************************************************************/typedef pthread_condattr_t ithread_condattr_t;	/**************************************************************************** * Name: ithread_rwlockattr_t * *  Description: *      Mutex attribute. *      typedef to pthread_rwlockattr_t *      Internal Use Only ***************************************************************************/typedef pthread_rwlockattr_t ithread_rwlockattr_t;	/**************************************************************************** * Name: ithread_rwlock_t * *  Description: *      Condition attribute. *      typedef to pthread_rwlock_t *      Internal Use Only ***************************************************************************/typedef pthread_rwlock_t ithread_rwlock_t;	/**************************************************************************** * Function: ithread_mutexattr_init * *  Description: *      Initializes a mutex attribute variable. *      Used to set the type of the mutex. *  Parameters: *      ithread_mutexattr_init * attr (must be valid non NULL pointer to  *                                     pthread_mutexattr_t) *  Returns: *      0 on success, Nonzero on failure. *      Always returns 0. *      See man page for pthread_mutexattr_init ***************************************************************************/#define ithread_mutexattr_init pthread_mutexattr_init/**************************************************************************** * Function: ithread_mutexattr_destroy * *  Description: *      Releases any resources held by the mutex attribute. *      Currently there are no resources associated with the attribute *  Parameters: *      ithread_mutexattr_t * attr (must be valid non NULL pointer to  *                                  pthread_mutexattr_t) *  Returns: *      0 on success, Nonzero on failure. *      Always returns 0. *      See man page for pthread_mutexattr_destroy ***************************************************************************/#define ithread_mutexattr_destroy pthread_mutexattr_destroy    /**************************************************************************** * Function: ithread_mutexattr_setkind_np * *  Description: *      Sets the mutex type in the attribute. *      Valid types are: ITHREAD_MUTEX_FAST_NP  *                       ITHREAD_MUTEX_RECURSIVE_NP  *                       ITHREAD_MUTEX_ERRORCHECK_NP * *  Parameters: *      ithread_mutexattr_t * attr (must be valid non NULL pointer to  *                                   ithread_mutexattr_t) *      int kind (one of ITHREAD_MUTEX_FAST_NP or ITHREAD_MUTEX_RECURSIVE_NP *                or ITHREAD_MUTEX_ERRORCHECK_NP) *  Returns: *      0 on success. Nonzero on failure. *      Returns EINVAL if the kind is not supported. *      See man page for pthread_mutexattr_setkind_np *****************************************************************************/#ifdef PTHREAD_MUTEX_RECURSIVE	#define ithread_mutexattr_setkind_np pthread_mutexattr_settype#else	#define ithread_mutexattr_setkind_np pthread_mutexattr_setkind_np#endif/**************************************************************************** * Function: ithread_mutexattr_getkind_np * *  Description: *      Gets the mutex type in the attribute. *      Valid types are: ITHREAD_MUTEX_FAST_NP  *                       ITHREAD_MUTEX_RECURSIVE_NP  *                       ITHREAD_MUTEX_ERRORCHECK_NP * *  Parameters: *      ithread_mutexattr_t * attr (must be valid non NULL pointer to  *                                   pthread_mutexattr_t) *      int *kind (one of ITHREAD_MUTEX_FAST_NP or ITHREAD_MUTEX_RECURSIVE_NP *                or ITHREAD_MUTEX_ERRORCHECK_NP) *  Returns: *      0 on success. Nonzero on failure. *      Always returns 0. *      See man page for pthread_mutexattr_getkind_np *****************************************************************************/#ifdef PTHREAD_MUTEX_RECURSIVE	#define ithread_mutexattr_getkind_np pthread_mutexattr_gettype#else	#define ithread_mutexattr_getkind_np pthread_mutexattr_getkind_np#endif  /**************************************************************************** * Function: ithread_mutex_init * *  Description: *      Initializes mutex. *      Must be called before use. *       *  Parameters: *      ithread_mutex_t * mutex (must be valid non NULL pointer to pthread_mutex_t) *      const ithread_mutexattr_t * mutex_attr  *  Returns: *      0 on success, Nonzero on failure. *      Always returns 0. *      See man page for pthread_mutex_init *****************************************************************************/#define ithread_mutex_init pthread_mutex_init/**************************************************************************** * Function: ithread_mutex_lock * *  Description: *      Locks mutex. *  Parameters: *      ithread_mutex_t * mutex (must be valid non NULL pointer to pthread_mutex_t) *      mutex must be initialized. *       *  Returns: *      0 on success, Nonzero on failure. *      Always returns 0. *      See man page for pthread_mutex_lock *****************************************************************************/#define ithread_mutex_lock pthread_mutex_lock  /**************************************************************************** * Function: ithread_mutex_unlock * *  Description: *      Unlocks mutex. * *  Parameters: *      ithread_mutex_t * mutex (must be valid non NULL pointer to pthread_mutex_t) *      mutex must be initialized. *       *  Returns: *      0 on success, Nonzero on failure. *      Always returns 0. *      See man page for pthread_mutex_unlock *****************************************************************************/#define ithread_mutex_unlock pthread_mutex_unlock/**************************************************************************** * Function: ithread_mutex_destroy * *  Description: *      Releases any resources held by the mutex.  *		Mutex can no longer be used after this call. *		Mutex is only destroyed when there are no longer any threads waiting on it.  *		Mutex cannot be destroyed if it is locked. *  Parameters: *      ithread_mutex_t * mutex (must be valid non NULL pointer to pthread_mutex_t) *      mutex must be initialized. *  Returns: *      0 on success. Nonzero on failure. *      Always returns 0. *      See man page for pthread_mutex_destroy *****************************************************************************/#define ithread_mutex_destroy pthread_mutex_destroy/**************************************************************************** * Function: ithread_rwlockattr_init * *  Description: *      Initializes a rwlock attribute variable to default values. *  Parameters: *      const ithread_rwlockattr_init *attr (must be valid non NULL pointer to  *                                           pthread_rwlockattr_t) *  Returns: *      0 on success, Nonzero on failure. *      Always returns 0. *      See man page for pthread_rwlockattr_init ***************************************************************************/#define ithread_rwlockattr_init pthread_rwlockattr_init/**************************************************************************** * Function: ithread_rwlockattr_destroy * *  Description: *      Releases any resources held by the rwlock attribute. *  Parameters: *      ithread_rwlockattr_t *attr (must be valid non NULL pointer to  *                                  pthread_rwlockattr_t) *  Returns: *      0 on success, Nonzero on failure. *      Always returns 0. *      See man page for pthread_rwlockattr_destroy ***************************************************************************/#define ithread_rwlockattr_destroy pthread_rwlockattr_destroy    /**************************************************************************** * Function: ithread_rwlockatttr_setpshared * *  Description: *      Sets the rwlock type in the attribute. *      Valid types are: ITHREAD_PROCESS_PRIVATE  *                       ITHREAD_PROCESS_SHARED * *  Parameters: *      ithread_rwlockattr_t * attr (must be valid non NULL pointer to  *                                   ithread_rwlockattr_t) *      int kind (one of ITHREAD_PROCESS_PRIVATE or ITHREAD_PROCESS_SHARED) * *  Returns: *      0 on success. Nonzero on failure. *      Returns EINVAL if the kind is not supported. *      See man page for pthread_rwlockattr_setkind_np *****************************************************************************/#define ithread_rwlockatttr_setpshared pthread_rwlockatttr_setpshared/**************************************************************************** * Function: ithread_rwlockatttr_getpshared * *  Description: *      Gets the rwlock type in the attribute. *      Valid types are: ITHREAD_PROCESS_PRIVATE  *                       ITHREAD_PROCESS_SHARED  * *  Parameters: *      ithread_rwlockattr_t * attr (must be valid non NULL pointer to 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -