aboutsummaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-01-24 00:29:55 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-01-24 00:29:55 +0100
commite9a40e3b91f699c08053d7307bf50b0764811b8e (patch)
tree790f2cae8fbca16cfa2b5c1f5ed98d4c4afdf198 /libbb/xfuncs.c
parentdc6cd12569e6ac3775b11f6285ccc1bb81b13af0 (diff)
downloadbusybox-e9a40e3b91f699c08053d7307bf50b0764811b8e.tar.gz
libbb: make ndelay_no/off a bit more clever. +14 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r--libbb/xfuncs.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index a02a504b0..23f27516f 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -25,19 +25,25 @@
#include "libbb.h"
/* Turn on nonblocking I/O on a fd */
-int FAST_FUNC ndelay_on(int fd)
+void FAST_FUNC ndelay_on(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
+ int flags = fcntl(fd, F_GETFL);
+ if (flags & O_NONBLOCK)
+ return;
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
}
-int FAST_FUNC ndelay_off(int fd)
+void FAST_FUNC ndelay_off(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
+ int flags = fcntl(fd, F_GETFL);
+ if (!(flags & O_NONBLOCK))
+ return;
+ fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
}
-int FAST_FUNC close_on_exec_on(int fd)
+void FAST_FUNC close_on_exec_on(int fd)
{
- return fcntl(fd, F_SETFD, FD_CLOEXEC);
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
}
char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src)