/** Set the initial value of an object. * @author Renaud Lottiaux * * @param set KDDM set hosting the object. * @param obj_entry Object entry of the object to set. * @param objid Identifier of the object to set. * @param object Object to store in the kddm set entry. * * This function assumes that a call to kddm_*_object_manual_ft has been done * before. A kddm_put_object must be done after. * * @return 0 if everything OK, -1 otherwise. */ int _kddm_set_object_state(struct kddm_set *set, objid_t objid, void *object, kddm_obj_state_t state) { struct kddm_obj *obj_entry; retry: obj_entry = __get_kddm_obj_entry(set, objid); BUG_ON(OBJ_STATE(obj_entry) != INV_OWNER); BUG_ON(!object_frozen(obj_entry)); if (obj_entry->object != NULL) { kddm_io_remove_object_and_unlock(obj_entry, set, objid, NULL); printk ("Humf.... Can do really better !\n"); goto retry; } obj_entry->object = object; atomic_inc(&set->nr_objects); ADD_TO_SET (COPYSET(obj_entry), kerrighed_node_id); kddm_insert_object (set, objid, obj_entry, state); put_kddm_obj_entry(set, obj_entry, objid); return 0; }
char * strpbrk(const char *s, const char *charset) { #ifdef FAST_STRPBRK uint8_t set[256], inv[256], idx = 0; #else static const size_t idx[8] = { 1, 2, 4, 8, 16, 32, 64, 128 }; uint8_t set[32]; (void)memset(set, 0, sizeof(set)); #endif _DIAGASSERT(s != NULL); _DIAGASSERT(charset != NULL); if (charset[0] == '\0') return NULL; if (charset[1] == '\0') return strchr(s, charset[0]); for (; *charset != '\0'; ++charset) ADD_TO_SET(UC(*charset)); for (; *s != '\0'; ++s) if (IS_IN_SET(UC(*s))) return __UNCONST(s); return NULL; }