libbb: introduce and use sleep1()

function                                             old     new   delta
sleep1                                                 -       9      +9
run_shutdown_and_kill_processes                       97      95      -2
restore_state_and_exit                               116     114      -2
reread_partition_table                                67      65      -2
flush_buffer_cache                                    80      78      -2
chat_main                                           1302    1300      -2
timeout_main                                         310     307      -3
telnet_main                                         1235    1232      -3
stop_handler                                          86      83      -3
process_action                                      1078    1075      -3
nbdclient_main                                      1185    1182      -3
init_main                                            789     786      -3
getty_main                                          1541    1538      -3
do_time                                              410     407      -3
runsv_main                                          1682    1677      -5
pause_and_low_level_reboot                            59      54      -5
inetd_main                                          1917    1911      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 9/-50)            Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2020-11-29 11:37:34 +01:00
parent 87bd558f3f
commit ec16c030bd
19 changed files with 33 additions and 29 deletions

View File

@@ -473,7 +473,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
if ('\\' == c) {
c = *++buf;
if ('d' == c) {
sleep(1);
sleep1();
len--;
continue;
}

View File

@@ -1436,7 +1436,7 @@ static void flush_buffer_cache(/*int fd*/ void)
fsync(fd); /* flush buffers */
ioctl_or_warn(fd, BLKFLSBUF, NULL); /* do it again, big time */
#ifdef HDIO_DRIVE_CMD
sleep(1);
sleep1();
if (ioctl(fd, HDIO_DRIVE_CMD, NULL) && errno != EINVAL) { /* await completion */
if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */
bb_simple_perror_msg("HDIO_DRIVE_CMD");
@@ -1511,7 +1511,7 @@ static void do_time(int cache /*,int fd*/)
* NB: *small* delay. User is expected to have a clue and to not run
* heavy io in parallel with measurements. */
sync();
sleep(1);
sleep1();
if (cache) { /* Time cache */
seek_to_zero();
read_big_block(buf);