aboutsummaryrefslogtreecommitdiffstats
path: root/src/msdos.c
diff options
context:
space:
mode:
authorRichard M. Stallman1994-05-17 07:24:12 +0000
committerRichard M. Stallman1994-05-17 07:24:12 +0000
commitb278e52a3bcff44d9fabe8fa5807125fb037341f (patch)
tree07dfb7843d3b6bf79830b9d54f662dee33074846 /src/msdos.c
parent56988bbec60fb4b82358c88a94299a82c74d1dd5 (diff)
downloademacs-b278e52a3bcff44d9fabe8fa5807125fb037341f.tar.gz
emacs-b278e52a3bcff44d9fabe8fa5807125fb037341f.zip
(gettimeofday): New function substituting the library
function of the same name. (init_gettimeofday): New function. (init_environment): Call init_gettimeofday after possibly setting TZ environment variable.
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/msdos.c b/src/msdos.c
index eb95a800767..f1f1c388aec 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -739,6 +739,7 @@ init_environment (argc, argv, skip_args)
739 break; 739 break;
740 } 740 }
741 tzset (); 741 tzset ();
742 init_gettimeofday ();
742} 743}
743 744
744/* Flash the screen as a substitute for BEEPs. */ 745/* Flash the screen as a substitute for BEEPs. */
@@ -889,7 +890,59 @@ internal_terminal_init ()
889 internal_terminal 890 internal_terminal
890 = (!noninteractive) && term && !strcmp (term, "internal"); 891 = (!noninteractive) && term && !strcmp (term, "internal");
891} 892}
893
894/* When time zones are set from Ms-Dos too may C-libraries are playing
895 tricks with time values. We solve this by defining our own version
896 of `gettimeofday' bypassing GO32. Our version needs to be initialized
897 once and after each call to `tzset' with TZ changed. */
898
899static int daylight, gmtoffset;
892 900
901int
902gettimeofday (struct timeval *tp, struct timezone *tzp)
903{
904 if (tp)
905 {
906 struct time t;
907 struct date d;
908 struct tm tmrec;
909
910 gettime (&t);
911 getdate (&d);
912 tmrec.tm_year = d.da_year - 1900;
913 tmrec.tm_mon = d.da_mon - 1;
914 tmrec.tm_mday = d.da_day;
915 tmrec.tm_hour = t.ti_hour;
916 tmrec.tm_min = t.ti_min;
917 tmrec.tm_sec = t.ti_sec;
918 tmrec.tm_gmtoff = gmtoffset;
919 tmrec.tm_isdst = daylight;
920 tp->tv_sec = mktime (&tmrec);
921 tp->tv_usec = t.ti_hund * (1000000 / 100);
922 }
923 if (tzp)
924 {
925 tzp->tz_minuteswest = gmtoffset;
926 tzp->tz_dsttime = daylight;
927 }
928 return 0;
929}
930
931void
932init_gettimeofday ()
933{
934 time_t ltm, gtm;
935 struct tm *lstm;
936
937 daylight = 0;
938 gmtoffset = 0;
939 ltm = gtm = time (NULL);
940 ltm = mktime (lstm = localtime (&ltm));
941 gtm = mktime (gmtime (&gtm));
942 daylight = lstm->tm_isdst;
943 gmtoffset = (int)(gtm - ltm) / 60;
944}
945
893/* These must be global. */ 946/* These must be global. */
894static _go32_dpmi_seginfo ctrl_break_vector; 947static _go32_dpmi_seginfo ctrl_break_vector;
895static _go32_dpmi_registers ctrl_break_regs; 948static _go32_dpmi_registers ctrl_break_regs;