[PATCH] Busybox 1.23.2 for Cygwin

Christian Franke Christian.Franke at t-online.de
Mon Jul 6 19:35:41 UTC 2015


Xabier Oneca -- xOneca wrote:
> Great job, Christian!

Thanks!

> I was curios by how many changes were nedded to port Busybox and was
> reading the patch file you linked.
>
> Only one note...
>
>> - date.c: Use clock_gettime() if syscall.h is not available.
> >From the patch linked, this the one for date:
>
>> --- origsrc/busybox-1.23.2/coreutils/date.c    2015-03-23 04:07:18.000000000 +0100
>> +++ src/busybox-1.23.2/coreutils/date.c    2015-06-25 21:16:30.764288700 +0200
>> @@ -138,7 +138,7 @@
>>   //usage:       "Wed Apr 12 18:52:41 MDT 2000\n"
>>
>>   #include "libbb.h"
>> -#if ENABLE_FEATURE_DATE_NANO
>> +#if ENABLE_FEATURE_DATE_NANO && defined(HAVE_SYS_SYSCALL_H)
>>   # include <sys/syscall.h>
>>   #endif
>>
>> @@ -260,10 +260,13 @@ int date_main(int argc UNUSED_PARAM, cha
>>   #endif
>>       } else {
>>   #if ENABLE_FEATURE_DATE_NANO
>> +# ifdef HAVE_SYS_SYSCALL_H
>>           /* libc has incredibly messy way of doing this,
>>            * typically requiring -lrt. We just skip all this mess */
>>           syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
>> -#else
>> +# else
>> +        clock_gettime(CLOCK_REALTIME, &ts);
>> +# endif
>>           time(&ts.tv_sec);
>>   #endif
>>       }
> There, before the change, time() was called when *not*
> ENABLE_FEATURE_DATE_NANO. Now, with your patch it is called if it
> *is*. Is this change intentional?

No! I accidentally dropped the #else. Thanks for catching.

This breaks builds with !ENABLE_FEATURE_DATE_NANO.

In the ENABLE_FEATURE_DATE_NANO case, the bug is not visible except when 
tv_sec increments between clock_gettime() and time() call and the "%N" 
format is actually used.

Correct one:

   #if ENABLE_FEATURE_DATE_NANO
  +# ifdef HAVE_SYS_SYSCALL_H
           /* libc has incredibly messy way of doing this,
        * typically requiring -lrt. We just skip all this mess */
           syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
  +# else
  +        clock_gettime(CLOCK_REALTIME, &ts);
  +# endif
  #else
           time(&ts.tv_sec);
  #endif


Cheers,
Christian



More information about the busybox mailing list