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

📄 mutex.h

📁 早期freebsd实现
💻 H
字号:
/* Copyright (C) 1992 Free Software Foundation, Inc.This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  *//* As a special exception, if you link this library with files   compiled with GCC to produce an executable, this does not cause   the resulting executable to be covered by the GNU General Public License.   This exception does not however invalidate any other reasons why   the executable file might be covered by the GNU General Public License.  */#ifndef _MUTEX_H#define _MUTEX_H#ifdef WANT_MUTEX#if defined (NeXT)#include  <cthreads.h>#define MUTEX               mutex_t#define MUTEX_ALLOC(mutex)  { *mutex = mutex_alloc (); }#define MUTEX_INIT(mutex)   mutex_init (mutex)#define MUTEX_FREE(mutex)   mutex_free (mutex)#define MUTEX_LOCK(mutex)   mutex_lock (mutex)#define MUTEX_UNLOCK(mutex) mutex_unlock (mutex)#define MUTEX_ISLOCK(mutex)     mutex->lock /* Gak */#elif defined (OSF)#elif defined (mach)#elif defined (sun)/* * Sun lwp uses monitors. * * Untested.  8-Dec-91, dennisg. */#include  <lwp/lwp.h>#include  <assert.h>#define MUTEX (mon_t)inline MUTEXMUTEX_ALLOC (mutex){  MUTEX mon;    mon_create (&mon);  return mon;}#define MUTEX_INIT(mutex)#define MUTEX_FREE(mutex)   mon_destroy (mutex)inline voidMUTEX_LOCK (mutex){  int level = mon_enter (mutex);  assert (level);}#define MUTEX_UNLOCK(mutex) mon_exit (mutex)inline intMUTEX_ISLOCK (mutex){  thread_t thread;  /* Won't work? */  return mon_waiters (mutex, &thread, NULL, 0);}#elif defined (COROUTINES)/* * A environment where threads are implemented as a *  set of coroutines. */#endif#endif#ifndef MUTEX/* * These are default mutex handler routines. *  There is no mutex support. * * Let the optimizer get rid of mutexes. */#define MUTEX void *#define MUTEX_ALLOC(mutex)  (MUTEX)-1#define MUTEX_INIT(mutex)   (mutex)#define MUTEX_FREE(mutex)   (mutex)#define MUTEX_LOCK(mutex)   (mutex)#define MUTEX_UNLOCK(mutex) (mutex)#define MUTEX_ISLOCK(mutex) 1#endif#endif /* not _MUTEX_H */

⌨️ 快捷键说明

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