Skip to content
Snippets Groups Projects
Commit db01829b authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Merge branch 'byteorder' of /git/repositories/labs/knot

parents 60ba00b3 920b03f3
No related branches found
No related tags found
No related merge requests found
......@@ -294,6 +294,10 @@ AC_DEFINE([DSFMT_MEXP], [521], [DSFMT parameters])
# Checks for library functions.
AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise poll posix_memalign pselect pthread_setaffinity_np regcomp select setgroups initgroups])
# Check for be64toh function
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <endian.h>]], [[return be64toh(0);]])],
[AC_DEFINE(HAVE_BE64TOH, 1, [Define to 1 if you have the `be64toh' function.])])
# Check for cpu_set_t/cpuset_t compatibility
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[cpu_set_t set; CPU_ZERO(&set);]])],
[AC_DEFINE(HAVE_CPUSET_LINUX, 1, [Define if Linux-like cpu_set_t exists.])])
......
......@@ -13,12 +13,24 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#ifndef _KNOT_ENDIAN_H
#define _KNOT_ENDIAN_H
#if defined(__linux__)
# include <endian.h>
# ifndef HAVE_BE64TOH
# include <arpa/inet.h>
# define be32toh(x) ntohl(x)
# define be16toh(x) ntohs(x)
# if BYTE_ORDER == LITTLE_ENDIAN
# include <byteswap.h>
# define be64toh(x) bswap_64 (x)
# else
# define be64toh(x) (x)
# endif
# endif
#elif defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/endian.h>
#elif defined(__OpenBSD__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment