[vlc-devel] [PATCH 1/3] compat: add clock_gettime for darwin

Rémi Denis-Courmont remi at remlab.net
Tue Mar 10 17:14:27 CET 2020


Le tiistaina 10. maaliskuuta 2020, 11.50.06 EET Marvin Scholz a écrit :
> ---
>  compat/clock_gettime.c | 130 +++++++++++++++++++++++++++++++++++++++++
>  configure.ac           |   4 ++
>  include/vlc_fixups.h   |  11 ++++
>  3 files changed, 145 insertions(+)
>  create mode 100644 compat/clock_gettime.c
> 
> diff --git a/compat/clock_gettime.c b/compat/clock_gettime.c
> new file mode 100644
> index 0000000000..dbe2434d9d
> --- /dev/null
> +++ b/compat/clock_gettime.c
> @@ -0,0 +1,130 @@
> +/**************************************************************************
> *** + * clock_gettime.c: POSIX clock_gettime() replacement
> +
> ***************************************************************************
> ** + * Copyright © 2020 VLC authors and VideoLAN
> + *
> + * Author: Marvin Scholz <epirat07 at gmail dot com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as published by
> + * the Free Software Foundation; either version 2.1 of the License, or + *
> (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with this program; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. +
> ***************************************************************************
> **/
> +
> +#ifndef __APPLE__
> +# error clock_gettime not implemented on your platform!
> +#endif

First, we usually do #if ... #else #error #endif for that case, so that 
somebody else can implement the function on another platform later.

And then, why bother with #error anyway? Just make the file compile nothing if 
it's not macOS, and remove the special casing in the configure script.

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/





More information about the vlc-devel mailing list