// of this type gives them access to the private members of time_zone
// and tzdb, without needing them declared in the <chrono> header.
+ // The tzdb_list singleton. This doesn't contain the actual linked list,
+ // but it has member functions that give access to it.
static tzdb_list _S_the_list;
#if USE_ATOMIC_SHARED_PTR
// Implementation of the private constructor used for the singleton object.
constexpr tzdb_list::tzdb_list(nullptr_t) { }
- // The tzdb_list singleton. This doesn't contain the actual linked list,
- // but it has member functions that give access to it.
- constinit tzdb_list tzdb_list::_Node::_S_the_list(nullptr);
-
- // Shared pointer to the first Node in the list.
- constinit tzdb_list::_Node::head_ptr tzdb_list::_Node::_S_head_owner{nullptr};
-
-#if USE_ATOMIC_LIST_HEAD
- // Lock-free access to the first Node in the list.
- constinit atomic<tzdb_list::_Node*> tzdb_list::_Node::_S_head_cache{nullptr};
-#endif
+#include "tzdb_globals.h"
// The data structures defined in this file (Rule, on_day, at_time etc.)
// are used to represent the information parsed from the tzdata.zi file
--- /dev/null
+// This is only in a header so we can use the system_header pragma,
+// to suppress the warning caused by using a reserved init_priority.
+#pragma GCC system_header
+
+[[gnu::init_priority(98)]]
+constinit tzdb_list tzdb_list::_Node::_S_the_list(nullptr);
+
+[[gnu::init_priority(98)]]
+constinit tzdb_list::_Node::head_ptr tzdb_list::_Node::_S_head_owner{nullptr};
+
+#if USE_ATOMIC_LIST_HEAD
+[[gnu::init_priority(98)]]
+constinit atomic<tzdb_list::_Node*> tzdb_list::_Node::_S_head_cache{nullptr};
+#endif
--- /dev/null
+// { dg-do run { target c++20 } }
+// { dg-require-effective-target tzdb }
+// { dg-require-effective-target cxx11_abi }
+// { dg-require-static-libstdcxx }
+// { dg-additional-options "-static-libstdc++" }
+
+#include <chrono>
+
+struct Global
+{
+ Global()
+ {
+ (void) std::chrono::current_zone(); // initialize tzdb on first use
+ }
+
+ ~Global()
+ {
+ (void) std::chrono::current_zone(); // attempt to use it again on exit
+ }
+
+} global;
+
+int main()
+{
+}