summaryrefslogtreecommitdiff
path: root/empty.c
blob: 3adc8fa1d6759b56bf26d91e4d8e50ed037cb0b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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);
}