1 /* vi: set sw=4 ts=4: */
3 * Busybox utility routines.
5 * Copyright (C) 2005 by Tito Ragusa <tito-wolit@tiscali.it>
7 * Licensed under GPLv2, see file LICENSE in this source tree.
11 /* void FAST_FUNC bb_do_delay(unsigned seconds) { ... } - no users yet */
13 #ifndef LOGIN_FAIL_DELAY
14 #define LOGIN_FAIL_DELAY 3
16 void FAST_FUNC
pause_after_failed_login(void)
18 #if 0 /* over-engineered madness */
21 end
= time(NULL
) + LOGIN_FAIL_DELAY
;
22 diff
= LOGIN_FAIL_DELAY
;
25 diff
= end
- time(NULL
);
28 sleep(LOGIN_FAIL_DELAY
);
32 void FAST_FUNC
sleep1(void)
37 void FAST_FUNC
msleep(unsigned ms
)
40 /* 1. usleep(n) is not guaranteed by standards to accept n >= 1000000
41 * 2. multiplication in usleep(ms * 1000) can overflow if ms > 4294967
42 * (sleep of ~71.5 minutes)
43 * Let's play safe and loop:
51 //usleep is often implemented as a call to nanosleep.
52 //Simply do the same to implement msleep.
53 //it's marginally larger, but wakes your CPU less often:
54 //function old new delta
57 ts
.tv_sec
= ms
/ 1000;
58 ts
.tv_nsec
= (ms
% 1000) * 1000000;
60 * If a signal has non-default handler, nanosleep returns early.
61 * Our version of msleep doesn't return early
62 * if interrupted by such signals:
64 while (nanosleep(&ts
, &ts
) != 0)