本文整理汇总了C++中MACH_PORT_VALID函数的典型用法代码示例。如果您正苦于以下问题:C++ MACH_PORT_VALID函数的具体用法?C++ MACH_PORT_VALID怎么用?C++ MACH_PORT_VALID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MACH_PORT_VALID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup_thread_target
error_t
setup_thread_target (void)
{
error_t err;
static task_t task;
static thread_t thread;
if (MACH_PORT_VALID (thread))
{
thread_terminate (thread);
mach_port_deallocate (mach_task_self (), thread);
}
if (MACH_PORT_VALID (task))
{
task_terminate (task);
mach_port_deallocate (mach_task_self (), task);
}
err = task_create (mach_task_self (), 0, &task);
if (err)
return err;
err = thread_create (task, &thread);
if (err)
return err;
return setup (thread, MACH_MSG_TYPE_COPY_SEND);
}
示例2: setup_proc_target
error_t
setup_proc_target (void)
{
error_t err;
static task_t task;
static process_t proc, target;
static mach_msg_type_name_t targetType = MACH_MSG_TYPE_COPY_SEND;
if (! MACH_PORT_VALID (proc))
proc = getproc ();
if (MACH_PORT_VALID (task))
mach_port_deallocate (mach_task_self (), task);
if (MACH_PORT_VALID (target))
mach_port_deallocate (mach_task_self (), target);
err = task_create (mach_task_self (), 0, &task);
if (err)
return err;
err = proc_task2proc (proc, task, &target);
if (err)
return err;
return setup (target, targetType);
}
示例3: mach_port_extract_member
kern_return_t
mach_port_extract_member(
ipc_space_t space,
mach_port_name_t name,
mach_port_name_t psname)
{
mach_port_name_t oldname;
ipc_object_t psobj;
ipc_object_t obj;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_PORT_VALID(name) || !MACH_PORT_VALID(psname))
return KERN_INVALID_RIGHT;
kr = ipc_object_translate_two(space,
name, MACH_PORT_RIGHT_RECEIVE, &obj,
psname, MACH_PORT_RIGHT_PORT_SET, &psobj);
if (kr != KERN_SUCCESS)
return kr;
/* obj and psobj are both locked (and were locked in that order) */
assert(psobj != IO_NULL);
assert(obj != IO_NULL);
kr = ipc_pset_remove((ipc_pset_t)psobj, (ipc_port_t)obj);
io_unlock(psobj);
io_unlock(obj);
return kr;
}
示例4: increase_priority
error_t
increase_priority (void)
{
mach_port_t pset = MACH_PORT_NULL, psetcntl = MACH_PORT_NULL;
error_t err;
err = thread_get_assignment (mach_thread_self (), &pset);
if (err)
goto out;
err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl);
if (err)
goto out;
err = thread_max_priority (mach_thread_self (), psetcntl, 0);
if (err)
goto out;
err = task_priority (mach_task_self (), 2, 1);
out:
if (MACH_PORT_VALID (pset))
mach_port_deallocate (mach_task_self (), pset);
if (MACH_PORT_VALID (psetcntl))
mach_port_deallocate (mach_task_self (), psetcntl);
return err;
}
示例5: mach_port_set_attributes
kern_return_t
mach_port_set_attributes(
ipc_space_t space,
mach_port_name_t name,
int flavor,
mach_port_info_t info,
mach_msg_type_number_t count)
{
ipc_port_t port;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
switch (flavor) {
case MACH_PORT_LIMITS_INFO: {
mach_port_limits_t *mplp = (mach_port_limits_t *)info;
if (count < MACH_PORT_LIMITS_INFO_COUNT)
return KERN_FAILURE;
if (mplp->mpl_qlimit > MACH_PORT_QLIMIT_MAX)
return KERN_INVALID_VALUE;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
ipc_mqueue_set_qlimit(&port->ip_messages, mplp->mpl_qlimit);
ip_unlock(port);
break;
}
case MACH_PORT_DNREQUESTS_SIZE: {
if (count < MACH_PORT_DNREQUESTS_SIZE_COUNT)
return KERN_FAILURE;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
kr = ipc_port_dngrow(port, *(int *)info);
if (kr != KERN_SUCCESS)
return kr;
break;
}
default:
return KERN_INVALID_ARGUMENT;
/*NOTREACHED*/
}
return KERN_SUCCESS;
}
示例6: ProtThreadRegister
extern void ProtThreadRegister(Bool setup)
{
kern_return_t kr;
mach_msg_type_number_t old_exception_count = 1;
exception_mask_t old_exception_masks;
exception_behavior_t behavior;
mach_port_t old_exception_ports;
exception_behavior_t old_behaviors;
thread_state_flavor_t old_flavors;
mach_port_t self;
static mach_port_t setupThread = MACH_PORT_NULL;
self = mach_thread_self();
AVER(MACH_PORT_VALID(self));
/* Avoid setting up the exception handler for the thread that calls
ProtSetup twice, in the case where the mutator registers that thread
explicitly. We need a special case because we don't require thread
registration of the sole thread of a single-threaded mutator. */
if (setup) {
AVER(setupThread == MACH_PORT_NULL);
setupThread = self;
} else {
AVER(setupThread != MACH_PORT_NULL);
if (self == setupThread)
return;
}
/* Ask to receive EXC_BAD_ACCESS exceptions on our port, complete
with thread state and identity information in the message.
The MACH_EXCEPTION_CODES flag causes the code fields to be
passed 64-bits wide, matching protRequestStruct [Fuller_2013]. */
behavior = (exception_behavior_t)(EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES);
AVER(MACH_PORT_VALID(protExcPort));
kr = thread_swap_exception_ports(self,
EXC_MASK_BAD_ACCESS,
protExcPort,
behavior,
THREAD_STATE_FLAVOR,
&old_exception_masks,
&old_exception_count,
&old_exception_ports,
&old_behaviors,
&old_flavors);
AVER(kr == KERN_SUCCESS);
if (kr != KERN_SUCCESS)
mach_error("ERROR: MPS thread_swap_exception_ports", kr); /* .trans.must */
AVER(old_exception_masks == EXC_MASK_BAD_ACCESS);
AVER(old_exception_count == 1);
AVER(old_exception_ports == MACH_PORT_NULL
|| old_exception_ports == protExcPort); /* .assume.only-port */
}
示例7: setup_auth_target
error_t
setup_auth_target (void)
{
static auth_t auth;
static mach_msg_type_name_t authType = MACH_MSG_TYPE_COPY_SEND;
if (MACH_PORT_VALID (auth))
mach_port_deallocate (mach_task_self (), auth);
auth = getauth ();
if (! MACH_PORT_VALID (auth))
return errno;
return setup (auth, authType);
}
示例8: inode_pager_setup
memory_object_t
inode_pager_setup(
struct inode *inode)
{
struct i_mem_object *imo;
if (inode == NULL)
return MEMORY_OBJECT_NULL;
imo = inode->i_mem_object;
if (imo == NULL) {
/*
* First time this inode is mapped. Create a memory object.
*/
imo = imo_create(inode, TRUE);
if (imo == NULL)
return MEMORY_OBJECT_NULL;
}
imo_ref(imo); /* 1 ref for the mapper */
#ifdef INODE_PAGER_DEBUG
if (inode_pager_debug) {
printk("inode_pager_setup: imo 0x%p: obj 0x%x, inode 0x%p\n",
imo, imo->imo_mem_obj, imo->imo_inode);
}
#endif /* INODE_PAGER_DEBUG */
ASSERT(MACH_PORT_VALID(imo->imo_mem_obj));
return imo->imo_mem_obj;
}
示例9: osfmach3_get_time
void
osfmach3_get_time(
struct timeval *xtime)
{
tvalspec_t cur_time;
#ifdef __powerpc__
if (use_highres && MACH_PORT_VALID(rt_clock)) {
kern_return_t kr;
/*
* We want a higher resolution time: ask the microkernel.
* XXX this doesn't work on MP PowerMac systems.
*/
kr = clock_get_time(rt_clock, &cur_time);
if (kr != KERN_SUCCESS) {
MACH3_DEBUG(2, kr,
("osfmach3_get_time: clock_get_time(0x%x)",
rt_clock));
/* use mapped time */
MTS_TO_TS(serv_mtime, &cur_time);
}
} else {
MTS_TO_TS(serv_mtime, &cur_time);
}
#else /* __powerpc__ */
MTS_TO_TS(serv_mtime, &cur_time);
#endif /* __powerpc__ */
xtime->tv_sec = cur_time.tv_sec + base_time.tv_sec;
xtime->tv_usec = (cur_time.tv_nsec + base_time.tv_nsec) / 1000;
if (xtime->tv_usec >= USEC_PER_SEC) {
xtime->tv_sec++;
xtime->tv_usec -= USEC_PER_SEC;
}
}
示例10: mach_port_set_seqno
kern_return_t
mach_port_set_seqno(
ipc_space_t space,
mach_port_name_t name,
mach_port_seqno_t seqno)
{
ipc_port_t port;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
ipc_mqueue_set_seqno(&port->ip_messages, seqno);
ip_unlock(port);
return KERN_SUCCESS;
}
示例11: mach_port_set_mscount
kern_return_t
mach_port_set_mscount(
ipc_space_t space,
mach_port_name_t name,
mach_port_mscount_t mscount)
{
ipc_port_t port;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
ipc_port_set_mscount(port, mscount);
ip_unlock(port);
return KERN_SUCCESS;
}
示例12: mach_port_mod_refs
kern_return_t
mach_port_mod_refs(
ipc_space_t space,
mach_port_name_t name,
mach_port_right_t right,
mach_port_delta_t delta)
{
ipc_entry_t entry;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (right >= MACH_PORT_RIGHT_NUMBER)
return KERN_INVALID_VALUE;
if (!MACH_PORT_VALID(name)) {
if (right == MACH_PORT_RIGHT_SEND ||
right == MACH_PORT_RIGHT_SEND_ONCE)
return KERN_SUCCESS;
return KERN_INVALID_NAME;
}
kr = ipc_right_lookup_write(space, name, &entry);
if (kr != KERN_SUCCESS)
return kr;
/* space is write-locked and active */
kr = ipc_right_delta(space, name, entry, right, delta); /* unlocks */
return kr;
}
示例13: mach_port_extract_right
kern_return_t
mach_port_extract_right(
ipc_space_t space,
mach_port_name_t name,
mach_msg_type_name_t msgt_name,
ipc_port_t *poly,
mach_msg_type_name_t *polyPoly)
{
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_MSG_TYPE_PORT_ANY(msgt_name))
return KERN_INVALID_VALUE;
if (!MACH_PORT_VALID(name)) {
/*
* really should copy out a dead name, if it is a send or
* send-once right being copied, but instead return an
* error for now.
*/
return KERN_INVALID_RIGHT;
}
kr = ipc_object_copyin(space, name, msgt_name, (ipc_object_t *) poly);
if (kr == KERN_SUCCESS)
*polyPoly = ipc_object_copyin_type(msgt_name);
return kr;
}
示例14: ThreadRegister
Res ThreadRegister(Thread *threadReturn, Arena arena)
{
Res res;
Thread thread;
Ring ring;
void *p;
AVER(threadReturn != NULL);
res = ControlAlloc(&p, arena, sizeof(ThreadStruct));
if (res != ResOK)
return res;
thread = (Thread)p;
thread->arena = arena;
RingInit(&thread->arenaRing);
thread->serial = arena->threadSerial;
++arena->threadSerial;
thread->alive = TRUE;
thread->forking = FALSE;
thread->port = mach_thread_self();
AVER(MACH_PORT_VALID(thread->port));
thread->sig = ThreadSig;
AVERT(Thread, thread);
ProtThreadRegister();
ring = ArenaThreadRing(arena);
RingAppend(ring, &thread->arenaRing);
*threadReturn = thread;
return ResOK;
}
示例15: main
int
main (int argc, char **argv)
{
error_t err;
mach_port_t bootstrap;
argp_parse (&argp, argc, argv, 0, 0, 0);
if (MACH_PORT_VALID (opt_device_master))
{
err = open_console (opt_device_master);
assert_perror (err);
mach_port_deallocate (mach_task_self (), opt_device_master);
}
save_argv = argv;
task_get_bootstrap_port (mach_task_self (), &bootstrap);
if (bootstrap == MACH_PORT_NULL)
error (2, 0, "Must be started as a translator");
/* Fetch our proc server port for easy use. If we are booting, it is not
set yet and `getproc' returns MACH_PORT_NULL; we reset PROCSERVER in
S_exec_init (below). */
procserver = getproc ();
err = trivfs_add_port_bucket (&port_bucket);
if (err)
error (1, 0, "error creating port bucket");
err = trivfs_add_control_port_class (&trivfs_control_class);
if (err)
error (1, 0, "error creating control port class");
err = trivfs_add_protid_port_class (&trivfs_protid_class);
if (err)
error (1, 0, "error creating protid port class");
execboot_portclass = ports_create_class (deadboot, NULL);
/* Reply to our parent. */
err = trivfs_startup (bootstrap, 0,
trivfs_control_class, port_bucket,
trivfs_protid_class, port_bucket, &fsys);
/* Reply to our parent. */
err = trivfs_startup (bootstrap, 0,
trivfs_control_class, port_bucket,
trivfs_protid_class, port_bucket,
&fsys);
mach_port_deallocate (mach_task_self (), bootstrap);
if (err)
error (3, err, "Contacting parent");
/* Launch. */
ports_manage_port_operations_multithread (port_bucket, exec_demuxer,
2 * 60 * 1000, 0, 0);
return 0;
}