scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 0205f444557f1a68a2875ad21d5a3efb04029246
parent 4cadec134543704e0a022dfcfd5ce2668145573f
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Tue, 14 Apr 2026 01:02:53 +0200

libc/time: Don't expose tzones

Tzones was using a namespace reserved for the user,
and since it is used only in localtime() it is just
better to include the .c directly there.

Diffstat:
Msrc/libc/libc.h | 8--------
Msrc/libc/time/Makefile | 3++-
Msrc/libc/time/gentz.awk | 2+-
Msrc/libc/time/localtime.c | 8++++++++
4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/libc/libc.h b/src/libc/libc.h @@ -22,16 +22,9 @@ enum { struct tm; struct _FILE; -struct tzone { - char *name; - int gmtoff; - int isdst; -}; - void *_getheap(void); int _dtoi(char c); - #ifdef stdin int _allocbuf(FILE *); int _flsbuf(FILE *); @@ -53,7 +46,6 @@ int _newyear(int); extern int _tzjulian; extern int _daysmon[12]; extern char *_tzname[2]; -extern struct tzone tzones[]; extern unsigned _exitn; extern void (*_flushall)(void); diff --git a/src/libc/time/Makefile b/src/libc/time/Makefile @@ -13,13 +13,14 @@ OBJS =\ localtime.$O\ mktime.$O\ strftime.$O\ - tz.$O\ all: $(OBJS) tz.c: timezone.lst awk -f gentz.awk timezone.lst > $@ +localtime.$O: tz.c + tz.$O: tz.c $(CC) $(PROJ_CFLAGS) -c -o $@ tz.c diff --git a/src/libc/time/gentz.awk b/src/libc/time/gentz.awk @@ -1,4 +1,4 @@ -BEGIN { print "#include \"../libc.h\"\nstruct tzone tzones[] = {" } +BEGIN { print "struct tzone tzones[] = {" } { split($2,a,":") min = a[1] * 60 diff --git a/src/libc/time/localtime.c b/src/libc/time/localtime.c @@ -4,6 +4,14 @@ #include "../libc.h" #undef localtime +struct tzone { + char *name; + int gmtoff; + int isdst; +}; + +#include "tz.c" + static time_t gmtoff(char *tz) {