summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2013-08-28 08:31:17 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-08-28 22:02:49 +0200
commit1658c567191c35beaddffafdb079abe33248037b (patch)
tree0f0090ea32f08db684f655fe6526557d31a7b98e
parent46c5deedec570bb5f99702a933ba99d76f9f09cb (diff)
downloadsssd-1658c567191c35beaddffafdb079abe33248037b.tar.gz
sssd-1658c567191c35beaddffafdb079abe33248037b.tar.xz
sssd-1658c567191c35beaddffafdb079abe33248037b.zip
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.
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac3
-rw-r--r--src/lib/idmap/sss_idmap_conv.c1
-rw-r--r--src/util/crypto/libcrypto/crypto_sha512crypt.c2
-rw-r--r--src/util/crypto/nss/nss_sha512crypt.c2
-rw-r--r--src/util/murmurhash3.c13
-rw-r--r--src/util/sss_endian.h57
-rw-r--r--src/util/util.h19
8 files changed, 66 insertions, 32 deletions
diff --git a/Makefile.am b/Makefile.am
index 23e084804..4981ed94d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -386,6 +386,7 @@ dist_noinst_HEADERS = \
src/util/io.h \
src/util/util_errors.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 b9b72e3d7..e23e7c078 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 ef93f2a9f..fd06b23dd 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 <endian.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
@@ -24,6 +23,7 @@
#include <sys/types.h>
#include "util/util.h"
+#include "util/sss_endian.h"
#include <openssl/evp.h>
#include <openssl/rand.h>
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 <endian.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
@@ -22,6 +21,7 @@
#include <sys/types.h>
#include "util/util.h"
+#include "util/sss_endian.h"
#include "util/crypto/nss/nss_util.h"
#include <prinit.h>
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 <stdlib.h>
#include <stdint.h>
-#include <endian.h>
#include <string.h>
-#include <byteswap.h>
-
-/* 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 <lslebodn@redhat.com>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SSS_ENDIAN_H_
+#define SSS_ENDIAN_H_
+
+#ifdef HAVE_ENDIAN_H
+# include <endian.h>
+#elif defined HAVE_SYS_ENDIAN_H
+# include <sys/endian.h>
+#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 <byteswap.h>
+
+/* 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 f350bc76e..516edc81c 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -564,25 +564,6 @@ errno_t sss_br_lock_file(int fd, size_t start, size_t len,
int num_tries, useconds_t wait);
#include "io.h"
-/* Endianness-compatibility for systems running older versions of glibc */
-
-#ifndef le32toh
-#include <byteswap.h>
-
-/* 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