delorie.com/archives/browse.cgi | search |
Date: | Thu, 21 Jun 2001 10:27:24 +0300 (IDT) |
From: | Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> |
X-Sender: | eliz AT is |
To: | Martin Str|mberg <ams AT ludd DOT luth DOT se> |
cc: | djgpp-workers AT delorie DOT com |
Subject: | Re: More signed/unsigned issues |
In-Reply-To: | <200106201707.TAA22797@father.ludd.luth.se> |
Message-ID: | <Pine.SUN.3.91.1010621102652.7710C-100000@is> |
MIME-Version: | 1.0 |
Reply-To: | djgpp-workers AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp-workers AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
On Wed, 20 Jun 2001, Martin Str|mberg wrote: > --- src/libc/posix/unistd/sleep.c 1995/03/12 21:28:52 1.1 > +++ src/libc/posix/unistd/sleep.c 2001/06/20 16:57:21 > @@ -7,7 +7,7 @@ unsigned int > sleep(unsigned int _seconds) > { > clock_t start_time = clock(); > - while (clock()-start_time < _seconds * CLOCKS_PER_SEC) > + while (clock()-start_time < (signed long long)_seconds * CLOCKS_PER_SEC) > __dpmi_yield(); > return 0; > } How about while (((unsigned)(clock() - start_time)) / CLOCKS_PER_SEC < _seconds) ? This removes the need for long long arithmetics, and also should work all the way till `clock's result overflows.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |