Frank Heckenbach wrote:
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.)
The following works as expected on W98 DOS box and plain DOS: #include <dpmi.h> #include <unistd.h> #include <dos.h>
unsigned usleep2(unsigned musec) { _go32_dpmi_registers dpmiregs;
/* If we are running from DOS box on MS-Windows, get Windows version. */ dpmiregs.x.ax = 0x1600; dpmiregs.x.ss = dpmiregs.x.sp = dpmiregs.x.flags = 0; _go32_dpmi_simulate_int (0x2f, &dpmiregs); /* 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)) { if (musec > 11263) {usleep(musec);} else usleep(11264); } else { delay(musec / 1000); }; }
Hope this helps
Maurice