diff options
author | comex | 2015-01-25 21:56:22 -0500 |
---|---|---|
committer | comex | 2015-01-25 22:01:25 -0500 |
commit | 1b5ec6c220f3ea457077a17f4cf6003502a06bb0 (patch) | |
tree | 19f8594402414d15b94c237d0f99e6efb6ac415e /test/injected-test-dylib.c | |
parent | this is dumb (diff) | |
download | substitute-1b5ec6c220f3ea457077a17f4cf6003502a06bb0.tar.gz |
right, fix cleanup. (compared to the old system, this avoids busywaiting, and properly frees the thread resources)
Diffstat (limited to 'test/injected-test-dylib.c')
-rw-r--r-- | test/injected-test-dylib.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/injected-test-dylib.c b/test/injected-test-dylib.c new file mode 100644 index 0000000..9a92ff2 --- /dev/null +++ b/test/injected-test-dylib.c @@ -0,0 +1,26 @@ +#include "substitute-internal.h" +#include <stdio.h> +#include <mach/mach.h> +#include <assert.h> +__attribute__((constructor)) +static void hi() { + printf("constructor\n"); +} + +void substitute_init(struct shuttle *shuttle, size_t nshuttle) { + printf("substitute_init nshuttle=%zd\n", nshuttle); + assert(nshuttle == 1); + assert(shuttle[0].type == SUBSTITUTE_SHUTTLE_MACH_PORT); + struct { + mach_msg_header_t hdr; + char body[5]; + } msg; + msg.hdr.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); + msg.hdr.msgh_size = sizeof(msg); + msg.hdr.msgh_remote_port = shuttle[0].u.mach.port; + msg.hdr.msgh_local_port = 0; + msg.hdr.msgh_voucher_port = 0; + msg.hdr.msgh_id = 42; + strncpy(msg.body, "hello", 5); + assert(!mach_msg_send(&msg.hdr)); +} |