Commit 7c8e17b9 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-18677 clang-cl 7 fails to compile innodb

ib_counter_element_t: Declare as struct, not union.

Based on patch by Vladislav Vaintroub
parent 7f6d8894
/***************************************************************************** /*****************************************************************************
Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation. Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -105,10 +105,16 @@ struct ib_counter_t { ...@@ -105,10 +105,16 @@ struct ib_counter_t {
} }
private: private:
/** Atomic which occupies whole CPU cache line */ /** Atomic which occupies whole CPU cache line.
union ib_counter_element_t { Note: We rely on the default constructor of std::atomic and
std::atomic<Type> value; do not explicitly initialize the contents. This works for us,
byte padding[CACHE_LINE_SIZE]; because ib_counter_t is only intended for usage with global
memory that is allocated from the .bss and thus guaranteed to
be zero-initialized by the run-time environment.
@see srv_stats
@see rw_lock_stats */
struct ib_counter_element_t {
MY_ALIGNED(CACHE_LINE_SIZE) std::atomic<Type> value;
}; };
static_assert(sizeof(ib_counter_element_t) == CACHE_LINE_SIZE, ""); static_assert(sizeof(ib_counter_element_t) == CACHE_LINE_SIZE, "");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment