* @brief Creates a per-process timer. * * This system call creates a new timer associated with the specified clock, and * initializes the timer with the provided event notification attributes. * Once created, the timer can be started, stopped, or controlled as needed. * The timer will trigger when the specified expiration time or interval is reached. * * @param[in] clockid The clock to b
| 3035 | * unsupported notification types may result in unexpected behavior. |
| 3036 | */ |
| 3037 | sysret_t sys_timer_create(clockid_t clockid, struct sigevent *restrict sevp, timer_t *restrict timerid) |
| 3038 | { |
| 3039 | int ret = 0; |
| 3040 | #ifdef ARCH_MM_MMU |
| 3041 | struct sigevent sevp_k; |
| 3042 | timer_t timerid_k; |
| 3043 | int utimer; |
| 3044 | |
| 3045 | if (sevp == NULL) |
| 3046 | { |
| 3047 | sevp_k.sigev_notify = SIGEV_SIGNAL; |
| 3048 | sevp_k.sigev_signo = SIGALRM; |
| 3049 | sevp = &sevp_k; |
| 3050 | } |
| 3051 | else |
| 3052 | { |
| 3053 | /* clear extra bytes if any */ |
| 3054 | if (sizeof(struct ksigevent) < sizeof(struct sigevent)) |
| 3055 | memset(&sevp_k, 0, sizeof(sevp_k)); |
| 3056 | |
| 3057 | /* musl passes `struct ksigevent` to kernel, we shoule only get size of that bytes */ |
| 3058 | if (!lwp_get_from_user(&sevp_k, (void *)sevp, sizeof(struct ksigevent))) |
| 3059 | { |
| 3060 | return -EINVAL; |
| 3061 | } |
| 3062 | } |
| 3063 | |
| 3064 | ret = _SYS_WRAP(timer_create(clockid, &sevp_k, &timerid_k)); |
| 3065 | |
| 3066 | if (ret != -RT_ERROR) |
| 3067 | { |
| 3068 | utimer = (rt_ubase_t)timerid_k; |
| 3069 | if (!lwp_put_to_user(sevp, (void *)&sevp_k, sizeof(struct ksigevent)) || |
| 3070 | !lwp_put_to_user(timerid, (void *)&utimer, sizeof(utimer))) |
| 3071 | ret = -EINVAL; |
| 3072 | } |
| 3073 | #else |
| 3074 | ret = _SYS_WRAP(timer_create(clockid, sevp, timerid)); |
| 3075 | #endif |
| 3076 | return ret; |
| 3077 | } |
| 3078 | |
| 3079 | /** |
| 3080 | * @brief Deletes a timer. |
nothing calls this directly
no test coverage detected