From 1dde83f0ec313166fc91e6784a0ca2e3db46acee Mon Sep 17 00:00:00 2001
From: Jonathan Wakely
Date: Mon, 15 Jan 2024 14:09:21 +0000
Subject: [PATCH] libstdc++: Enable most of for freestanding
This makes durations, time points and calendrical types available for
freestanding. The clocks and time zone utilities are disabled for
freestanding, as they require functions in the hosted lib.
Add support for a new macro _GLIBCXX_NO_FREESTANDING_CHRONO which can be
used to explicitly disable for freestanding.
libstdc++-v3/ChangeLog:
* doc/xml/manual/using.xml (_GLIBCXX_NO_FREESTANDING_CHRONO):
Document macro.
* doc/html/*: Regenerate.
* include/bits/chrono.h [_GLIBCXX_NO_FREESTANDING_CHRONO]:
Only include when this macro is defined.
[_GLIBCXX_HOSTED]: Only define clocks for hosted.
* include/bits/version.def (chrono_udls): Remove hosted=yes.
* include/bits/version.h: Regenerate.
* include/std/chrono [_GLIBCXX_HOSTED]: Only define clocks and
time zone utilities for hosted.
* testsuite/std/time/freestanding.cc: New test.
---
.../doc/html/manual/using_macros.html | 7 +++
libstdc++-v3/doc/xml/manual/using.xml | 12 +++++
libstdc++-v3/include/bits/chrono.h | 24 ++++++---
libstdc++-v3/include/bits/version.def | 1 -
libstdc++-v3/include/bits/version.h | 2 +-
libstdc++-v3/include/std/chrono | 24 +++++++--
.../testsuite/std/time/freestanding.cc | 52 +++++++++++++++++++
7 files changed, 109 insertions(+), 13 deletions(-)
create mode 100644 libstdc++-v3/testsuite/std/time/freestanding.cc
diff --git a/libstdc++-v3/doc/html/manual/using_macros.html b/libstdc++-v3/doc/html/manual/using_macros.html
index ae5646926307..67623b5e2aff 100644
--- a/libstdc++-v3/doc/html/manual/using_macros.html
+++ b/libstdc++-v3/doc/html/manual/using_macros.html
@@ -124,4 +124,11 @@
must be present on all vector operations or none, so this macro must
be defined to the same value for all translation units that create,
destroy, or modify vectors.
+
_GLIBCXX_NO_FREESTANDING_CHRONO
+ Undefined by default. When defined, the
+ <chrono>
header cannot
+ be used with -ffreestanding
.
+ When not defined, durations, time points, and calendar types are
+ available for freestanding, but the standard clocks and the time zone
+ database are not (because they require OS support).