MeVisLab Toolbox Reference
macSignpost.h
Go to the documentation of this file.
1
/*************************************************************************************
2
**
3
** Copyright 2018, MeVis Medical Solutions AG
4
**
5
** The user may use this file in accordance with the license agreement provided with
6
** the Software or, alternatively, in accordance with the terms contained in a
7
** written agreement between the user and MeVis Medical Solutions AG.
8
**
9
** For further information use the contact form at https://www.mevislab.de/contact
10
**
11
**************************************************************************************/
12
13
#ifndef MAC_SIGNPOST_H
14
#define MAC_SIGNPOST_H
15
17
18
#if defined(__APPLE__)
19
20
#include "
macVersionMacros.h
"
21
22
//
23
// /* Create once, e.g. in Constructor */
24
// os_log_t splog = macosSignpostLog_CREATE(::getenv("MYENVVAR_SIGNPOSTS_ENABLED")!=NULL, "com.mycompany.myproduct", "CategoryA");
25
//
26
// /* Measure critical section */
27
// macosSignpostInterval_BEGIN(splog, "MyFunc", "AlgoA %{public}s", myDynamicString);
28
// ...
29
// macosSignpostInterval_END(splog, "MyFunc", "AlgoA %{public}s", myDynamicString);
30
//
31
// /* Use Apple Instruments with Instrument 'os_signpost' for inspection */
32
//
33
34
// Signpost is available with macOS 10.14 and requires the unified logging system introduced with macOS 10.12
35
#if __has_include(<os/signpost.h>)
36
37
#define macosSignpostAPIIsDeclared 1
38
#include <os/signpost.h>
39
40
#define macosSignpostLog_CREATE(enable, subsystem, category) \
41
[]{ \
42
if (__builtin_available(macOS 10.14, *)) { \
43
return (enable) ? os_log_create(subsystem, category) : OS_LOG_DISABLED; \
44
} else { \
45
return OS_LOG_DISABLED; \
46
} \
47
}()
48
49
#define macosSignpostInterval_BEGIN(log, name, ...) \
50
os_signpost_id_t _local_interval_id; \
51
if (__builtin_available(macOS 10.14, *)) { \
52
_local_interval_id = os_signpost_id_generate(log); \
53
os_signpost_interval_begin(log, _local_interval_id, name, ##__VA_ARGS__); \
54
}
55
56
#define macosSignpostInterval_END(log, name, ...) \
57
if (__builtin_available(macOS 10.14, *)) { \
58
os_signpost_interval_end(log, _local_interval_id, name, ##__VA_ARGS__); \
59
}
60
61
#define macosSignpostAssociatedEvent_EMIT(log, name, ...) \
62
if (__builtin_available(macOS 10.14, *)) { \
63
os_signpost_event_emit(log, _local_interval_id, name, ##__VA_ARGS__); \
64
}
65
66
#define macosSignpostExclusiveEvent_EMIT(log, name, ...) \
67
if (__builtin_available(macOS 10.14, *)) { \
68
os_signpost_event_emit(log, OS_SIGNPOST_ID_EXCLUSIVE, name, ##__VA_ARGS__); \
69
}
70
71
#else
72
73
#include <stdint.h>
74
75
// Declare some types for use in structs and classes
76
typedef
void
*
os_log_t
;
77
typedef
uint64_t
os_signpost_id_t
;
78
79
#define OS_LOG_DISABLED ((os_log_t)NULL)
80
81
#define macosSignpostLog_CREATE(env_var, subsystem, category) OS_LOG_DISABLED
82
#define macosSignpostInterval_BEGIN(log, name, ...) {}
83
#define macosSignpostInterval_END(log, name, ...) {}
84
#define macosSignpostAssociatedEvent_EMIT(log, name, ...) {}
85
#define macosSignpostExclusiveEvent_EMIT(log, name, ...) {}
86
87
#endif
88
89
#endif
// __APPLE__
90
#endif
// __macSignpost_H
os_log_t
void * os_log_t
OS Signpost related functions.
Definition:
macSignpost.h:76
os_signpost_id_t
uint64_t os_signpost_id_t
Definition:
macSignpost.h:77
macVersionMacros.h
MeVis
Foundation
Sources
OSXSupport
macSignpost.h
Generated by
1.9.1