~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Revision revid:marko.makela@oracle.com-20100505101406-u4low2x26q6itck0 from MySQL InnoDB

Original revid:marko.makela@oracle.com-20100505101406-u4low2x26q6itck0

Original Authors: Marko Mäkelä <marko.makela@oracle.com>
Original commit message:
Merge from mysql-5.1-innodb:

  ------------------------------------------------------------
  revno: 3446
  revision-id: marko.makela@oracle.com-20100505100507-6kcd2hf32hruxbv7
  parent: marko.makela@oracle.com-20100505095328-vetnl0flhmhao7p5
  committer: Marko Mäkelä <marko.makela@oracle.com>
  branch nick: 5.1-innodb
  timestamp: Wed 2010-05-05 13:05:07 +0300
  message:
    Add Valgrind diagnostics to track down Bug #38999.
  ------------------------------------------------------------

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. Currently in Windows this is the same
 
34
as os_fast_mutex_lock!
 
35
@return 0 if success, != 0 if was reserved by another thread */
 
36
UNIV_INLINE
 
37
ulint
 
38
os_fast_mutex_trylock(
 
39
/*==================*/
 
40
        os_fast_mutex_t*        fast_mutex)     /*!< in: mutex to acquire */
 
41
{
 
42
#ifdef __WIN__
 
43
        EnterCriticalSection(fast_mutex);
 
44
 
 
45
        return(0);
 
46
#else
 
47
        /* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock
 
48
        so that it returns 0 on success. In the operating system
 
49
        libraries, HP-UX-10.20 follows the old Posix 1003.4a Draft 4 and
 
50
        returns 1 on success (but MySQL remaps that to 0), while Linux,
 
51
        FreeBSD, Solaris, AIX, Tru64 Unix, HP-UX-11.0 return 0 on success. */
 
52
 
 
53
        return((ulint) pthread_mutex_trylock(fast_mutex));
 
54
#endif
 
55
}