A few minor portability improvements

Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Dan Fandrich 2010-06-18 22:37:42 -07:00 committed by Denys Vlasenko
parent eb08b6ed5c
commit fdd7b566ec
5 changed files with 8 additions and 5 deletions

View File

@ -32,7 +32,9 @@
#define memeq(a, b, size) (memcmp(a, b, size) == 0) #define memeq(a, b, size) (memcmp(a, b, size) == 0)
#define memzero(buf, size) memset(buf, 0, size) #define memzero(buf, size) memset(buf, 0, size)
#ifndef min
#define min(x, y) ((x) < (y) ? (x) : (y)) #define min(x, y) ((x) < (y) ? (x) : (y))
#endif
#define min_t(type, x, y) min(x, y) #define min_t(type, x, y) min(x, y)
/* /*

View File

@ -168,10 +168,10 @@
#if defined(__BIG_ENDIAN__) && __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 defined(__BYTE_ORDER) && __BYTE_ORDER == __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 == __LITTLE_ENDIAN #elif (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || defined(__386__)
# define BB_BIG_ENDIAN 0 # define BB_BIG_ENDIAN 0
# define BB_LITTLE_ENDIAN 1 # define BB_LITTLE_ENDIAN 1
#else #else

View File

@ -7,6 +7,7 @@
* Licensed under GPLv2, see file LICENSE in this tarball for details. * Licensed under GPLv2, see file LICENSE in this tarball for details.
*/ */
#include <sys/types.h>
#include <sys/socket.h> /* netinet/in.h needs it */ #include <sys/socket.h> /* netinet/in.h needs it */
#include <netinet/in.h> #include <netinet/in.h>
#include <net/if.h> #include <net/if.h>

View File

@ -12,11 +12,11 @@
* 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 "libbb.h"
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "libbb.h"
#define CLASS_A_NETMASK ntohl(0xFF000000) #define CLASS_A_NETMASK ntohl(0xFF000000)
#define CLASS_B_NETMASK ntohl(0xFFFF0000) #define CLASS_B_NETMASK ntohl(0xFFFF0000)
#define CLASS_C_NETMASK ntohl(0xFFFFFF00) #define CLASS_C_NETMASK ntohl(0xFFFFFF00)

View File

@ -1217,7 +1217,7 @@ static void hush_exit(int exitcode)
static int check_and_run_traps(int sig) static int check_and_run_traps(int sig)
{ {
static const struct timespec zero_timespec = { 0, 0 }; static const struct timespec zero_timespec;
smalluint save_rcode; smalluint save_rcode;
int last_sig = 0; int last_sig = 0;