/*********************************************************
- * Copyright (C) 1998-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
/* Basic atomic types: 8, 16, 32, 64 and 128 bits */
-typedef struct Atomic_uint8 {
+typedef ALIGNED(1) struct Atomic_uint8 {
volatile uint8 value;
-} Atomic_uint8 ALIGNED(1);
+} Atomic_uint8;
-typedef struct Atomic_uint16 {
+typedef ALIGNED(2) struct Atomic_uint16 {
volatile uint16 value;
-} Atomic_uint16 ALIGNED(2);
+} Atomic_uint16;
-typedef struct Atomic_uint32 {
+typedef ALIGNED(4) struct Atomic_uint32 {
volatile uint32 value;
-} Atomic_uint32 ALIGNED(4);
+} Atomic_uint32;
-typedef struct Atomic_uint64 {
+typedef ALIGNED(8) struct Atomic_uint64 {
volatile uint64 value;
-} Atomic_uint64 ALIGNED(8);
+} Atomic_uint64;
#if defined __GNUC__ && defined VM_64BIT && \
(defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 || defined VM_ARM_64)
-typedef struct Atomic_uint128 {
+typedef ALIGNED(16) struct Atomic_uint128 {
volatile uint128 value;
-} Atomic_uint128 ALIGNED(16);
+} Atomic_uint128;
#endif
/*
/*********************************************************
- * Copyright (C) 1998-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#endif
#ifndef UNUSED_TYPE
-// XXX _Pragma would better but doesn't always work right now.
# define UNUSED_TYPE(_parm) UNUSED_PARAM(_parm)
#endif
#ifndef UNUSED_VARIABLE
-// XXX is there a better way?
# define UNUSED_VARIABLE(_var) (void)_var
#endif
/*
* ALIGNED specifies minimum alignment in "n" bytes.
+ *
+ * NOTE: __declspec(align) has limited syntax; it must essentially be
+ * an integer literal. Expressions, such as sizeof(), do not
+ * work.
*/
#ifdef __GNUC__
#define ALIGNED(n) __attribute__((__aligned__(n)))
+#elif defined(_MSC_VER)
+#define ALIGNED(n) __declspec(align(n))
#else
#define ALIGNED(n)
#endif
-/*
- * Encapsulate the syntactic differences between gcc and msvc alignment control.
- * BOUNDARY must match in the prefix and suffix.
- */
-
-#ifdef _WIN32
-#define ALIGN_PREFIX(BOUNDRY) __declspec(align(BOUNDRY))
-#define ALIGN_SUFFIX(BOUNDRY)
-#else
-#define ALIGN_PREFIX(BOUNDRY)
-#define ALIGN_SUFFIX(BOUNDRY) __attribute__((__aligned__(BOUNDRY)))
-#endif
-
-
/*
* Once upon a time, this was used to silence compiler warnings that
* get generated when the compiler thinks that a function returns