Debian Codegraph @

src/include/fl_lock.h

raw
1 // ----------------------------------------------------------------------------
2 // fl_lock.h
3 //
4 // Copyright (C) 2007
5 // Stelios Bounanos, M0GLD
6 //
7 // ----------------------------------------------------------------------------
8 // Copyright (C) 2014
9 // David Freese, W1HKJ
10 //
11 // This file is part of flmsg
12 //
13 // flrig is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // flrig is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program. If not, see <http://www.gnu.org/licenses/>.
25 // ----------------------------------------------------------------------------
26
27 #ifndef FL_LOCK_H_
28 #define FL_LOCK_H_
29
30 // disabled calls
31 #define FL_LOCK_D(x) ((void)0)
32 #define FL_UNLOCK_D(x) ((void)0)
33 #define FL_AWAKE_D(x) ((void)0)
34 // enabled calls
35 #define FL_LOCK_E(x) FL_LOCK(x)
36 #define FL_UNLOCK_E(x) FL_UNLOCK(x)
37 #define FL_AWAKE_E(x) FL_AWAKE(x)
38
39 #if !defined(NDEBUG) && !defined(NO_LOCKS)
40 # include <FL/Fl.H>
41 #endif
42
43 #ifdef NDEBUG
44 # define FL_LOCK(x) Fl::lock(x)
45 # define FL_UNLOCK(x) Fl::unlock(x)
46 # define FL_AWAKE(x) Fl::awake(x)
47 #else // debugging
48 # include <stacktrace.h>
49
50 # ifndef NO_LOCKS
51 # include "debug.h"
52 # define FL_LOCK(x) \
53 do { \
54 switch (GET_THREAD_ID()) { \
55 case TRX_TID: \
56 LOG_ERROR("trx lock"); \
57 break; \
58 case FLMAIN_TID: \
59 LOG_WARN("flrun lock"); \
60 break; \
61 default: \
62 LOG_VERBOSE("lock"); \
63 } \
64 pstack_maybe(); \
65 Fl::lock(x); \
66 } while (0);
67
68 # define FL_UNLOCK(x) Fl::unlock(x)
69 # define FL_AWAKE(x) Fl::awake(x)
70 # else // no locks
71 # define FL_LOCK(x) ((void)0)
72 # define FL_UNLOCK(x) ((void)0)
73 # define FL_AWAKE(x) ((void)0)
74 # endif // NO_LOCKS
75 #endif // NDEBUG
76
77 #endif // FL_LOCK_H_
78
79 // Local Variables:
80 // mode: c++
81 // c-file-style: "linux"
82 // End: