Lines Matching refs:_name
197 #define DEFINE_FREE(_name, _type, _free) \ argument
198 static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
200 #define __free(_name) __cleanup(__free_##_name) argument
243 #define DEFINE_CLASS(_name, _type, _exit, _init, _init_args...) \ argument
244 typedef _type class_##_name##_t; \
245 static inline void class_##_name##_destructor(_type *p) \
247 static inline _type class_##_name##_constructor(_init_args) \
250 #define EXTEND_CLASS(_name, ext, _init, _init_args...) \ argument
251 typedef class_##_name##_t class_##_name##ext##_t; \
252 static inline void class_##_name##ext##_destructor(class_##_name##_t *p)\
253 { class_##_name##_destructor(p); } \
254 static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
255 { class_##_name##_t t = _init; return t; }
257 #define CLASS(_name, var) \ argument
258 class_##_name##_t var __cleanup(class_##_name##_destructor) = \
259 class_##_name##_constructor
291 #define __DEFINE_CLASS_IS_CONDITIONAL(_name, _is_cond) \ argument
292 static __maybe_unused const bool class_##_name##_is_conditional = _is_cond
294 #define DEFINE_GUARD(_name, _type, _lock, _unlock) \ argument
295 __DEFINE_CLASS_IS_CONDITIONAL(_name, false); \
296 DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
297 static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
300 #define DEFINE_GUARD_COND(_name, _ext, _condlock) \ argument
301 __DEFINE_CLASS_IS_CONDITIONAL(_name##_ext, true); \
302 EXTEND_CLASS(_name, _ext, \
304 class_##_name##_t _T) \
305 static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
306 { return class_##_name##_lock_ptr(_T); }
308 #define guard(_name) \ argument
309 CLASS(_name, __UNIQUE_ID(guard))
311 #define __guard_ptr(_name) class_##_name##_lock_ptr argument
312 #define __is_cond_ptr(_name) class_##_name##_is_conditional argument
323 #define __scoped_guard(_name, _label, args...) \ argument
324 for (CLASS(_name, scope)(args); \
325 __guard_ptr(_name)(&scope) || !__is_cond_ptr(_name); \
332 #define scoped_guard(_name, args...) \ argument
333 __scoped_guard(_name, __UNIQUE_ID(label), args)
335 #define __scoped_cond_guard(_name, _fail, _label, args...) \ argument
336 for (CLASS(_name, scope)(args); true; ({ goto _label; })) \
337 if (!__guard_ptr(_name)(&scope)) { \
338 BUILD_BUG_ON(!__is_cond_ptr(_name)); \
344 #define scoped_cond_guard(_name, _fail, args...) \ argument
345 __scoped_cond_guard(_name, _fail, __UNIQUE_ID(label), args)
366 #define __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, ...) \ argument
370 } class_##_name##_t; \
372 static inline void class_##_name##_destructor(class_##_name##_t *_T) \
377 static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \
383 #define __DEFINE_LOCK_GUARD_1(_name, _type, _lock) \ argument
384 static inline class_##_name##_t class_##_name##_constructor(_type *l) \
386 class_##_name##_t _t = { .lock = l }, *_T = &_t; \
391 #define __DEFINE_LOCK_GUARD_0(_name, _lock) \ argument
392 static inline class_##_name##_t class_##_name##_constructor(void) \
394 class_##_name##_t _t = { .lock = (void*)1 }, \
400 #define DEFINE_LOCK_GUARD_1(_name, _type, _lock, _unlock, ...) \ argument
401 __DEFINE_CLASS_IS_CONDITIONAL(_name, false); \
402 __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) \
403 __DEFINE_LOCK_GUARD_1(_name, _type, _lock)
405 #define DEFINE_LOCK_GUARD_0(_name, _lock, _unlock, ...) \ argument
406 __DEFINE_CLASS_IS_CONDITIONAL(_name, false); \
407 __DEFINE_UNLOCK_GUARD(_name, void, _unlock, __VA_ARGS__) \
408 __DEFINE_LOCK_GUARD_0(_name, _lock)
410 #define DEFINE_LOCK_GUARD_1_COND(_name, _ext, _condlock) \ argument
411 __DEFINE_CLASS_IS_CONDITIONAL(_name##_ext, true); \
412 EXTEND_CLASS(_name, _ext, \
413 ({ class_##_name##_t _t = { .lock = l }, *_T = &_t;\
416 typeof_member(class_##_name##_t, lock) l) \
417 static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
418 { return class_##_name##_lock_ptr(_T); }