Skip to content

Commit

Permalink
Add the Mach.replyPort() system call
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremie-koenig committed Jun 30, 2011
1 parent 55b7f9e commit 1cc37e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion HelloMach.java
Expand Up @@ -15,7 +15,7 @@ private static final int MSGH_BITS(int remote, int local) {

private static void hello(MachPort stdout) throws Exception {
ByteBuffer msg = ByteBuffer.allocateDirect(1000);
MachPort reply = MachPort.allocate();
MachPort reply = Mach.replyPort();

msg.order(ByteOrder.nativeOrder());

Expand Down
7 changes: 7 additions & 0 deletions mach/Mach.c
Expand Up @@ -2,6 +2,13 @@
#include <mach-java.h>
#include "Mach.h"

JNIEXPORT jobject JNICALL
Java_org_gnu_mach_Mach_replyPort (JNIEnv *env, jclass cls)
{
/* FIXME: exception */
return mach_java_makeport(env, mach_reply_port());
}

JNIEXPORT jint JNICALL
Java_org_gnu_mach_Mach_msg (JNIEnv *env, jclass cls, jobject msg, jint option,
jobject rcvName, jlong timeout, jobject notify)
Expand Down
11 changes: 11 additions & 0 deletions mach/Mach.java
@@ -1,6 +1,9 @@
package org.gnu.mach;
import java.nio.ByteBuffer;

/**
* Mach system calls.
*/
public class Mach {
public static final long MSG_TIMEOUT_NONE = 0;

Expand Down Expand Up @@ -29,6 +32,14 @@ public class Mach {
public static final int RCV_INTERRUPT = 0x00000400;
public static final int RCV_LARGE = 0x00000800;

/**
* Create a reply port.
*
* This is a wrapper around the mach_reply_port() system call, which
* creates a new MachPort object with the returned name.
*/
public static native MachPort replyPort();

/**
* Native call to mach_msg().
*
Expand Down

0 comments on commit 1cc37e5

Please sign in to comment.