Whamcloud - gitweb
fix typo
[fs/lustre-release.git] / lustre / utils / thread.c
1 /*****************************************************************************
2  *  $Id: thread.c,v 1.1.10.2 2008/12/18 18:02:31 johann Exp $
3  *****************************************************************************
4  *  Copyright (C) 2003 The Regents of the University of California.
5  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
6  *  Written by Chris Dunlap <cdunlap@llnl.gov>.
7  *
8  *  This file is from LSD-Tools, the LLNL Software Development Toolbox.
9  *
10  *  LSD-Tools is free software; you can redistribute it and/or modify it under
11  *  the terms of the GNU General Public License as published by the Free
12  *  Software Foundation; either version 2 of the License, or (at your option)
13  *  any later version.
14  *
15  *  LSD-Tools is distributed in the hope that it will be useful, but WITHOUT
16  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18  *  more details.
19  *
20  *  You should have received a copy of the GNU General Public License along
21  *  with LSD-Tools; if not, write to the Free Software Foundation, Inc.,
22  *  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *****************************************************************************/
24
25
26 #if HAVE_CONFIG_H
27 #  include "config.h"
28 #endif /* HAVE_CONFIG_H */
29
30 #include <assert.h>
31 #include <errno.h>
32 #include <pthread.h>
33 #include "thread.h"
34
35
36 #if WITH_PTHREADS
37 #ifndef NDEBUG
38 int
39 lsd_mutex_is_locked (pthread_mutex_t *mutex)
40 {
41 /*  Returns true if the mutex is locked; o/w, returns false.
42  */
43     int rc;
44
45     assert (mutex != NULL);
46     rc = pthread_mutex_trylock (mutex);
47     return (rc == EBUSY ? 1 : 0);
48 }
49 #endif /* !NDEBUG */
50 #endif /* WITH_PTHREADS */