Lines Matching full:ec
105 * ec is a struct ck_ec32 *, or a struct ck_ec64 *.
115 * `void ck_ec_init(ec, value)`: initializes the event count to value.
117 * `value ck_ec_value(ec)`: returns the current value of the event
120 * `bool ck_ec_has_waiters(ec)`: returns whether some thread has
123 * `void ck_ec_inc(ec, mode)`: increments the value of the event
127 * `value ck_ec_add(ec, mode, value)`: increments the event counter by
139 * `int ck_ec_wait(ec, mode, value, deadline)`: waits until the event
146 * `int ck_ec_wait_pred(ec, mode, value, pred, data, deadline)`: waits
418 static void ck_ec32_init(struct ck_ec32 *ec, uint32_t value);
427 static void ck_ec64_init(struct ck_ec64 *ec, uint64_t value);
430 #define ck_ec_init(EC, VALUE) \ argument
431 (_Generic(*(EC), \
433 struct ck_ec64 : ck_ec64_init)((EC), (VALUE)))
441 static uint32_t ck_ec32_value(const struct ck_ec32* ec);
450 static uint64_t ck_ec64_value(const struct ck_ec64* ec);
453 #define ck_ec_value(EC) \ argument
454 (_Generic(*(EC), \
456 struct ck_ec64 : ck_ec64_value)((EC)))
464 static bool ck_ec32_has_waiters(const struct ck_ec32 *ec);
469 static bool ck_ec64_has_waiters(const struct ck_ec64 *ec);
472 #define ck_ec_has_waiters(EC) \ argument
473 (_Generic(*(EC), \
475 struct ck_ec64 : ck_ec64_has_waiters)((EC)))
483 static void ck_ec32_inc(struct ck_ec32 *ec, const struct ck_ec_mode *mode);
488 static void ck_ec64_inc(struct ck_ec64 *ec, const struct ck_ec_mode *mode);
491 #define ck_ec_inc(EC, MODE) \ argument
492 (_Generic(*(EC), \
494 struct ck_ec64 : ck_ec64_inc)((EC), (MODE)))
502 static uint32_t ck_ec32_add(struct ck_ec32 *ec,
509 static uint64_t ck_ec64_add(struct ck_ec64 *ec,
514 #define ck_ec_add(EC, MODE, DELTA) \ argument
515 (_Generic(*(EC), \
517 struct ck_ec64 : ck_ec64_add)((EC), (MODE), (DELTA)))
537 static int ck_ec32_wait(struct ck_ec32 *ec,
545 static int ck_ec64_wait(struct ck_ec64 *ec,
551 #define ck_ec_wait(EC, MODE, OLD_VALUE, DEADLINE) \ argument
552 (_Generic(*(EC), \
554 struct ck_ec64 : ck_ec64_wait)((EC), (MODE), \
570 static int ck_ec32_wait_pred(struct ck_ec32 *ec,
581 static int ck_ec64_wait_pred(struct ck_ec64 *ec,
590 #define ck_ec_wait_pred(EC, MODE, OLD_VALUE, PRED, DATA, DEADLINE) \ argument
591 (_Generic(*(EC), \
594 ((EC), (MODE), (OLD_VALUE), (PRED), (DATA), (DEADLINE)))
602 CK_CC_FORCE_INLINE void ck_ec32_init(struct ck_ec32 *ec, uint32_t value) in ck_ec32_init() argument
604 ec->counter = value & ~(1UL << 31); in ck_ec32_init()
608 CK_CC_FORCE_INLINE uint32_t ck_ec32_value(const struct ck_ec32 *ec) in ck_ec32_value() argument
610 uint32_t ret = ck_pr_load_32(&ec->counter) & ~(1UL << 31); in ck_ec32_value()
616 CK_CC_FORCE_INLINE bool ck_ec32_has_waiters(const struct ck_ec32 *ec) in ck_ec32_has_waiters() argument
618 return ck_pr_load_32(&ec->counter) & (1UL << 31); in ck_ec32_has_waiters()
622 void ck_ec32_wake(struct ck_ec32 *ec, const struct ck_ec_ops *ops);
624 CK_CC_FORCE_INLINE void ck_ec32_inc(struct ck_ec32 *ec, in ck_ec32_inc() argument
629 ck_ec32_add(ec, mode, 1); in ck_ec32_inc()
660 : "+m"(ec->counter), "=@ccle"(flagged) \ in ck_ec32_inc()
665 : "+m"(ec->counter), "=r"(flagged) \ in ck_ec32_inc()
679 ck_ec32_wake(ec, mode->ops); in ck_ec32_inc()
686 CK_CC_FORCE_INLINE uint32_t ck_ec32_add_epilogue(struct ck_ec32 *ec, in ck_ec32_add_epilogue() argument
696 ck_ec32_wake(ec, mode->ops); in ck_ec32_add_epilogue()
702 static CK_CC_INLINE uint32_t ck_ec32_add_mp(struct ck_ec32 *ec, in ck_ec32_add_mp() argument
709 old = ck_pr_faa_32(&ec->counter, delta); in ck_ec32_add_mp()
710 return ck_ec32_add_epilogue(ec, mode, old); in ck_ec32_add_mp()
714 static CK_CC_INLINE uint32_t ck_ec32_add_sp(struct ck_ec32 *ec, in ck_ec32_add_sp() argument
726 return ck_ec32_value(ec); in ck_ec32_add_sp()
732 : "+m"(ec->counter), "+r"(old) in ck_ec32_add_sp()
734 return ck_ec32_add_epilogue(ec, mode, old); in ck_ec32_add_sp()
738 CK_CC_FORCE_INLINE uint32_t ck_ec32_add(struct ck_ec32 *ec, in ck_ec32_add() argument
744 return ck_ec32_add_sp(ec, mode, delta); in ck_ec32_add()
748 return ck_ec32_add_mp(ec, mode, delta); in ck_ec32_add()
763 int ck_ec32_wait_slow(struct ck_ec32 *ec,
768 CK_CC_FORCE_INLINE int ck_ec32_wait(struct ck_ec32 *ec, in ck_ec32_wait() argument
773 if (ck_ec32_value(ec) != old_value) { in ck_ec32_wait()
777 return ck_ec32_wait_slow(ec, mode->ops, old_value, deadline); in ck_ec32_wait()
780 int ck_ec32_wait_pred_slow(struct ck_ec32 *ec,
789 ck_ec32_wait_pred(struct ck_ec32 *ec, in ck_ec32_wait_pred() argument
797 if (ck_ec32_value(ec) != old_value) { in ck_ec32_wait_pred()
801 return ck_ec32_wait_pred_slow(ec, mode->ops, old_value, in ck_ec32_wait_pred()
806 CK_CC_FORCE_INLINE void ck_ec64_init(struct ck_ec64 *ec, uint64_t value) in ck_ec64_init() argument
808 ec->counter = value << 1; in ck_ec64_init()
812 CK_CC_FORCE_INLINE uint64_t ck_ec64_value(const struct ck_ec64 *ec) in ck_ec64_value() argument
814 uint64_t ret = ck_pr_load_64(&ec->counter) >> 1; in ck_ec64_value()
820 CK_CC_FORCE_INLINE bool ck_ec64_has_waiters(const struct ck_ec64 *ec) in ck_ec64_has_waiters() argument
822 return ck_pr_load_64(&ec->counter) & 1; in ck_ec64_has_waiters()
825 void ck_ec64_wake(struct ck_ec64 *ec, const struct ck_ec_ops *ops);
827 CK_CC_FORCE_INLINE void ck_ec64_inc(struct ck_ec64 *ec, in ck_ec64_inc() argument
831 (void)ck_ec64_add(ec, mode, 1); in ck_ec64_inc()
835 CK_CC_FORCE_INLINE uint64_t ck_ec_add64_epilogue(struct ck_ec64 *ec, in ck_ec_add64_epilogue() argument
842 ck_ec64_wake(ec, mode->ops); in ck_ec_add64_epilogue()
848 static CK_CC_INLINE uint64_t ck_ec64_add_mp(struct ck_ec64 *ec, in ck_ec64_add_mp() argument
855 return ck_ec_add64_epilogue(ec, mode, ck_pr_faa_64(&ec->counter, inc)); in ck_ec64_add_mp()
860 static CK_CC_INLINE uint64_t ck_ec64_add_sp(struct ck_ec64 *ec, in ck_ec64_add_sp() argument
872 return ck_ec64_value(ec); in ck_ec64_add_sp()
878 : "+m"(ec->counter), "+r"(old) in ck_ec64_add_sp()
880 return ck_ec_add64_epilogue(ec, mode, old); in ck_ec64_add_sp()
889 CK_CC_FORCE_INLINE uint64_t ck_ec64_add(struct ck_ec64 *ec, in ck_ec64_add() argument
895 return ck_ec64_add_sp(ec, mode, delta); in ck_ec64_add()
899 return ck_ec64_add_mp(ec, mode, delta); in ck_ec64_add()
902 int ck_ec64_wait_slow(struct ck_ec64 *ec,
907 CK_CC_FORCE_INLINE int ck_ec64_wait(struct ck_ec64 *ec, in ck_ec64_wait() argument
912 if (ck_ec64_value(ec) != old_value) { in ck_ec64_wait()
916 return ck_ec64_wait_slow(ec, mode->ops, old_value, deadline); in ck_ec64_wait()
919 int ck_ec64_wait_pred_slow(struct ck_ec64 *ec,
929 ck_ec64_wait_pred(struct ck_ec64 *ec, in ck_ec64_wait_pred() argument
937 if (ck_ec64_value(ec) != old_value) { in ck_ec64_wait_pred()
941 return ck_ec64_wait_pred_slow(ec, mode->ops, old_value, in ck_ec64_wait_pred()