5 // Created by James McIlree on 10/25/12.
6 // Copyright (c) 2014 Apple. All rights reserved.
10 // We have to specialize this, as the K64 min alignment is 4 bytes longer,
11 // to maintain 8 byte alignment for the uint64_t _TOD_secs.
14 template <typename KERNEL_SIZE> class TraceDataHeaderFields {};
17 class TraceDataHeaderFields<Kernel32> {
20 uint32_t thread_count;
21 uint32_t TOD_secs_top_half;
22 uint32_t TOD_secs_bottom_half;
25 // NOTE! The compiler has shown a tendency to place this on non 8 byte
26 // aligned addresses when stack allocating. We need to construct the
27 // uint64_t values by logical-or and shifting, treating as a pointer
30 TraceDataHeaderFields(uint32_t v, uint32_t tc, uint64_t s, uint32_t us) :
35 TOD_secs_top_half = (uint32_t)(s >> 32);
36 TOD_secs_bottom_half = (uint32_t)(s & 0xFFFFFFFF);
40 return ((uint64_t)TOD_secs_top_half << 32) | (uint64_t)TOD_secs_bottom_half;
45 class TraceDataHeaderFields<Kernel64> {
48 uint32_t thread_count;
51 uint32_t _force_alignment; // Need to force 8 byte alignment in 32 bit code
53 TraceDataHeaderFields(uint32_t v, uint32_t tc, uint64_t s, uint32_t us) :
67 template <typename KERNEL_SIZE>
68 class TraceDataHeader {
70 TraceDataHeaderFields<KERNEL_SIZE> _fields;
73 TraceDataHeader() : _fields(0, 0, 0, 0) {}
74 TraceDataHeader(uint32_t v, uint32_t tc, uint64_t s, uint32_t us) : _fields(v, tc, s, us) {}
76 uint32_t version() const { return _fields.version; }
77 uint32_t thread_count() const { return _fields.thread_count; }
78 uint64_t TOD_secs() const { return _fields.TOD_secs(); }
79 uint32_t TOD_usecs() const { return _fields.TOD_usecs; }