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

📄 rvmutex_.h

📁 h.248协议源码
💻 H
字号:
#if (0)
******************************************************************************
Filename    :
Description :
******************************************************************************
                Copyright (c) 1999 RADVision Inc.
************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision LTD.
No part of this publication may be reproduced in any form whatsoever 
without written prior approval by RADVision LTD..

RADVision LTD. reserves the right to revise this publication and make 
changes without obligation to notify any person of such revisions or 
changes.
******************************************************************************
$Revision:$
$Date:$
$Author: S. Cipolli$
******************************************************************************
#endif

#ifndef RV_MUTEX__H
#define RV_MUTEX__H

#include <assert.h>
#include "rvplatform.h"

/* WIN32 implementation */
#if defined(RV_MUTEX_WIN32)
#include <windows.h>

typedef CRITICAL_SECTION RvMutex_;

#define rvMutexConstruct_(m)		(InitializeCriticalSection(m), (m))
#define rvMutexDestruct_(m)			(DeleteCriticalSection(m))
#define rvMutexLock_(m)				(EnterCriticalSection(m))
#define rvMutexUnlock_(m)			(LeaveCriticalSection(m))

/* POSIX (plus semi-standard PTHREAD_MUTEX_RECURSIVE attribute) implementation */
/* Solaris 2.6 won't work with this use RV_MUTEX_GENERIC */
/* Solaris 2.7 and 2.8 only work with patches applied */
#elif defined(RV_MUTEX_POSIX)
#include <pthread.h>

typedef pthread_mutex_t RvMutex_;

RvMutex_* rvMutexConstruct_(RvMutex_* m);
#define rvMutexDestruct_(m)			(pthread_mutex_destroy(m))
#define rvMutexLock_(m)				(pthread_mutex_lock(m))
#define rvMutexUnlock_(m)			(pthread_mutex_unlock(m))

/* Red Hat Linux implementation */
#elif defined(RV_MUTEX_REDHAT)
#include <pthread.h>

typedef pthread_mutex_t RvMutex_;

RvMutex_* rvMutexConstruct_(RvMutex_* m);
#define rvMutexDestruct_(m)			(pthread_mutex_destroy(m))
#define rvMutexLock_(m)				(pthread_mutex_lock(m))
#define rvMutexUnlock_(m)			(pthread_mutex_unlock(m))

/* VxWorks implementation */
#elif defined(RV_MUTEX_VXWORKS)
#include "semLib.h"

typedef SEM_ID RvMutex_;

#define rvMutexConstruct_(m)		(*(m) = semMCreate(SEM_Q_PRIORITY|SEM_INVERSION_SAFE), (m))
#define rvMutexDestruct_(m)			(semDelete(*(m)))
#define rvMutexLock_(m)				(semTake(*(m), WAIT_FOREVER))
#define rvMutexUnlock_(m)			(semGive(*(m)))

#elif defined(RV_MUTEX_PSOS)
#include <psos.h>

typedef unsigned long RvMutex_;

#define rvMutexConstruct_(m)           (mu_create("", MU_RECURSIVE |MU_PRIOR|MU_PRIO_INHERIT, 0, m), (m))
#define rvMutexDestruct_(m)            (mu_delete(*m))
#define rvMutexLock_(m)                (mu_lock(*m, MU_WAIT, 0))
#define rvMutexUnlock_(m)              (mu_unlock(*m))


/* Generic (platform independent) implementation */
#elif defined(RV_MUTEX_GENERIC) 

#include "rvthread_.h"
#include "rvsem_.h"

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct {
	RvSem_ handle;
	RvSem_ lock;
	RvThreadId owner;
	int count;
	int waiters;
} RvMutex_;

RvMutex_* rvMutexConstruct_(RvMutex_* m);
void rvMutexLock_(RvMutex_* m);
void rvMutexUnlock_(RvMutex_* m);
void rvMutexDestruct_(RvMutex_* m);

#if defined(__cplusplus)
}
#endif

#else
#	error Unknown mutex implementation
#endif

#endif

⌨️ 快捷键说明

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