On Tuesday 06 April 2010 00:02, Peter Korsgaard wrote: > >>>>> "Denys" == Denys Vlasenko <[email protected]> writes: > > Hi, > > >> int usleep (__useconds_t usec) > >> { > >> const struct timespec ts = { > >> .tv_sec = (long int) (usec / 1000000), > > Denys> what is the purpose of this cast? > Denys> If anything, (unsligned long)usec / 1000000 > Denys> may make more sense - unsigned division is easier. > > >> .tv_nsec = (long int) (usec % 1000000) * 1000ul > > Denys> Unless gcc is clever enough to notice it and optimize it out, > Denys> you use long multiply where int multiply will do. > > This was purely a cut'n'paste from the uclibc implementation - > libc/unistd/usleep.c
Another moderately scary looking code there, then... > Denys> But please wrap it in #ifs so that if usleep _is_ available, > Denys> we do not duplicate it. > > The question is what this define should be - Do you want a visible > CONFIG_HAVE_USLEEP or can we do anything clever about autodetecting > usleep (I don't quite see how)? I'd settle for check a-la "if we are on UCLIBC and UCLIBC_OPTION_WHICH_SWITCHED_OFF_USLEEP_IS_ON", acking on the theory other libs will either provide usleep or add their own #if. -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
