Main Page   Reference Manual   Namespace List   Compound List   Namespace Members   Compound Members   File Members  

private_mutex_instances.h
Go to the documentation of this file.
1 // $Header$
2 //
3 // Copyright (C) 2001 - 2004, by
4 //
5 // Carlo Wood, Run on IRC <carlo@alinoe.com>
6 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
7 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
8 //
9 // This file may be distributed under the terms of the Q Public License
10 // version 1.0 as appearing in the file LICENSE.QPL included in the
11 // packaging of this file.
12 //
13 
18 #ifndef LIBCWD_PRIVATE_MUTEX_INSTANCES_H
19 #define LIBCWD_PRIVATE_MUTEX_INSTANCES_H
20 
21 #if LIBCWD_THREAD_SAFE
22 
23 #if CWDEBUG_DEBUGT
24 #ifndef LIBCW_PTHREAD_H
25 #define LIBCW_PTHREAD_H
26 #include <pthread.h>
27 #endif
28 #endif
29 
30 namespace libcwd {
31  namespace _private_ {
32 
33 // The different instance-ids used in libcwd.
34 enum mutex_instance_nt {
35  // Recursive mutexes.
36  static_tsd_instance,
37  object_files_instance, // rwlock
38  end_recursive_types,
39  // Fast mutexes.
40 #if CWDEBUG_ALLOC
41  memblk_map_instance,
42  location_cache_instance, // rwlock
43 #endif
44  threadlist_instance, // rwlock
45  debug_objects_instance, // rwlock
46  debug_channels_instance, // rwlock
47 #if CWDEBUG_DEBUGT
48  keypair_map_instance,
49  pthread_lock_interface_instance, // Dummy instance that is used to store who locked the ostream.
50  instance_rdlocked_size, // Must come after last rwlock and pthread_lock_interface_instance.
51 #endif
52  mutex_initialization_instance,
53  ids_singleton_tct_S_ids_instance,
54 #if CWDEBUG_ALLOC
55  alloc_tag_desc_instance,
56  list_allocations_instance,
57 #endif
58  dlopen_map_instance,
59  dlclose_instance,
60  backtrace_instance,
61  write_max_len_instance,
62  set_ostream_instance,
63  kill_threads_instance,
64  function_instance,
65  // Values reserved for read/write locks.
66  reserved_instance_low,
67  reserved_instance_high = 3 * reserved_instance_low,
68  // Values reserved for test executables.
69  test_instance0 = reserved_instance_high,
70  test_instance1,
71  test_instance2,
72  test_instance3,
73  instance_locked_size // Must be last in list
74 };
75 
76 #if CWDEBUG_DEBUG || CWDEBUG_DEBUGT
77 extern int instance_locked[instance_locked_size]; // MT: Each element is locked by the
78 inline bool is_locked(int instance) { return instance_locked[instance] > 0; }
79 #endif
80 #if CWDEBUG_DEBUGT
81 extern pthread_t locked_by[instance_locked_size]; // The id of the thread that last locked it, or 0 when that thread unlocked it.
82 extern void const* locked_from[instance_locked_size]; // and where is was locked.
83 size_t const read_lock_offset = instance_locked_size;
84 size_t const high_priority_read_lock_offset = 2 * instance_locked_size;
85 #endif
86 
87  } // namespace _private_
88 } // namespace libcwd
89 
90 #endif // LIBCWD_THREAD_SAFE
91 #endif // LIBCWD_PRIVATE_MUTEX_INSTANCES_H
92 
namespace for libcwd.
Definition: debug.cc:87
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.