diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-05-31 22:16:38 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-05-31 22:16:38 +0000 |
commit | 3ea433409694393b67dd9dee3b184268ab75ac56 (patch) | |
tree | f2d3fe127fb6c3c1d3b919631de6e6ed7cbc1791 | |
parent | 2c31c731f0026b9f92dc0e07542fb8e38cad7dd2 (diff) | |
download | busybox-w32-3ea433409694393b67dd9dee3b184268ab75ac56.tar.gz busybox-w32-3ea433409694393b67dd9dee3b184268ab75ac56.tar.bz2 busybox-w32-3ea433409694393b67dd9dee3b184268ab75ac56.zip |
use "glibc errno" trick not only for ash, but for entire busybox
(add/remove: 1/1 grow/shrink: 37/37 up/down: 139/-228) Total: -89 bytes
git-svn-id: svn://busybox.net/trunk/busybox@18716 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | applets/applets.c | 9 | ||||
-rw-r--r-- | archival/libunarchive/data_skip.c | 6 | ||||
-rw-r--r-- | archival/libunarchive/seek_by_jump.c | 5 | ||||
-rw-r--r-- | coreutils/mv.c | 3 | ||||
-rw-r--r-- | debianutils/mktemp.c | 5 | ||||
-rw-r--r-- | include/libbb.h | 8 | ||||
-rw-r--r-- | libbb/error_msg.c | 4 | ||||
-rw-r--r-- | libbb/perror_msg.c | 4 | ||||
-rw-r--r-- | libbb/run_shell.c | 13 | ||||
-rw-r--r-- | libbb/safe_write.c | 5 | ||||
-rw-r--r-- | loginutils/login.c | 1 | ||||
-rw-r--r-- | miscutils/devfsd.c | 11 | ||||
-rw-r--r-- | networking/libiproute/libnetlink.c | 8 | ||||
-rw-r--r-- | shell/ash.c | 11 | ||||
-rw-r--r-- | util-linux/ipcs.c | 8 | ||||
-rw-r--r-- | util-linux/setarch.c | 5 |
16 files changed, 23 insertions, 83 deletions
diff --git a/applets/applets.c b/applets/applets.c index e905ebec4..bd3704394 100644 --- a/applets/applets.c +++ b/applets/applets.c | |||
@@ -641,10 +641,19 @@ void run_applet_and_exit(const char *name, char **argv) | |||
641 | } | 641 | } |
642 | 642 | ||
643 | 643 | ||
644 | #ifdef __GLIBC__ | ||
645 | /* Make it reside in R/W memory: */ | ||
646 | int *const bb_errno __attribute__ ((section (".data"))); | ||
647 | #endif | ||
648 | |||
644 | int main(int argc, char **argv) | 649 | int main(int argc, char **argv) |
645 | { | 650 | { |
646 | const char *s; | 651 | const char *s; |
647 | 652 | ||
653 | #ifdef __GLIBC__ | ||
654 | (*(int **)&bb_errno) = __errno_location(); | ||
655 | #endif | ||
656 | |||
648 | #if !BB_MMU | 657 | #if !BB_MMU |
649 | /* NOMMU re-exec trick sets high-order bit in first byte of name */ | 658 | /* NOMMU re-exec trick sets high-order bit in first byte of name */ |
650 | if (argv[0][0] & 0x80) { | 659 | if (argv[0][0] & 0x80) { |
diff --git a/archival/libunarchive/data_skip.c b/archival/libunarchive/data_skip.c index dc3505a56..d9778da2e 100644 --- a/archival/libunarchive/data_skip.c +++ b/archival/libunarchive/data_skip.c | |||
@@ -3,12 +3,8 @@ | |||
3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <sys/types.h> | ||
7 | #include <errno.h> | ||
8 | #include <unistd.h> | ||
9 | #include <stdlib.h> | ||
10 | #include "unarchive.h" | ||
11 | #include "libbb.h" | 6 | #include "libbb.h" |
7 | #include "unarchive.h" | ||
12 | 8 | ||
13 | void data_skip(archive_handle_t *archive_handle) | 9 | void data_skip(archive_handle_t *archive_handle) |
14 | { | 10 | { |
diff --git a/archival/libunarchive/seek_by_jump.c b/archival/libunarchive/seek_by_jump.c index d605f61dd..6cd256418 100644 --- a/archival/libunarchive/seek_by_jump.c +++ b/archival/libunarchive/seek_by_jump.c | |||
@@ -3,11 +3,6 @@ | |||
3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <sys/types.h> | ||
7 | #include <errno.h> | ||
8 | #include <unistd.h> | ||
9 | #include <stdlib.h> | ||
10 | |||
11 | #include "libbb.h" | 6 | #include "libbb.h" |
12 | #include "unarchive.h" | 7 | #include "unarchive.h" |
13 | 8 | ||
diff --git a/coreutils/mv.c b/coreutils/mv.c index ad36051f9..8d9c9827a 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c | |||
@@ -15,10 +15,7 @@ | |||
15 | 15 | ||
16 | #include <sys/types.h> | 16 | #include <sys/types.h> |
17 | #include <sys/stat.h> | 17 | #include <sys/stat.h> |
18 | #include <unistd.h> | ||
19 | #include <dirent.h> | 18 | #include <dirent.h> |
20 | #include <errno.h> | ||
21 | #include <stdlib.h> | ||
22 | #include <getopt.h> /* struct option */ | 19 | #include <getopt.h> /* struct option */ |
23 | #include "libbb.h" | 20 | #include "libbb.h" |
24 | #include "libcoreutils/coreutils.h" | 21 | #include "libcoreutils/coreutils.h" |
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c index 966257aed..9e7ef7b4c 100644 --- a/debianutils/mktemp.c +++ b/debianutils/mktemp.c | |||
@@ -10,11 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
13 | #include <stdio.h> | ||
14 | #include <errno.h> | ||
15 | #include <string.h> | ||
16 | #include <unistd.h> | ||
17 | #include <stdlib.h> | ||
18 | 13 | ||
19 | int mktemp_main(int argc, char **argv); | 14 | int mktemp_main(int argc, char **argv); |
20 | int mktemp_main(int argc, char **argv) | 15 | int mktemp_main(int argc, char **argv) |
diff --git a/include/libbb.h b/include/libbb.h index 5e0b438be..385b30f16 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -165,6 +165,14 @@ | |||
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | 167 | ||
168 | #if defined(__GLIBC__) | ||
169 | /* glibc uses __errno_location() to get a ptr to errno */ | ||
170 | /* We can just memorize it once - no multithreading in busybox :) */ | ||
171 | extern int *const bb_errno; | ||
172 | #undef errno | ||
173 | #define errno (*bb_errno) | ||
174 | #endif | ||
175 | |||
168 | #if defined(__GLIBC__) && __GLIBC__ < 2 | 176 | #if defined(__GLIBC__) && __GLIBC__ < 2 |
169 | int vdprintf(int d, const char *format, va_list ap); | 177 | int vdprintf(int d, const char *format, va_list ap); |
170 | #endif | 178 | #endif |
diff --git a/libbb/error_msg.c b/libbb/error_msg.c index b2141f3a2..5f53f0311 100644 --- a/libbb/error_msg.c +++ b/libbb/error_msg.c | |||
@@ -7,10 +7,6 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <stdio.h> | ||
11 | #include <errno.h> | ||
12 | #include <string.h> | ||
13 | #include <stdlib.h> | ||
14 | #include "libbb.h" | 10 | #include "libbb.h" |
15 | 11 | ||
16 | void bb_error_msg(const char *s, ...) | 12 | void bb_error_msg(const char *s, ...) |
diff --git a/libbb/perror_msg.c b/libbb/perror_msg.c index 7fb0830be..5145795f5 100644 --- a/libbb/perror_msg.c +++ b/libbb/perror_msg.c | |||
@@ -7,10 +7,6 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <stdio.h> | ||
11 | #include <errno.h> | ||
12 | #include <string.h> | ||
13 | #include <stdlib.h> | ||
14 | #include "libbb.h" | 10 | #include "libbb.h" |
15 | 11 | ||
16 | void bb_perror_msg(const char *s, ...) | 12 | void bb_perror_msg(const char *s, ...) |
diff --git a/libbb/run_shell.c b/libbb/run_shell.c index 6be09088d..25d55dd63 100644 --- a/libbb/run_shell.c +++ b/libbb/run_shell.c | |||
@@ -28,19 +28,12 @@ | |||
28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdio.h> | ||
32 | #include <errno.h> | ||
33 | #include <unistd.h> | ||
34 | #include <string.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <syslog.h> | ||
37 | #include <ctype.h> | ||
38 | #include "libbb.h" | 31 | #include "libbb.h" |
39 | #ifdef CONFIG_SELINUX | 32 | #if ENABLE_SELINUX |
40 | #include <selinux/selinux.h> /* for setexeccon */ | 33 | #include <selinux/selinux.h> /* for setexeccon */ |
41 | #endif | 34 | #endif |
42 | 35 | ||
43 | #ifdef CONFIG_SELINUX | 36 | #if ENABLE_SELINUX |
44 | static security_context_t current_sid; | 37 | static security_context_t current_sid; |
45 | 38 | ||
46 | void | 39 | void |
@@ -90,7 +83,7 @@ void run_shell(const char *shell, int loginshell, const char *command, const cha | |||
90 | args[argno++] = *additional_args; | 83 | args[argno++] = *additional_args; |
91 | } | 84 | } |
92 | args[argno] = NULL; | 85 | args[argno] = NULL; |
93 | #ifdef CONFIG_SELINUX | 86 | #if ENABLE_SELINUX |
94 | if (current_sid && !setexeccon(current_sid)) { | 87 | if (current_sid && !setexeccon(current_sid)) { |
95 | freecon(current_sid); | 88 | freecon(current_sid); |
96 | execve(shell, (char **) args, environ); | 89 | execve(shell, (char **) args, environ); |
diff --git a/libbb/safe_write.c b/libbb/safe_write.c index c81f1247f..5bbb82e84 100644 --- a/libbb/safe_write.c +++ b/libbb/safe_write.c | |||
@@ -7,13 +7,8 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <stdio.h> | ||
11 | #include <errno.h> | ||
12 | #include <unistd.h> | ||
13 | #include "libbb.h" | 10 | #include "libbb.h" |
14 | 11 | ||
15 | |||
16 | |||
17 | ssize_t safe_write(int fd, const void *buf, size_t count) | 12 | ssize_t safe_write(int fd, const void *buf, size_t count) |
18 | { | 13 | { |
19 | ssize_t n; | 14 | ssize_t n; |
diff --git a/loginutils/login.c b/loginutils/login.c index d725466aa..142695008 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <selinux/selinux.h> /* for is_selinux_enabled() */ | 12 | #include <selinux/selinux.h> /* for is_selinux_enabled() */ |
13 | #include <selinux/get_context_list.h> /* for get_default_context() */ | 13 | #include <selinux/get_context_list.h> /* for get_default_context() */ |
14 | #include <selinux/flask.h> /* for security class definitions */ | 14 | #include <selinux/flask.h> /* for security class definitions */ |
15 | #include <errno.h> | ||
16 | #endif | 15 | #endif |
17 | 16 | ||
18 | enum { | 17 | enum { |
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 0b08fb6e5..994b80e76 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -56,23 +56,12 @@ | |||
56 | 56 | ||
57 | #include "libbb.h" | 57 | #include "libbb.h" |
58 | #include "xregex.h" | 58 | #include "xregex.h" |
59 | #include <unistd.h> | ||
60 | #include <stdio.h> | ||
61 | #include <stdlib.h> | ||
62 | #include <stdarg.h> | ||
63 | #include <string.h> | ||
64 | #include <ctype.h> | ||
65 | #include <sys/stat.h> | ||
66 | #include <sys/types.h> | ||
67 | #include <sys/wait.h> | 59 | #include <sys/wait.h> |
68 | #include <sys/ioctl.h> | 60 | #include <sys/ioctl.h> |
69 | #include <sys/socket.h> | 61 | #include <sys/socket.h> |
70 | #include <sys/un.h> | 62 | #include <sys/un.h> |
71 | #include <dirent.h> | 63 | #include <dirent.h> |
72 | #include <fcntl.h> | ||
73 | #include <syslog.h> | 64 | #include <syslog.h> |
74 | #include <signal.h> | ||
75 | #include <errno.h> | ||
76 | #include <sys/sysmacros.h> | 65 | #include <sys/sysmacros.h> |
77 | 66 | ||
78 | 67 | ||
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index 5307cec2c..0f6040977 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c | |||
@@ -11,16 +11,10 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "libbb.h" | ||
15 | #include <sys/socket.h> | 14 | #include <sys/socket.h> |
16 | |||
17 | #include <errno.h> | ||
18 | #include <string.h> | ||
19 | #include <time.h> | ||
20 | #include <unistd.h> | ||
21 | |||
22 | #include <sys/uio.h> | 15 | #include <sys/uio.h> |
23 | 16 | ||
17 | #include "libbb.h" | ||
24 | #include "libnetlink.h" | 18 | #include "libnetlink.h" |
25 | 19 | ||
26 | void rtnl_close(struct rtnl_handle *rth) | 20 | void rtnl_close(struct rtnl_handle *rth) |
diff --git a/shell/ash.c b/shell/ash.c index b1d22e5d2..ea10a65cf 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -127,13 +127,6 @@ static char optlist[NOPTS]; | |||
127 | 127 | ||
128 | /* ============ Misc data */ | 128 | /* ============ Misc data */ |
129 | 129 | ||
130 | #ifdef __GLIBC__ | ||
131 | /* glibc sucks */ | ||
132 | static int *dash_errno; | ||
133 | #undef errno | ||
134 | #define errno (*dash_errno) | ||
135 | #endif | ||
136 | |||
137 | static char nullstr[1]; /* zero length string */ | 130 | static char nullstr[1]; /* zero length string */ |
138 | static const char homestr[] = "HOME"; | 131 | static const char homestr[] = "HOME"; |
139 | static const char snlfmt[] = "%s\n"; | 132 | static const char snlfmt[] = "%s\n"; |
@@ -12734,10 +12727,6 @@ int ash_main(int argc, char **argv) | |||
12734 | struct jmploc jmploc; | 12727 | struct jmploc jmploc; |
12735 | struct stackmark smark; | 12728 | struct stackmark smark; |
12736 | 12729 | ||
12737 | #ifdef __GLIBC__ | ||
12738 | dash_errno = __errno_location(); | ||
12739 | #endif | ||
12740 | |||
12741 | #if PROFILE | 12730 | #if PROFILE |
12742 | monitor(4, etext, profile_buf, sizeof(profile_buf), 50); | 12731 | monitor(4, etext, profile_buf, sizeof(profile_buf), 50); |
12743 | #endif | 12732 | #endif |
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c index 393f94832..d7d901921 100644 --- a/util-linux/ipcs.c +++ b/util-linux/ipcs.c | |||
@@ -8,12 +8,6 @@ | |||
8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include "libbb.h" | ||
12 | #include <errno.h> | ||
13 | #include <time.h> | ||
14 | #include <pwd.h> | ||
15 | #include <grp.h> | ||
16 | |||
17 | /* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */ | 11 | /* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */ |
18 | /* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */ | 12 | /* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */ |
19 | /* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */ | 13 | /* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */ |
@@ -23,7 +17,7 @@ | |||
23 | #include <sys/msg.h> | 17 | #include <sys/msg.h> |
24 | #include <sys/shm.h> | 18 | #include <sys/shm.h> |
25 | 19 | ||
26 | 20 | #include "libbb.h" | |
27 | 21 | ||
28 | /*-------------------------------------------------------------------*/ | 22 | /*-------------------------------------------------------------------*/ |
29 | /* SHM_DEST and SHM_LOCKED are defined in kernel headers, | 23 | /* SHM_DEST and SHM_LOCKED are defined in kernel headers, |
diff --git a/util-linux/setarch.c b/util-linux/setarch.c index f6433d6ba..2fb47f9e8 100644 --- a/util-linux/setarch.c +++ b/util-linux/setarch.c | |||
@@ -7,11 +7,6 @@ | |||
7 | * Licensed under GPL v2 or later, see file License for details. | 7 | * Licensed under GPL v2 or later, see file License for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <stdlib.h> | ||
11 | #include <unistd.h> | ||
12 | #include <string.h> | ||
13 | #include <errno.h> | ||
14 | #include <stdio.h> | ||
15 | #include <sys/personality.h> | 10 | #include <sys/personality.h> |
16 | 11 | ||
17 | #include "libbb.h" | 12 | #include "libbb.h" |