Beispiel #1
0
void
kobj_init(kobj_t obj, kobj_class_t cls)
{
	KOBJ_ASSERT(MA_NOTOWNED);
  retry:
	KOBJ_LOCK();

	/*
	 * Consider compiling the class' method table.
	 */
	if (!cls->ops) {
		/*
		 * kobj_class_compile doesn't want the lock held
		 * because of the call to malloc - we drop the lock
		 * and re-try.
		 */
		KOBJ_UNLOCK();
		kobj_class_compile(cls);
		goto retry;
	}

	kobj_init_common(obj, cls);

	KOBJ_UNLOCK();
}
Beispiel #2
0
void
kobj_init_static(kobj_t obj, kobj_class_t cls)
{

	KASSERT(kobj_mutex_inited == 0,
	    ("%s: only supported during early cycles", __func__));

	kobj_init_common(obj, cls);
}
Beispiel #3
0
static int
kobj_init1(kobj_t obj, kobj_class_t cls, int mflags)
{
	int error;

	KOBJ_LOCK();
	while (cls->ops == NULL) {
		/*
		 * kobj_class_compile doesn't want the lock held
		 * because of the call to malloc - we drop the lock
		 * and re-try.
		 */
		KOBJ_UNLOCK();
		error = kobj_class_compile1(cls, mflags);
		if (error != 0)
			return (error);
		KOBJ_LOCK();
	}
	kobj_init_common(obj, cls);
	KOBJ_UNLOCK();
	return (0);
}