Skip to content

Commit

Permalink
Add mktime() to LIBC and bump release to v3.09-9
Browse files Browse the repository at this point in the history
  • Loading branch information
agn453 committed Aug 16, 2021
1 parent b7f0bf2 commit e151cfb
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 50 deletions.
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ emulation using RunZ80, SIMH or ZXCC.
Each release is a consolidated milestone with various updates and
patches applied.

The latest release is V3.09-8 (see Modification History below).
The latest release is V3.09-9 (see Modification History below).

If you only wish to download the latest binary distribution, download
it from
Expand Down Expand Up @@ -1060,6 +1060,44 @@ find this in his repository at

https://github.com/nikitinprior/dlibr


### v3.09-9 update release

I've added a mktime() routine to the C library (LIBC.LIB and LIB280C.LIB)
and consolidated the recent updates as a release v3.09-9.


```
mktime()
time_t mktime(struct tm *)
A routine to convert the broken out time (in the structure pointed
to by the parameter) into a time value representing the number
of seconds since the Unix epoch (since CP/M has no knowledge of the
local timezone - the time is assumed to be respresenting Universal
Coordinated Time or UTC). The value returned is the number of
seconds since midnight 01-Jan-1970.
This can be used (for example) to manipulate a file's time-stamp
or for computing time differences.
External declarations, as well as the tm structure definition, are
contained in the TIME.H include file. The tm structure includes
at least the following fields:
int tm_sec; /* seconds (0 - 60) */
int tm_min; /* minutes (0 - 59) */
int tm_hour; /* hours (0 - 23) */
int tm_mday; /* day of month (1 - 31) */
int tm_mon; /* month of year (0 - 11) */
int tm_year; /* year - 1900 */
int tm_wday; /* day of week (Sunday = 0) */
int tm_yday; /* day of year (0 - 365) */
int tm_isdst; /* is summer time in effect? */
```


--
Tony Nicholson
04-Aug-2021
16-Aug-2021
53 changes: 27 additions & 26 deletions cpm/BUILD-C.LOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,76 @@
10E>;
10E>date
A:DATE COM (User 0)
Mon 18/01/2021 15:53:55
Mon 16/08/2021 12:29:57
10E>;
10E>; Build Z80 version
10E>c -o -v c309-8.c
10E>c -o -v c309-9.c
A:C COM (User 0)
Hi-Tech C Compiler (CP/M-80) V3.09-8
Copyright (C) 1984-87 HI-TECH SOFTWARE
Updated from https://github.com/agn453/HI-TECH-Z80-C
0:A:CPP -DCPM -DHI_TECH_C -Dz80 -I0:A: C309-8.C M:$CTMP1.$$$
0:A:CPP -DCPM -DHI_TECH_C -Dz80 -I0:A: C309-9.C M:$CTMP1.$$$
0:A:P1 M:$CTMP1.$$$ M:$CTMP2.$$$ M:$CTMP3.$$$
0:A:CGEN M:$CTMP2.$$$ M:$CTMP1.$$$
0:A:OPTIM M:$CTMP1.$$$ M:$CTMP2.$$$
0:A:ZAS -J -N -OC309-8.OBJ M:$CTMP2.$$$
0:A:ZAS -J -N -OC309-9.OBJ M:$CTMP2.$$$
ERA M:$CTMP1.$$$
ERA M:$CTMP2.$$$
ERA M:$CTMP3.$$$
ERA M:$CTMP5.$$$
0:A:LINQ -Z -Ptext=0,data,bss -C100H -OC309-8.COM 0:A:CRTCPM.OBJ C309-8.OBJ 0:A:LIBC.LIB
ERA C309-8.OBJ
0:A:LINQ -Z -Ptext=0,data,bss -C100H -OC309-9.COM 0:A:CRTCPM.OBJ C309-9.OBJ 0:A:LIBC.LIB
ERA C309-9.OBJ
ERA M:$$EXEC.$$$

