summaryrefslogtreecommitdiffstats
path: root/src
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:17:50 +0200
commitfc97ab822fb6090789b62d2cec16615e1ab78e1b (patch)
tree313f81590557f056eec4d384551c60949c5945df /src
parent298b57aa1f9eccced5ac5113aa8def1c4053eae3 (diff)
downloadsssd-fc97ab822fb6090789b62d2cec16615e1ab78e1b.tar.gz
sssd-fc97ab822fb6090789b62d2cec16615e1ab78e1b.tar.xz
sssd-fc97ab822fb6090789b62d2cec16615e1ab78e1b.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.
Diffstat (limited to 'src')
-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
6 files changed, 62 insertions, 32 deletions
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 <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 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 <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