Move the lib/ stuff around a bit
authorJens Axboe <jens.axboe@oracle.com>
Fri, 30 May 2008 20:17:45 +0000 (22:17 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 30 May 2008 20:17:45 +0000 (22:17 +0200)
And actually remember to commit the lib/ files...

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
crc/sha256.c
crc/sha512.c
lib/bswap.h [new file with mode: 0644]
lib/strsep.c [new file with mode: 0644]
lib/strsep.h [new file with mode: 0644]
os/os.h

index fe08ab3a0e0554ed417e6b7c11dedadffd20677b..0091d4477284dca5deca9c3e603c4e292ddac2b2 100644 (file)
 #include <string.h>
 #include <inttypes.h>
 
 #include <string.h>
 #include <inttypes.h>
 
+#include "../lib/bswap.h"
 #include "sha256.h"
 
 #include "sha256.h"
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static int __be32_to_cpu(uint32_t val)
-{
-       uint32_t c1, c2, c3, c4;
-
-       c1 = (val >> 24) & 0xff;
-       c2 = (val >> 16) & 0xff;
-       c3 = (val >> 8) & 0xff;
-       c4 = val & 0xff;
-
-       return c1 | c2 << 8 | c3 << 16 | c4 << 24;
-}
-#else
-#define __be32_to_cpu(x)       (x)
-#endif
-
 #define SHA256_DIGEST_SIZE     32
 #define SHA256_HMAC_BLOCK_SIZE 64
 
 #define SHA256_DIGEST_SIZE     32
 #define SHA256_HMAC_BLOCK_SIZE 64
 
index d9069e30d6cdeea90e63d0800d7532ff49617bd7..0d44ace580dbe1795a000d68c987775c63b786ff 100644 (file)
 #include <string.h>
 #include <inttypes.h>
 
 #include <string.h>
 #include <inttypes.h>
 
+#include "../lib/bswap.h"
 #include "sha512.h"
 
 #include "sha512.h"
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static int __be64_to_cpu(uint64_t val)
-{
-       uint64_t c1, c2, c3, c4, c5, c6, c7, c8;
-
-       c1 = (val >> 56) & 0xff;
-       c2 = (val >> 48) & 0xff;
-       c3 = (val >> 40) & 0xff;
-       c4 = (val >> 32) & 0xff;
-       c5 = (val >> 24) & 0xff;
-       c6 = (val >> 16) & 0xff;
-       c7 = (val >> 8) & 0xff;
-       c8 = val & 0xff;
-
-       return c1 | c2 << 8 | c3 << 16 | c4 << 24 | c5 << 32 | c6 << 40 | c7 << 48 | c8 << 56;
-}
-#else
-#define __be64_to_cpu(x)       (x)
-#endif
-
 #define SHA384_DIGEST_SIZE 48
 #define SHA512_DIGEST_SIZE 64
 #define SHA384_HMAC_BLOCK_SIZE 128
 #define SHA384_DIGEST_SIZE 48
 #define SHA512_DIGEST_SIZE 64
 #define SHA384_HMAC_BLOCK_SIZE 128
diff --git a/lib/bswap.h b/lib/bswap.h
new file mode 100644 (file)
index 0000000..30fcac5
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef FIO_BSWAP_H
+#define FIO_BSWAP_H
+
+#include <inttypes.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+static inline uint32_t __be32_to_cpu(uint32_t val)
+{
+       uint32_t c1, c2, c3, c4;
+
+       c1 = (val >> 24) & 0xff;
+       c2 = (val >> 16) & 0xff;
+       c3 = (val >> 8) & 0xff;
+       c4 = val & 0xff;
+
+       return c1 | c2 << 8 | c3 << 16 | c4 << 24;
+}
+
+static inline uint64_t __be64_to_cpu(uint64_t val)
+{
+       uint64_t c1, c2, c3, c4, c5, c6, c7, c8;
+
+       c1 = (val >> 56) & 0xff;
+       c2 = (val >> 48) & 0xff;
+       c3 = (val >> 40) & 0xff;
+       c4 = (val >> 32) & 0xff;
+       c5 = (val >> 24) & 0xff;
+       c6 = (val >> 16) & 0xff;
+       c7 = (val >> 8) & 0xff;
+       c8 = val & 0xff;
+
+       return c1 | c2 << 8 | c3 << 16 | c4 << 24 | c5 << 32 | c6 << 40 | c7 << 48 | c8 << 56;
+}
+#else
+static inline uint64_t __be64_to_cpu(uint64_t val)
+{
+       return val;
+}
+
+static inline uint32_t __be32_to_cpu(uint32_t val)
+{
+       return val;
+}
+#endif
+
+#endif
diff --git a/lib/strsep.c b/lib/strsep.c
new file mode 100644 (file)
index 0000000..f8e55b5
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+
+char *strsep(char **stringp, const char *delim)
+{
+        char *s;
+        const char *spanp;
+        int c, sc;
+        char *tok;
+
+        if ((s = *stringp) == NULL)
+                return (NULL);
+        for (tok = s;;) {
+                c = *s++;
+                spanp = delim;
+                do {
+                        if ((sc = *spanp++) == c) {
+                                if (c == 0)
+                                        s = NULL;
+                                else
+                                        s[-1] = 0;
+                                *stringp = s;
+                                return (tok);
+                        }
+                } while (sc != 0);
+        }
+}
diff --git a/lib/strsep.h b/lib/strsep.h
new file mode 100644 (file)
index 0000000..782a360
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef FIO_LIB_H
+#define FIO_LIB_H
+
+char *strsep(char **, const char *);
+
+#endif
diff --git a/os/os.h b/os/os.h
index b1ed1bb6953dfc563904a7f4f13496a0c669b87a..2dfed5e2dc042aeb5546ad9a5be91609749da089 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -25,7 +25,7 @@
 #endif
 
 #ifndef FIO_HAVE_STRSEP
 #endif
 
 #ifndef FIO_HAVE_STRSEP
-#include "../lib/lib.h"
+#include "../lib/strsep.h"
 #endif
 
 #ifndef FIO_HAVE_FADVISE
 #endif
 
 #ifndef FIO_HAVE_FADVISE