[tz] FreeBSD and USG_COMPAT

Andras Farkas deepbluemistake at gmail.com
Sat Nov 23 09:18:09 UTC 2019


With the attached diff (don't commit this, it's a lot simpler than a
final commit would be, which would include some ifdef'ing with
USG_COMPAT or another macro) I can get things to compile and get
programs to successfully run which use daylight and timezone, when
CFLAGS is set to '-DUSG_COMPAT=1 -DHAVE_POSIX_DECLS=0'
However, even with this diff, if CFLAGS is set only to -DUSG_COMPAT=1
I get the output as in newusgcompat.txt.

On Sat, Nov 23, 2019 at 3:50 AM Andras Farkas <deepbluemistake at gmail.com> wrote:
>
> FreeBSD doesn't support the int daylight or long timezone in time.h
> itself.  tzcode supports them on OSes which already support them, like
> OpenBSD.
> I'm trying to figure out if it should be possible to compile tzcode to
> support daylight and timezone even on OSes which don't support them.
>
> I've saved the output of make (both stdout and stderr) when CFLAGS is
> set to -DUSG_COMPAT=1 alone into usgcompat.txt
> I've saved the output of make (both stdout and stderr) when CFLAGS is
> set to '-DUSG_COMPAT=1 -DHAVE_POSIX_DECLS=0' into both.txt
>
> What I'm seeing is that the OS's time.h is being included, under both
> configurations.
>
> This topic originated in this thread:
> http://mm.icann.org/pipermail/tz/2019-November/028596.html
> http://mm.icann.org/pipermail/tz/2019-November/thread.html
-------------- next part --------------
--- tzdb-2019cold/private.h	2018-07-16 13:16:52.000000000 -0400
+++ tzdb-2019cnew/private.h	2019-11-23 04:00:17.903330000 -0500
@@ -133,6 +133,7 @@
 */
 
 /* Avoid clashes with NetBSD by renaming NetBSD's declarations.  */
+/* Also avoid clash with timezone(3) function on FreeBSD */
 #define localtime_rz sys_localtime_rz
 #define mktime_z sys_mktime_z
 #define posix2time_z sys_posix2time_z
@@ -140,6 +141,7 @@
 #define timezone_t sys_timezone_t
 #define tzalloc sys_tzalloc
 #define tzfree sys_tzfree
+#define timezone sys_timezone
 #include <time.h>
 #undef localtime_rz
 #undef mktime_z
@@ -148,6 +150,7 @@
 #undef timezone_t
 #undef tzalloc
 #undef tzfree
+#undef timezone
 
 #include <sys/types.h>	/* for time_t */
 #include <string.h>
-------------- next part --------------
cc -DTZDIR='"/usr/share/zoneinfo"'  -DUSG_COMPAT=1 -c localtime.c -o localtime.o
localtime.c:277:5: error: use of undeclared identifier 'timezone'
    timezone = - ttisp->tt_utoff;
    ^
localtime.c:295:2: error: use of undeclared identifier 'daylight'
        daylight = 0;
        ^
localtime.c:296:2: error: use of undeclared identifier 'timezone'
        timezone = 0;
        ^
localtime.c:318:4: error: use of undeclared identifier 'daylight'
                        daylight = 1;
                        ^
4 errors generated.
*** Error code 1

Stop.
make: stopped in /usr/home/dogg/min/mod/tzdb-2019c


More information about the tz mailing list