1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2024 Oxide Computer Company 14 */ 15 16 #ifndef _CLOCK_LOCK_H 17 #define _CLOCK_LOCK_H 18 19 /* 20 * Common definitions for the clock_lock test. 21 */ 22 23 #include <stdbool.h> 24 #include <time.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 typedef struct lock_ops { 31 void (*lo_create)(const char *, void **); 32 void (*lo_destroy)(void *); 33 void (*lo_lock)(void *); 34 void (*lo_unlock)(void *); 35 } lock_ops_t; 36 37 typedef struct clock_test { 38 const char *ct_desc; 39 const lock_ops_t *ct_ops; 40 bool ct_enter; 41 bool (*ct_test)(const struct clock_test *, void *); 42 } clock_test_t; 43 44 extern const clock_test_t clock_cond_tests[]; 45 extern size_t clock_cond_ntests; 46 extern const clock_test_t clock_mutex_tests[]; 47 extern size_t clock_mutex_ntests; 48 extern const clock_test_t clock_rwlock_tests[]; 49 extern size_t clock_rwlock_ntests; 50 extern const clock_test_t clock_sem_tests[]; 51 extern size_t clock_sem_ntests; 52 53 /* 54 * Timeouts and functions tests can use. 55 */ 56 extern const struct timespec clock_to_100ms; 57 extern const struct timespec clock_to_invns; 58 extern const struct timespec clock_to_invnegs; 59 extern const struct timespec clock_to_invnegns; 60 61 extern void clock_rel_to_abs(clockid_t, const struct timespec *restrict, 62 struct timespec *restrict); 63 extern bool clock_abs_after(clockid_t, const struct timespec *); 64 extern bool clock_rel_after(clockid_t, const struct timespec *, 65 const struct timespec *); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif /* _CLOCK_LOCK_H */ 72