641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
3 |
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
|
4 |
||
5 |
This program is free software; you can redistribute it and/or modify it under
|
|
6 |
the terms of the GNU General Public License as published by the Free Software
|
|
7 |
Foundation; version 2 of the License.
|
|
8 |
||
9 |
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
12 |
||
13 |
You should have received a copy of the GNU General Public License along with
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
15 |
St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
16 |
|
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file include/os0sync.ic
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
The interface to the operating system synchronization primitives.
|
22 |
||
23 |
Created 9/6/1995 Heikki Tuuri
|
|
24 |
*******************************************************/
|
|
25 |
||
26 |
#ifdef __WIN__ |
|
27 |
#include <winbase.h> |
|
28 |
#endif
|
|
29 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
30 |
#include <pthread.h> |
31 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
32 |
/**********************************************************//**
|
1819.9.44
by Calvin Sun, Stewart Smith
Merge Revision revid:calvin.sun@oracle.com-20100720204231-h3nw0d9q3h79krr4 from MySQL InnoDB |
33 |
Acquires ownership of a fast mutex.
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
34 |
@return 0 if success, != 0 if was reserved by another thread */
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
35 |
UNIV_INLINE
|
36 |
ulint
|
|
37 |
os_fast_mutex_trylock( |
|
38 |
/*==================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
39 |
os_fast_mutex_t* fast_mutex) /*!< in: mutex to acquire */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
40 |
{
|
41 |
#ifdef __WIN__ |
|
1819.9.44
by Calvin Sun, Stewart Smith
Merge Revision revid:calvin.sun@oracle.com-20100720204231-h3nw0d9q3h79krr4 from MySQL InnoDB |
42 |
if (TryEnterCriticalSection(fast_mutex)) { |
43 |
||
44 |
return(0); |
|
45 |
} else { |
|
46 |
||
47 |
return(1); |
|
48 |
} |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
49 |
#else
|
50 |
/* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock |
|
51 |
so that it returns 0 on success. In the operating system
|
|
52 |
libraries, HP-UX-10.20 follows the old Posix 1003.4a Draft 4 and
|
|
53 |
returns 1 on success (but MySQL remaps that to 0), while Linux,
|
|
54 |
FreeBSD, Solaris, AIX, Tru64 Unix, HP-UX-11.0 return 0 on success. */
|
|
55 |
||
56 |
return((ulint) pthread_mutex_trylock(fast_mutex)); |
|
57 |
#endif
|
|
58 |
}
|