summaryrefslogtreecommitdiff
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:02:49 +0200
commit1658c567191c35beaddffafdb079abe33248037b (patch)
tree0f0090ea32f08db684f655fe6526557d31a7b98e /src
parent46c5deedec570bb5f99702a933ba99d76f9f09cb (diff)
downloadsssd-1658c567191c35beaddffafdb079abe33248037b.tar.gz
sssd-1658c567191c35beaddffafdb079abe33248037b.tar.bz2
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.
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 ef93f2a9..fd06b23d 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 f4c3e0da..88628b68 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 76eb8a63..2838c471 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 80e52ed5..cab138e1 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 00000000..952f8e1a
--- /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 f350bc76..516edc81 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