diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/busybox.h | 23 | ||||
-rw-r--r-- | include/libbb.h | 43 | ||||
-rw-r--r-- | include/platform.h | 82 |
3 files changed, 93 insertions, 55 deletions
diff --git a/include/busybox.h b/include/busybox.h index f16be706d..9fb95036e 100644 --- a/include/busybox.h +++ b/include/busybox.h | |||
@@ -2,24 +2,7 @@ | |||
2 | /* | 2 | /* |
3 | * Busybox main internal header file | 3 | * Busybox main internal header file |
4 | * | 4 | * |
5 | * | 5 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | ||
21 | * Permission has been granted to redistribute this code under the GPL. | ||
22 | * | ||
23 | */ | 6 | */ |
24 | #ifndef _BB_INTERNAL_H_ | 7 | #ifndef _BB_INTERNAL_H_ |
25 | #define _BB_INTERNAL_H_ 1 | 8 | #define _BB_INTERNAL_H_ 1 |
@@ -66,8 +49,8 @@ enum SUIDRoot { | |||
66 | struct BB_applet { | 49 | struct BB_applet { |
67 | const char *name; | 50 | const char *name; |
68 | int (*main) (int argc, char **argv); | 51 | int (*main) (int argc, char **argv); |
69 | enum Location location:4; | 52 | __extension__ enum Location location:4; |
70 | enum SUIDRoot need_suid:4; | 53 | __extension__ enum SUIDRoot need_suid:4; |
71 | }; | 54 | }; |
72 | 55 | ||
73 | /* From busybox.c */ | 56 | /* From busybox.c */ |
diff --git a/include/libbb.h b/include/libbb.h index 2e697a350..8ec1a24c0 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -2,27 +2,14 @@ | |||
2 | /* | 2 | /* |
3 | * Busybox main internal header file | 3 | * Busybox main internal header file |
4 | * | 4 | * |
5 | * | 5 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | 6 | * |
20 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | 7 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell |
21 | * Permission has been granted to redistribute this code under the GPL. | 8 | * Permission has been granted to redistribute this code under the GPL. |
22 | * | 9 | * |
23 | */ | 10 | */ |
24 | #ifndef __LIBCONFIG_H__ | 11 | #ifndef __LIBBUSYBOX_H__ |
25 | #define __LIBCONFIG_H__ 1 | 12 | #define __LIBBUSYBOX_H__ 1 |
26 | 13 | ||
27 | #include <stdio.h> | 14 | #include <stdio.h> |
28 | #include <stdlib.h> | 15 | #include <stdlib.h> |
@@ -36,6 +23,7 @@ | |||
36 | 23 | ||
37 | #include <features.h> | 24 | #include <features.h> |
38 | 25 | ||
26 | #include "platform.h" | ||
39 | #include "bb_config.h" | 27 | #include "bb_config.h" |
40 | #ifdef CONFIG_SELINUX | 28 | #ifdef CONFIG_SELINUX |
41 | #include <selinux/selinux.h> | 29 | #include <selinux/selinux.h> |
@@ -50,21 +38,6 @@ | |||
50 | # include "sha1.h" | 38 | # include "sha1.h" |
51 | #endif | 39 | #endif |
52 | 40 | ||
53 | /* Convenience macros to test the version of gcc. */ | ||
54 | #if defined __GNUC__ && defined __GNUC_MINOR__ | ||
55 | # define __GNUC_PREREQ(maj, min) \ | ||
56 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) | ||
57 | #else | ||
58 | # define __GNUC_PREREQ(maj, min) 0 | ||
59 | #endif | ||
60 | |||
61 | /* __restrict is known in EGCS 1.2 and above. */ | ||
62 | #if !__GNUC_PREREQ (2,92) | ||
63 | # define __restrict /* Ignore */ | ||
64 | #endif | ||
65 | |||
66 | #define attribute_noreturn __attribute__ ((__noreturn__)) | ||
67 | |||
68 | /* Some useful definitions */ | 41 | /* Some useful definitions */ |
69 | #define FALSE ((int) 0) | 42 | #define FALSE ((int) 0) |
70 | #define TRUE ((int) 1) | 43 | #define TRUE ((int) 1) |
@@ -86,7 +59,7 @@ | |||
86 | #define MAX(a,b) (((a)>(b))?(a):(b)) | 59 | #define MAX(a,b) (((a)>(b))?(a):(b)) |
87 | #endif | 60 | #endif |
88 | 61 | ||
89 | extern void bb_show_usage(void) __attribute__ ((noreturn, externally_visible)); | 62 | extern void bb_show_usage(void) ATTRIBUTE_NORETURN ATTRIBUTE_EXTERNALLY_VISIBLE; |
90 | extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); | 63 | extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
91 | extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); | 64 | extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); |
92 | extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); | 65 | extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
@@ -95,7 +68,7 @@ extern void bb_vherror_msg(const char *s, va_list p); | |||
95 | extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); | 68 | extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
96 | extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); | 69 | extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); |
97 | 70 | ||
98 | extern void bb_perror_nomsg_and_die(void) __attribute__ ((noreturn)); | 71 | extern void bb_perror_nomsg_and_die(void) ATTRIBUTE_NORETURN; |
99 | extern void bb_perror_nomsg(void); | 72 | extern void bb_perror_nomsg(void); |
100 | 73 | ||
101 | /* These two are used internally -- you shouldn't need to use them */ | 74 | /* These two are used internally -- you shouldn't need to use them */ |
@@ -147,7 +120,7 @@ extern FILE *bb_wfopen_input(const char *filename); | |||
147 | extern FILE *bb_xfopen(const char *path, const char *mode); | 120 | extern FILE *bb_xfopen(const char *path, const char *mode); |
148 | 121 | ||
149 | extern int bb_fclose_nonstdin(FILE *f); | 122 | extern int bb_fclose_nonstdin(FILE *f); |
150 | extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn)); | 123 | extern void bb_fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN; |
151 | 124 | ||
152 | #define BB_GETOPT_ERROR 0x80000000UL | 125 | #define BB_GETOPT_ERROR 0x80000000UL |
153 | extern const char *bb_opt_complementally; | 126 | extern const char *bb_opt_complementally; |
@@ -498,4 +471,4 @@ extern int hash_fd(int fd, const size_t size, const uint8_t hash_algo, uint8_t * | |||
498 | #include <dmalloc.h> | 471 | #include <dmalloc.h> |
499 | #endif | 472 | #endif |
500 | 473 | ||
501 | #endif /* __LIBCONFIG_H__ */ | 474 | #endif /* __LIBBUSYBOX_H__ */ |
diff --git a/include/platform.h b/include/platform.h new file mode 100644 index 000000000..763292d7a --- /dev/null +++ b/include/platform.h | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | Copyright 2006, Bernhard Fischer | ||
3 | |||
4 | Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | ||
5 | */ | ||
6 | #ifndef __PLATFORM_H | ||
7 | #define __PLATFORM_H 1 | ||
8 | |||
9 | /* Convenience macros to test the version of gcc. */ | ||
10 | #undef __GNUC_PREREQ | ||
11 | #if defined __GNUC__ && defined __GNUC_MINOR__ | ||
12 | # define __GNUC_PREREQ(maj, min) \ | ||
13 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) | ||
14 | #else | ||
15 | # define __GNUC_PREREQ(maj, min) 0 | ||
16 | #endif | ||
17 | |||
18 | /* __restrict is known in EGCS 1.2 and above. */ | ||
19 | #if !__GNUC_PREREQ (2,92) | ||
20 | # ifndef __restrict | ||
21 | # define __restrict /* Ignore */ | ||
22 | # endif | ||
23 | #endif | ||
24 | |||
25 | /* Define macros for some gcc attributes. This permits us to use the | ||
26 | macros freely, and know that they will come into play for the | ||
27 | version of gcc in which they are supported. */ | ||
28 | |||
29 | #if !__GNUC_PREREQ (2,7) | ||
30 | # ifndef __attribute__ | ||
31 | # define __attribute__(x) | ||
32 | # endif | ||
33 | #endif | ||
34 | |||
35 | #if 0 | ||
36 | /* Attribute __malloc__ on functions was valid as of gcc 2.96. */ | ||
37 | #ifndef ATTRIBUTE_MALLOC | ||
38 | # if __GNUC_PREREQ (2,96) | ||
39 | # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) | ||
40 | # else | ||
41 | # define ATTRIBUTE_MALLOC | ||
42 | # endif /* GNUC >= 2.96 */ | ||
43 | #endif /* ATTRIBUTE_MALLOC */ | ||
44 | #endif | ||
45 | |||
46 | #ifndef ATTRIBUTE_UNUSED | ||
47 | #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) | ||
48 | #endif /* ATTRIBUTE_UNUSED */ | ||
49 | |||
50 | #ifndef ATTRIBUTE_NORETURN | ||
51 | #define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) | ||
52 | #endif /* ATTRIBUTE_NORETURN */ | ||
53 | |||
54 | #ifndef ATTRIBUTE_PACKED | ||
55 | #define ATTRIBUTE_PACKED __attribute__ ((__packed__)) | ||
56 | #endif /* ATTRIBUTE_NORETURN */ | ||
57 | |||
58 | /* -fwhole-program makes all symbols local. The attribute externally_visible | ||
59 | forces a symbol global. */ | ||
60 | #ifndef ATTRIBUTE_EXTERNALLY_VISIBLE | ||
61 | # if __GNUC_PREREQ (4,1) | ||
62 | # define ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((__externally_visible__)) | ||
63 | # else | ||
64 | # define ATTRIBUTE_EXTERNALLY_VISIBLE | ||
65 | # endif /* GNUC >= 4.1 */ | ||
66 | #endif /* ATTRIBUTE_EXTERNALLY_VISIBLE */ | ||
67 | |||
68 | /* We use __extension__ in some places to suppress -pedantic warnings | ||
69 | about GCC extensions. This feature didn't work properly before | ||
70 | gcc 2.8. */ | ||
71 | #if !__GNUC_PREREQ (2,8) | ||
72 | # ifndef __extension__ | ||
73 | # define __extension__ | ||
74 | # endif | ||
75 | #endif | ||
76 | |||
77 | |||
78 | /* include USAGE_APPLET_x helper macros for usage.h. */ | ||
79 | /* | ||
80 | #include "_usage.h" | ||
81 | */ | ||
82 | #endif /* platform.h */ | ||