2323#include " Common.h"
2424#include " Cycles.h"
2525#include " Packer.h"
26+ #include " Portability.h"
2627#include " TestUtil.h"
2728#include " Util.h"
2829
@@ -221,10 +222,12 @@ namespace Log {
221222 * in the first two bits and this structure is used to extract those bits
222223 * when the type/identify is unknown.
223224 */
225+ NANOLOG_PACK_PUSH
224226 struct UnknownHeader {
225227 uint8_t entryType:2 ;
226228 uint8_t other:6 ;
227- } __attribute((packed));
229+ } NANOLOG_PACK_ATTR;
230+ NANOLOG_PACK_POP
228231
229232 static_assert (sizeof (UnknownHeader) == 1 , " Unknown Header should have a"
230233 " byte size of 1 to ensure that we can always determine the entry"
@@ -239,6 +242,7 @@ namespace Log {
239242 * (1-8 bytes) pack()-ed rdtsc() timestamp
240243 * (0-n bytes) arguments (determined by preprocessor)
241244 */
245+ NANOLOG_PACK_PUSH
242246 struct CompressedEntry {
243247 // Byte representation of an EntryType::LOG_MSGS_OR_DIC to identify this
244248 // as a CompressedRecordEntry.
@@ -252,7 +256,8 @@ namespace Log {
252256
253257 // Value returned by pack(timestamp)
254258 uint8_t additionalTimestampBytes:4 ;
255- } __attribute__((packed));
259+ } NANOLOG_PACK_ATTR;
260+ NANOLOG_PACK_POP
256261
257262 /* *
258263 * Marker in the compressed log that indicates to which StagingBuffer/thread
@@ -261,6 +266,7 @@ namespace Log {
261266 * thread finishes processing a peek() and moves on to outputting the next
262267 * StagingBuffer.
263268 */
269+ NANOLOG_PACK_PUSH
264270 struct BufferExtent {
265271 // Byte representation of EntryType::BUFFER_EXTENT
266272 uint8_t entryType:2 ;
@@ -289,7 +295,8 @@ namespace Log {
289295 static constexpr uint32_t maxSizeOfHeader () {
290296 return sizeof (BufferExtent) + sizeof (uint32_t );
291297 }
292- } __attribute__((packed));
298+ } NANOLOG_PACK_ATTR;
299+ NANOLOG_PACK_POP
293300
294301 /* *
295302 * Synchronization data structure in the compressed log that correlates the
@@ -298,6 +305,7 @@ namespace Log {
298305 * once at the beginning of a new log. If multiple exist in the log file,
299306 * that means the file has been appended to.
300307 */
308+ NANOLOG_PACK_PUSH
301309 struct Checkpoint {
302310 // Byte representation of an EntryType::CHECKPOINT
303311 uint64_t entryType:2 ;
@@ -322,14 +330,16 @@ namespace Log {
322330 // in the log file.
323331 uint32_t totalMetadataEntries;
324332
325- } __attribute__((packed));
333+ } NANOLOG_PACK_ATTR;
334+ NANOLOG_PACK_POP
326335
327336 /* *
328337 * A DictionaryFragment contains a partial mapping of unique identifiers to
329338 * static log information on disk. Following this structure is one or more
330339 * CompressedLogInfo. The order in which these log infos appear determine
331340 * its unique identifier (i.e. by order of appearance starting at 0).
332341 */
342+ NANOLOG_PACK_PUSH
333343 struct DictionaryFragment {
334344 // Byte representation of an EntryType::LOG_MSG_OR_DIC to indicate
335345 // the start of a dictionary fragment.
@@ -341,12 +351,14 @@ namespace Log {
341351 // Total number of FormatMetadata encountered so far in the log
342352 // including this fragment (used as a sanity check only).
343353 uint32_t totalMetadataEntries;
344- } __attribute__((packed));
354+ } NANOLOG_PACK_ATTR;
355+ NANOLOG_PACK_POP
345356
346357 /* *
347358 * Stores the static log information associated with a log message on disk.
348359 * Following this structure are the filename and format string.
349360 */
361+ NANOLOG_PACK_PUSH
350362 struct CompressedLogInfo {
351363 // LogLevel severity of the original log invocation
352364 uint8_t severity;
@@ -361,14 +373,16 @@ namespace Log {
361373 // Length of the format string that is associated with this log
362374 // invocation and comes after filename.
363375 uint16_t formatStringLength;
364- } __attribute((packed));
376+ } NANOLOG_PACK_ATTR;
377+ NANOLOG_PACK_POP
365378
366379 /* *
367380 * Describes a unique log message within the user sources. The order in
368381 * which this structure appears in the log file determines the associated
369382 * logId. Following this structure are the source filename and
370383 * PrintFragments required for this message.
371384 */
385+ NANOLOG_PACK_PUSH
372386 struct FormatMetadata {
373387 // Number of nibbles in the dynamic data stream used to pack() arguments
374388 uint8_t numNibbles;
@@ -387,12 +401,14 @@ namespace Log {
387401
388402 // Filename for the original source file containing the LOG statement
389403 char filename[];
390- } __attribute__((packed));
404+ } NANOLOG_PACK_ATTR;
405+ NANOLOG_PACK_POP
391406
392407 /* *
393408 * Describes how to interpret the dynamic log stream and partially
394409 * reconstruct the original log message.
395410 */
411+ NANOLOG_PACK_PUSH
396412 struct PrintFragment {
397413 // The type of the argument to pull from the dynamic buffer to the
398414 // partial format string (formatFragment)
@@ -410,7 +426,8 @@ namespace Log {
410426 // A fragment of the original LOG statement that contains at most
411427 // one format specifier.
412428 char formatFragment[];
413- } __attribute__((packed));
429+ } NANOLOG_PACK_ATTR;
430+ NANOLOG_PACK_POP
414431
415432
416433 /* *
0 commit comments