ARGOBOTS
abti_log.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #ifndef ABTI_LOG_H_INCLUDED
7 #define ABTI_LOG_H_INCLUDED
8 
9 #include "abt_config.h"
10 
11 #ifdef ABT_CONFIG_USE_DEBUG_LOG
12 typedef struct {
13  ABTI_sched *p_sched;
14 } ABTI_log;
15 
16 extern ABTD_XSTREAM_LOCAL ABTI_log *lp_ABTI_log;
17 
18 void ABTI_log_init(void);
19 void ABTI_log_finalize(void);
20 void ABTI_log_print(FILE *fh, const char *format, ...);
21 void ABTI_log_event(FILE *fh, const char *format, ...);
22 void ABTI_log_debug(FILE *fh, char *path, int line, const char *format, ...);
23 void ABTI_log_pool_push(ABTI_pool *p_pool, ABT_unit unit,
24  ABTI_native_thread_id producer_id);
25 void ABTI_log_pool_remove(ABTI_pool *p_pool, ABT_unit unit,
26  ABTI_native_thread_id consumer_id);
27 void ABTI_log_pool_pop(ABTI_pool *p_pool, ABT_unit unit);
28 
29 static inline void ABTI_log_set_sched(ABTI_sched *p_sched)
30 {
31  lp_ABTI_log->p_sched = p_sched;
32 }
33 
34 static inline ABTI_sched *ABTI_log_get_sched(void)
35 {
36  return lp_ABTI_log->p_sched;
37 }
38 
39 #define ABTI_LOG_INIT() ABTI_log_init()
40 #define ABTI_LOG_FINALIZE() ABTI_log_finalize()
41 #define ABTI_LOG_SET_SCHED(s) ABTI_log_set_sched(s)
42 #define ABTI_LOG_GET_SCHED(ret) ret = ABTI_log_get_sched()
43 #define LOG_EVENT(fmt, ...) ABTI_log_event(stderr, fmt, __VA_ARGS__)
44 #define LOG_DEBUG(fmt, ...) \
45  ABTI_log_debug(stderr, __FILE__, __LINE__, fmt, __VA_ARGS__)
46 
47 #define LOG_EVENT_POOL_PUSH(p_pool, unit, produer_id) \
48  ABTI_log_pool_push(p_pool, unit, produer_id)
49 #define LOG_EVENT_POOL_REMOVE(p_pool, unit, consumer_id) \
50  ABTI_log_pool_remove(p_pool, unit, consumer_id)
51 #define LOG_EVENT_POOL_POP(p_pool, unit) ABTI_log_pool_pop(p_pool, unit)
52 
53 #else
54 
55 #define ABTI_LOG_INIT()
56 #define ABTI_LOG_FINALIZE()
57 #define ABTI_LOG_SET_SCHED(s)
58 #define ABTI_LOG_GET_SCHED(ret)
59 
60 #define LOG_EVENT(fmt, ...)
61 #define LOG_DEBUG(fmt, ...)
62 
63 #define LOG_EVENT_POOL_PUSH(p_pool, unit, produer_id)
64 #define LOG_EVENT_POOL_REMOVE(p_pool, unit, consumer_id)
65 #define LOG_EVENT_POOL_POP(p_pool, unit)
66 
67 #endif /* ABT_CONFIG_USE_DEBUG_LOG */
68 
69 #endif /* ABTI_LOG_H_INCLUDED */
struct ABT_unit_opaque * ABT_unit
Definition: abt.h:275