On 8/23/12 2:51 PM, Pekka Enberg wrote:
+#ifdef ANDROID
+/* While stdlib.h has a prototype for it,
+   Bionic doesn't actually implement on_exit() */
+#ifndef ATEXIT_MAX
+#define ATEXIT_MAX 32
+#endif
+static int __on_exit_count = 0;
+typedef void (*on_exit_func_t)(int, void*);
+static on_exit_func_t __on_exit_funcs[ATEXIT_MAX];
+static void *__on_exit_args[ATEXIT_MAX];
+static int __exitcode = 0;
+static void __handle_on_exit_funcs();
+static int on_exit(on_exit_func_t function, void *arg);
+#define exit(x) (exit)(__exitcode = (x))
+
+static int on_exit(on_exit_func_t function, void *arg) {
+       if(__on_exit_count == ATEXIT_MAX)
+               return ENOMEM;
+       else if(__on_exit_count == 0)
+               atexit(__handle_on_exit_funcs);
+       __on_exit_funcs[__on_exit_count] = function;
+       __on_exit_args[__on_exit_count++] = arg;
+       return 0;
+}
+
+static void __handle_on_exit_funcs() {
+       for(int i=0; i<__on_exit_count; i++) {
+               __on_exit_funcs[i](__exitcode, __on_exit_args[i]);
+       }
+}
+#endif
+

Why not add support for the missing functions (on_exit, getsid, psignal and getline) to Bionic instead of perf?


diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0f99f39..77c5ced 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -70,15 +70,19 @@
  #include <sys/socket.h>
  #include <sys/ioctl.h>
  #include <sys/select.h>
+#ifndef ANDROID
  #include <netinet/in.h>
  #include <netinet/tcp.h>
  #include <arpa/inet.h>
+#endif
  #include <netdb.h>

netinet/*, arpa/inet.h,netdb.h and sys/socket.h can be removed from util.h

David

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to