C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
_pack.h
Go to the documentation of this file.
1/*
2 © 2023 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14#ifndef CPP_API_EXTENSIONS_SRC_SME_AQPP_ABSTRACTION_COMPILER__PACK_H
15#define CPP_API_EXTENSIONS_SRC_SME_AQPP_ABSTRACTION_COMPILER__PACK_H
16
18
19// Packing is a slightly complex topic, it actually depends greatly on the compiler and harware target
20// Many reading material links are supplied as references
21// The macros provided are to be utilized for single byte packing only
22// Alignment should be addressed with updated standard for C++ using "alignas" and "alignof"
23
24//https://developer.arm.com/documentation/100748/0616/Writing-Optimized-Code/Packing-data-structures
25
26#if defined( SUPPORT_GCC_ATTRIBUTES)
27// https://gcc.gnu.org/onlinedocs/gcc-3.3/gcc/Type-Attributes.html
28// https://web.mit.edu/rhel-doc/3/rhel-gcc-en-3/variable-attributes.html
29// https://debrouxl.github.io/gcc4ti/gnuexts.html
30 #define _prepack
31 #define _endpack __attribute__((packed))
32
33#elif defined( SUPPORT_MS_ATTRIBUTES)
34// https://docs.microsoft.com/en-us/cpp/preprocessor/pack?view=msvc-170
35// https://docs.microsoft.com/en-us/cpp/build_target/x64-software-conventions?view=msvc-170#examples-of-structure-alignment
36 #define _prepack __pragma( pack( push, 1) )
37 #define _endpack __pragma( pack( pop) )
38
39#else // default for unkown compiler
40 #define _prepack
41 #define _endpack
42
43#endif
44
45#define _pack( __DECL__ ) _prepack __DECL__ _endpack
46
47//https://stackoverflow.com/questions/17091382/memory-alignment-how-to-use-alignof-alignas
48//https://developer.ibm.com/articles/pa-dalign//
49
50#endif /* ABSTRACTION_COMPILER__PACK_H_ */