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_LOCK_PTR(_name, _exp) \ argument
295 static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
298 #define DEFINE_CLASS_IS_GUARD(_name) \ argument
299 __DEFINE_CLASS_IS_CONDITIONAL(_name, false); \
300 __DEFINE_GUARD_LOCK_PTR(_name, _T)
302 #define DEFINE_CLASS_IS_COND_GUARD(_name) \ argument
303 __DEFINE_CLASS_IS_CONDITIONAL(_name, true); \
304 __DEFINE_GUARD_LOCK_PTR(_name, _T)
306 #define DEFINE_GUARD(_name, _type, _lock, _unlock) \ argument
307 DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
308 DEFINE_CLASS_IS_GUARD(_name)
310 #define DEFINE_GUARD_COND(_name, _ext, _condlock) \ argument
311 __DEFINE_CLASS_IS_CONDITIONAL(_name##_ext, true); \
312 EXTEND_CLASS(_name, _ext, \
314 class_##_name##_t _T) \
315 static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
316 { return class_##_name##_lock_ptr(_T); }
318 #define guard(_name) \ argument
319 CLASS(_name, __UNIQUE_ID(guard))
321 #define __guard_ptr(_name) class_##_name##_lock_ptr argument
322 #define __is_cond_ptr(_name) class_##_name##_is_conditional argument
333 #define __scoped_guard(_name, _label, args...) \ argument
334 for (CLASS(_name, scope)(args); \
335 __guard_ptr(_name)(&scope) || !__is_cond_ptr(_name); \
342 #define scoped_guard(_name, args...) \ argument
343 __scoped_guard(_name, __UNIQUE_ID(label), args)
345 #define __scoped_cond_guard(_name, _fail, _label, args...) \ argument
346 for (CLASS(_name, scope)(args); true; ({ goto _label; })) \
347 if (!__guard_ptr(_name)(&scope)) { \
348 BUILD_BUG_ON(!__is_cond_ptr(_name)); \
354 #define scoped_cond_guard(_name, _fail, args...) \ argument
355 __scoped_cond_guard(_name, _fail, __UNIQUE_ID(label), args)
377 #define __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, ...) \ argument
381 } class_##_name##_t; \
383 static inline void class_##_name##_destructor(class_##_name##_t *_T) \
388 __DEFINE_GUARD_LOCK_PTR(_name, &_T->lock)
390 #define __DEFINE_LOCK_GUARD_1(_name, _type, _lock) \ argument
391 static inline class_##_name##_t class_##_name##_constructor(_type *l) \
393 class_##_name##_t _t = { .lock = l }, *_T = &_t; \
398 #define __DEFINE_LOCK_GUARD_0(_name, _lock) \ argument
399 static inline class_##_name##_t class_##_name##_constructor(void) \
401 class_##_name##_t _t = { .lock = (void*)1 }, \
407 #define DEFINE_LOCK_GUARD_1(_name, _type, _lock, _unlock, ...) \ argument
408 __DEFINE_CLASS_IS_CONDITIONAL(_name, false); \
409 __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) \
410 __DEFINE_LOCK_GUARD_1(_name, _type, _lock)
412 #define DEFINE_LOCK_GUARD_0(_name, _lock, _unlock, ...) \ argument
413 __DEFINE_CLASS_IS_CONDITIONAL(_name, false); \
414 __DEFINE_UNLOCK_GUARD(_name, void, _unlock, __VA_ARGS__) \
415 __DEFINE_LOCK_GUARD_0(_name, _lock)
417 #define DEFINE_LOCK_GUARD_1_COND(_name, _ext, _condlock) \ argument
418 __DEFINE_CLASS_IS_CONDITIONAL(_name##_ext, true); \
419 EXTEND_CLASS(_name, _ext, \
420 ({ class_##_name##_t _t = { .lock = l }, *_T = &_t;\
423 typeof_member(class_##_name##_t, lock) l) \
424 static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
425 { return class_##_name##_lock_ptr(_T); }