- static int (*volatile cgt)(clockid_t, struct timespec *);
- if (!cgt) {
- void *f = __vdsosym(VDSO_CGT_VER, VDSO_CGT_SYM);
- if (!f) f = (void *)sc_clock_gettime;
- a_cas_p(&cgt, 0, f);
+ int (*f)(clockid_t, struct timespec *) =
+ (int (*)(clockid_t, struct timespec *))vdso_func;
+ if (f) {
+ r = f(clk, ts);
+ if (!r) return r;
+ if (r == -EINVAL) return __syscall_ret(r);
+ /* Fall through on errors other than EINVAL. Some buggy
+ * vdso implementations return ENOSYS for clocks they
+ * can't handle, rather than making the syscall. This
+ * also handles the case where cgt_init fails to find
+ * a vdso function to use. */