mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
more fixes for endian portability.
This commit is contained in:
47
configure
vendored
47
configure
vendored
@@ -12561,6 +12561,7 @@ if test -n "$_ldlib"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: LD_LIBRARY_PATH: $LD_LIBRARY_PATH" >&5
|
||||
$as_echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" >&6; }
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking is libsodium compiled correctly" >&5
|
||||
$as_echo_n "checking is libsodium compiled correctly... " >&6; }
|
||||
if test "$cross_compiling" = yes; then :
|
||||
@@ -12602,6 +12603,52 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# check endianess
|
||||
# program returns 0 on little and 1 on big endian systems
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking are we on a big endian system" >&5
|
||||
$as_echo_n "checking are we on a big endian system... " >&6; }
|
||||
if test "$cross_compiling" = yes; then :
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "cannot run test program while cross compiling
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
long one= 1; exit(!(*((char *)(&one))));
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"; then :
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
bigendian=""
|
||||
|
||||
else
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
bigendian=1
|
||||
|
||||
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
fi
|
||||
|
||||
|
||||
if test -n "$bigendian"; then
|
||||
CFLAGS="$CFLAGS -D__BYTE_ORDER=__BIG_ENDIAN"
|
||||
fi
|
||||
|
||||
# Specify output files
|
||||
ac_config_files="$ac_config_files Makefile libpcp/Makefile src/Makefile man/Makefile tests/Makefile"
|
||||
|
||||
|
||||
21
configure.ac
21
configure.ac
@@ -173,6 +173,7 @@ if test -n "$_ldlib"; then
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${_ldlib}"
|
||||
AC_MSG_RESULT([LD_LIBRARY_PATH: $LD_LIBRARY_PATH])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([is libsodium compiled correctly])
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
@@ -189,6 +190,26 @@ AC_LANG_PROGRAM([[
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# check endianess
|
||||
# program returns 0 on little and 1 on big endian systems
|
||||
AC_MSG_CHECKING([are we on a big endian system])
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[]],[[long one= 1; exit(!(*((char *)(&one)))); ]])],
|
||||
[
|
||||
AC_MSG_RESULT([no])
|
||||
bigendian=""
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT([yes])
|
||||
bigendian=1
|
||||
]
|
||||
)
|
||||
|
||||
if test -n "$bigendian"; then
|
||||
CFLAGS="$CFLAGS -D__BYTE_ORDER=__BIG_ENDIAN"
|
||||
fi
|
||||
|
||||
# Specify output files
|
||||
AC_CONFIG_FILES([Makefile libpcp/Makefile src/Makefile man/Makefile tests/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <endian.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h> /* uint32_t */
|
||||
@@ -19,7 +18,6 @@ extern "C" {
|
||||
#include <string.h>
|
||||
#include <string.h> /* memcmp,strlen */
|
||||
#include <strings.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>
|
||||
@@ -341,25 +339,32 @@ void pcp_pad_remove(unsigned char **unpadded, unsigned char *padded,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
#else
|
||||
# include <endian.h>
|
||||
#else // no endian.h
|
||||
# ifdef HAVE_SYS_ENDIAN_H
|
||||
#else
|
||||
# include <sys/endian.h>
|
||||
# ifdef HAVE_BETOH32
|
||||
// openbsd, use aliases
|
||||
# define be32toh betoh32
|
||||
# define htobe32 hto32be
|
||||
#else
|
||||
|
||||
# endif
|
||||
# else // no sys/endian.h
|
||||
# if __BYTE_ORDER == __BIG_ENDIAN
|
||||
// Copyright (c) 1999 Joseph Samuel Myers. bsd-games
|
||||
# define be32toh(x) ((void)0)
|
||||
# define htobe32(x) ((void)0)
|
||||
# else
|
||||
# ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
# else
|
||||
# ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
# else
|
||||
# error Need either netinet/in.h or arpa/inet.h for ntohl() and htonl()
|
||||
# endif
|
||||
# endif
|
||||
# define be32toh(x) ((u_int32_t)ntohl((u_int32_t)(x)))
|
||||
# define htobe32(x) ((u_int32_t)htonl((u_int32_t)(x)))
|
||||
# endif
|
||||
|
||||
#endif // HAVE_BETOH32
|
||||
# endif // HAVE_SYS_ENDIAN_H
|
||||
#endif // HAVE_ENDIAN_H
|
||||
|
||||
|
||||
@@ -11,26 +11,31 @@
|
||||
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
# include <endian.h>
|
||||
#else
|
||||
#else // no endian.h
|
||||
# ifdef HAVE_SYS_ENDIAN_H
|
||||
# include <sys/endian.h>
|
||||
#else
|
||||
# ifdef HAVE_BETOH32
|
||||
// openbsd, use aliases
|
||||
# define be32toh betoh32
|
||||
# define htobe32 hto32be
|
||||
#else
|
||||
|
||||
# endif
|
||||
# else // no sys/endian.h
|
||||
# if __BYTE_ORDER == __BIG_ENDIAN
|
||||
// Copyright (c) 1999 Joseph Samuel Myers. bsd-games
|
||||
# define be32toh(x) ((void)0)
|
||||
# define htobe32(x) ((void)0)
|
||||
# else
|
||||
# ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
# else
|
||||
# ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
# else
|
||||
# error Need either netinet/in.h or arpa/inet.h for ntohl() and htonl()
|
||||
# endif
|
||||
# endif
|
||||
# define be32toh(x) ((u_int32_t)ntohl((u_int32_t)(x)))
|
||||
# define htobe32(x) ((u_int32_t)htonl((u_int32_t)(x)))
|
||||
# endif
|
||||
|
||||
#endif // HAVE_BETOH32
|
||||
# endif // HAVE_SYS_ENDIAN_H
|
||||
#endif // HAVE_ENDIAN_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user