#ifdef __GNUC__
#define noreturn __attribute__((noreturn))
+#if CFG_TOYBOX_DEBUG
+#define printf_format __attribute__((format(printf, 1, 2)))
+#else
+#define printf_format
+#endif
#else
#define noreturn
+#define printf_format
#endif
// Always use long file support.
#include <features.h>
+// Types various replacement prototypes need
+#include <sys/types.h>
+
// Various constants old build environments might not have even if kernel does
#ifndef AT_FDCWD
// correct name to the broken name.
char *dirname(char *path);
-char *__xpg_basename (char *path);
+char *__xpg_basename(char *path);
static inline char *basename(char *path) { return __xpg_basename(path); }
// uClibc pretends to be glibc and copied a lot of its bugs, but has a few more
#endif // glibc in general
-#ifndef __GLIBC__
+#if !defined(__GLIBC__) && !defined(__BIONIC__)
// POSIX basename.
#include <libgen.h>
#endif
-#ifdef __MUSL__
-#include <unistd.h>
-// Without this "rm -r dir" fails with "is directory".
-#define faccessat(A, B, C, D) faccessat(A, B, C, 0)
+// glibc was handled above; for 32-bit bionic we need to avoid a collision
+// with toybox's basename_r so we can't include <libgen.h> even though that
+// would give us a POSIX basename(3).
+#if defined(__BIONIC__)
+char *basename(char *path);
+char *dirname(char *path);
#endif
// Work out how to do endianness
#define O_NOFOLLOW 0
#endif
+#ifndef O_NOATIME
+#define O_NOATIME 01000000
+#endif
+
#ifndef O_CLOEXEC
#define O_CLOEXEC 02000000
#endif
+#ifndef O_PATH
+#define O_PATH 010000000
+#endif
+
#if defined(__SIZEOF_DOUBLE__) && defined(__SIZEOF_LONG__) \
&& __SIZEOF_DOUBLE__ <= __SIZEOF_LONG__
typedef double FLOAT;
#endif
//#define strncpy(...) @@strncpyisbadmmkay@@
-//#define strncat(...) @@strcatisbadmmkay@@
+//#define strncat(...) @@strncatisbadmmkay@@
-#if CFG_TOYBOX_SELINUX
-#include <selinux/selinux.h>
-#else
-#define is_selinux_enabled() 0
-int getcon(void* con);
-#endif