libvlc: comments and doxygen cleanups
[vlc.git] / compat / clock_getres.c
blobb30bcdc96bbbbbd2e5cfc7f4c007fb4cb8c6ad1a
1 /*****************************************************************************
2 * clock_getres.c: POSIX clock_getres() replacement
3 *****************************************************************************
4 * Copyright © 2020 VLC authors and VideoLAN
6 * Author: Marvin Scholz <epirat07 at gmail dot com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifdef __APPLE__
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif
29 #include <sys/errno.h>
30 #include <sys/types.h>
31 #include <sys/time.h>
32 #include <mach/clock_types.h>
34 int clock_getres(clockid_t clock_id, struct timespec *tp)
36 switch (clock_id) {
37 case CLOCK_MONOTONIC:
38 case CLOCK_REALTIME:
39 // For realtime, it is using gettimeofday and for
40 // the monotonic time it is relative to the system
41 // boot time. Both of these use timeval, which has
42 // at best microsecond precision.
43 tp->tv_sec = 0;
44 tp->tv_nsec = NSEC_PER_USEC;
45 break;
46 default:
47 errno = EINVAL;
48 return -1;
51 return 0;
54 #endif