aboutsummaryrefslogtreecommitdiffstats
path: root/src/msdos.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/msdos.c b/src/msdos.c
index a79fad0ccd4..4dec901988b 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -31,7 +31,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <time.h> 31#include <time.h>
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/time.h> 33#include <sys/time.h>
34/* gettine and settime in dos.h clash with their namesakes from
35 gnulib, so we move out of our way the prototypes in dos.h. */
36#define gettime dos_h_gettime_
37#define settime dos_h_settime_
34#include <dos.h> 38#include <dos.h>
39#undef gettime
40#undef settime
35#include <errno.h> 41#include <errno.h>
36#include <sys/stat.h> /* for _fixpath */ 42#include <sys/stat.h> /* for _fixpath */
37#include <unistd.h> /* for chdir, dup, dup2, etc. */ 43#include <unistd.h> /* for chdir, dup, dup2, etc. */
@@ -103,18 +109,18 @@ int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY);
103 109
104#endif /* not SYSTEM_MALLOC */ 110#endif /* not SYSTEM_MALLOC */
105 111
112/* Return the current timestamp in milliseconds since midnight. */
106static unsigned long 113static unsigned long
107event_timestamp (void) 114event_timestamp (void)
108{ 115{
109 struct time t; 116 struct timespec t;
110 unsigned long s; 117 unsigned long s;
111 118
112 gettime (&t); 119 gettime (&t);
113 s = t.ti_min; 120 s = t.tv_sec;
114 s *= 60; 121 s %= 86400;
115 s += t.ti_sec;
116 s *= 1000; 122 s *= 1000;
117 s += t.ti_hund * 10; 123 s += t.tv_nsec * 1000000;
118 124
119 return s; 125 return s;
120} 126}
@@ -4097,10 +4103,10 @@ dos_yield_time_slice (void)
4097 because wait_reading_process_output takes care of that. */ 4103 because wait_reading_process_output takes care of that. */
4098int 4104int
4099sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 4105sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
4100 EMACS_TIME *timeout) 4106 EMACS_TIME *timeout, void *ignored)
4101{ 4107{
4102 int check_input; 4108 int check_input;
4103 struct time t; 4109 struct timespec t;
4104 4110
4105 check_input = 0; 4111 check_input = 0;
4106 if (rfds) 4112 if (rfds)
@@ -4130,18 +4136,13 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
4130 EMACS_TIME clnow, cllast, cldiff; 4136 EMACS_TIME clnow, cllast, cldiff;
4131 4137
4132 gettime (&t); 4138 gettime (&t);
4133 EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L); 4139 EMACS_SET_SECS_NSECS (cllast, t.tv_sec, t.tv_nsec);
4134 4140
4135 while (!check_input || !detect_input_pending ()) 4141 while (!check_input || !detect_input_pending ())
4136 { 4142 {
4137 gettime (&t); 4143 gettime (&t);
4138 EMACS_SET_SECS_USECS (clnow, t.ti_sec, t.ti_hund * 10000L); 4144 EMACS_SET_SECS_NSECS (clnow, t.tv_sec, t.tv_nsec);
4139 EMACS_SUB_TIME (cldiff, clnow, cllast); 4145 EMACS_SUB_TIME (cldiff, clnow, cllast);
4140
4141 /* When seconds wrap around, we assume that no more than
4142 1 minute passed since last `gettime'. */
4143 if (EMACS_TIME_SIGN (cldiff) < 0)
4144 EMACS_SET_SECS (cldiff, EMACS_SECS (cldiff) + 60);
4145 EMACS_SUB_TIME (*timeout, *timeout, cldiff); 4146 EMACS_SUB_TIME (*timeout, *timeout, cldiff);
4146 4147
4147 /* Stop when timeout value crosses zero. */ 4148 /* Stop when timeout value crosses zero. */