Debian Codegraph @

liblsd/thread.c

raw
1 /*****************************************************************************
2 * $Id: thread.c 2918 2003-09-11 21:09:45Z dun $
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 <[email protected]>.
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 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 */