Rename <openssl/time.h> to <openssl/posix_time.h>
There's a desire to upstream this in a compatible way to other
projects so they can use the same public API as us, however for
some C based build systems having an include file potentially
on the include path that can end up being picked up when you
include <time.h> is problematic and annoying, so let's
just avoid the unnecessary pain.
Update-Note: <openssl/time.h> has moved to <openssl/posix_time.h>
Change-Id: I7c6aa92e95a10ff65275851fcf596b06e4848789
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65847
Commit-Queue: Bob Beck <bbe@google.com>
Auto-Submit: Bob Beck <bbe@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/crypto/asn1/a_gentm.c b/crypto/asn1/a_gentm.c
index 64cb1b5..f6f9c46 100644
--- a/crypto/asn1/a_gentm.c
+++ b/crypto/asn1/a_gentm.c
@@ -58,7 +58,7 @@
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/mem.h>
-#include <openssl/time.h>
+#include <openssl/posix_time.h>
#include <stdlib.h>
#include <string.h>
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c
index d8ec85f..d2c672c 100644
--- a/crypto/asn1/a_time.c
+++ b/crypto/asn1/a_time.c
@@ -55,7 +55,7 @@
* [including the GNU Public Licence.] */
#include <openssl/asn1.h>
-#include <openssl/time.h>
+#include <openssl/posix_time.h>
#include <string.h>
#include <time.h>
diff --git a/crypto/asn1/a_utctm.c b/crypto/asn1/a_utctm.c
index 2963bbe..f21435d 100644
--- a/crypto/asn1/a_utctm.c
+++ b/crypto/asn1/a_utctm.c
@@ -58,7 +58,7 @@
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/mem.h>
-#include <openssl/time.h>
+#include <openssl/posix_time.h>
#include <stdlib.h>
#include <string.h>
diff --git a/crypto/asn1/asn1_test.cc b/crypto/asn1/asn1_test.cc
index c2e5f5b..76d6889 100644
--- a/crypto/asn1/asn1_test.cc
+++ b/crypto/asn1/asn1_test.cc
@@ -29,8 +29,8 @@
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/pem.h>
+#include <openssl/posix_time.h>
#include <openssl/span.h>
-#include <openssl/time.h>
#include <openssl/x509.h>
#include "../test/test_util.h"
diff --git a/crypto/asn1/posix_time.c b/crypto/asn1/posix_time.c
index 31d184c..5ac4eeb 100644
--- a/crypto/asn1/posix_time.c
+++ b/crypto/asn1/posix_time.c
@@ -15,7 +15,7 @@
// Time conversion to/from POSIX time_t and struct tm, with no support
// for time zones other than UTC
-#include <openssl/time.h>
+#include <openssl/posix_time.h>
#include <assert.h>
#include <inttypes.h>
diff --git a/include/openssl/posix_time.h b/include/openssl/posix_time.h
new file mode 100644
index 0000000..7910e34
--- /dev/null
+++ b/include/openssl/posix_time.h
@@ -0,0 +1,45 @@
+/* Copyright (c) 2022, Google Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+#ifndef OPENSSL_HEADER_POSIX_TIME_H
+#define OPENSSL_HEADER_POSIX_TIME_H
+
+#include <openssl/base.h>
+
+#include <time.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+// Time functions.
+
+
+// OPENSSL_posix_to_tm converts a int64_t POSIX time value in |time|, which must
+// be in the range of year 0000 to 9999, to a broken out time value in |tm|. It
+// returns one on success and zero on error.
+OPENSSL_EXPORT int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm);
+
+// OPENSSL_tm_to_posix converts a time value between the years 0 and 9999 in
+// |tm| to a POSIX time value in |out|. One is returned on success, zero is
+// returned on failure. It is a failure if |tm| contains out of range values.
+OPENSSL_EXPORT int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out);
+
+
+#if defined(__cplusplus)
+} // extern C
+#endif
+
+#endif // OPENSSL_HEADER_POSIX_TIME_H
diff --git a/include/openssl/time.h b/include/openssl/time.h
index 50db22d..6909594 100644
--- a/include/openssl/time.h
+++ b/include/openssl/time.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2022, Google Inc.
+/* Copyright (c) 2024, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -15,31 +15,8 @@
#ifndef OPENSSL_HEADER_TIME_H
#define OPENSSL_HEADER_TIME_H
-#include <openssl/base.h>
+// Compatibility header, to be deprecated. use <openssl/posix_time.h> instead.
-#include <time.h>
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-
-// Time functions.
-
-
-// OPENSSL_posix_to_tm converts a int64_t POSIX time value in |time|, which must
-// be in the range of year 0000 to 9999, to a broken out time value in |tm|. It
-// returns one on success and zero on error.
-OPENSSL_EXPORT int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm);
-
-// OPENSSL_tm_to_posix converts a time value between the years 0 and 9999 in
-// |tm| to a POSIX time value in |out|. One is returned on success, zero is
-// returned on failure. It is a failure if |tm| contains out of range values.
-OPENSSL_EXPORT int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out);
-
-
-#if defined(__cplusplus)
-} // extern C
-#endif
+#include <openssl/posix_time.h>
#endif // OPENSSL_HEADER_TIME_H
diff --git a/pki/encode_values.cc b/pki/encode_values.cc
index 25dc677..0054fa2 100644
--- a/pki/encode_values.cc
+++ b/pki/encode_values.cc
@@ -6,7 +6,7 @@
#include "parse_values.h"
-#include <openssl/time.h>
+#include <openssl/posix_time.h>
namespace bssl::der {
diff --git a/util/doc.config b/util/doc.config
index 29bba67..d2bc500 100644
--- a/util/doc.config
+++ b/util/doc.config
@@ -14,9 +14,9 @@
"include/openssl/mem.h",
"include/openssl/obj.h",
"include/openssl/pool.h",
+ "include/openssl/posix_time.h",
"include/openssl/rand.h",
- "include/openssl/stack.h",
- "include/openssl/time.h"
+ "include/openssl/stack.h"
]
},{
"Name": "Low-level crypto primitives",