10E>;
10E>; Now build Z280 version
10E>;
10E>; First a Z280 version using the Z80 LIBC.C (runs on Z80)
10E>c309-8 -o -v -ec280z80.com -dZ280 c309-8.c
E:C309-8 COM
Hi-Tech C Compiler (CP/M-80) V3.09-8
10E>c309-9 -o -v -ec280z80.com -dZ280 c309-9.c
E:C309-9 COM
Hi-Tech C Compiler (CP/M-80) V3.09-9
Copyright (C) 1984-87 HI-TECH SOFTWARE
Updated from https://github.com/agn453/HI-TECH-Z80-C
0:A:CPP -DCPM -DHI_TECH_C -Dz80 -DZ280 -I0:A: C309-8.C M:$CTMP1.$$$
0:A:CPP -DCPM -DHI_TECH_C -Dz80 -DZ280 -I0:A: C309-9.C M:$CTMP1.$$$
0:A:P1 M:$CTMP1.$$$ M:$CTMP2.$$$ M:$CTMP3.$$$
0:A:CGEN M:$CTMP2.$$$ M:$CTMP1.$$$
0:A:OPTIM M:$CTMP1.$$$ M:$CTMP2.$$$
0:A:ZAS -J -N -OC309-8.OBJ M:$CTMP2.$$$
0:A:ZAS -J -N -OC309-9.OBJ M:$CTMP2.$$$
ERA M:$CTMP1.$$$
ERA M:$CTMP2.$$$
ERA M:$CTMP3.$$$
ERA M:$CTMP5.$$$
0:A:LINQ -Z -Ptext=0,data,bss -C100H -OC280Z80.COM 0:A:CRTCPM.OBJ C309-8.OBJ 0:A:LIBC.LIB
ERA C309-8.OBJ
0:A:LINQ -Z -Ptext=0,data,bss -C100H -OC280Z80.COM 0:A:CRTCPM.OBJ C309-9.OBJ 0:A:LIBC.LIB
ERA C309-9.OBJ
ERA M:$$EXEC.$$$

10E>;
10E>; and the Z280 optimized version from it (only runs on a Z280)
10E>c280z80 -of2 -v -ec280-8.com c309-8.c
10E>c280z80 -of2 -v -ec280-8.com c309-9.c
E:C280Z80 COM
Hi-Tech C Compiler (CP/M-80) V3.09-8 [Z280 MPU version]
Hi-Tech C Compiler (CP/M-80) V3.09-9 [Z280 MPU version]
Copyright (C) 1984-87 HI-TECH SOFTWARE
Updated from https://github.com/agn453/HI-TECH-Z80-C
0:A:CPP -DCPM -DHI_TECH_C -Dz80 -DZ280 -I0:A: C309-8.C M:$CTMP1.$$$
0:A:CPP -DCPM -DHI_TECH_C -Dz80 -DZ280 -I0:A: C309-9.C M:$CTMP1.$$$
0:A:P1 M:$CTMP1.$$$ M:$CTMP2.$$$ M:$CTMP3.$$$
0:A:CGEN M:$CTMP2.$$$ M:$CTMP1.$$$
0:A:OPTIM -F M:$CTMP1.$$$ M:$CTMP2.$$$
0:A:OPTIMH -F M:$CTMP2.$$$ M:$CTMP5.$$$
479 bytes optimized away
1522 bytes replaced
0:A:ZAS -N -OC309-8.OBJ M:$CTMP5.$$$
0:A:ZAS -N -OC309-9.OBJ M:$CTMP5.$$$
ERA M:$CTMP1.$$$
ERA M:$CTMP2.$$$
ERA M:$CTMP3.$$$
ERA M:$CTMP5.$$$
0:A:LINQ -Z -Ptext=0,data,bss -C100H -OC280-8.COM 0:A:C280CPM.OBJ C309-8.OBJ 0:A:LIB280C.LIB
ERA C309-8.OBJ
0:A:LINQ -Z -Ptext=0,data,bss -C100H -OC280-8.COM 0:A:C280CPM.OBJ C309-9.OBJ 0:A:LIB280C.LIB
ERA C309-9.OBJ
ERA M:$$EXEC.$$$

10E>;
10E>c280-8 -o2 -v optimh.c
E:C280-8 COM
Hi-Tech C Compiler (CP/M-80) V3.09-8 [Z280 MPU version]
Hi-Tech C Compiler (CP/M-80) V3.09-9 [Z280 MPU version]
Copyright (C) 1984-87 HI-TECH SOFTWARE
Updated from https://github.com/agn453/HI-TECH-Z80-C
0:A:CPP -DCPM -DHI_TECH_C -Dz80 -DZ280 -I0:A: OPTIMH.C M:$CTMP1.$$$
Expand Down Expand Up @@ -103,12 +103,13 @@ Directory For Drive E: User 10
Name Bytes Recs Attributes Prot Update Create
------------ ------ ------ ------------ ------ -------------- --------------

C280-8 COM 24k 189 Dir RW None 18/01/21 16:03 18/01/21 16:03
C280Z80 COM 28k 204 Dir RW None 18/01/21 16:00 18/01/21 16:00
C280-8 COM 24k 189 Dir RW None 16/08/21 12:39 16/08/21 12:39
C280Z80 COM 28k 204 Dir RW None 16/08/21 12:36 16/08/21 12:36
C309-8 COM 28k 201 Dir RW None 18/01/21 15:56 18/01/21 15:56
C309-9 COM 28k 201 Dir RW None 16/08/21 12:32 16/08/21 12:32

