[vlc-commits] [Git][videolan/vlc][master] 2 commits: compat: remove NSEC_PER_SEC in clock_nanosleep
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Sun Sep 5 15:13:26 UTC 2021
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
d4b029ee by Mehdi Sabwat at 2021-09-05T14:58:30+00:00
compat: remove NSEC_PER_SEC in clock_nanosleep
This is to allow clock_nanosleep code to be used on platforms other
than Macosx.
- - - - -
3f3296b0 by Mehdi Sabwat at 2021-09-05T14:58:30+00:00
compat: make clock_nanosleep usable by other OSes
This is to allow clock_nanosleep to be used by emscripten
and potentially other platforms.
The file should not be compiled on windows platforms, as it won't
find sys/errno.h
mach/clock_types.h is needed for clock_id_t, and is only available on
macos.
- - - - -
2 changed files:
- compat/clock_nanosleep.c
- include/vlc_fixups.h
Changes:
=====================================
compat/clock_nanosleep.c
=====================================
@@ -20,7 +20,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#ifdef __APPLE__
+#ifndef _WIN32
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -32,14 +32,17 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/sysctl.h>
+
+# ifdef __APPLE__
#include <mach/clock_types.h>
+# endif
int clock_nanosleep(clockid_t clock_id, int flags,
const struct timespec *rqtp, struct timespec *rmtp)
{
// Validate timespec
if (rqtp == NULL || rqtp->tv_sec < 0 ||
- rqtp->tv_nsec < 0 || (unsigned long)rqtp->tv_nsec >= NSEC_PER_SEC) {
+ rqtp->tv_nsec < 0 || (unsigned long)rqtp->tv_nsec >= 1000*1000*1000) {
errno = EINVAL;
return -1;
}
@@ -68,7 +71,7 @@ int clock_nanosleep(clockid_t clock_id, int flags,
ts_rel.tv_nsec = rqtp->tv_nsec - ts_now.tv_nsec;
if (ts_rel.tv_nsec < 0) {
ts_rel.tv_sec -= 1;
- ts_rel.tv_nsec += NSEC_PER_SEC;
+ ts_rel.tv_nsec += 1000*1000*1000;
}
// Check if time already elapsed
=====================================
include/vlc_fixups.h
=====================================
@@ -687,6 +687,9 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp);
# ifndef HAVE_CLOCK_GETRES
int clock_getres(clockid_t clock_id, struct timespec *tp);
# endif
+#endif
+
+#ifndef _WIN32
# ifndef HAVE_CLOCK_NANOSLEEP
int clock_nanosleep(clockid_t clock_id, int flags,
const struct timespec *rqtp, struct timespec *rmtp);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f7447e6a61b5925843f136d8ca1a98e81ae218cc...3f3296b03f69635e68b878f34210b831f6afdfce
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f7447e6a61b5925843f136d8ca1a98e81ae218cc...3f3296b03f69635e68b878f34210b831f6afdfce
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list