*: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
[oweals/busybox.git] / include / platform.h
index 0e0ccaf90c69bc0547b59086fcb7ea8026c2f2da..8d6ed9a3e4166a9a743a01caaa2393483dc03b87 100644 (file)
 # endif
 #endif
 
+#if __GNUC_PREREQ(3,0) && defined(i386)
+/* || defined(__x86_64__)? */
+# define FAST_FUNC __attribute__((regparm(3)))
+#else
+# define FAST_FUNC
+#endif
+
 /* ---- Endian Detection ------------------------------------ */
 
 #if (defined __digital__ && defined __unix__)
 #define SWAP_LE64(x) (x)
 #endif
 
+/* ---- Unaligned access ------------------------------------ */
+
+/* parameter is supposed to be an uint32_t* ptr */
+#if defined(i386) || defined(__x86_64__) /* + other arches? */
+#define get_unaligned_u32p(u32p) (*(u32p))
+#else
+/* performs reasonably well (gcc usually inlines memcpy here) */
+#define get_unaligned_u32p(u32p) ({ uint32_t __t; memcpy(&__t, (u32p), 4); __t; })
+#endif
+
 /* ---- Networking ------------------------------------------ */
+
 #ifndef __APPLE__
 # include <arpa/inet.h>
 # ifndef __socklen_t_defined
@@ -146,6 +164,7 @@ typedef int socklen_t;
 #endif
 
 /* ---- Compiler dependent settings ------------------------- */
+
 #if (defined __digital__ && defined __unix__) || defined __APPLE__
 # undef HAVE_MNTENT_H
 # undef HAVE_SYS_STATFS_H
@@ -163,9 +182,10 @@ __extension__ typedef unsigned long long __u64;
 #endif
 
 /*----- Kernel versioning ------------------------------------*/
+
 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
 
-/* ---- miscellaneous --------------------------------------- */
+/* ---- Miscellaneous --------------------------------------- */
 
 #if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ < 5 && \
        !defined(__dietlibc__) && \
@@ -235,12 +255,10 @@ typedef unsigned smalluint;
     (defined __UCLIBC__ && __UCLIBC_MAJOR__ >= 0 && __UCLIBC_MINOR__ >= 9 && \
     __UCLIBC_SUBLEVEL__ > 28 && !defined __ARCH_USE_MMU__)
 #define BB_MMU 0
-#define BB_NOMMU 1
 #define USE_FOR_NOMMU(...) __VA_ARGS__
 #define USE_FOR_MMU(...)
 #else
 #define BB_MMU 1
-/* BB_NOMMU is not defined in this case! */
 #define USE_FOR_NOMMU(...)
 #define USE_FOR_MMU(...) __VA_ARGS__
 #endif