comparison src/msdos.c @ 13020:a656ccd43989

(gettimeofday): Don't bother setting time zone, since nobody uses it, and our hacks to get it get in the way of the above fix. Use simpler method for getting time stamp. (init_gettimeofday, daylight, gmtoffset): Remove.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Sep 1995 04:37:51 +0000
parents a3620c5ffad7
children 169d50e2ee4c
comparison
equal deleted inserted replaced
13019:5381e2022370 13020:a656ccd43989
883 case 358: /* Finland */ 883 case 358: /* Finland */
884 case 972: /* Israel */ 884 case 972: /* Israel */
885 setenv ("TZ", "EET-02", 0); 885 setenv ("TZ", "EET-02", 0);
886 break; 886 break;
887 } 887 }
888 tzset ();
889 init_gettimeofday ();
890 } 888 }
891 889
892 /* Flash the screen as a substitute for BEEPs. */ 890 /* Flash the screen as a substitute for BEEPs. */
893 891
894 static void 892 static void
1415 #endif 1413 #endif
1416 } 1414 }
1417 1415
1418 /* When time zones are set from Ms-Dos too may C-libraries are playing 1416 /* When time zones are set from Ms-Dos too may C-libraries are playing
1419 tricks with time values. We solve this by defining our own version 1417 tricks with time values. We solve this by defining our own version
1420 of `gettimeofday' bypassing GO32. Our version needs to be initialized 1418 of `gettimeofday' bypassing GO32. */
1421 once and after each call to `tzset' with TZ changed. */
1422
1423 static int daylight, gmtoffset;
1424 1419
1425 int 1420 int
1426 gettimeofday (struct timeval *tp, struct timezone *tzp) 1421 gettimeofday (struct timeval *tp, struct timezone *tzp)
1427 { 1422 {
1428 if (tp) 1423 if (tp)
1429 { 1424 {
1430 struct time t; 1425 struct time t;
1431 struct date d;
1432 struct tm tmrec;
1433 1426
1434 gettime (&t); 1427 gettime (&t);
1435 getdate (&d); 1428 tp->tv_sec = time (NULL);
1436 tmrec.tm_year = d.da_year - 1900; 1429 /* If tp->tv_sec%60 != t.ti_sec, the seconds counter turned over
1437 tmrec.tm_mon = d.da_mon - 1; 1430 between the call to `gettime' and the call to `time'. */
1438 tmrec.tm_mday = d.da_day; 1431 tp->tv_usec = tp->tv_sec%60 != t.ti_sec ? 0 : t.ti_hund * (1000000/100);
1439 tmrec.tm_hour = t.ti_hour; 1432 }
1440 tmrec.tm_min = t.ti_min; 1433 /* Ignore tzp; it's obsolescent. */
1441 tmrec.tm_sec = t.ti_sec;
1442 tmrec.tm_gmtoff = gmtoffset;
1443 tmrec.tm_isdst = daylight;
1444 tp->tv_sec = mktime (&tmrec);
1445 tp->tv_usec = t.ti_hund * (1000000 / 100);
1446 }
1447 if (tzp)
1448 {
1449 tzp->tz_minuteswest = gmtoffset;
1450 tzp->tz_dsttime = daylight;
1451 }
1452 return 0; 1434 return 0;
1453 }
1454
1455 void
1456 init_gettimeofday ()
1457 {
1458 time_t ltm, gtm;
1459 struct tm *lstm;
1460
1461 daylight = 0;
1462 gmtoffset = 0;
1463 ltm = gtm = time (NULL);
1464 ltm = mktime (lstm = localtime (&ltm));
1465 gtm = mktime (gmtime (&gtm));
1466 daylight = lstm->tm_isdst;
1467 gmtoffset = (int)(gtm - ltm) / 60;
1468 } 1435 }
1469 1436
1470 /* These must be global. */ 1437 /* These must be global. */
1471 static _go32_dpmi_seginfo ctrl_break_vector; 1438 static _go32_dpmi_seginfo ctrl_break_vector;
1472 static _go32_dpmi_registers ctrl_break_regs; 1439 static _go32_dpmi_registers ctrl_break_regs;