diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-02-21 17:14:49 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-02-21 17:14:49 +0200 |
commit | 7c8e17b9312e15f3352e3a4a65962c09fcf29c21 (patch) | |
tree | d92cc1e13ce05edc1c78e60b4733c25492c692f3 /storage/innobase/include | |
parent | 7f6d88944c8afdcba12677840db8bc4e81cbe0db (diff) | |
download | mariadb-git-7c8e17b9312e15f3352e3a4a65962c09fcf29c21.tar.gz |
MDEV-18677 clang-cl 7 fails to compile innodb
ib_counter_element_t: Declare as struct, not union.
Based on patch by Vladislav Vaintroub
Diffstat (limited to 'storage/innobase/include')
-rw-r--r-- | storage/innobase/include/ut0counter.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/storage/innobase/include/ut0counter.h b/storage/innobase/include/ut0counter.h index 1fc2c297e8d..3c02bacdc2d 100644 --- a/storage/innobase/include/ut0counter.h +++ b/storage/innobase/include/ut0counter.h @@ -1,7 +1,7 @@ /***************************************************************************** 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 the terms of the GNU General Public License as published by the Free Software @@ -105,10 +105,16 @@ struct ib_counter_t { } private: - /** Atomic which occupies whole CPU cache line */ - union ib_counter_element_t { - std::atomic<Type> value; - byte padding[CACHE_LINE_SIZE]; + /** Atomic which occupies whole CPU cache line. + Note: We rely on the default constructor of std::atomic and + do not explicitly initialize the contents. This works for us, + 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, ""); |