123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include <stdlib.h>
- #include <assert.h>
- #include <stdio.h>
- #include <mach.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <sys/ioctl.h>
- #include <mach/mach_kernel.h>
- static mach_port_t mach_task_self_=0;
- extern mach_msg_return_t
- mach_msg
- (mach_msg_header_t *msg,
- mach_msg_option_t option,
- mach_msg_size_t send_size,
- mach_msg_size_t rcv_size,
- mach_port_t rcv_name,
- mach_msg_timeout_t timeout,
- mach_port_t notify)
- {
- struct mach_msg_args args;
- args.msg = msg;
- args.option = option;
- args.send_size = send_size;
- args.rcv_size = rcv_size;
- args.rcv_name = rcv_name;
- args.timeout = timeout;
- args.notify = notify;
- return ioctl(MACH_TRAP_DUMMY_FD,NR_mach_msg,&args);
- }
- #if 0
- mach_port_t mig_get_reply_port()
- {
- //TODO 3
- }
- void mig_dealloc_reply_port (mach_port_t port)
- {
- //TODO 4
- }
- void mig_put_reply_port (mach_port_t port)
- {
- //TODO 5
- }
- #endif
- mach_port_t mach_task_self()
- {
- return mach_task_self_;
- }
- kern_return_t mach_port_allocate
- (ipc_space_t task,
- mach_port_right_t right,
- mach_port_t *name)
- {
- struct mach_port_allocate_args args;
- args.task = task;
- args.right = right;
- args.name = name;
- return ioctl(MACH_TRAP_DUMMY_FD,NR_mach_port_allocate,&args);
- }
- void gnumach_init(void)
- {
- //ioctl(MACH_TRAP_DUMMY_FD,0);//get api version
- mach_task_self_ = ioctl(MACH_TRAP_DUMMY_FD,NR_mach_task_self);
-
- }
|