Fix <sys/sysmacros.h>.

1. The definitions were wrong.
2. The definitions were inline functions.
3. The definitions were polluting the namespace even for code that doesn't
   want BSD cruft.

Note that everybody will still get these by default, because you still get
all the BSD stuff by default.

Bug: http://b/12706131
Change-Id: I062ecd09feef7a6e8ba1922d465b96a9c4bf4f4e
diff --git a/libc/include/sys/sysmacros.h b/libc/include/sys/sysmacros.h
index 6f053a8..54e43dd 100644
--- a/libc/include/sys/sysmacros.h
+++ b/libc/include/sys/sysmacros.h
@@ -25,28 +25,20 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SYS_SYSMACROS_H_
 #define _SYS_SYSMACROS_H_
 
-/* some rogue code includes this file directly :-( */
-#ifndef _SYS_TYPES_H_
-# include <sys/types.h>
-#endif
+#define makedev(__major, __minor) \
+  ( \
+    (((__major) & 0xfffff000ULL) << 32) | (((__major) & 0xfffULL) << 8) | \
+    (((__minor) & 0xffffff00ULL) << 12) | (((__minor) & 0xffULL)) \
+  )
 
-static __inline__ int major(dev_t _dev)
-{
-  return (_dev >> 8) & 0xfff;
-}
+#define major(__dev) \
+  ((unsigned) ((((unsigned long long) (__dev) >> 32) & 0xfffff000) | (((__dev) >> 8) & 0xfff)))
 
-static __inline__ int minor(dev_t _dev)
-{
-  return (_dev & 0xff) | ((_dev >> 12) & 0xfff00);
-}
-
-static __inline__ dev_t makedev(int __ma, int __mi)
-{
-  return ((__ma & 0xfff) << 8) | (__mi & 0xff) | ((__mi & 0xfff00) << 12);
-}
+#define minor(__dev) \
+  ((unsigned) ((((__dev) >> 12) & 0xffffff00) | ((__dev) & 0xff)))
 
 #endif /* _SYS_SYSMACROS_H_ */
-
diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h
index a6b0fd8..217fd60 100644
--- a/libc/include/sys/types.h
+++ b/libc/include/sys/types.h
@@ -139,19 +139,18 @@
 typedef unsigned int        uint_t;
 typedef unsigned int        uint;
 
-/* for some applications */
+#ifdef __BSD_VISIBLE
 #include <sys/sysmacros.h>
 
-#ifdef __BSD_VISIBLE
-typedef	unsigned char	u_char;
-typedef	unsigned short	u_short;
-typedef	unsigned int	u_int;
-typedef	unsigned long	u_long;
+typedef unsigned char  u_char;
+typedef unsigned short u_short;
+typedef unsigned int   u_int;
+typedef unsigned long  u_long;
 
-typedef uint32_t       u_int32_t;
-typedef uint16_t       u_int16_t;
-typedef uint8_t        u_int8_t;
-typedef uint64_t       u_int64_t;
+typedef uint32_t u_int32_t;
+typedef uint16_t u_int16_t;
+typedef uint8_t  u_int8_t;
+typedef uint64_t u_int64_t;
 #endif
 
 #endif