os0sync.ic 870 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/******************************************************
The interface to the operating system synchronization primitives.

(c) 1995 Innobase Oy

Created 9/6/1995 Heikki Tuuri
*******************************************************/

#ifdef __WIN__
#include <winbase.h>
#endif

#ifndef _WIN32
/**************************************************************
Acquires ownership of a fast mutex. */
UNIV_INLINE
ulint
os_fast_mutex_trylock(
/*==================*/
						/* out: 0 if success, != 0 if
						was reserved by another
						thread */
	os_fast_mutex_t*	fast_mutex)	/* in: mutex to acquire */
{
#ifdef __WIN__	
	int	ret;

28
	/* TODO: TryEnterCriticalSection is probably not found from
29 30 31 32 33 34 35 36 37 38 39 40
	NT versions < 4! */
	ret = TryEnterCriticalSection(fast_mutex);

	if (ret) {
		return(0);
	}

	return(1);
#else
	return((ulint) pthread_mutex_trylock(fast_mutex));
#endif
}
41
#endif
42