Date: Thu, 21 Jun 2001 10:27:24 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Martin Str|mberg cc: djgpp-workers AT delorie DOT com Subject: Re: More signed/unsigned issues In-Reply-To: <200106201707.TAA22797@father.ludd.luth.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Precedence: bulk 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.