Hi Waldemar,

The following snippet should do it when compiled statically for MIPS32
and emulated using qemu-user-static:

#include <time.h>
#include <stddef.h>
#include <unistd.h>

int main(int argc, char **argv) {

        time_t start = time(NULL);
        sleep(2);
        time_t end = time(NULL);

        return end != start;
}

When I strace the resulting binary, I saw:
[pid 2271212] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 2271212] clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=2}, 
0x7ffca592a250) = 0
[pid 2271212] brk(0x611d0d49b000)       = 0x611d0d49b000
[pid 2271212] exit_group(1)             = ?

But I expected to see:
[pid 2271212] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 2271212] clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=2, tv_nsec=0}, 
0x7ffca592a250) = 0
[pid 2271212] brk(0x611d0d49b000)       = 0x611d0d49b000
[pid 2271212] exit_group(1)             = ?

kind regards
 Nadav

Waldemar Brodkorb wrote,
> Hi Nadav,
> 
> do you have some test code showing the issue?
> 
> best regards
>  Waldemar
> 
> Nadav Tasher wrote,
> 
> > Without this change `timespec` is too large for the `clock_nanosleep` 
> > syscall,
> > which translates to sleep(0) on 32bit systems when TIME64 is enabled (the 
> > default).
> > 
> > Tested on MIPS.
> > 
> > Signed-off-by: Nadav Tasher <tasherna...@gmail.com>
> > ---
> >  include/time.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/time.h b/include/time.h
> > index 1a1408990..25dfb9e2e 100644
> > --- a/include/time.h
> > +++ b/include/time.h
> > @@ -118,7 +118,7 @@ typedef __timer_t timer_t;
> >     has nanoseconds instead of microseconds.  */
> >  struct timespec
> >    {
> > -    __time_t tv_sec;               /* Seconds.  */
> > +    int tv_sec;            /* Seconds.  */
> >      long int tv_nsec;              /* Nanoseconds.  */
> >    };
> >  
> > -- 
> > 2.34.1
> > 
> > _______________________________________________
> > devel mailing list -- devel@uclibc-ng.org
> > To unsubscribe send an email to devel-le...@uclibc-ng.org
> > 
_______________________________________________
devel mailing list -- devel@uclibc-ng.org
To unsubscribe send an email to devel-le...@uclibc-ng.org

Reply via email to