#include <time.h>
#include <sys/param.h>
#include <sys/time.h>
+/* gettime and settime in dos.h clash with their namesakes from
+ gnulib, so we move out of our way the prototypes in dos.h. */
+#define gettime dos_h_gettime_
+#define settime dos_h_settime_
#include <dos.h>
+#undef gettime
+#undef settime
#include <errno.h>
#include <sys/stat.h> /* for _fixpath */
#include <unistd.h> /* for chdir, dup, dup2, etc. */
#endif /* not SYSTEM_MALLOC */
+/* Return the current timestamp in milliseconds since midnight. */
static unsigned long
event_timestamp (void)
{
- struct time t;
+ struct timespec t;
unsigned long s;
gettime (&t);
- s = t.ti_min;
- s *= 60;
- s += t.ti_sec;
+ s = t.tv_sec;
+ s %= 86400;
s *= 1000;
- s += t.ti_hund * 10;
+ s += t.tv_nsec * 1000000;
return s;
}
/* If the user specified a special video mode for these dimensions,
use that mode. */
- sprintf (video_name, "screen-dimensions-%dx%d", *rows, *cols);
- video_mode = Fsymbol_value (Fintern_soft (build_string (video_name), Qnil));
+ video_mode
+ = Fsymbol_value (Fintern_soft (make_formatted_string
+ (video_name, "screen-dimensions-%dx%d",
+ *rows, *cols), Qnil));
if (INTEGERP (video_mode)
&& (video_mode_value = XINT (video_mode)) > 0)
/* Extract parm names and values into those vectors. */
i = 0;
- for (tail = alist; CONSP (tail); tail = Fcdr (tail))
+ for (tail = alist; CONSP (tail); tail = XCDR (tail))
{
- Lisp_Object elt;
-
- elt = Fcar (tail);
+ Lisp_Object elt = XCAR (tail);
parms[i] = Fcar (elt);
CHECK_SYMBOL (parms[i]);
values[i] = Fcdr (elt);
}
Vinitial_window_system = Qpc;
- Vwindow_system_version = make_number (23); /* RE Emacs version */
+ Vwindow_system_version = make_number (24); /* RE Emacs version */
tty->terminal->type = output_msdos_raw;
/* If Emacs was dumped on DOS/V machine, forget the stale VRAM
sc = regs.h.ah;
total_doskeys += 2;
- XVECTOR (recent_doskeys)->contents[recent_doskeys_index++]
- = make_number (c);
+ ASET (recent_doskeys, recent_doskeys_index, make_number (c));
+ recent_doskeys_index++;
if (recent_doskeys_index == NUM_RECENT_DOSKEYS)
recent_doskeys_index = 0;
- XVECTOR (recent_doskeys)->contents[recent_doskeys_index++]
- = make_number (sc);
+ ASET (recent_doskeys, recent_doskeys_index, make_number (sc));
+ recent_doskeys_index++;
if (recent_doskeys_index == NUM_RECENT_DOSKEYS)
recent_doskeys_index = 0;
{
XMenu *menu;
- menu = (XMenu *) xmalloc (sizeof (XMenu));
+ menu = xmalloc (sizeof (XMenu));
menu->allocated = menu->count = menu->panecount = menu->width = 0;
return menu;
}
if (menu->allocated == 0)
{
int count = menu->allocated = 10;
- menu->text = (char **) xmalloc (count * sizeof (char *));
- menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *));
- menu->panenumber = (int *) xmalloc (count * sizeof (int));
- menu->help_text = (const char **) xmalloc (count * sizeof (char *));
+ menu->text = xmalloc (count * sizeof (char *));
+ menu->submenu = xmalloc (count * sizeof (XMenu *));
+ menu->panenumber = xmalloc (count * sizeof (int));
+ menu->help_text = xmalloc (count * sizeof (char *));
}
else if (menu->allocated == menu->count)
{
width = menu->width;
/* We multiply width by 2 to account for possible control characters.
FIXME: cater to non-ASCII characters in menus. */
- text = (struct glyph *) xmalloc ((width * 2 + 2) * sizeof (struct glyph));
+ text = xmalloc ((width * 2 + 2) * sizeof (struct glyph));
ScreenGetCursor (&row, &col);
mouse_get_xy (&mx, &my);
IT_update_begin (sf);
#ifndef HAVE_SELECT
#include "sysselect.h"
-#ifndef EMACS_TIME_ZERO_OR_NEG_P
-#define EMACS_TIME_ZERO_OR_NEG_P(time) \
- ((long)(time).tv_sec < 0 \
- || ((time).tv_sec == 0 \
- && (long)(time).tv_usec <= 0))
-#endif
-
/* This yields the rest of the current time slice to the task manager.
It should be called by any code which knows that it has nothing
useful to do except idle.
because wait_reading_process_output takes care of that. */
int
sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
- EMACS_TIME *timeout)
+ EMACS_TIME *timeout, void *ignored)
{
int check_input;
- struct time t;
+ struct timespec t;
check_input = 0;
if (rfds)
EMACS_TIME clnow, cllast, cldiff;
gettime (&t);
- EMACS_SET_SECS_USECS (cllast, t.ti_sec, t.ti_hund * 10000L);
+ cllast = make_emacs_time (t.tv_sec, t.tv_nsec);
while (!check_input || !detect_input_pending ())
{
gettime (&t);
- EMACS_SET_SECS_USECS (clnow, t.ti_sec, t.ti_hund * 10000L);
- EMACS_SUB_TIME (cldiff, clnow, cllast);
-
- /* When seconds wrap around, we assume that no more than
- 1 minute passed since last `gettime'. */
- if (EMACS_TIME_NEG_P (cldiff))
- EMACS_SET_SECS (cldiff, EMACS_SECS (cldiff) + 60);
- EMACS_SUB_TIME (*timeout, *timeout, cldiff);
+ clnow = make_emacs_time (t.tv_sec, t.tv_nsec);
+ cldiff = sub_emacs_time (clnow, cllast);
+ *timeout = sub_emacs_time (*timeout, cldiff);
/* Stop when timeout value crosses zero. */
- if (EMACS_TIME_ZERO_OR_NEG_P (*timeout))
+ if (EMACS_TIME_SIGN (*timeout) <= 0)
return 0;
cllast = clnow;
dos_yield_time_slice ();
DEFSYM (Qreverse, "reverse");
DEFVAR_LISP ("dos-unsupported-char-glyph", Vdos_unsupported_char_glyph,
- doc: /* *Glyph to display instead of chars not supported by current codepage.
+ doc: /* Glyph to display instead of chars not supported by current codepage.
This variable is used only by MS-DOS terminals. */);
Vdos_unsupported_char_glyph = make_number ('\177');