Total Bytes = 80k Total Records = 594 Files Found = 3
Total 1k Blocks = 76 Used/Max Dir Entries For Drive E: 1228/2048
Total Bytes = 108k Total Records = 795 Files Found = 4
Total 1k Blocks = 102 Used/Max Dir Entries For Drive E: 1064/2048

10E>dir optimh.com [fu
A:DIR COM (User 0)
Expand All @@ -120,10 +121,10 @@ Directory For Drive E: User 10
Name Bytes Recs Attributes Prot Update Create
------------ ------ ------ ------------ ------ -------------- --------------

OPTIMH COM 20k 144 Dir RW None 18/01/21 16:06 18/01/21 16:06
OPTIMH COM 20k 144 Dir RW None 16/08/21 12:42 16/08/21 12:42

Total Bytes = 20k Total Records = 144 Files Found = 1
Total 1k Blocks = 18 Used/Max Dir Entries For Drive E: 1228/2048
Total 1k Blocks = 18 Used/Max Dir Entries For Drive E: 1064/2048

10E>;
10E>; Done
Expand Down
8 changes: 4 additions & 4 deletions cpm/BUILD-C.SUB
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ put console output to file build-c.log [system]
date
;
; Build Z80 version
c -o -v c309-8.c
c -o -v c309-9.c
;
; Now build Z280 version
;
; First a Z280 version using the Z80 LIBC.C (runs on Z80)
c309-8 -o -v -ec280z80.com -dZ280 c309-8.c
c309-9 -o -v -ec280z80.com -dZ280 c309-9.c
;
; and the Z280 optimized version from it (only runs on a Z280)
c280z80 -of2 -v -ec280-8.com c309-8.c
c280z80 -of2 -v -ec280-9.com c309-9.c
;
c280-8 -o2 -v optimh.c
c280-9 -o2 -v optimh.c
;
dir c*.com [fu
dir optimh.com [fu
Expand Down
14 changes: 8 additions & 6 deletions cpm/BUILDCPM.SUB
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
c
<-c -o start1.as open.c read.c write.c chmod.c seek.c \
<fcbname.c rename.c creat.c time.c convtime.c timezone.c \
<stat.c isatty.c cleanup.c close.c unlink.c dup.c getfcb.c \
<srand1.c getch.c signal.c getuid.as abort.c execl.as bdos.as \
<bios.as _exit.as exit.as fakeclea.as fakecpcl.as sys_err.c
c
<-c -o start1.as open.c read.c write.c chmod.c seek.c \
<fcbname.c rename.c creat.c time.c convtime.c timezone.c \
<stat.c isatty.c cleanup.c close.c unlink.c dup.c getfcb.c \
<srand1.c getch.c signal.c getuid.as abort.c execl.as bdos.as \
<bios.as _exit.as exit.as fakeclea.as fakecpcl.as sys_err.c \
<mktime.c

2 changes: 1 addition & 1 deletion cpm/C.C → cpm/C309-9.C
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ int main(int argc, char **argv)
signal_t prev_sig;
prev_sig=signal(SIGINT,SIG_IGN);

fprintf(stderr, "Hi-Tech C Compiler (CP/M-80) V3.09-8");
fprintf(stderr, "Hi-Tech C Compiler (CP/M-80) V3.09-9");
#ifdef Z280
fprintf(stderr, " [Z280 MPU version]");
#endif
Expand Down
41 changes: 41 additions & 0 deletions cpm/MKTIME.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Convert structure to time value */

#include <time.h>

/* leap year calculator expects year argument as years offset from 1900 */
#define LEAP_YEAR(Y) ( ((1900+(Y))>0) && !((1900+(Y))%4) && ( ((1900+(Y))%100) || !((1900+(Y))%400) ) )

#define SECS_PER_DAY (86400l)
#define SECS_PER_HOUR (3600l)
#define SECS_PER_MIN (60l)

static unsigned char monthDays[]={31,28,31,30,31,30,31,31,30,31,30,31};

time_t mktime(struct tm *ptm){

int i;
time_t seconds;

/* seconds from 1970 till 1 jan 00:00:00 of the given year */
seconds= (ptm->tm_year-70)*(SECS_PER_DAY * 365);
for (i = 70; i < ptm->tm_year; i++) {
if (LEAP_YEAR(i)) {
seconds += SECS_PER_DAY; /* add extra days for leap years */
}
}

/* add days for this year */
for (i = 0; i < ptm->tm_mon; i++) {
if ( (i == 1) && LEAP_YEAR(ptm->tm_year)) {
seconds += SECS_PER_DAY * 29;
} else {
seconds += SECS_PER_DAY * (int)monthDays[i];
}
}
seconds += (ptm->tm_mday-1) * SECS_PER_DAY;
seconds += ptm->tm_hour * SECS_PER_HOUR;
seconds += ptm->tm_min * SECS_PER_MIN;
seconds += ptm->tm_sec;
seconds += time_zone * SECS_PER_MIN;
return (time_t)seconds;
}
Binary file renamed dist/C309-8.COM → dist/C309-9.COM
Binary file not shown.
Binary file modified dist/LIBC.LIB
Binary file not shown.
3 changes: 2 additions & 1 deletion dist/TIME.H
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ extern int time_zone; /* minutes WESTWARD of Greenwich */
operating systems like MS-DOS there is
no time zone information available */

extern time_t time(time_t *); /* seconds since 00:00:00 Jan 1 1970 */
extern time_t time(time_t *); /* seconds since 00:00:00 Jan 1 1970 */
extern char * asctime(struct tm *); /* converts struct tm to ascii time */
extern char * ctime(time_t *); /* current local time in ascii form */
extern struct tm * gmtime(time_t *); /* Universal time */
extern struct tm * localtime(time_t *); /* local time */
extern size_t strftime(char *s, size_t maxs, char *f, struct tm *t);
extern time_t mktime(struct tm *); /* convert struct tm to time value */

#endif
Binary file modified htc-bin.lbr
Binary file not shown.
8 changes: 5 additions & 3 deletions stdio/C280LIBC.LOG
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ c> max.as \
c> memcmp.c \
c> memcpy.c \
c> memset.c \
c> mods.txt \
c> mktime.c \
c> open.c \
c> perror.c \
c> pnum.c \
Expand Down Expand Up @@ -307,6 +307,9 @@ MEMCPY.C
MEMSET.C
14 bytes optimized away
28 bytes replaced
MKTIME.C
75 bytes optimized away
140 bytes replaced
OPEN.C
29 bytes optimized away
78 bytes replaced
Expand Down Expand Up @@ -386,8 +389,7 @@ c> write.c \
c> xtoi.as \
c> zc280cpm.as \
c> zd280cpm.as \
c> zr280cpm.as \
c>
c> zr280cpm.as
PUTS.C
10 bytes optimized away
20 bytes replaced
Expand Down
2 changes: 1 addition & 1 deletion stdio/C280LIBC.SUB
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ c280
<memcmp.c \
<memcpy.c \
<memset.c \
<mods.txt \
<mktime.c \
<open.c \
<perror.c \
<pnum.c \
Expand Down
4 changes: 2 additions & 2 deletions stdio/COMPLIBC.SUB
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Compile all LIBC6.LIB modules from sources
; Compile all LIBC9.LIB modules from sources
c
<-o -c abort.c \
<abs.as \
Expand Down Expand Up @@ -102,7 +102,7 @@ c
<memcmp.c \
<memcpy.c \
<memset.c \
<mods.txt \
<mktime.c \
<open.c \
<perror.c \
<pnum.c \
Expand Down
1 change: 1 addition & 0 deletions stdio/M280LIBC.SUB
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ libr
<time.obj \
<convtime.obj \
<timezone.obj \
<mktime.obj \
<isatty.obj \
<close.obj \
<unlink.obj \
Expand Down
9 changes: 5 additions & 4 deletions stdio/MAKELIBC.SUB
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; Use librarian to place all modules in LIBC7.LIB
; Use librarian to place all modules in LIBC9.LIB
; NB: the ordering is important for resolving dependencies at link time
era LIBC7.lib
era LIBC9.lib
libr
<r LIBC7.lib \
<r LIBC9.lib \
<start1.obj \
<getargs.obj \
<assert.obj \
Expand Down Expand Up @@ -54,6 +54,7 @@ libr
<time.obj \
<convtime.obj \
<timezone.obj \
<mktime.obj \
<isatty.obj \
<close.obj \
<unlink.obj \
Expand Down Expand Up @@ -160,4 +161,4 @@ libr
<toupper.obj \
<asmod.obj \
<xtoi.obj
; Library LIBC7.LIB created
; Library LIBC9.LIB created
Binary file renamed z280dist/C280-8.COM → z280dist/C280-9.COM
Binary file not shown.
Binary file removed z280dist/C280Z80.COM
Binary file not shown.
Binary file modified z280dist/LIB280C.LIB
Binary file not shown.

0 comments on commit e151cfb

Please sign in to comment.