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>
This commit is contained in:
parent
b22bbfffec
commit
9b1b62adc4
@ -68,6 +68,10 @@
|
|||||||
# define CSWTCH _POSIX_VDISABLE
|
# define CSWTCH _POSIX_VDISABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef IUCLC
|
||||||
|
# define IUCLC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* SunOS 5.3 loses (^Z doesn't work) if 'swtch' is the same as 'susp'.
|
/* SunOS 5.3 loses (^Z doesn't work) if 'swtch' is the same as 'susp'.
|
||||||
So the default is to disable 'swtch.' */
|
So the default is to disable 'swtch.' */
|
||||||
#if defined(__sparc__) && defined(__svr4__)
|
#if defined(__sparc__) && defined(__svr4__)
|
||||||
|
@ -29,6 +29,10 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#if defined __FreeBSD__
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -86,7 +90,9 @@ int klogctl(int type, char *b, int len);
|
|||||||
/* This is declared here rather than #including <libgen.h> in order to avoid
|
/* This is declared here rather than #including <libgen.h> in order to avoid
|
||||||
* confusing the two versions of basename. See the dirname/basename man page
|
* confusing the two versions of basename. See the dirname/basename man page
|
||||||
* for details. */
|
* for details. */
|
||||||
|
#if !defined __FreeBSD__
|
||||||
char *dirname(char *path);
|
char *dirname(char *path);
|
||||||
|
#endif
|
||||||
/* Include our own copy of struct sysinfo to avoid binary compatibility
|
/* Include our own copy of struct sysinfo to avoid binary compatibility
|
||||||
* problems with Linux 2.4, which changed things. Grumble, grumble. */
|
* problems with Linux 2.4, which changed things. Grumble, grumble. */
|
||||||
struct sysinfo {
|
struct sysinfo {
|
||||||
|
@ -36,12 +36,10 @@
|
|||||||
#undef inline
|
#undef inline
|
||||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
|
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
|
||||||
/* it's a keyword */
|
/* it's a keyword */
|
||||||
#else
|
#elif __GNUC_PREREQ(2,7)
|
||||||
# if __GNUC_PREREQ(2,7)
|
|
||||||
# define inline __inline__
|
# define inline __inline__
|
||||||
# else
|
#else
|
||||||
# define inline
|
# define inline
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __const
|
#ifndef __const
|
||||||
@ -52,6 +50,7 @@
|
|||||||
#define NORETURN __attribute__ ((__noreturn__))
|
#define NORETURN __attribute__ ((__noreturn__))
|
||||||
#define PACKED __attribute__ ((__packed__))
|
#define PACKED __attribute__ ((__packed__))
|
||||||
#define ALIGNED(m) __attribute__ ((__aligned__(m)))
|
#define ALIGNED(m) __attribute__ ((__aligned__(m)))
|
||||||
|
|
||||||
/* __NO_INLINE__: some gcc's do not honor inlining! :( */
|
/* __NO_INLINE__: some gcc's do not honor inlining! :( */
|
||||||
#if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__)
|
#if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__)
|
||||||
# define ALWAYS_INLINE __attribute__ ((always_inline)) inline
|
# define ALWAYS_INLINE __attribute__ ((always_inline)) inline
|
||||||
@ -122,24 +121,34 @@
|
|||||||
|
|
||||||
/* ---- Endian Detection ------------------------------------ */
|
/* ---- Endian Detection ------------------------------------ */
|
||||||
|
|
||||||
#if (defined __digital__ && defined __unix__)
|
#if defined(__digital__) && defined(__unix__)
|
||||||
# include <sex.h>
|
# include <sex.h>
|
||||||
# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN)
|
# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN)
|
||||||
# define __BYTE_ORDER BYTE_ORDER
|
# define __BYTE_ORDER BYTE_ORDER
|
||||||
|
#elif defined __FreeBSD__
|
||||||
|
char *strchrnul(const char *s, int c);
|
||||||
|
# include <sys/resource.h> /* rlimit */
|
||||||
|
# include <machine/endian.h>
|
||||||
|
# define bswap_64 __bswap64
|
||||||
|
# define bswap_32 __bswap32
|
||||||
|
# define bswap_16 __bswap16
|
||||||
|
# define __BIG_ENDIAN__ (_BYTE_ORDER == _BIG_ENDIAN)
|
||||||
#elif !defined __APPLE__
|
#elif !defined __APPLE__
|
||||||
# include <byteswap.h>
|
# include <byteswap.h>
|
||||||
# include <endian.h>
|
# include <endian.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __BIG_ENDIAN__
|
#if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__
|
||||||
# define BB_BIG_ENDIAN 1
|
# define BB_BIG_ENDIAN 1
|
||||||
# define BB_LITTLE_ENDIAN 0
|
# define BB_LITTLE_ENDIAN 0
|
||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||||
# define BB_BIG_ENDIAN 1
|
# define BB_BIG_ENDIAN 1
|
||||||
# define BB_LITTLE_ENDIAN 0
|
# define BB_LITTLE_ENDIAN 0
|
||||||
#else
|
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
# define BB_BIG_ENDIAN 0
|
# define BB_BIG_ENDIAN 0
|
||||||
# define BB_LITTLE_ENDIAN 1
|
# define BB_LITTLE_ENDIAN 1
|
||||||
|
#else
|
||||||
|
# error "Can't determine endiannes"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */
|
/* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */
|
||||||
@ -183,7 +192,7 @@
|
|||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
# ifndef __socklen_t_defined
|
# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
@ -192,20 +201,13 @@ typedef int socklen_t;
|
|||||||
|
|
||||||
/* ---- Compiler dependent settings ------------------------- */
|
/* ---- Compiler dependent settings ------------------------- */
|
||||||
|
|
||||||
#if (defined __digital__ && defined __unix__) || defined __APPLE__
|
#if (defined __digital__ && defined __unix__) \
|
||||||
|
|| defined __APPLE__ || defined __FreeBSD__
|
||||||
# undef HAVE_MNTENT_H
|
# undef HAVE_MNTENT_H
|
||||||
# undef HAVE_SYS_STATFS_H
|
# undef HAVE_SYS_STATFS_H
|
||||||
#else
|
#else
|
||||||
# define HAVE_MNTENT_H 1
|
# define HAVE_MNTENT_H 1
|
||||||
# define HAVE_SYS_STATFS_H 1
|
# define HAVE_SYS_STATFS_H 1
|
||||||
#endif /* ___digital__ && __unix__ */
|
|
||||||
|
|
||||||
/* linux/loop.h relies on __u64. Make sure we have that as a proper type
|
|
||||||
* until userspace is widely fixed. */
|
|
||||||
#if (defined __INTEL_COMPILER && !defined __GNUC__) || \
|
|
||||||
(defined __GNUC__ && defined __STRICT_ANSI__)
|
|
||||||
__extension__ typedef long long __s64;
|
|
||||||
__extension__ typedef unsigned long long __u64;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*----- Kernel versioning ------------------------------------*/
|
/*----- Kernel versioning ------------------------------------*/
|
||||||
@ -231,7 +233,8 @@ __extension__ typedef unsigned long long __u64;
|
|||||||
# define HAVE_STDINT_H
|
# define HAVE_STDINT_H
|
||||||
#elif !defined __APPLE__
|
#elif !defined __APPLE__
|
||||||
/* Largest integral types. */
|
/* Largest integral types. */
|
||||||
# if __BIG_ENDIAN__
|
# if BB_BIG_ENDIAN
|
||||||
|
/* Looks BROKEN! */
|
||||||
typedef long intmax_t;
|
typedef long intmax_t;
|
||||||
typedef unsigned long uintmax_t;
|
typedef unsigned long uintmax_t;
|
||||||
# else
|
# else
|
||||||
@ -308,18 +311,15 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Don't use lchown with glibc older than 2.1.x ... uClibc lacks it */
|
/* Don't use lchown with glibc older than 2.1.x */
|
||||||
#if (defined __GLIBC__ && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1) || \
|
#if defined(__GLIBC__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1
|
||||||
defined __UC_LIBC__
|
|
||||||
# define lchown chown
|
# define lchown chown
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined __digital__ && defined __unix__)
|
#if defined(__digital__) && defined(__unix__)
|
||||||
|
|
||||||
# include <standards.h>
|
# include <standards.h>
|
||||||
# define HAVE_STANDARDS_H
|
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
# define HAVE_INTTYPES_H
|
|
||||||
# define PRIu32 "u"
|
# define PRIu32 "u"
|
||||||
/* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */
|
/* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */
|
||||||
# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0)
|
# 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)
|
|||||||
# define ADJ_TICK MOD_CLKB
|
# define ADJ_TICK MOD_CLKB
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else /* !__digital__ */
|
#else
|
||||||
|
|
||||||
# define bb_setpgrp() setpgrp()
|
# define bb_setpgrp() setpgrp()
|
||||||
|
|
||||||
@ -387,9 +387,4 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c)
|
|||||||
# define HAVE_NO_UTSNAME_DOMAINNAME
|
# define HAVE_NO_UTSNAME_DOMAINNAME
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If this system doesn't have IUCLC bit in struct termios::c_iflag... */
|
|
||||||
#ifndef IUCLC
|
|
||||||
# define IUCLC 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,6 +37,9 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt)
|
|||||||
tcgetattr(fd, &oldtio);
|
tcgetattr(fd, &oldtio);
|
||||||
tcflush(fd, TCIFLUSH);
|
tcflush(fd, TCIFLUSH);
|
||||||
tio = oldtio;
|
tio = oldtio;
|
||||||
|
#ifndef IUCLC
|
||||||
|
# define IUCLC 0
|
||||||
|
#endif
|
||||||
tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
|
tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
|
||||||
tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP);
|
tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP);
|
||||||
tcsetattr_stdin_TCSANOW(&tio);
|
tcsetattr_stdin_TCSANOW(&tio);
|
||||||
|
39
libbb/loop.c
39
libbb/loop.c
@ -7,27 +7,35 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
#include <linux/version.h>
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
||||||
|
|
||||||
/* For 2.6, use the cleaned up header to get the 64 bit API. */
|
/* For 2.6, use the cleaned up header to get the 64 bit API. */
|
||||||
#include <linux/version.h>
|
/* linux/loop.h relies on __u64. Make sure we have that as a proper type
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
* until userspace is widely fixed. */
|
||||||
#include <linux/loop.h>
|
# if (defined __INTEL_COMPILER && !defined __GNUC__) \
|
||||||
|
|| (defined __GNUC__ && defined __STRICT_ANSI__)
|
||||||
|
__extension__ typedef long long __s64;
|
||||||
|
__extension__ typedef unsigned long long __u64;
|
||||||
|
# endif
|
||||||
|
# include <linux/loop.h>
|
||||||
typedef struct loop_info64 bb_loop_info;
|
typedef struct loop_info64 bb_loop_info;
|
||||||
#define BB_LOOP_SET_STATUS LOOP_SET_STATUS64
|
# define BB_LOOP_SET_STATUS LOOP_SET_STATUS64
|
||||||
#define BB_LOOP_GET_STATUS LOOP_GET_STATUS64
|
# define BB_LOOP_GET_STATUS LOOP_GET_STATUS64
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
/* For 2.4 and earlier, use the 32 bit API (and don't trust the headers) */
|
/* For 2.4 and earlier, use the 32 bit API (and don't trust the headers) */
|
||||||
#else
|
/* Stuff stolen from linux/loop.h for 2.4 and earlier kernels */
|
||||||
/* Stuff stolen from linux/loop.h for 2.4 and earlier kernels*/
|
# include <linux/posix_types.h>
|
||||||
#include <linux/posix_types.h>
|
# define LO_NAME_SIZE 64
|
||||||
#define LO_NAME_SIZE 64
|
# define LO_KEY_SIZE 32
|
||||||
#define LO_KEY_SIZE 32
|
# define LOOP_SET_FD 0x4C00
|
||||||
#define LOOP_SET_FD 0x4C00
|
# define LOOP_CLR_FD 0x4C01
|
||||||
#define LOOP_CLR_FD 0x4C01
|
# define BB_LOOP_SET_STATUS 0x4C02
|
||||||
#define BB_LOOP_SET_STATUS 0x4C02
|
# define BB_LOOP_GET_STATUS 0x4C03
|
||||||
#define BB_LOOP_GET_STATUS 0x4C03
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int lo_number;
|
int lo_number;
|
||||||
__kernel_dev_t lo_device;
|
__kernel_dev_t lo_device;
|
||||||
@ -60,7 +68,6 @@ char* FAST_FUNC query_loop(const char *device)
|
|||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FAST_FUNC del_loop(const char *device)
|
int FAST_FUNC del_loop(const char *device)
|
||||||
{
|
{
|
||||||
int fd, rc;
|
int fd, rc;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#include <features.h>
|
//#include <features.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifndef _PATH_SHADOW
|
#ifndef _PATH_SHADOW
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
#include <utmp.h> /* updwtmp() */
|
#include <utmp.h> /* updwtmp() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef IUCLC
|
||||||
|
# define IUCLC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some heuristics to find out what environment we are in: if it is not
|
* Some heuristics to find out what environment we are in: if it is not
|
||||||
* System V, assume it is SunOS 4.
|
* System V, assume it is SunOS 4.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <features.h>
|
//#include <features.h>
|
||||||
#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
|
#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
|
||||||
#include <netpacket/packet.h>
|
#include <netpacket/packet.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <features.h>
|
//#include <features.h>
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION)
|
#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION)
|
||||||
#include <netpacket/packet.h>
|
#include <netpacket/packet.h>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <features.h>
|
//#include <features.h>
|
||||||
#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
|
#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
|
||||||
#include <netpacket/packet.h>
|
#include <netpacket/packet.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user