>From abb3d642eaa58e3343c6a7e29ed38f63b888d3bd Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 2 Dec 2019 18:25:18 -0800
Subject: [PATCH] Support -DUSG_COMPAT=2 on FreeBSD

* private.h (timezone) [USG_COMPAT == 2]: Define to sys_timezone
when including <time.h>, to avoid declaration clash on FreeBSD.
Problem reported by Andras Farkas in:
https://mm.icann.org/pipermail/tz/2019-November/028644.html
---
 private.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/private.h b/private.h
index 0d6d80f..8513663 100644
--- a/private.h
+++ b/private.h
@@ -132,11 +132,16 @@
 ** Nested includes
 */
 
-/* Avoid clashes with NetBSD by renaming NetBSD's declarations.  */
+/* Avoid clashes with NetBSD by renaming NetBSD's declarations.
+   If defining the 'timezone' variable, avoid a clash with FreeBSD's
+   'timezone' function by renaming its declaration.  */
 #define localtime_rz sys_localtime_rz
 #define mktime_z sys_mktime_z
 #define posix2time_z sys_posix2time_z
 #define time2posix_z sys_time2posix_z
+#if defined USG_COMPAT && USG_COMPAT == 2
+# define timezone sys_timezone
+#endif
 #define timezone_t sys_timezone_t
 #define tzalloc sys_tzalloc
 #define tzfree sys_tzfree
@@ -145,6 +150,9 @@
 #undef mktime_z
 #undef posix2time_z
 #undef time2posix_z
+#if defined USG_COMPAT && USG_COMPAT == 2
+# undef timezone
+#endif
 #undef timezone_t
 #undef tzalloc
 #undef tzfree
-- 
2.23.0

