Eli Zaretskii wrote:
Date: Mon, 23 Apr 2001 17:27:16 +0200 From: Frank Heckenbach frank@g-n-u.de
You could use delay() on plain DOS and usleep() on Windows and OS/2.
So, how to distinguish them? -- I suppose that's in the FAQ or something, so perhaps some other DJGPP user can tell me how to do it or send me some code.
Function 1600h of Int 2Fh returns info that can be used to see if you are running on Windows (and on what version of Windows). Ralf Brown's Interrupt List has all the details. Here's a working code fragment (from the Emacs distribution's dosfns.c file) that is used in the DJGPP port of Emacs to set the Lisp variable dos-windows-version:
/* If we are running from DOS box on MS-Windows, get Windows version. */ dpmiregs.x.ax = 0x1600; /* enhanced mode installation check */ dpmiregs.x.ss = dpmiregs.x.sp = dpmiregs.x.flags = 0; _go32_dpmi_simulate_int (0x2f, &dpmiregs); /* We only support Windows-specific features when we run on Windows 9X or on Windows 3.X/enhanced mode.
Int 2Fh/AX=1600h returns: AL = 00: no Windows at all; AL = 01: Windows/386 2.x; AL = 80h: Windows 3.x in mode other than enhanced; AL = FFh: Windows/386 2.x We also check AH > 0 (Windows 3.1 or later), in case AL tricks us. */
if (dpmiregs.h.al > 2 && dpmiregs.h.al != 0x80 && dpmiregs.h.al != 0xff && (dpmiregs.h.al > 3 || dpmiregs.h.ah > 0)) { dos_windows_version = dpmiregs.x.ax; Vdos_windows_version = Fcons (make_number (dpmiregs.h.al), make_number (dpmiregs.h.ah));
Maurice (or someone else?), is your C good enough that you can make a usleep replacement that calls usleep or delay based on this distinction, and test it on plain Dos and under Windoze? (In the case of usleep(), if the value is > 0 and < than the minimum possible (12ms or something), you might want to round it up to the minimum.)
If you can send me such a routine, I can just drop it in. Otherwise, testing is a little difficult for me.
Frank