diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-12-19 10:13:09 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-12-19 15:31:03 +0100 |
commit | 58dedd2cc54d59875b114d4edcadd6bd589ff37c (patch) | |
tree | c3da9ccc20a6655bd82644b32e00e14552f384df /empty.c |
Initial checkin.
Diffstat (limited to 'empty.c')
-rw-r--r-- | empty.c | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014 Justus Winter <4winter@informatik.uni-hamburg.de> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define _GNU_SOURCE +#include <hurd.h> +#include <error.h> +#include <mach.h> +#include <stdio.h> +#include <stdlib.h> + +static mach_msg_header_t send_buffer = { + .msgh_bits = MACH_MSGH_BITS_REMOTE(MACH_MSG_TYPE_MAKE_SEND), +}; + +error_t +send_empty (mach_port_t server) +{ + send_buffer.msgh_remote_port = server; + + return mach_msg (&send_buffer, + MACH_SEND_MSG|MACH_MSG_OPTION_NONE, + sizeof (send_buffer), + 0, + MACH_PORT_NULL, + MACH_MSG_TIMEOUT_NONE, + MACH_PORT_NULL); +} + +static mach_msg_header_t receive_buffer = { + .msgh_size = sizeof (receive_buffer), +}; + +error_t +receive_empty (mach_port_t port) +{ + return mach_msg (&receive_buffer, + MACH_RCV_MSG|MACH_MSG_OPTION_NONE, + 0, + sizeof (receive_buffer), + port, + MACH_MSG_TIMEOUT_NONE, + MACH_PORT_NULL); +} |