From c3ca6f01a3204ac81397d5abe77c1280d8eb0591 Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 11 Jul 2015 16:12:18 -0400 Subject: fix anti-noise --- darwin-bootstrap/bundle-loader.c | 2 +- darwin-bootstrap/substituted.m | 4 +-- lib/darwin/xxpc.h | 66 ++++++++++++++++++++++++++++++++++++++++ lib/xxpc.h | 63 -------------------------------------- 4 files changed, 69 insertions(+), 66 deletions(-) create mode 100644 lib/darwin/xxpc.h delete mode 100644 lib/xxpc.h diff --git a/darwin-bootstrap/bundle-loader.c b/darwin-bootstrap/bundle-loader.c index 90ebbf2..49e6152 100644 --- a/darwin-bootstrap/bundle-loader.c +++ b/darwin-bootstrap/bundle-loader.c @@ -2,7 +2,7 @@ #define IB_LOG_TO_SYSLOG #include "ib-log.h" #include "darwin/mach-decls.h" -#include "xxpc.h" +#include "darwin/xxpc.h" #include #include #include diff --git a/darwin-bootstrap/substituted.m b/darwin-bootstrap/substituted.m index 28576ea..ca793ba 100644 --- a/darwin-bootstrap/substituted.m +++ b/darwin-bootstrap/substituted.m @@ -1,6 +1,6 @@ #import #import -#include "xxpc.h" +#include "darwin/xxpc.h" #include "substitute.h" /* This is a daemon contacted by all processes which can load extensions. It @@ -231,7 +231,7 @@ static void init_peer(xxpc_object_t peer) { xxpc_connection_cancel(peer); xxpc_release(reply); } else if (ty == XXPC_TYPE_ERROR) { - if (event == XXPC_ERROR_CONNECTION_INTERRUPTED) + if (event == XXPC_ERROR_CONNECTION_INVALID) return; NSLog(@"XPC error from peer: %@", event); } else { diff --git a/lib/darwin/xxpc.h b/lib/darwin/xxpc.h new file mode 100644 index 0000000..88aab7a --- /dev/null +++ b/lib/darwin/xxpc.h @@ -0,0 +1,66 @@ +#pragma once +/* distinct names to avoid incompatibility if gets included somehow + * on OS X. No ARC support! */ +#include + +typedef struct _xxpc_object { + int x; +} *xxpc_object_t, *xxpc_connection_t, *xxpc_type_t; +typedef void (^xxpc_handler_t)(xxpc_object_t); + +#define DEFINE_CONST(name, sym) \ + extern struct _xxpc_object name[1] asm("_" #sym) + +DEFINE_CONST(XXPC_TYPE_CONNECTION, _xpc_type_connection); +DEFINE_CONST(XXPC_TYPE_ERROR, _xpc_type_error); +DEFINE_CONST(XXPC_TYPE_DICTIONARY, _xpc_type_dictionary); +DEFINE_CONST(XXPC_TYPE_ARRAY, _xpc_type_array); +DEFINE_CONST(XXPC_TYPE_STRING, _xpc_type_string); +DEFINE_CONST(XXPC_ERROR_CONNECTION_INTERRUPTED, + _xpc_error_connection_interrupted); +DEFINE_CONST(XXPC_ERROR_CONNECTION_INVALID, + _xpc_error_connection_invalid); + + +#define XXPC_ARRAY_APPEND -1 +#define XXPC_CONNECTION_MACH_SERVICE_LISTENER 1 + +#define WRAP(name, args...) \ + x##name args asm("_" #name) + +void WRAP(xpc_release, (xxpc_object_t)); +xxpc_object_t WRAP(xpc_retain, (xxpc_object_t)); +char *WRAP(xpc_copy_description, (xxpc_object_t)); + +xxpc_type_t WRAP(xpc_get_type, (xxpc_object_t)); +xxpc_object_t WRAP(xpc_string_create, (const char *)); +void WRAP(xpc_array_append_value, (xxpc_object_t, xxpc_object_t)); +xxpc_object_t WRAP(xpc_array_create, (const xxpc_object_t *, size_t)); +size_t WRAP(xpc_array_get_count, (const xxpc_object_t)); +xxpc_object_t WRAP(xpc_array_get_value, (xxpc_object_t, size_t)); +const char *WRAP(xpc_array_get_string, (xxpc_object_t, size_t)); +void WRAP(xpc_array_set_string, (xxpc_object_t, size_t, const char *)); +xxpc_object_t WRAP(xpc_dictionary_create, (const char *const *, + const xxpc_object_t *, size_t)); + +xxpc_object_t WRAP(xpc_dictionary_create_reply, (xxpc_object_t)); +bool WRAP(xpc_dictionary_get_bool, (xxpc_object_t, const char *)); +const char *WRAP(xpc_dictionary_get_string, (xxpc_object_t, const char *)); +xxpc_object_t WRAP(xpc_dictionary_get_value, (xxpc_object_t, const char *)); +void WRAP(xpc_dictionary_set_bool, (xxpc_object_t, const char *, bool)); +void WRAP(xpc_dictionary_set_string, (xxpc_object_t, const char *, const char *)); +void WRAP(xpc_dictionary_set_value, (xxpc_object_t, const char *, xxpc_object_t)); + +xxpc_connection_t WRAP(xpc_connection_create_mach_service, (const char *, + dispatch_queue_t, + uint64_t)); +void WRAP(xpc_connection_resume, (xxpc_connection_t)); +void WRAP(xpc_connection_set_event_handler, (xxpc_connection_t, xxpc_handler_t)); +void WRAP(xpc_connection_send_message_with_reply, + (xxpc_connection_t, xxpc_object_t, dispatch_queue_t, xxpc_handler_t)); +void WRAP(xpc_connection_send_message, (xxpc_connection_t, xxpc_object_t)); +void WRAP(xpc_connection_cancel, (xxpc_connection_t)); + +#undef DEFINE_TYPE +#undef DEFINE_CONST +#undef WRAP diff --git a/lib/xxpc.h b/lib/xxpc.h deleted file mode 100644 index 1e2bb5b..0000000 --- a/lib/xxpc.h +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once -/* distinct names to avoid incompatibility if gets included somehow - * on OS X. No ARC support! */ -#include - -typedef struct _xxpc_object { - int x; -} *xxpc_object_t, *xxpc_connection_t, *xxpc_type_t; -typedef void (^xxpc_handler_t)(xxpc_object_t); - -#define DEFINE_CONST(name, sym) \ - extern struct _xxpc_object name[1] asm("_" #sym) - -DEFINE_CONST(XXPC_TYPE_CONNECTION, _xpc_type_connection); -DEFINE_CONST(XXPC_TYPE_ERROR, _xpc_type_error); -DEFINE_CONST(XXPC_TYPE_DICTIONARY, _xpc_type_dictionary); -DEFINE_CONST(XXPC_TYPE_ARRAY, _xpc_type_array); -DEFINE_CONST(XXPC_TYPE_STRING, _xpc_type_string); -DEFINE_CONST(XXPC_ERROR_CONNECTION_INTERRUPTED, _xpc_error_connection_interrupted); - - -#define XXPC_ARRAY_APPEND -1 -#define XXPC_CONNECTION_MACH_SERVICE_LISTENER 1 - -#define WRAP(name, args...) \ - x##name args asm("_" #name) - -void WRAP(xpc_release, (xxpc_object_t)); -xxpc_object_t WRAP(xpc_retain, (xxpc_object_t)); -char *WRAP(xpc_copy_description, (xxpc_object_t)); - -xxpc_type_t WRAP(xpc_get_type, (xxpc_object_t)); -xxpc_object_t WRAP(xpc_string_create, (const char *)); -void WRAP(xpc_array_append_value, (xxpc_object_t, xxpc_object_t)); -xxpc_object_t WRAP(xpc_array_create, (const xxpc_object_t *, size_t)); -size_t WRAP(xpc_array_get_count, (const xxpc_object_t)); -xxpc_object_t WRAP(xpc_array_get_value, (xxpc_object_t, size_t)); -const char *WRAP(xpc_array_get_string, (xxpc_object_t, size_t)); -void WRAP(xpc_array_set_string, (xxpc_object_t, size_t, const char *)); -xxpc_object_t WRAP(xpc_dictionary_create, (const char *const *, - const xxpc_object_t *, size_t)); - -xxpc_object_t WRAP(xpc_dictionary_create_reply, (xxpc_object_t)); -bool WRAP(xpc_dictionary_get_bool, (xxpc_object_t, const char *)); -const char *WRAP(xpc_dictionary_get_string, (xxpc_object_t, const char *)); -xxpc_object_t WRAP(xpc_dictionary_get_value, (xxpc_object_t, const char *)); -void WRAP(xpc_dictionary_set_bool, (xxpc_object_t, const char *, bool)); -void WRAP(xpc_dictionary_set_string, (xxpc_object_t, const char *, const char *)); -void WRAP(xpc_dictionary_set_value, (xxpc_object_t, const char *, xxpc_object_t)); - -xxpc_connection_t WRAP(xpc_connection_create_mach_service, (const char *, - dispatch_queue_t, - uint64_t)); -void WRAP(xpc_connection_resume, (xxpc_connection_t)); -void WRAP(xpc_connection_set_event_handler, (xxpc_connection_t, xxpc_handler_t)); -void WRAP(xpc_connection_send_message_with_reply, - (xxpc_connection_t, xxpc_object_t, dispatch_queue_t, xxpc_handler_t)); -void WRAP(xpc_connection_send_message, (xxpc_connection_t, xxpc_object_t)); -void WRAP(xpc_connection_cancel, (xxpc_connection_t)); - -#undef DEFINE_TYPE -#undef DEFINE_CONST -#undef WRAP -- cgit v1.2.3