static int kobj_class_compile1(kobj_class_t cls, int mflags) { kobj_ops_t ops; KOBJ_ASSERT(MA_NOTOWNED); ops = malloc(sizeof(struct kobj_ops), M_KOBJ, mflags); if (ops == NULL) return (ENOMEM); /* * We may have lost a race for kobj_class_compile here - check * to make sure someone else hasn't already compiled this * class. */ KOBJ_LOCK(); if (cls->ops) { KOBJ_UNLOCK(); free(ops, M_KOBJ); return (0); } kobj_class_compile_common(cls, ops); KOBJ_UNLOCK(); return (0); }
void kobj_class_compile(kobj_class_t cls) { kobj_ops_t ops; KOBJ_ASSERT(MA_NOTOWNED); /* * Allocate space for the compiled ops table. */ ops = malloc(sizeof(struct kobj_ops), M_KOBJ, M_NOWAIT); if (!ops) panic("%s: out of memory", __func__); KOBJ_LOCK(); /* * We may have lost a race for kobj_class_compile here - check * to make sure someone else hasn't already compiled this * class. */ if (cls->ops) { KOBJ_UNLOCK(); free(ops, M_KOBJ); return; } kobj_class_compile_common(cls, ops); KOBJ_UNLOCK(); }
void kobj_class_compile_static(kobj_class_t cls, kobj_ops_t ops) { /* * Increment refs to make sure that the ops table is not freed. */ cls->refs++; kobj_class_compile_common(cls, ops); }
void kobj_class_compile(kobj_class_t cls) { kobj_ops_t ops; /* * Allocate space for the compiled ops table. */ ops = malloc(sizeof(struct kobj_ops), M_KOBJ, M_NOWAIT); if (!ops) panic("kobj_compile_methods: out of memory"); kobj_class_compile_common(cls, ops); }
void kobj_class_compile_static(kobj_class_t cls, kobj_ops_t ops) { KASSERT(kobj_mutex_inited == 0, ("%s: only supported during early cycles", __func__)); /* * Increment refs to make sure that the ops table is not freed. */ cls->refs++; kobj_class_compile_common(cls, ops); }
void kobj_class_compile_static(kobj_class_t cls, kobj_ops_t ops) { KOBJ_ASSERT(MA_NOTOWNED); /* * Increment refs to make sure that the ops table is not freed. */ KOBJ_LOCK(); cls->refs++; kobj_class_compile_common(cls, ops); KOBJ_UNLOCK(); }