~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/******************************************************
2
The interface to the operating system synchronization primitives.
3
4
(c) 1995 Innobase Oy
5
6
Created 9/6/1995 Heikki Tuuri
7
*******************************************************/
8
9
#ifdef __WIN__
10
#include <winbase.h>
11
#endif
12
13
/**************************************************************
14
Acquires ownership of a fast mutex. Currently in Windows this is the same
15
as os_fast_mutex_lock! */
16
UNIV_INLINE
17
ulint
18
os_fast_mutex_trylock(
19
/*==================*/
20
						/* out: 0 if success, != 0 if
21
						was reserved by another
22
						thread */
23
	os_fast_mutex_t*	fast_mutex)	/* in: mutex to acquire */
24
{
25
#ifdef __WIN__
26
	EnterCriticalSection(fast_mutex);
27
28
	return(0);
29
#else
30
#if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10)
31
	/* Since the hot backup version is standalone, MySQL does not redefine
32
	pthread_mutex_trylock for HP-UX-10.20, and consequently we must invert
33
	the return value here */
34
35
	return((ulint) (1 - pthread_mutex_trylock(fast_mutex)));
36
#else
37
	/* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock
38
	so that it returns 0 on success. In the operating system
39
	libraries, HP-UX-10.20 follows the old Posix 1003.4a Draft 4 and
40
	returns 1 on success (but MySQL remaps that to 0), while Linux,
41
	FreeBSD, Solaris, AIX, Tru64 Unix, HP-UX-11.0 return 0 on success. */
42
43
	return((ulint) pthread_mutex_trylock(fast_mutex));
44
#endif
45
#endif
46
}