~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/os0sync.ic

  • Committer: Monty Taylor
  • Date: 2008-12-18 07:24:54 UTC
  • mto: This revision was merged to the branch mainline in revision 714.
  • Revision ID: monty@bitters-20081218072454-8pnep622damjgqli
Fixed one more my_time thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/os0sync.ic
 
1
/******************************************************
21
2
The interface to the operating system synchronization primitives.
22
3
 
 
4
(c) 1995 Innobase Oy
 
5
 
23
6
Created 9/6/1995 Heikki Tuuri
24
7
*******************************************************/
25
8
 
27
10
#include <winbase.h>
28
11
#endif
29
12
 
30
 
#include <pthread.h>
31
 
 
32
 
/**********************************************************//**
33
 
Acquires ownership of a fast mutex.
34
 
@return 0 if success, != 0 if was reserved by another thread */
 
13
/**************************************************************
 
14
Acquires ownership of a fast mutex. Currently in Windows this is the same
 
15
as os_fast_mutex_lock! */
35
16
UNIV_INLINE
36
17
ulint
37
18
os_fast_mutex_trylock(
38
19
/*==================*/
39
 
        os_fast_mutex_t*        fast_mutex)     /*!< in: mutex to acquire */
 
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 */
40
24
{
41
25
#ifdef __WIN__
42
 
        if (TryEnterCriticalSection(fast_mutex)) {
43
 
 
44
 
                return(0);
45
 
        } else {
46
 
 
47
 
                return(1);
48
 
        }
 
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)));
49
36
#else
50
37
        /* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock
51
38
        so that it returns 0 on success. In the operating system
55
42
 
56
43
        return((ulint) pthread_mutex_trylock(fast_mutex));
57
44
#endif
 
45
#endif
58
46
}