From fc97ab822fb6090789b62d2cec16615e1ab78e1b Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 28 Aug 2013 08:31:17 +0200 Subject: UTIL: Create new wraper header file sss_endian.h Some platform have header file endian.h and anothers have sys/endian.h. We nedd to use conditional build to handle it correctly, therefore new header file sss_endian.h was created. --- Makefile.am | 1 + configure.ac | 3 ++ src/lib/idmap/sss_idmap_conv.c | 1 + src/util/crypto/libcrypto/crypto_sha512crypt.c | 2 +- src/util/crypto/nss/nss_sha512crypt.c | 2 +- src/util/murmurhash3.c | 13 +----- src/util/sss_endian.h | 57 ++++++++++++++++++++++++++ src/util/util.h | 19 --------- 8 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 src/util/sss_endian.h diff --git a/Makefile.am b/Makefile.am index 288de2319..edca9171e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -360,6 +360,7 @@ dist_noinst_HEADERS = \ src/util/dlinklist.h \ src/util/util.h \ src/util/strtonum.h \ + src/util/sss_endian.h \ src/util/sss_nss.h \ src/util/sss_ldap.h \ src/util/sss_python.h \ diff --git a/configure.ac b/configure.ac index 95780d9aa..a4b132f51 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,9 @@ AC_CHECK_HEADERS([security/pam_appl.h security/pam_misc.h security/pam_modules.h [AC_MSG_ERROR([PAM development libraries not installed])] ) +#Check for endian headers +AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h]) + #Set the NSS library install path AC_ARG_ENABLE([nsslibdir], [AS_HELP_STRING([--enable-nsslibdir], [Where to install nss libraries ($libdir)])], diff --git a/src/lib/idmap/sss_idmap_conv.c b/src/lib/idmap/sss_idmap_conv.c index a33604226..947c281be 100644 --- a/src/lib/idmap/sss_idmap_conv.c +++ b/src/lib/idmap/sss_idmap_conv.c @@ -30,6 +30,7 @@ #include "lib/idmap/sss_idmap.h" #include "lib/idmap/sss_idmap_private.h" #include "util/util.h" +#include "util/sss_endian.h" #define SID_ID_AUTHS 6 #define SID_SUB_AUTHS 15 diff --git a/src/util/crypto/libcrypto/crypto_sha512crypt.c b/src/util/crypto/libcrypto/crypto_sha512crypt.c index f4c3e0dae..88628b686 100644 --- a/src/util/crypto/libcrypto/crypto_sha512crypt.c +++ b/src/util/crypto/libcrypto/crypto_sha512crypt.c @@ -12,7 +12,6 @@ #include "config.h" -#include #include #include #include @@ -24,6 +23,7 @@ #include #include "util/util.h" +#include "util/sss_endian.h" #include #include diff --git a/src/util/crypto/nss/nss_sha512crypt.c b/src/util/crypto/nss/nss_sha512crypt.c index 76eb8a635..2838c4716 100644 --- a/src/util/crypto/nss/nss_sha512crypt.c +++ b/src/util/crypto/nss/nss_sha512crypt.c @@ -10,7 +10,6 @@ #include "config.h" -#include #include #include #include @@ -22,6 +21,7 @@ #include #include "util/util.h" +#include "util/sss_endian.h" #include "util/crypto/nss/nss_util.h" #include diff --git a/src/util/murmurhash3.c b/src/util/murmurhash3.c index 80e52ed56..cab138e17 100644 --- a/src/util/murmurhash3.c +++ b/src/util/murmurhash3.c @@ -8,19 +8,10 @@ #include #include -#include #include -#include - -/* support RHEL5 lack of definitions */ -#ifndef le32toh -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define le32toh(x) (x) -# else -# define le32toh(x) bswap_32 (x) -# endif -#endif +#include "config.h" +#include "util/sss_endian.h" static uint32_t rotl(uint32_t x, int8_t r) { diff --git a/src/util/sss_endian.h b/src/util/sss_endian.h new file mode 100644 index 000000000..952f8e1aa --- /dev/null +++ b/src/util/sss_endian.h @@ -0,0 +1,57 @@ +/* + SSSD + + Authors: + Lukas Slebodnik + + Copyright (C) 2013 Red Hat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef SSS_ENDIAN_H_ +#define SSS_ENDIAN_H_ + +#ifdef HAVE_ENDIAN_H +# include +#elif defined HAVE_SYS_ENDIAN_H +# include +#endif /* !HAVE_ENDIAN_H && !HAVE_SYS_ENDIAN_H */ + +/* Endianness-compatibility for systems running older versions of glibc */ + +#ifndef le32toh +#ifndef HAVE_BYTESWAP_H +#error missing le32toh and byteswap.h +#else /* defined HAVE_BYTESWAP_H */ +#include + +/* support RHEL5 lack of definitions */ +/* Copied from endian.h on glibc 2.15 */ +#ifdef __USE_BSD +/* Conversion interfaces. */ +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define le32toh(x) (x) +# define htole32(x) (x) +# else +# define le32toh(x) __bswap_32 (x) +# define htole32(x) __bswap_32 (x) +# endif +#endif /* __USE_BSD */ + +#endif /* HAVE_BYTESWAP_H */ + +#endif /* le32toh */ + +#endif /* SSS_ENDIAN_H_ */ diff --git a/src/util/util.h b/src/util/util.h index 1f7c6c344..606eab03f 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -567,25 +567,6 @@ struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx, errno_t sss_br_lock_file(int fd, size_t start, size_t len, int num_tries, useconds_t wait); -/* Endianness-compatibility for systems running older versions of glibc */ - -#ifndef le32toh -#include - -/* Copied from endian.h on glibc 2.15 */ -#ifdef __USE_BSD -/* Conversion interfaces. */ -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define le32toh(x) (x) -# define htole32(x) (x) -# else -# define le32toh(x) __bswap_32 (x) -# define htole32(x) __bswap_32 (x) -# endif -#endif /* __USE_BSD */ - -#endif /* le32toh */ - #ifdef HAVE_PAC_RESPONDER #define BUILD_WITH_PAC_RESPONDER true #else -- cgit