Line data Source code
1 : /* SPDX-FileCopyrightText: Copyright 2026 Cozens Software Solutions Limited
2 : * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 OR LicenseRef-PolyForm-Internal-Use-1.0.0 OR LicenseRef-COSOSO-Commercial
3 : */
4 :
5 : #include "SolidSyslogPosixSleep.h"
6 :
7 : #include <stdint.h>
8 : #include <time.h>
9 :
10 : enum
11 : {
12 : MILLISECONDS_PER_SECOND = 1000U,
13 : NANOSECONDS_PER_MILLISECOND = 1000000L
14 : };
15 :
16 1 : void SolidSyslogPosix_Sleep(uint32_t milliseconds)
17 : {
18 1 : struct timespec ts = {
19 1 : .tv_sec = (time_t) (milliseconds / MILLISECONDS_PER_SECOND),
20 1 : .tv_nsec = (long) (milliseconds % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND
21 : };
22 1 : (void) nanosleep(&ts, NULL);
23 1 : }
|