[fuchsia] Cleanup bioniccompat.

Bug: NONE
Test: Compile fuchsia, walleye.

Change-Id: Ic2f198c17578b234206d5ba84354b7ddd5f2d36c
diff --git a/bioniccompat/include/basename.h b/bioniccompat/include/basename.h
index b19540b..a156e38 100644
--- a/bioniccompat/include/basename.h
+++ b/bioniccompat/include/basename.h
@@ -18,10 +18,16 @@
 #ifndef BASENAME_H
 #define BASENAME_H
 
-extern "C" inline const char* __gnu_basename(const char* path) {
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+inline const char* __gnu_basename(const char* path) {
   const char* last_slash = strrchr(path, '/');
   return (last_slash != NULL) ? last_slash + 1 : path;
 }
 #define basename __gnu_basename
 
+__END_DECLS
+
 #endif  // BASENAME_H
diff --git a/bioniccompat/include/compat/fcntl.h b/bioniccompat/include/compat/fcntl.h
index 8891e07..bcf807b 100644
--- a/bioniccompat/include/compat/fcntl.h
+++ b/bioniccompat/include/compat/fcntl.h
@@ -19,6 +19,7 @@
 #include <fcntl.h>
 
 #include <errno.h>
+#include <sys/cdefs.h>
 
 /*
  * zircon does not support this operation.
diff --git a/bioniccompat/include/compat/pwd.h b/bioniccompat/include/compat/pwd.h
index 3d07972..923e0b3 100644
--- a/bioniccompat/include/compat/pwd.h
+++ b/bioniccompat/include/compat/pwd.h
@@ -17,12 +17,12 @@
 #ifndef COMPAT_PWD_H
 #define COMPAT_PWD_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <pwd.h>
 
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
 static struct passwd PASSWORD = {
   .pw_name = (char *)"android",
   .pw_uid = 1,
@@ -45,8 +45,6 @@
   return 0;
 }
 
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
 
 #endif  // COMPAT_PWD_H
diff --git a/bioniccompat/include/sys/capability.h b/bioniccompat/include/sys/capability.h
index c49d103..8a7213d 100644
--- a/bioniccompat/include/sys/capability.h
+++ b/bioniccompat/include/sys/capability.h
@@ -18,26 +18,31 @@
 #define SYS_CAPABILITY_H
 
 #include <errno.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
 
 typedef struct __user_cap_header_struct {
-  u_int32_t version;
+  uint32_t version;
   int pid;
 } *cap_user_header_t;
 
 typedef struct __user_cap_data_struct {
-  u_int32_t effective;
-  u_int32_t permitted;
-  u_int32_t inheritable;
+  uint32_t effective;
+  uint32_t permitted;
+  uint32_t inheritable;
 } *cap_user_data_t;
 
-extern "C" inline int capget(cap_user_header_t hdrp, cap_user_data_t datap) {
+inline int capget(cap_user_header_t hdrp, cap_user_data_t datap) {
   datap->effective = datap->permitted = datap->inheritable = 0;
   return 0;
 }
 
-extern "C" inline int capset(cap_user_header_t hdrp, const cap_user_data_t datap) {
+inline int capset(cap_user_header_t hdrp, const cap_user_data_t datap) {
   errno = EPERM;
   return -1;
 }
 
+__END_DECLS
+
 #endif  // SYS_CAPABILITY_H
diff --git a/bioniccompat/include/sys/cdefs.h b/bioniccompat/include/sys/cdefs.h
index 3f721bf..e9c44b4 100644
--- a/bioniccompat/include/sys/cdefs.h
+++ b/bioniccompat/include/sys/cdefs.h
@@ -21,3 +21,7 @@
 #define __BEGIN_DECLS
 #define __END_DECLS
 #endif
+
+#ifndef __UNUSED
+#define __UNUSED __attribute__((__unused__))
+#endif  // __UNUSED
diff --git a/bioniccompat/include/sys/compat/mman.h b/bioniccompat/include/sys/compat/mman.h
index 9336def..f92b110 100644
--- a/bioniccompat/include/sys/compat/mman.h
+++ b/bioniccompat/include/sys/compat/mman.h
@@ -18,13 +18,18 @@
 #define SYS_COMPAT_MMAN_H
 
 #include "mman.h"
+#include "sys/cdefs.h"
+
+__BEGIN_DECLS
 
 // Fuchsia holds all pages in memory, see http://b/119503290 for more.
-extern "C" inline int mincore(void *addr __UNUSED, size_t length, unsigned char *vec) {
+inline int mincore(void *addr __UNUSED, size_t length, unsigned char *vec) {
   for(size_t i = 0; i < length; i++) {
     vec[i] = 1;
   }
   return 0;
 }
 
+__END_DECLS
+
 #endif  // SYS_COMPAT_MMAN_H
diff --git a/bioniccompat/include/sys/compat/types.h b/bioniccompat/include/sys/compat/types.h
index a477235..7315be3 100644
--- a/bioniccompat/include/sys/compat/types.h
+++ b/bioniccompat/include/sys/compat/types.h
@@ -17,9 +17,12 @@
 #ifndef SYS_COMPAT_TYPES_H
 #define SYS_COMPAT_TYPES_H
 
+#include <sys/cdefs.h>
 #include <threads.h>
 #include <zircon/process.h>
 
+__BEGIN_DECLS
+
 /*
  * Zircon does not define an identifier for thread id. Instead
  * we rely on the handle. This is slightly risky as there is a
@@ -28,8 +31,10 @@
  * future. In particular, we should revisit when the Zircon team
  * determines whether or not to implement actual thread IDs.
  */
-extern "C" inline pid_t gettid() {
+inline pid_t gettid() {
   return zx_thread_self();
 }
 
+__END_DECLS
+
 #endif  // SYS_COMPAT_TYPES_H
diff --git a/bioniccompat/include/sys/prctl.h b/bioniccompat/include/sys/prctl.h
index ec5b127..2d7d8a0 100644
--- a/bioniccompat/include/sys/prctl.h
+++ b/bioniccompat/include/sys/prctl.h
@@ -18,14 +18,19 @@
 #define SYS_PRCTL_H
 
 #include <errno.h>
+#include <sys/cdefs.h>
 
-extern "C" inline int prctl(int option,
-                            unsigned long arg2,
-                            unsigned long arg3,
-                            unsigned long arg4,
-                            unsigned long arg5) {
+__BEGIN_DECLS
+
+inline int prctl(int option,
+                 unsigned long arg2,
+                 unsigned long arg3,
+                 unsigned long arg4,
+                 unsigned long arg5) {
   errno = EINVAL;
   return -1;
 }
 
+__END_DECLS
+
 #endif  // SYS_PRCTL_H
diff --git a/bioniccompat/include/sys/resource.h b/bioniccompat/include/sys/resource.h
index bc4cab1..fba944f 100644
--- a/bioniccompat/include/sys/resource.h
+++ b/bioniccompat/include/sys/resource.h
@@ -18,6 +18,10 @@
 #ifndef SYS_RESOURCE_H
 #define SYS_RESOURCE_H
 
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
 typedef unsigned long rlim_t;
 
 #define RLIM_INFINITY ((rlim_t) -1)
@@ -31,7 +35,7 @@
  * Fuchsia has no concept of resource limits yet. Tell the system that
  * usage is unlimited (no soft or hard cap).
  */
-extern "C" inline int getrlimit(int resource, struct rlimit *rlim) {
+inline int getrlimit(int resource, struct rlimit *rlim) {
   if (!rlim) {
     errno = EINVAL;
     return -1;
@@ -41,4 +45,6 @@
   return 0;
 }
 
+__END_DECLS
+
 #endif  // SYS_RESOURCE_H
diff --git a/bioniccompat/include/sys/sendfile.h b/bioniccompat/include/sys/sendfile.h
index 80e2878..6a4c6c0 100644
--- a/bioniccompat/include/sys/sendfile.h
+++ b/bioniccompat/include/sys/sendfile.h
@@ -17,13 +17,11 @@
 #ifndef SYS_SENDFILE_H
 #define SYS_SENDFILE_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
+__BEGIN_DECLS
+
 /*
  * sendfile() here is a relatively straightforward implementation, but
  * obviously not as efficient as the typical syscall implementation which
@@ -32,8 +30,6 @@
  */
 ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count);
 
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
 
 #endif  // SYS_SENDFILE_H
diff --git a/bioniccompat/include/sys/xattr.h b/bioniccompat/include/sys/xattr.h
index 77674ca..fc31abb 100644
--- a/bioniccompat/include/sys/xattr.h
+++ b/bioniccompat/include/sys/xattr.h
@@ -17,11 +17,10 @@
 #ifndef SYS_XATTR_H
 #define SYS_XATTR_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <errno.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
 
 #ifndef ENOATTR
 #define ENOATTR ENODATA
@@ -52,8 +51,6 @@
   return -1;
 }
 
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
 
 #endif  // SYS_XATTR_H