Untangling PDC_usleep()/delay_output(), stage 1.

This commit is contained in:
William McBrine
2006-01-03 08:07:33 +00:00
parent 0b0da6eeb2
commit 295fa25e67
2 changed files with 33 additions and 74 deletions

View File

@@ -63,7 +63,7 @@
#endif
#ifdef PDCDEBUG
char *rcsid_PDCutil = "$Id: pdcutil.c,v 1.8 2006/01/03 07:34:43 wmcbrine Exp $";
char *rcsid_PDCutil = "$Id: pdcutil.c,v 1.9 2006/01/03 08:07:33 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -160,7 +160,8 @@ void PDC_beep ()
/*man-start*********************************************************************
PDC_usleep() - waits for specified number of microseconds
PDC_usleep() - waits for specified number of microseconds _or_
milliseconds, depending on the platform; should die
PDCurses Description:
This routine is intended to provide a mechanism to wait the
@@ -173,53 +174,36 @@ void PDC_beep ()
Acknowledgement
PDC_usleep() was written by John Steele (jsteele@netcom.com)
and hacked savagely by Mark Hessling
and even more savagely by William McBrine
**man-end**********************************************************************/
/***********************************************************************/
#if defined(HAVE_USLEEP)
# ifdef HAVE_PROTO
#ifdef HAVE_PROTO
void PDC_usleep(long wait)
# else
#else
void PDC_usleep(wait)
long wait;
# endif
/***********************************************************************/
{
#if defined(HAVE_USLEEP)
PDC_LOG(("PDC_usleep() - called\n"));
usleep(wait);
return;
}
/***********************************************************************/
#elif defined(HAVE_POLL)
# include <poll.h>
# ifdef HAVE_PROTO
void PDC_usleep(long wait)
# else
void PDC_usleep(wait)
long wait;
# endif
/***********************************************************************/
{
# include <poll.h>
struct pollfd fd;
PDC_LOG(("PDC_usleep() - called\n"));
poll(&fd,0L,min(1L,wait/1000));
return;
}
/***********************************************************************/
#elif defined(PC)
# ifdef HAVE_PROTO
void PDC_usleep(long wait)
# else
void PDC_usleep(wait)
long wait;
# endif
/***********************************************************************/
{
far long *ticks = MK_FP(0x0040, 0x006c);
long t1, t2;
@@ -244,32 +228,24 @@ long wait;
t2 = *ticks;
} while (t1 == t2);
}
}
/***********************************************************************/
# else
# ifdef HAVE_PROTO
void PDC_usleep(long wait)
# else
void PDC_usleep(wait)
long wait;
# endif
/***********************************************************************/
{
#ifndef WIN32
#else
# ifndef WIN32
clock_t goal;
#endif
# endif
PDC_LOG(("PDC_usleep() - called\n"));
#if defined(WIN32)
# if defined(WIN32)
Sleep(wait);
#else
# else
goal = (clock_t)wait + clock();
while (goal > clock())
;
# endif
#endif
return;
}
#endif
#ifndef HAVE_VSSCANF
/*

View File

@@ -66,7 +66,7 @@
#endif
#ifdef PDCDEBUG
char *rcsid_util = "$Id: util.c,v 1.10 2006/01/03 07:34:43 wmcbrine Exp $";
char *rcsid_util = "$Id: util.c,v 1.11 2006/01/03 08:07:33 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -322,48 +322,31 @@ int ms;
{
PDC_LOG(("delay_output() - called: ms %d\n",ms));
#if (defined(TC) || defined(__WATCOMC__)) && defined(DOS)
#if defined(WIN32)
Sleep(ms);
#elif (defined(TC) || defined(__WATCOMC__)) && defined(DOS)
delay( ms );
return( OK );
#endif
#if defined(WIN32) || defined(PC)
#elif defined(PC)
PDC_usleep( ms );
return( OK );
#endif
#if defined(OS2)
#elif defined(OS2)
# if defined(EMX)
_sleep2(ms);
# else
DosSleep(ms);
# endif
return( OK );
#endif
#if defined(DOS) && defined(MSC)
#elif defined(DOS) && defined(MSC)
PDC_usleep((clock_t)ms);
return( OK );
#endif
#if defined(DOS) && defined(NDP)
#elif defined(DOS) && defined(NDP)
clock_t goal;
goal = ms + (float)( (float)clock()/(float)CLOCKS_PER_SEC )*1000;
while (goal > (float)( (float)clock()/(float)CLOCKS_PER_SEC )*1000)
;
return( OK );
#endif
#if defined(UNIX) || defined(__DJGPP__)
#elif defined(UNIX) || defined(__DJGPP__)
usleep(1000*ms);
return( OK );
#endif
#if defined(XCURSES)
#elif defined(XCURSES)
PDC_usleep(ms*1000);
return( OK );
#endif
return OK;
}
/***********************************************************************/
#ifdef HAVE_PROTO