summaryrefslogtreecommitdiff
path: root/src/shared/missing.h
diff options
context:
space:
mode:
authorblueness <basile@opensource.dyc.edu>2015-09-11 14:44:10 -0400
committerblueness <basile@opensource.dyc.edu>2015-09-11 14:44:10 -0400
commit0cc8789c71ec4c5d359fb84861a10de6e863ae13 (patch)
tree17a89fbb4b78d69d6a2c680d983eabddf6aef470 /src/shared/missing.h
parent6de52b4e649bd77bb3adff7f7c564c90ae1e463e (diff)
parent0e2be0c217028e73073e7f9ccb010cc8b4d756db (diff)
Merge pull request #122 from RomainNaour/musl-fixes
Musl fixes
Diffstat (limited to 'src/shared/missing.h')
-rw-r--r--src/shared/missing.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 2dc9d842d3..9031119a45 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -158,3 +158,14 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle
#ifndef AT_EMPTY_PATH
#define AT_EMPTY_PATH 0x1000
#endif
+
+#if !HAVE_DECL_STRNDUPA
+#define strndupa(s, n) \
+ ({ \
+ const char *__old = (s); \
+ size_t __len = strnlen(__old, (n)); \
+ char *__new = (char *)alloca(__len + 1); \
+ __new[__len] = '\0'; \
+ (char *)memcpy(__new, __old, __len); \
+ })
+#endif