aboutsummaryrefslogtreecommitdiff
path: root/libbb/read.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-06-27 02:52:20 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-06-27 02:52:20 +0000
commitdefc1ea34074e7882724c460260d307cdf981a70 (patch)
treefca9b9a5fe243f9c0c76b84824ea2ff92ea8e589 /libbb/read.c
parent26bc57d8b26425f23f4be974cce7bf35c95c9a1a (diff)
downloadbusybox-w32-defc1ea34074e7882724c460260d307cdf981a70.tar.gz
busybox-w32-defc1ea34074e7882724c460260d307cdf981a70.tar.bz2
busybox-w32-defc1ea34074e7882724c460260d307cdf981a70.zip
*: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
text data bss dec hex filename 808035 611 6868 815514 c719a busybox_old 804472 611 6868 811951 c63af busybox_unstripped
Diffstat (limited to 'libbb/read.c')
-rw-r--r--libbb/read.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/libbb/read.c b/libbb/read.c
index fa9874d31..7b804125a 100644
--- a/libbb/read.c
+++ b/libbb/read.c
@@ -9,7 +9,7 @@
9 9
10#include "libbb.h" 10#include "libbb.h"
11 11
12ssize_t safe_read(int fd, void *buf, size_t count) 12ssize_t FAST_FUNC safe_read(int fd, void *buf, size_t count)
13{ 13{
14 ssize_t n; 14 ssize_t n;
15 15
@@ -56,7 +56,7 @@ ssize_t safe_read(int fd, void *buf, size_t count)
56 * which detects EAGAIN and uses poll() to wait on the fd. 56 * which detects EAGAIN and uses poll() to wait on the fd.
57 * Thankfully, poll() doesn't care about O_NONBLOCK flag. 57 * Thankfully, poll() doesn't care about O_NONBLOCK flag.
58 */ 58 */
59ssize_t nonblock_safe_read(int fd, void *buf, size_t count) 59ssize_t FAST_FUNC nonblock_safe_read(int fd, void *buf, size_t count)
60{ 60{
61 struct pollfd pfd[1]; 61 struct pollfd pfd[1];
62 ssize_t n; 62 ssize_t n;
@@ -78,7 +78,7 @@ ssize_t nonblock_safe_read(int fd, void *buf, size_t count)
78 * Returns the amount read, or -1 on an error. 78 * Returns the amount read, or -1 on an error.
79 * A short read is returned on an end of file. 79 * A short read is returned on an end of file.
80 */ 80 */
81ssize_t full_read(int fd, void *buf, size_t len) 81ssize_t FAST_FUNC full_read(int fd, void *buf, size_t len)
82{ 82{
83 ssize_t cc; 83 ssize_t cc;
84 ssize_t total; 84 ssize_t total;
@@ -107,7 +107,7 @@ ssize_t full_read(int fd, void *buf, size_t len)
107} 107}
108 108
109// Die with an error message if we can't read the entire buffer. 109// Die with an error message if we can't read the entire buffer.
110void xread(int fd, void *buf, size_t count) 110void FAST_FUNC xread(int fd, void *buf, size_t count)
111{ 111{
112 if (count) { 112 if (count) {
113 ssize_t size = full_read(fd, buf, count); 113 ssize_t size = full_read(fd, buf, count);
@@ -117,7 +117,7 @@ void xread(int fd, void *buf, size_t count)
117} 117}
118 118
119// Die with an error message if we can't read one character. 119// Die with an error message if we can't read one character.
120unsigned char xread_char(int fd) 120unsigned char FAST_FUNC xread_char(int fd)
121{ 121{
122 char tmp; 122 char tmp;
123 xread(fd, &tmp, 1); 123 xread(fd, &tmp, 1);
@@ -125,7 +125,7 @@ unsigned char xread_char(int fd)
125} 125}
126 126
127// Read one line a-la fgets. Works only on seekable streams 127// Read one line a-la fgets. Works only on seekable streams
128char *reads(int fd, char *buffer, size_t size) 128char* FAST_FUNC reads(int fd, char *buffer, size_t size)
129{ 129{
130 char *p; 130 char *p;
131 131
@@ -152,7 +152,7 @@ char *reads(int fd, char *buffer, size_t size)
152// Reads one line a-la fgets (but doesn't save terminating '\n'). 152// Reads one line a-la fgets (but doesn't save terminating '\n').
153// Reads byte-by-byte. Useful when it is important to not read ahead. 153// Reads byte-by-byte. Useful when it is important to not read ahead.
154// Bytes are appended to pfx (which must be malloced, or NULL). 154// Bytes are appended to pfx (which must be malloced, or NULL).
155char *xmalloc_reads(int fd, char *buf, size_t *maxsz_p) 155char* FAST_FUNC xmalloc_reads(int fd, char *buf, size_t *maxsz_p)
156{ 156{
157 char *p; 157 char *p;
158 size_t sz = buf ? strlen(buf) : 0; 158 size_t sz = buf ? strlen(buf) : 0;
@@ -185,7 +185,7 @@ char *xmalloc_reads(int fd, char *buf, size_t *maxsz_p)
185 return xrealloc(buf, p - buf); 185 return xrealloc(buf, p - buf);
186} 186}
187 187
188ssize_t read_close(int fd, void *buf, size_t size) 188ssize_t FAST_FUNC read_close(int fd, void *buf, size_t size)
189{ 189{
190 /*int e;*/ 190 /*int e;*/
191 size = full_read(fd, buf, size); 191 size = full_read(fd, buf, size);
@@ -195,7 +195,7 @@ ssize_t read_close(int fd, void *buf, size_t size)
195 return size; 195 return size;
196} 196}
197 197
198ssize_t open_read_close(const char *filename, void *buf, size_t size) 198ssize_t FAST_FUNC open_read_close(const char *filename, void *buf, size_t size)
199{ 199{
200 int fd = open(filename, O_RDONLY); 200 int fd = open(filename, O_RDONLY);
201 if (fd < 0) 201 if (fd < 0)
@@ -205,7 +205,7 @@ ssize_t open_read_close(const char *filename, void *buf, size_t size)
205 205
206// Read (potentially big) files in one go. File size is estimated 206// Read (potentially big) files in one go. File size is estimated
207// by stat. 207// by stat.
208void *xmalloc_open_read_close(const char *filename, size_t *sizep) 208void* FAST_FUNC xmalloc_open_read_close(const char *filename, size_t *sizep)
209{ 209{
210 char *buf; 210 char *buf;
211 size_t size; 211 size_t size;
@@ -247,7 +247,7 @@ void *xmalloc_open_read_close(const char *filename, size_t *sizep)
247 247
248// Read (potentially big) files in one go. File size is estimated by 248// Read (potentially big) files in one go. File size is estimated by
249// lseek to end. 249// lseek to end.
250void *xmalloc_open_read_close(const char *filename, size_t *sizep) 250void* FAST_FUNC xmalloc_open_read_close(const char *filename, size_t *sizep)
251{ 251{
252 char *buf; 252 char *buf;
253 size_t size; 253 size_t size;
@@ -284,7 +284,7 @@ void *xmalloc_open_read_close(const char *filename, size_t *sizep)
284} 284}
285#endif 285#endif
286 286
287void *xmalloc_xopen_read_close(const char *filename, size_t *sizep) 287void* FAST_FUNC xmalloc_xopen_read_close(const char *filename, size_t *sizep)
288{ 288{
289 void *buf = xmalloc_open_read_close(filename, sizep); 289 void *buf = xmalloc_open_read_close(filename, sizep);
290 if (!buf) 290 if (!buf)