#40 PDC_usleep bug (WIN32)

closed-fixed
None
5
2006-01-03
2005-06-18
No

PDC_usleep seems to have a bug on WIN32.
Suggested patch:

diff -Nur PDCurses-2.6.orig/pdcurses/pdcutil.c
PDCurses-2.6/pdcurses/pdcutil.c
--- PDCurses-2.6.orig/pdcurses/pdcutil.c 2001-01-10
09:27:22.000000000 +0100
+++ PDCurses-2.6/pdcurses/pdcutil.c 2005-06-18
21:09:44.000000000 +0200
@@ -227,7 +227,7 @@
# endif

#if defined(WIN32)
- Sleep(wait);
+ Sleep(wait / 1000);
#else
goal = (clock_t)wait + clock();
while (goal > clock())
diff -Nur PDCurses-2.6.orig/pdcurses/util.c PDCurses-
2.6/pdcurses/util.c
--- PDCurses-2.6.orig/pdcurses/util.c 2001-04-22
07:53:22.000000000 +0200
+++ PDCurses-2.6/pdcurses/util.c 2005-06-18
21:09:20.000000000 +0200
@@ -268,7 +268,7 @@
#endif

#if defined(WIN32)
- PDC_usleep( ms );
+ PDC_usleep(ms * 1000);
return( OK );
#endif

Discussion

  • William McBrine

    William McBrine - 2005-12-10

    Logged In: YES
    user_id=27933

    I see your point, although it's largely cosmetic -- i.e.,
    PDC_usleep() is specified as microseconds, and in Windows,
    it's receiving milliseconds from delay_output; but the pause
    is the right length. Several other platforms are the same way.

    Rather than add an extra multiply/divide, I'm more inclined
    to eliminate PDC_usleep() altogether. It's a private
    function, and it's only called from delay_output (and one
    place in XCurses). It gives a false impression of
    microsecond accuracy, when in reality, many platforms can't
    even manage millisecond accuracy.

     
  • William McBrine

    William McBrine - 2005-12-10
    • assigned_to: nobody --> wmcbrine
    • status: open --> open-postponed
     
  • Anonymous - 2005-12-12

    Logged In: YES
    user_id=1268768

    I'll be glad of anything that results in a correct and
    working sleep-function with WIN32.

     
  • William McBrine

    William McBrine - 2005-12-12
    • status: open-postponed --> pending-postponed
     
  • William McBrine

    William McBrine - 2005-12-12

    Logged In: YES
    user_id=27933

    Hmm... you're using Cygwin, aren't you? I just fixed
    PDC_usleep() for Cygwin -- by taking out HAVE_USLEEP, so it
    falls back to Sleep() instead of trying to use usleep() --
    and only now do I realize that usleep() was working after
    all, just with a delay value that was 1/1000th what it
    should be.

    With the other Win32 compilers, delay_output() already
    worked correctly, which is why I thought this was only
    cosmetic. My apologies. I tested it on Cygwin only last night.

    I'll tentatively mark this as "Fixed", although it still
    might not work if you build from the configure script (for
    X) instead of gccwin32.mak.

     
  • William McBrine

    William McBrine - 2005-12-12
    • status: pending-postponed --> pending-fixed
     
  • Anonymous - 2006-01-02
    • status: pending-fixed --> open-fixed
     
  • Anonymous - 2006-01-02

    Logged In: YES
    user_id=1268768

    PDC_usleep()'s argument is in microseconds. As long as this
    function exists, it should accept microseconds (ms * 1000)
    on all platforms (due to portability). PDC_usleep() calls
    Sleep() in case of WIN32, which has a millisecond (us /
    1000) argument.

     
  • William McBrine

    William McBrine - 2006-01-03

    Logged In: YES
    user_id=27933

    Yeah, it should. But then, it also shouldn't be used outside
    of PDCurses. Use napms().

     
  • William McBrine

    William McBrine - 2006-01-03
    • status: open-fixed --> closed-fixed
     
  • William McBrine

    William McBrine - 2006-01-03

    Logged In: YES
    user_id=27933

    PDC_usleep() has been removed in CVS.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks