Export of internal Abseil changes

--
6eac0cc7bca997ee95afd4ec485077ae8fd99333 by Abseil Team <absl-team@google.com>:

Add comment not to use `ABSL_ATTRIBUTE_PACKED` with `std::atomic`.

PiperOrigin-RevId: 395231460
GitOrigin-RevId: 6eac0cc7bca997ee95afd4ec485077ae8fd99333
Change-Id: Ib4e83bed0f313724b309b6278e9e24a6e5fe9b2c
pull/1013/head
Abseil Team 4 years ago committed by dinord
parent 6039dd95bb
commit 8c800bb08d
  1. 20
      absl/base/attributes.h

@ -548,13 +548,19 @@
// ABSL_ATTRIBUTE_PACKED
//
// Instructs the compiler not to use natural alignment for a tagged data
// structure, but instead to reduce its alignment to 1. This attribute can
// either be applied to members of a structure or to a structure in its
// entirety. Applying this attribute (judiciously) to a structure in its
// entirety to optimize the memory footprint of very commonly-used structs is
// fine. Do not apply this attribute to a structure in its entirety if the
// purpose is to control the offsets of the members in the structure. Instead,
// apply this attribute only to structure members that need it.
// structure, but instead to reduce its alignment to 1.
//
// Therefore, DO NOT APPLY THIS ATTRIBUTE TO STRUCTS CONTAINING ATOMICS. Doing
// so can cause atomic variables to be mis-aligned and silently violate
// atomicity on x86.
//
// This attribute can either be applied to members of a structure or to a
// structure in its entirety. Applying this attribute (judiciously) to a
// structure in its entirety to optimize the memory footprint of very
// commonly-used structs is fine. Do not apply this attribute to a structure in
// its entirety if the purpose is to control the offsets of the members in the
// structure. Instead, apply this attribute only to structure members that need
// it.
//
// When applying ABSL_ATTRIBUTE_PACKED only to specific structure members the
// natural alignment of structure members not annotated is preserved. Aligned

Loading…
Cancel
Save