]> git.saurik.com Git - apple/xnu.git/blobdiff - libkern/firehose/tracepoint_private.h
xnu-6153.141.1.tar.gz
[apple/xnu.git] / libkern / firehose / tracepoint_private.h
index e0ccc4f7ec7a7ff449e1e029f9f7d8e9c615161d..f5ad06986e7b0211327deab077e5d19d56d01d8e 100644 (file)
@@ -45,6 +45,7 @@ typedef union {
                uint32_t _code;
        } ftid;
        firehose_tracepoint_id_t ftid_value;
+       _Atomic(firehose_tracepoint_id_t) ftid_atomic_value;
 } firehose_tracepoint_id_u;
 
 #define FIREHOSE_STAMP_SLOP (1ULL << 36) // ~1minute
@@ -75,16 +76,17 @@ typedef struct firehose_tracepoint_s {
                        uint64_t ft_length : 16;
                };
                uint64_t ft_stamp_and_length;
+               _Atomic(uint64_t) ft_atomic_stamp_and_length;
        };
        uint8_t ft_data[];
 } *firehose_tracepoint_t;
 
 #define FIREHOSE_TRACE_ID_MAKE(ns, type, flags, code) \
        (((firehose_tracepoint_id_u){ .ftid = { \
-               ._namespace = ns, \
-               ._type = type, \
-               ._flags = flags, \
-               ._code = code, \
+               ._namespace = ns, \
+               ._type = type, \
+               ._flags = flags, \
+               ._code = code, \
        } }).ftid_value)
 
 #define FIREHOSE_TRACE_ID_SET_NS(tid, ns) \
@@ -93,6 +95,15 @@ typedef struct firehose_tracepoint_s {
 #define FIREHOSE_TRACE_ID_SET_TYPE(tid, ns, type) \
        ((tid).ftid._type = _firehose_tracepoint_type_##ns##_##type)
 
+#define FIREHOSE_TRACE_ID_PC_STYLE(tid) \
+               ((tid).ftid._flags & _firehose_tracepoint_flags_pc_style_mask)
+
+#define FIREHOSE_TRACE_ID_SET_PC_STYLE(tid, flag) ({ \
+               firehose_tracepoint_id_u _tmp_tid = (tid); \
+               _tmp_tid.ftid._flags &= ~_firehose_tracepoint_flags_pc_style_mask; \
+               _tmp_tid.ftid._flags |= _firehose_tracepoint_flags_pc_style_##flag; \
+})
+
 #define FIREHOSE_TRACE_ID_HAS_FLAG(tid, ns, flag) \
        ((tid).ftid._flags & _firehose_tracepoint_flags_##ns##_##flag)
 #define FIREHOSE_TRACE_ID_SET_FLAG(tid, ns, flag) \
@@ -103,6 +114,21 @@ typedef struct firehose_tracepoint_s {
 #define FIREHOSE_TRACE_ID_SET_CODE(tid, code) \
        ((tid).ftid._code = code)
 
+/*!
+ * @typedef firehose_loss_payload_s
+ *
+ * @abstract
+ * The payload for tracepoints in the loss namespace, generated by the firehose
+ * itself when unreliable tracepoints are lost.
+ */
+typedef struct firehose_loss_payload_s {
+       uint64_t start_stamp; /* may (rarely!) disagree with the tracepoint stamp */
+       uint64_t end_stamp;
+#define FIREHOSE_LOSS_COUNT_WIDTH 6 /* as many bits as can be spared */
+#define FIREHOSE_LOSS_COUNT_MAX ((1u << FIREHOSE_LOSS_COUNT_WIDTH) - 1)
+       uint32_t count;
+} firehose_loss_payload_s, *firehose_loss_payload_t;
+
 __BEGIN_DECLS
 
 #if __has_feature(address_sanitizer)
@@ -131,7 +157,7 @@ static inline uint64_t
 firehose_tracepoint_time(firehose_activity_flags_t flags)
 {
        if (firehose_precise_timestamps_enabled() ||
-                       (flags & firehose_activity_flags_precise_timestamp)) {
+           (flags & firehose_activity_flags_precise_timestamp)) {
                return mach_continuous_time();
        } else {
                return mach_continuous_approximate_time();
@@ -143,10 +169,10 @@ __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
 __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
 void
 firehose_trace_metadata(firehose_stream_t stream, firehose_tracepoint_id_u ftid,
-                       uint64_t stamp, const void* pubdata, size_t publen);
+    uint64_t stamp, const void* pubdata, size_t publen);
 #endif
 __END_DECLS
 
-OS_ASSUME_NONNULL_END
+    OS_ASSUME_NONNULL_END
 
 #endif // __FIREHOSE_FIREHOSE__