const Where &AbstractRangeElement::bottomOfCallout() { Callout *co = callout(); if (co) { return co->bottomOfCallout(); } static Where empty; return empty; }
/* * Use the device, fileid pair to snoop an incore cnode. * * A cnode can exists in chash even after it has been * deleted from the catalog, so this function returns * ENOENT if C_NOEXIST is set in the cnode's flag. * */ int hfs_chash_snoop(struct hfsmount *hfsmp, ino_t inum, int existence_only, int (*callout)(const struct cat_desc *, const struct cat_attr *, void *), void * arg) { struct cnode *cp; int result = ENOENT; /* * Go through the hash list * If a cnode is in the process of being cleaned out or being * allocated, wait for it to be finished and then try again. */ hfs_chash_lock(hfsmp); for (cp = CNODEHASH(hfsmp, inum)->lh_first; cp; cp = cp->c_hash.le_next) { if (cp->c_fileid != inum) continue; /* * Under normal circumstances, we would want to return ENOENT if a cnode is in * the hash and it is marked C_NOEXISTS or C_DELETED. However, if the CNID * namespace has wrapped around, then we have the possibility of collisions. * In that case, we may use this function to validate whether or not we * should trust the nextCNID value in the hfs mount point. * * If we didn't do this, then it would be possible for a cnode that is no longer backed * by anything on-disk (C_NOEXISTS) to still exist in the hash along with its * vnode. The cat_create routine could then create a new entry in the catalog * re-using that CNID. Then subsequent hfs_getnewvnode calls will repeatedly fail * trying to look it up/validate it because it is marked C_NOEXISTS. So we want * to prevent that from happening as much as possible. */ if (existence_only) { result = 0; break; } /* Skip cnodes that have been removed from the catalog */ if (cp->c_flag & (C_NOEXISTS | C_DELETED)) { break; } /* Skip cnodes being created or reclaimed. */ if (!ISSET(cp->c_hflag, H_ALLOC | H_TRANSIT | H_ATTACH)) { result = callout(&cp->c_desc, &cp->c_attr, arg); } break; } hfs_chash_unlock(hfsmp); return (result); }
rtems_status_code rtems_io_read( rtems_device_major_number major, rtems_device_minor_number minor, void *argument ) { rtems_device_driver_entry callout; if ( major >= _IO_Number_of_drivers ) return RTEMS_INVALID_NUMBER; callout = _IO_Driver_address_table[major].read_entry; return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; }
/* * Handle the return of a child process from fork1(). This function * is called from the MD fork_trampoline() entry point. */ void fork_exit(void (*callout)(void *, struct trapframe *), void *arg, struct trapframe *frame) { struct proc *p; struct thread *td; struct thread *dtd; td = curthread; p = td->td_proc; KASSERT(p->p_state == PRS_NORMAL, ("executing process is still new")); CTR4(KTR_PROC, "fork_exit: new thread %p (td_sched %p, pid %d, %s)", td, td_get_sched(td), p->p_pid, td->td_name); sched_fork_exit(td); /* * Processes normally resume in mi_switch() after being * cpu_switch()'ed to, but when children start up they arrive here * instead, so we must do much the same things as mi_switch() would. */ if ((dtd = PCPU_GET(deadthread))) { PCPU_SET(deadthread, NULL); thread_stash(dtd); } thread_unlock(td); /* * cpu_fork_kthread_handler intercepts this function call to * have this call a non-return function to stay in kernel mode. * initproc has its own fork handler, but it does return. */ KASSERT(callout != NULL, ("NULL callout in fork_exit")); callout(arg, frame); /* * Check if a kernel thread misbehaved and returned from its main * function. */ if (p->p_flag & P_KPROC) { printf("Kernel thread \"%s\" (pid %d) exited prematurely.\n", td->td_name, p->p_pid); kthread_exit(); } mtx_assert(&Giant, MA_NOTOWNED); if (p->p_sysent->sv_schedtail != NULL) (p->p_sysent->sv_schedtail)(td); td->td_pflags &= ~TDP_FORKING; }
epos_status_code epos_io_initialize( epos_device_major_number major, epos_device_minor_number minor, void *argument ) { epos_device_driver_entry callout; if ( major >= _IO_Number_of_drivers ) return RTEMS_INVALID_NUMBER; callout = _IO_Driver_address_table[major].initialization_entry; return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL; }
static inline char * _os_assert_log_ctx_impl(os_log_callout_t callout, void *ctx, uint64_t code) { char *result = NULL; _SIMPLE_STRING asl_message = _simple_asl_msg_new(); if (asl_message) { Dl_info info; char message[256]; _os_construct_message(code, asl_message, &info, message, sizeof(message)); (void)callout(asl_message, ctx, message); _simple_sfree(asl_message); result = strdup(message); } return result; }
void do_round(long minutes) { time_t start = time(NULL); time_t end = start + (minutes * 60); int total_punches_start = total_punches; while (1) { time_t now = time(NULL); if ((end - now) < 1) { break; } callout(choose_combo()); sleep_rand(5); } say("stop"); int total_punches_round = total_punches - total_punches_start; char phrase[BUFFER_SIZE]; snprintf(phrase, BUFFER_SIZE, "total punches that round %i", total_punches_round); say(phrase); snprintf(phrase, BUFFER_SIZE, "total punches %i", total_punches); say(phrase); }
static int use_item_callback(unit *u, const item_type *itype, int amount, struct order *ord) { int len; char fname[64]; len = snprintf(fname, sizeof(fname), "use_%s", itype->rtype->_name); if (len > 0 && (size_t)len < sizeof(fname)) { int result; int(*callout)(unit *, const item_type *, int, struct order *); /* check if we have a register_item_use function */ callout = (int(*)(unit *, const item_type *, int, struct order *))get_function(fname); if (callout) { return callout(u, itype, amount, ord); } /* check if we have a matching lua function */ result = lua_use_item(u, itype, fname, amount, ord); if (result != 0) { return result; } /* if the item is a potion, try use_potion, the generic function for * potions that add an effect: */ if (itype->flags & ITF_POTION) { return use_potion(u, itype, amount, ord); } else { log_error("no such callout: %s", fname); } log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname); } return 0; }