aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-07-05 03:34:12 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-07-05 03:34:12 +0200
commit9b1b62adc4e4c1e80d9f72180c6b7b1eaef9f95a (patch)
tree65a7b5ebb093903fd030aecda6ee204660d458d4
parentb22bbfffec182997827b0a71eeb93ddafbde602c (diff)
downloadbusybox-w32-9b1b62adc4e4c1e80d9f72180c6b7b1eaef9f95a.tar.gz
busybox-w32-9b1b62adc4e4c1e80d9f72180c6b7b1eaef9f95a.tar.bz2
busybox-w32-9b1b62adc4e4c1e80d9f72180c6b7b1eaef9f95a.zip
Patches to enable FreeBSD build
platform.h: fix wrong check for endianness, fix lchown aliasing to chown on uclibc. Code seems to not be affected in my testing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/stty.c4
-rw-r--r--include/libbb.h6
-rw-r--r--include/platform.h61
-rw-r--r--libbb/bb_askpass.c3
-rw-r--r--libbb/loop.c39
-rw-r--r--libpwdgrp/pwd_grp.c2
-rw-r--r--loginutils/getty.c4
-rw-r--r--networking/udhcp/clientpacket.c2
-rw-r--r--networking/udhcp/clientsocket.c2
-rw-r--r--networking/udhcp/socket.c2
10 files changed, 72 insertions, 53 deletions
diff --git a/coreutils/stty.c b/coreutils/stty.c
index e02fe7c72..5506fdb66 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -68,6 +68,10 @@
68# define CSWTCH _POSIX_VDISABLE 68# define CSWTCH _POSIX_VDISABLE
69#endif 69#endif
70 70
71#ifndef IUCLC
72# define IUCLC 0
73#endif
74
71/* SunOS 5.3 loses (^Z doesn't work) if 'swtch' is the same as 'susp'. 75/* SunOS 5.3 loses (^Z doesn't work) if 'swtch' is the same as 'susp'.
72 So the default is to disable 'swtch.' */ 76 So the default is to disable 'swtch.' */
73#if defined(__sparc__) && defined(__svr4__) 77#if defined(__sparc__) && defined(__svr4__)
diff --git a/include/libbb.h b/include/libbb.h
index 77674f8a2..835beb20c 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -29,6 +29,10 @@
29#include <sys/ioctl.h> 29#include <sys/ioctl.h>
30#include <sys/mman.h> 30#include <sys/mman.h>
31#include <sys/socket.h> 31#include <sys/socket.h>
32#if defined __FreeBSD__
33#include <netinet/in.h>
34#include <arpa/inet.h>
35#endif
32#include <sys/stat.h> 36#include <sys/stat.h>
33#include <sys/time.h> 37#include <sys/time.h>
34#include <sys/types.h> 38#include <sys/types.h>
@@ -86,7 +90,9 @@ int klogctl(int type, char *b, int len);
86/* This is declared here rather than #including <libgen.h> in order to avoid 90/* This is declared here rather than #including <libgen.h> in order to avoid
87 * confusing the two versions of basename. See the dirname/basename man page 91 * confusing the two versions of basename. See the dirname/basename man page
88 * for details. */ 92 * for details. */
93#if !defined __FreeBSD__
89char *dirname(char *path); 94char *dirname(char *path);
95#endif
90/* Include our own copy of struct sysinfo to avoid binary compatibility 96/* Include our own copy of struct sysinfo to avoid binary compatibility
91 * problems with Linux 2.4, which changed things. Grumble, grumble. */ 97 * problems with Linux 2.4, which changed things. Grumble, grumble. */
92struct sysinfo { 98struct sysinfo {
diff --git a/include/platform.h b/include/platform.h
index e2136a2ea..99e747f0d 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -36,12 +36,10 @@
36#undef inline 36#undef inline
37#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L 37#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
38/* it's a keyword */ 38/* it's a keyword */
39#elif __GNUC_PREREQ(2,7)
40# define inline __inline__
39#else 41#else
40# if __GNUC_PREREQ(2,7) 42# define inline
41# define inline __inline__
42# else
43# define inline
44# endif
45#endif 43#endif
46 44
47#ifndef __const 45#ifndef __const
@@ -52,6 +50,7 @@
52#define NORETURN __attribute__ ((__noreturn__)) 50#define NORETURN __attribute__ ((__noreturn__))
53#define PACKED __attribute__ ((__packed__)) 51#define PACKED __attribute__ ((__packed__))
54#define ALIGNED(m) __attribute__ ((__aligned__(m))) 52#define ALIGNED(m) __attribute__ ((__aligned__(m)))
53
55/* __NO_INLINE__: some gcc's do not honor inlining! :( */ 54/* __NO_INLINE__: some gcc's do not honor inlining! :( */
56#if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__) 55#if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__)
57# define ALWAYS_INLINE __attribute__ ((always_inline)) inline 56# define ALWAYS_INLINE __attribute__ ((always_inline)) inline
@@ -122,24 +121,34 @@
122 121
123/* ---- Endian Detection ------------------------------------ */ 122/* ---- Endian Detection ------------------------------------ */
124 123
125#if (defined __digital__ && defined __unix__) 124#if defined(__digital__) && defined(__unix__)
126# include <sex.h> 125# include <sex.h>
127# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN) 126# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN)
128# define __BYTE_ORDER BYTE_ORDER 127# define __BYTE_ORDER BYTE_ORDER
128#elif defined __FreeBSD__
129char *strchrnul(const char *s, int c);
130# include <sys/resource.h> /* rlimit */
131# include <machine/endian.h>
132# define bswap_64 __bswap64
133# define bswap_32 __bswap32
134# define bswap_16 __bswap16
135# define __BIG_ENDIAN__ (_BYTE_ORDER == _BIG_ENDIAN)
129#elif !defined __APPLE__ 136#elif !defined __APPLE__
130# include <byteswap.h> 137# include <byteswap.h>
131# include <endian.h> 138# include <endian.h>
132#endif 139#endif
133 140
134#ifdef __BIG_ENDIAN__ 141#if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__
135# define BB_BIG_ENDIAN 1 142# define BB_BIG_ENDIAN 1
136# define BB_LITTLE_ENDIAN 0 143# define BB_LITTLE_ENDIAN 0
137#elif __BYTE_ORDER == __BIG_ENDIAN 144#elif __BYTE_ORDER == __BIG_ENDIAN
138# define BB_BIG_ENDIAN 1 145# define BB_BIG_ENDIAN 1
139# define BB_LITTLE_ENDIAN 0 146# define BB_LITTLE_ENDIAN 0
140#else 147#elif __BYTE_ORDER == __LITTLE_ENDIAN
141# define BB_BIG_ENDIAN 0 148# define BB_BIG_ENDIAN 0
142# define BB_LITTLE_ENDIAN 1 149# define BB_LITTLE_ENDIAN 1
150#else
151# error "Can't determine endiannes"
143#endif 152#endif
144 153
145/* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ 154/* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */
@@ -183,7 +192,7 @@
183 192
184#ifndef __APPLE__ 193#ifndef __APPLE__
185# include <arpa/inet.h> 194# include <arpa/inet.h>
186# ifndef __socklen_t_defined 195# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
187typedef int socklen_t; 196typedef int socklen_t;
188# endif 197# endif
189#else 198#else
@@ -192,20 +201,13 @@ typedef int socklen_t;
192 201
193/* ---- Compiler dependent settings ------------------------- */ 202/* ---- Compiler dependent settings ------------------------- */
194 203
195#if (defined __digital__ && defined __unix__) || defined __APPLE__ 204#if (defined __digital__ && defined __unix__) \
205 || defined __APPLE__ || defined __FreeBSD__
196# undef HAVE_MNTENT_H 206# undef HAVE_MNTENT_H
197# undef HAVE_SYS_STATFS_H 207# undef HAVE_SYS_STATFS_H
198#else 208#else
199# define HAVE_MNTENT_H 1 209# define HAVE_MNTENT_H 1
200# define HAVE_SYS_STATFS_H 1 210# define HAVE_SYS_STATFS_H 1
201#endif /* ___digital__ && __unix__ */
202
203/* linux/loop.h relies on __u64. Make sure we have that as a proper type
204 * until userspace is widely fixed. */
205#if (defined __INTEL_COMPILER && !defined __GNUC__) || \
206 (defined __GNUC__ && defined __STRICT_ANSI__)
207__extension__ typedef long long __s64;
208__extension__ typedef unsigned long long __u64;
209#endif 211#endif
210 212
211/*----- Kernel versioning ------------------------------------*/ 213/*----- Kernel versioning ------------------------------------*/
@@ -224,14 +226,15 @@ __extension__ typedef unsigned long long __u64;
224/* Don't perpetuate e2fsck crap into the headers. Clean up e2fsck instead. */ 226/* Don't perpetuate e2fsck crap into the headers. Clean up e2fsck instead. */
225 227
226#if defined __GLIBC__ || defined __UCLIBC__ \ 228#if defined __GLIBC__ || defined __UCLIBC__ \
227 || defined __dietlibc__ || defined _NEWLIB_VERSION 229 || defined __dietlibc__ || defined _NEWLIB_VERSION
228# include <features.h> 230# include <features.h>
229# define HAVE_FEATURES_H 231# define HAVE_FEATURES_H
230# include <stdint.h> 232# include <stdint.h>
231# define HAVE_STDINT_H 233# define HAVE_STDINT_H
232#elif !defined __APPLE__ 234#elif !defined __APPLE__
233/* Largest integral types. */ 235/* Largest integral types. */
234# if __BIG_ENDIAN__ 236# if BB_BIG_ENDIAN
237/* Looks BROKEN! */
235typedef long intmax_t; 238typedef long intmax_t;
236typedef unsigned long uintmax_t; 239typedef unsigned long uintmax_t;
237# else 240# else
@@ -308,18 +311,15 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c)
308} 311}
309#endif 312#endif
310 313
311/* Don't use lchown with glibc older than 2.1.x ... uClibc lacks it */ 314/* Don't use lchown with glibc older than 2.1.x */
312#if (defined __GLIBC__ && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1) || \ 315#if defined(__GLIBC__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1
313 defined __UC_LIBC__
314# define lchown chown 316# define lchown chown
315#endif 317#endif
316 318
317#if (defined __digital__ && defined __unix__) 319#if defined(__digital__) && defined(__unix__)
318 320
319# include <standards.h> 321# include <standards.h>
320# define HAVE_STANDARDS_H
321# include <inttypes.h> 322# include <inttypes.h>
322# define HAVE_INTTYPES_H
323# define PRIu32 "u" 323# define PRIu32 "u"
324/* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */ 324/* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */
325# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0) 325# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0)
@@ -336,7 +336,7 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c)
336# define ADJ_TICK MOD_CLKB 336# define ADJ_TICK MOD_CLKB
337# endif 337# endif
338 338
339#else /* !__digital__ */ 339#else
340 340
341# define bb_setpgrp() setpgrp() 341# define bb_setpgrp() setpgrp()
342 342
@@ -387,9 +387,4 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c)
387# define HAVE_NO_UTSNAME_DOMAINNAME 387# define HAVE_NO_UTSNAME_DOMAINNAME
388#endif 388#endif
389 389
390/* If this system doesn't have IUCLC bit in struct termios::c_iflag... */
391#ifndef IUCLC
392# define IUCLC 0
393#endif
394
395#endif 390#endif
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c
index c0dcf0c5f..073175c1f 100644
--- a/libbb/bb_askpass.c
+++ b/libbb/bb_askpass.c
@@ -37,6 +37,9 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt)
37 tcgetattr(fd, &oldtio); 37 tcgetattr(fd, &oldtio);
38 tcflush(fd, TCIFLUSH); 38 tcflush(fd, TCIFLUSH);
39 tio = oldtio; 39 tio = oldtio;
40#ifndef IUCLC
41# define IUCLC 0
42#endif
40 tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY); 43 tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
41 tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP); 44 tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP);
42 tcsetattr_stdin_TCSANOW(&tio); 45 tcsetattr_stdin_TCSANOW(&tio);
diff --git a/libbb/loop.c b/libbb/loop.c
index 7d2b420be..24dab1ac0 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -7,27 +7,35 @@
7 * 7 *
8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
9 */ 9 */
10
11#include "libbb.h" 10#include "libbb.h"
12
13/* For 2.6, use the cleaned up header to get the 64 bit API. */
14#include <linux/version.h> 11#include <linux/version.h>
12
15#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 13#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
16#include <linux/loop.h> 14
15/* For 2.6, use the cleaned up header to get the 64 bit API. */
16/* linux/loop.h relies on __u64. Make sure we have that as a proper type
17 * until userspace is widely fixed. */
18# if (defined __INTEL_COMPILER && !defined __GNUC__) \
19 || (defined __GNUC__ && defined __STRICT_ANSI__)
20__extension__ typedef long long __s64;
21__extension__ typedef unsigned long long __u64;
22# endif
23# include <linux/loop.h>
17typedef struct loop_info64 bb_loop_info; 24typedef struct loop_info64 bb_loop_info;
18#define BB_LOOP_SET_STATUS LOOP_SET_STATUS64 25# define BB_LOOP_SET_STATUS LOOP_SET_STATUS64
19#define BB_LOOP_GET_STATUS LOOP_GET_STATUS64 26# define BB_LOOP_GET_STATUS LOOP_GET_STATUS64
20 27
21/* For 2.4 and earlier, use the 32 bit API (and don't trust the headers) */
22#else 28#else
23/* Stuff stolen from linux/loop.h for 2.4 and earlier kernels*/ 29
24#include <linux/posix_types.h> 30/* For 2.4 and earlier, use the 32 bit API (and don't trust the headers) */
25#define LO_NAME_SIZE 64 31/* Stuff stolen from linux/loop.h for 2.4 and earlier kernels */
26#define LO_KEY_SIZE 32 32# include <linux/posix_types.h>
27#define LOOP_SET_FD 0x4C00 33# define LO_NAME_SIZE 64
28#define LOOP_CLR_FD 0x4C01 34# define LO_KEY_SIZE 32
29#define BB_LOOP_SET_STATUS 0x4C02 35# define LOOP_SET_FD 0x4C00
30#define BB_LOOP_GET_STATUS 0x4C03 36# define LOOP_CLR_FD 0x4C01
37# define BB_LOOP_SET_STATUS 0x4C02
38# define BB_LOOP_GET_STATUS 0x4C03
31typedef struct { 39typedef struct {
32 int lo_number; 40 int lo_number;
33 __kernel_dev_t lo_device; 41 __kernel_dev_t lo_device;
@@ -60,7 +68,6 @@ char* FAST_FUNC query_loop(const char *device)
60 return dev; 68 return dev;
61} 69}
62 70
63
64int FAST_FUNC del_loop(const char *device) 71int FAST_FUNC del_loop(const char *device)
65{ 72{
66 int fd, rc; 73 int fd, rc;
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c
index 56bfcbe91..e2077ade0 100644
--- a/libpwdgrp/pwd_grp.c
+++ b/libpwdgrp/pwd_grp.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21#include "libbb.h" 21#include "libbb.h"
22#include <features.h> 22//#include <features.h>
23#include <assert.h> 23#include <assert.h>
24 24
25#ifndef _PATH_SHADOW 25#ifndef _PATH_SHADOW
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 24a182ff4..34b09cecc 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -22,6 +22,10 @@
22#include <utmp.h> /* updwtmp() */ 22#include <utmp.h> /* updwtmp() */
23#endif 23#endif
24 24
25#ifndef IUCLC
26# define IUCLC 0
27#endif
28
25/* 29/*
26 * Some heuristics to find out what environment we are in: if it is not 30 * Some heuristics to find out what environment we are in: if it is not
27 * System V, assume it is SunOS 4. 31 * System V, assume it is SunOS 4.
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 84a6765ee..0a3e6441b 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -8,7 +8,7 @@
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 <features.h> 11//#include <features.h>
12#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION 12#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
13#include <netpacket/packet.h> 13#include <netpacket/packet.h>
14#include <net/ethernet.h> 14#include <net/ethernet.h>
diff --git a/networking/udhcp/clientsocket.c b/networking/udhcp/clientsocket.c
index 851d5ab5f..0febc0459 100644
--- a/networking/udhcp/clientsocket.c
+++ b/networking/udhcp/clientsocket.c
@@ -21,7 +21,7 @@
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23 23
24#include <features.h> 24//#include <features.h>
25#include <asm/types.h> 25#include <asm/types.h>
26#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION) 26#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION)
27#include <netpacket/packet.h> 27#include <netpacket/packet.h>
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index 6b15766c9..a0ffbf893 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include <net/if.h> 26#include <net/if.h>
27#include <features.h> 27//#include <features.h>
28#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION 28#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
29#include <netpacket/packet.h> 29#include <netpacket/packet.h>
30#include <net/ethernet.h> 30#include <net/ethernet.h>