~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-18 00:22:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: osullivan.padraig@gmail.com-20090918002238-zq7mui4r2yzoidz1
Extracted KeyUse into its own header file and placed it within the
drizzled::optimizer namespace.

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
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
 
 
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 */
35
 
UNIV_INLINE
36
 
ulint
37
 
os_fast_mutex_trylock(
38
 
/*==================*/
39
 
        os_fast_mutex_t*        fast_mutex)     /*!< in: mutex to acquire */
40
 
{
41
 
#ifdef __WIN__
42
 
        if (TryEnterCriticalSection(fast_mutex)) {
43
 
 
44
 
                return(0);
45
 
        } else {
46
 
 
47
 
                return(1);
48
 
        }
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
 
}