- be gentle to the intel compiler and make sure we have __u64 which is needed for...
[oweals/busybox.git] / include / platform.h
index 860143f7f9f3b14690bf4a2eb202162f87c7bea5..69d031dcae377fddde7b25a0228aaf6afb095e11 100644 (file)
@@ -133,6 +133,14 @@ typedef int socklen_t;
 #endif
 
 /* ---- Compiler dependent settings ------------------------- */
+#if (defined __digital__ && defined __unix__)
+# undef HAVE_MNTENT_H
+#else
+# define HAVE_MNTENT_H 1
+#endif /* ___digital__ && __unix__ */
+
+/* linux/loop.h relies on __u64. Make sure we have that as a proper type
+ * until userspace is widely fixed.  */
 #ifndef __GNUC__
 #if defined __INTEL_COMPILER
 __extension__ typedef __signed__ long long __s64;
@@ -140,12 +148,6 @@ __extension__ typedef unsigned long long __u64;
 #endif /* __INTEL_COMPILER */
 #endif /* ifndef __GNUC__ */
 
-#if (defined __digital__ && defined __unix__)
-# undef HAVE_MNTENT_H
-#else
-# define HAVE_MNTENT_H 1
-#endif /* ___digital__ && __unix__ */
-
 /*----- Kernel versioning ------------------------------------*/
 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
 
@@ -179,6 +181,27 @@ typedef unsigned long long int  uintmax_t;
 #endif
 #endif
 
+/* Size-saving "small" ints (arch-dependent) */
+#if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__)
+/* add other arches which benefit from this... */
+typedef signed char smallint;
+typedef unsigned char smalluint;
+#else
+/* for arches where byte accesses generate larger code: */
+typedef int smallint;
+typedef unsigned smalluint;
+#endif
+
+/* ISO C Standard:  7.16  Boolean type and values  <stdbool.h> */
+#if (defined __digital__ && defined __unix__)
+/* old system without (proper) C99 support */
+#define bool smalluint
+#else
+/* modern system, so use it */
+#include <stdbool.h>
+#endif
+
+
 /* uclibc does not implement daemon() for no-mmu systems.
  * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably.
  * For earlier versions there is no reliable way to check if we are building
@@ -193,9 +216,18 @@ typedef unsigned long long int  uintmax_t;
 /* Platforms that haven't got dprintf need to implement fdprintf() in
  * libbb.  This would require a platform.c.  It's not going to be cleaned
  * out of the tree, so stop saying it should be. */
+#if !defined(__dietlibc__)
+/* Needed for: glibc */
+/* Not needed for: dietlibc */
+/* Others: ?? (add as needed) */
 #define fdprintf dprintf
-#ifdef __dietlibc__
-int dprintf(int fd, const char *format, ...);
+#endif
+
+#if defined(__dietlibc__)
+static ATTRIBUTE_ALWAYS_INLINE char* strchrnul(const char *s, char c) {
+       while (*s && *s != c) ++s;
+       return (char*)s;
+}
 #endif
 
 /* Don't use lchown with glibc older than 2.1.x ... uC-libc lacks it */
@@ -218,7 +250,7 @@ int dprintf(int fd, const char *format, ...);
 #define PRIu32 "u"
 
 /* use legacy setpgrp(pidt_,pid_t) for now.  move to platform.c */
-#define bb_setpgrp do{pid_t __me = getpid();setpgrp(__me,__me);}while(0)
+#define bb_setpgrp do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0)
 
 #if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET
 #define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET)