summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/libgen/basename_r.c4
-rw-r--r--contrib/libgen/dirname_r.c4
-rw-r--r--libglusterfs/src/Makefile.am3
-rw-r--r--libglusterfs/src/compat.c7
4 files changed, 10 insertions, 8 deletions
diff --git a/contrib/libgen/basename_r.c b/contrib/libgen/basename_r.c
index e3fae60d1..d63bce4e5 100644
--- a/contrib/libgen/basename_r.c
+++ b/contrib/libgen/basename_r.c
@@ -1,7 +1,10 @@
+#ifdef THREAD_UNSAFE_BASENAME
/*
* borrowed from glibc-2.12.1/string/basename.c
* Modified to return "." for NULL or "", as required for SUSv2.
*/
+#include <string.h>
+#include <stdlib.h>
/* Return the name-within-directory of a file name.
Copyright (C) 1996,97,98,2002 Free Software Foundation, Inc.
@@ -34,3 +37,4 @@ basename_r (filename)
p = strrchr (filename, '/');
return p ? p + 1 : (char *) filename;
}
+#endif /* THREAD_UNSAFE_BASENAME */
diff --git a/contrib/libgen/dirname_r.c b/contrib/libgen/dirname_r.c
index 78fe0ee8c..02981f5ec 100644
--- a/contrib/libgen/dirname_r.c
+++ b/contrib/libgen/dirname_r.c
@@ -1,9 +1,12 @@
+#ifdef THREAD_UNSAFE_DIRNAME
/*
* Borrowed from glibc-2.12.1/string/memrchr.c
* Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
* Removed code for long bigger than 32 bytes, renamed __ptr_t as void *
* changed reg_char type to char.
*/
+#include <string.h>
+#include <stdlib.h>
/* memrchr -- find the last occurrence of a byte in a memory block
Copyright (C) 1991, 93, 96, 97, 99, 2000 Free Software Foundation, Inc.
@@ -237,3 +240,4 @@ dirname_r (char *path)
return path;
}
+#endif /* THREAD_UNSAFE_DIRNAME */
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index ca83246ba..0156c974a 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -22,7 +22,8 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
$(CONTRIBDIR)/uuid/uuid_time.c $(CONTRIBDIR)/uuid/compare.c \
$(CONTRIBDIR)/uuid/isnull.c $(CONTRIBDIR)/uuid/unpack.c syncop.c \
graph-print.c trie.c run.c options.c fd-lk.c circ-buff.c \
- event-history.c gidcache.c ctx.c
+ event-history.c gidcache.c ctx.c \
+ $(CONTRIBDIR)/libgen/basename_r.c $(CONTRIBDIR)/libgen/dirname_r.c
nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c
diff --git a/libglusterfs/src/compat.c b/libglusterfs/src/compat.c
index 2f02eeac5..eb6d8d4b7 100644
--- a/libglusterfs/src/compat.c
+++ b/libglusterfs/src/compat.c
@@ -543,10 +543,3 @@ strnlen(const char *string, size_t maxlen)
return len;
}
#endif /* STRNLEN */
-
-#ifdef THREAD_UNSAFE_BASENAME
-#include "../../contrib/libgen/basename_r.c"
-#endif
-#ifdef THREAD_UNSAFE_DIRNAME
-#include "../../contrib/libgen/dirname_r.c"
-#endif