summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve MacLean <Steve.MacLean@Microsoft.com>2020-05-21 17:49:53 -0400
committerSteve MacLean <Steve.MacLean@Microsoft.com>2020-05-21 18:02:15 -0400
commitda8dc856ab5646e04160060aae9425db3f5428ce (patch)
treed7e15df27d0b9007e8db57d99c189a62fe398ee8
parentd627f4aea024f7d1bfaa7ce7293379316c7713ea (diff)
downloadlibunwind-da8dc856ab5646e04160060aae9425db3f5428ce.tar.gz
Use C11 alignas(x)
-rw-r--r--include/compiler.h2
-rw-r--r--include/libunwind-aarch64.h14
-rw-r--r--include/unwind.h5
-rw-r--r--src/mi/mempool.c3
4 files changed, 7 insertions, 17 deletions
diff --git a/include/compiler.h b/include/compiler.h
index 726936c0..60e0ee0d 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -31,7 +31,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#define COMPILER_H
#ifdef __GNUC__
-# define ALIGNED(x) __attribute__((aligned(x)))
# define CONST_ATTR __attribute__((__const__))
# define UNUSED __attribute__((unused))
# define NOINLINE __attribute__((noinline))
@@ -54,7 +53,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# define unlikely(x) (x)
# endif
#else
-# define ALIGNED(x)
# define ALWAYS_INLINE
# define CONST_ATTR
# define UNUSED
diff --git a/include/libunwind-aarch64.h b/include/libunwind-aarch64.h
index 2a8b4227..797b13c0 100644
--- a/include/libunwind-aarch64.h
+++ b/include/libunwind-aarch64.h
@@ -34,6 +34,7 @@ extern "C" {
#include <inttypes.h>
#include <stddef.h>
#include <ucontext.h>
+#include <stdalign.h>
#ifndef UNW_EMPTY_STRUCT
# define UNW_EMPTY_STRUCT
@@ -182,13 +183,6 @@ unw_tdep_save_loc_t;
* however, the __reserved struct is quite large: tune it down to only
* the necessary used fields. */
-#ifdef _MSC_VER
-// __attribute__((__aligned__(16))) is a GNUC attribute not recognized by MSVC
-// Since the field alignment doesn't matter for UNW_REMOTE_ONLY,
-// Temproarily define __attribute__(x) to remove it
-#define __attribute__(x)
-#endif
-
struct unw_sigcontext
{
uint64_t fault_address;
@@ -196,13 +190,9 @@ struct unw_sigcontext
uint64_t sp;
uint64_t pc;
uint64_t pstate;
- uint8_t __reserved[(66 * 8)] __attribute__((__aligned__(16)));
+ uint8_t alignas(16) __reserved[(66 * 8)];
};
-#ifdef _MSC_VER
-#undef __attribute__
-#endif
-
typedef struct
{
unsigned long uc_flags;
diff --git a/include/unwind.h b/include/unwind.h
index 7cf128de..8eb5ff75 100644
--- a/include/unwind.h
+++ b/include/unwind.h
@@ -28,6 +28,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/* For uint64_t */
#include <stdint.h>
+#include <stdalign.h>
#ifdef __cplusplus
extern "C" {
@@ -76,11 +77,11 @@ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action,
even on 32-bit machines for gcc compatibility. */
struct _Unwind_Exception
{
- uint64_t exception_class;
+ uint64_t alignas(8) exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
unsigned long private_1;
unsigned long private_2;
- } __attribute__((__aligned__));
+ };
extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
diff --git a/src/mi/mempool.c b/src/mi/mempool.c
index 536b64e8..d7f0d83b 100644
--- a/src/mi/mempool.c
+++ b/src/mi/mempool.c
@@ -25,6 +25,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "libunwind_i.h"
+#include <stdalign.h>
/* From GCC docs: ``Gcc also provides a target specific macro
* __BIGGEST_ALIGNMENT__, which is the largest alignment ever used for any data
@@ -39,7 +40,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
# define MAX_ALIGN MAX_ALIGN_(sizeof (long double))
#endif
-static char sos_memory[SOS_MEMORY_SIZE] ALIGNED(MAX_ALIGN);
+static char alignas(MAX_ALIGN) sos_memory[SOS_MEMORY_SIZE];
static size_t sos_memory_freepos;
static size_t pg_size;