diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-01-24 00:29:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-01-24 00:29:55 +0100 |
commit | e9a40e3b91f699c08053d7307bf50b0764811b8e (patch) | |
tree | 790f2cae8fbca16cfa2b5c1f5ed98d4c4afdf198 /libbb | |
parent | dc6cd12569e6ac3775b11f6285ccc1bb81b13af0 (diff) | |
download | busybox-w32-e9a40e3b91f699c08053d7307bf50b0764811b8e.tar.gz busybox-w32-e9a40e3b91f699c08053d7307bf50b0764811b8e.tar.bz2 busybox-w32-e9a40e3b91f699c08053d7307bf50b0764811b8e.zip |
libbb: make ndelay_no/off a bit more clever. +14 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xfuncs.c | 18 |
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 @@ | |||
25 | #include "libbb.h" | 25 | #include "libbb.h" |
26 | 26 | ||
27 | /* Turn on nonblocking I/O on a fd */ | 27 | /* Turn on nonblocking I/O on a fd */ |
28 | int FAST_FUNC ndelay_on(int fd) | 28 | void FAST_FUNC ndelay_on(int fd) |
29 | { | 29 | { |
30 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); | 30 | int flags = fcntl(fd, F_GETFL); |
31 | if (flags & O_NONBLOCK) | ||
32 | return; | ||
33 | fcntl(fd, F_SETFL, flags | O_NONBLOCK); | ||
31 | } | 34 | } |
32 | 35 | ||
33 | int FAST_FUNC ndelay_off(int fd) | 36 | void FAST_FUNC ndelay_off(int fd) |
34 | { | 37 | { |
35 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK); | 38 | int flags = fcntl(fd, F_GETFL); |
39 | if (!(flags & O_NONBLOCK)) | ||
40 | return; | ||
41 | fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); | ||
36 | } | 42 | } |
37 | 43 | ||
38 | int FAST_FUNC close_on_exec_on(int fd) | 44 | void FAST_FUNC close_on_exec_on(int fd) |
39 | { | 45 | { |
40 | return fcntl(fd, F_SETFD, FD_CLOEXEC); | 46 | fcntl(fd, F_SETFD, FD_CLOEXEC); |
41 | } | 47 | } |
42 | 48 | ||
43 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) | 49 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) |