diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:20:33 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:28:57 +0000 |
commit | d17ea114e5ef69ad5d5d7413280a13e6428098aa (patch) | |
tree | 2c01a75df69f30d27b1432467cfe7c1467a498da /chromium/third_party/blink/renderer/platform/wtf/static_constructors.h | |
parent | 8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (diff) | |
download | qtwebengine-chromium-d17ea114e5ef69ad5d5d7413280a13e6428098aa.tar.gz |
BASELINE: Update Chromium to 67.0.3396.47
Change-Id: Idcb1341782e417561a2473eeecc82642dafda5b7
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/wtf/static_constructors.h')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/wtf/static_constructors.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/platform/wtf/static_constructors.h b/chromium/third_party/blink/renderer/platform/wtf/static_constructors.h new file mode 100644 index 00000000000..38d15e5178a --- /dev/null +++ b/chromium/third_party/blink/renderer/platform/wtf/static_constructors.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_STATIC_CONSTRUCTORS_H_ +#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_STATIC_CONSTRUCTORS_H_ + +// We need to avoid having static constructors. This is accomplished by defining +// a static array of the appropriate size and alignment, and defining a const +// reference that points to the buffer. During initialization, the object will +// be constructed with placement new into the buffer. This works with MSVC, GCC, +// and Clang without producing dynamic initialization code even at -O0. The only +// downside is that all external translation units will have to emit one more +// load, while a real global could be referenced directly by absolute or +// relative addressing. + +// Use an array of pointers instead of an array of char in case there is some +// alignment issue. +#define DEFINE_GLOBAL(type, name) \ + void* name##Storage[(sizeof(type) + sizeof(void*) - 1) / sizeof(void*)]; \ + const type& name = *reinterpret_cast<type*>(&name##Storage) + +#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_STATIC_CONSTRUCTORS_H_ |