libcheck: Update the compatibility code and checks

This brings us up-to-speed with the latest compatibility code from upstream
check git. For completeness, we do all the checks that upstream check does, but
we skip the snprintf/vsnprintf code because it's not straightforward (involves
running code and that is bad for cross-compilation) and not necessary for the
platforms we support anyway.

If someone really wants this, they can uncomment this and copy the relevant
checks from the check git repository.

https://bugzilla.gnome.org/show_bug.cgi?id=775870
This commit is contained in:
Nirbheek Chauhan 2016-12-09 15:18:11 +05:30
parent eb1f861012
commit d8e8e92176
20 changed files with 565 additions and 15 deletions

View file

@ -441,3 +441,11 @@
#mesondefine HAVE_UNWIND
#mesondefine HAVE_DW
#mesondefine HAVE_BACKTRACE
#mesondefine HAVE_MALLOC
#mesondefine HAVE_REALLOC
#mesondefine HAVE_GETTIMEOFDAY
#mesondefine HAVE_GETLINE
#mesondefine STRUCT_TIMESPEC_DEFINITION_MISSING
#mesondefine STRUCT_ITIMERSPEC_DEFINITION_MISSING
#mesondefine clockid_t
#mesondefine timer_t

View file

@ -22,10 +22,45 @@ if !HAVE_CLOCK_GETTIME
CFILES += libcompat/clock_gettime.c
endif
if !HAVE_GETTIMEOFDAY
CFILES += libcompat/gettimeofday.c
endif
if !HAVE_LOCALTIME_R
CFILES += libcompat/localtime_r.c
endif
if !HAVE_MALLOC
CFILES += libcompat/malloc.c
endif
if !HAVE_REALLOC
CFILES += libcompat/realloc.c
endif
if !HAVE_STRSIGNAL
CFILES += libcompat/strsignal.c
endif
# If either vsnprintf or snprintf is unavailable
# XXX: Commented out because none of our supported platforms need it yet and the
# check is a bit involved. No use slowing everyone down for this yet.
#if !HAVE_VSNPRINTF
#CFILES += libcompat/snprintf.c
#else
#if !HAVE_SNPRINTF
#CFILES += libcompat/snprintf.c
#endif
#endif
if !HAVE_STRDUP
CFILES += libcompat/strdup.c
endif
if !HAVE_GETLINE
CFILES += libcompat/getline.c
endif
if !HAVE_TIMER_CREATE_SETTIME_DELETE
CFILES +=\
libcompat/timer_create.c \
@ -58,3 +93,7 @@ libcheckinternal_la_LIBADD += $(PTHREAD_LIBS)
else
libcheckinternal_la_CFLAGS += -D_GNU_SOURCE
endif
# Don't want libcompat to think we don't have these and substitute replacements
# See the commented-out vsnprintf/snprintf CFILES stuff above
libcheckinternal_la_CFLAGS += -DHAVE_SNPRINTF -DHAVE_VSNPRINTF

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
unsigned int

View file

@ -1,9 +1,30 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
#ifdef __APPLE__
#include <mach/clock.h>
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <CoreServices/CoreServices.h>
#include <unistd.h>
#endif

View file

@ -0,0 +1,56 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
#include <stdio.h>
#define INITIAL_SIZE 16
#define DELIMITER '\n'
ssize_t
getline (char **lineptr, size_t * n, FILE * stream)
{
ssize_t written = 0;
int character;
if (*lineptr == NULL || *n < INITIAL_SIZE) {
free (*lineptr);
*lineptr = (char *) malloc (INITIAL_SIZE);
*n = INITIAL_SIZE;
}
while ((character = fgetc (stream)) != EOF) {
written += 1;
if (written >= *n) {
*n = *n * 2;
*lineptr = realloc (*lineptr, *n);
}
(*lineptr)[written - 1] = character;
if (character == DELIMITER) {
break;
}
}
(*lineptr)[written] = '\0';
return written;
}

View file

@ -0,0 +1,49 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
#include <errno.h>
#if defined(_MSC_VER) || defined(__BORLANDC__)
#define EPOCHFILETIME (116444736000000000i64)
#else
#define EPOCHFILETIME (116444736000000000LL)
#endif
int
gettimeofday (struct timeval *tv, void *tz)
{
#if _MSC_VER
union
{
__int64 ns100; /*time since 1 Jan 1601 in 100ns units */
FILETIME ft;
} now;
GetSystemTimeAsFileTime (&now.ft);
tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL);
tv->tv_sec = (long) ((now.ns100 - EPOCHFILETIME) / 10000000LL);
return (0);
#else
// Return that there is no implementation of this on the system
errno = ENOSYS;
return -1;
#endif /* _MSC_VER */
}

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
/* silence warnings about an empty library */

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef LIBCOMPAT_H
#define LIBCOMPAT_H
@ -84,10 +104,22 @@
CK_DLL_EXP unsigned int alarm (unsigned int seconds);
#endif /* !HAVE_DECL_ALARM */
#if !HAVE_MALLOC
CK_DLL_EXP void *rpl_malloc (size_t n);
#endif /* !HAVE_MALLOC */
#if !HAVE_REALLOC
CK_DLL_EXP void *rpl_realloc (void *p, size_t n);
#endif /* !HAVE_REALLOC */
#if !HAVE_GETPID && HAVE__GETPID
#define getpid _getpid
#endif /* !HAVE_GETPID && HAVE__GETPID */
#if !HAVE_GETTIMEOFDAY
CK_DLL_EXP int gettimeofday (struct timeval *tv, void *tz);
#endif /* !HAVE_GETTIMEOFDAY */
#if !HAVE_DECL_LOCALTIME_R
#if !defined(localtime_r)
CK_DLL_EXP struct tm *localtime_r (const time_t * clock, struct tm *result);
@ -168,6 +200,33 @@ CK_DLL_EXP int timer_settime (timer_t timerid, int flags,
CK_DLL_EXP int timer_delete (timer_t timerid);
#endif /* HAVE_LIBRT */
/*
* The following checks are to determine if the system's
* snprintf (or its variants) should be replaced with
* the C99 compliant version in libcompat.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#if HAVE_STDARG_H
#include <stdarg.h>
#if !HAVE_VSNPRINTF
CK_DLL_EXP int rpl_vsnprintf (char *, size_t, const char *, va_list);
#define vsnprintf rpl_vsnprintf
#endif
#if !HAVE_SNPRINTF
CK_DLL_EXP int rpl_snprintf (char *, size_t, const char *, ...);
#define snprintf rpl_snprintf
#endif
#endif /* HAVE_STDARG_H */
#if !HAVE_GETLINE
CK_DLL_EXP ssize_t getline (char **lineptr, size_t * n, FILE * stream);
#endif
/* silence warnings about an empty library */
CK_DLL_EXP void
ck_do_nothing (void)

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
#if !defined(localtime_r)

View file

@ -0,0 +1,41 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
/*
* AC_FUNC_MALLOC in configure defines malloc to rpl_malloc if
* malloc (0) is NULL to provide GNU compatibility
*/
#include "libcompat.h"
/* malloc has been defined to rpl_malloc, so first undo that */
#undef malloc
/* this gives us the real malloc to use below */
void *malloc (size_t n);
/* force malloc(0) to return a valid pointer */
void *
rpl_malloc (size_t n)
{
if (n == 0)
n = 1;
return malloc (n);
}

View file

@ -0,0 +1,44 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
/*
* AC_FUNC_REALLOC in configure defines realloc to rpl_realloc if
* realloc (p, 0) or realloc (0, n) is NULL to provide GNU
* compatibility
*/
#include "libcompat.h"
/* realloc has been defined to rpl_realloc, so first undo that */
#undef realloc
/* this gives us the real realloc to use below */
void *realloc (void *p, size_t n);
/* force realloc(p, 0) and realloc (NULL, n) to return a valid pointer */
void *
rpl_realloc (void *p, size_t n)
{
if (n == 0)
n = 1;
if (p == 0)
return malloc (n);
return realloc (p, n);
}

View file

@ -0,0 +1,28 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
char *
strdup (const char *str CK_ATTRIBUTE_UNUSED)
{
assert (0);
return NULL;
}

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
char *

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
int

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
int

View file

@ -1,3 +1,23 @@
/*
* Check: a unit test framework for C
* Copyright (C) 2001, 2002 Arien Malec
*
* This library 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 library 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 library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "libcompat.h"
int

View file

@ -15,15 +15,39 @@ if not cdata.has('HAVE_ALARM')
libcheck_files += ['libcompat/alarm.c']
endif
if not cdata.has('HAVE_GETTIMEOFDAY')
libcheck_files += ['libcompat/gettimeofday.c']
endif
if not cdata.has('HAVE_CLOCK_GETTIME')
libcheck_files += ['libcompat/clock_gettime.c']
endif
if not cdata.has('HAVE_DECL_LOCALTIME_R')
libcheck_files += ['libcompat/localtime_r.c']
endif
if not cdata.has('HAVE_MALLOC')
libcheck_files += ['libcompat/malloc.c']
endif
if not cdata.has('HAVE_REALLOC')
libcheck_files += ['libcompat/realloc.c']
endif
if not cdata.has('HAVE_DECL_STRSIGNAL')
libcheck_files += ['libcompat/strsignal.c']
endif
# FIXME: check for symbols timer_create, timer_settime, timer_delete as well
if not cdata.has('HAVE_DECL_STRDUP') and not cdata.has('HAVE__STRDUP')
libcheck_files += ['libcompat/strdup.c']
endif
if not cdata.has('HAVE_GETLINE')
libcheck_files += ['libcompat/getline.c']
endif
# FIXME: check that timer_create, timer_settime, timer_delete are in rt_lib
if not rt_lib.found()
libcheck_files += [
'libcompat/timer_create.c',
@ -42,5 +66,8 @@ libcheck = static_library('check',
libcheck_files,
include_directories : [configinc, internal_check_h_inc],
dependencies : [rt_lib, mathlib],
c_args: gst_c_args,
c_args: gst_c_args +
# Don't want libcompat to think we don't have these and substitute
# replacements since we don't check for or define these.
['-DHAVE_VSNPRINTF', '-DHAVE_SNPRINTF'],
pic: true)

View file

@ -24,6 +24,8 @@ check_cdata.set('CHECK_MINOR_VERSION', 9)
check_cdata.set('CHECK_MICRO_VERSION', 14)
if host_machine.system() != 'windows'
check_cdata.set('HAVE_FORK', 1)
else
check_cdata.set('HAVE_FORK', 0)
endif
subdir('libcheck')

View file

@ -6,8 +6,8 @@ AC_DEFUN([AG_GST_CHECK_CHECKS],
AC_MSG_NOTICE([Running check unit test framework checks now...])
CHECK_MAJOR_VERSION=0
CHECK_MINOR_VERSION=9
CHECK_MICRO_VERSION=14
CHECK_MINOR_VERSION=10
CHECK_MICRO_VERSION=0
CHECK_VERSION=$CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION
AC_SUBST(CHECK_MAJOR_VERSION)
@ -18,7 +18,18 @@ AC_SUBST(CHECK_VERSION)
dnl Checks for header files and declarations
AC_CHECK_HEADERS([unistd.h sys/wait.h sys/time.h], [], [], [AC_INCLUDES_DEFAULT])
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AM_CONDITIONAL(HAVE_MALLOC, test "x$ac_cv_func_malloc" = "xyes")
AM_CONDITIONAL(HAVE_REALLOC, test "x$ac_cv_func_realloc" = "xyes")
dnl Check for localtime_r()
AC_CHECK_FUNCS([localtime_r])
AM_CONDITIONAL(HAVE_LOCALTIME_R, test "x$ac_cv_func_localtime_r" = "xyes")
dnl Check for gettimeofday()
AC_CHECK_FUNCS([gettimeofday])
AM_CONDITIONAL(HAVE_GETTIMEOFDAY, test "x$ac_cv_func_gettimeofday" = "xyes")
dnl Check for getpid() and _getpid()
AC_CHECK_FUNCS([getpid _getpid])
@ -26,6 +37,11 @@ AC_CHECK_FUNCS([getpid _getpid])
dnl Check for strdup() and _strdup()
AC_CHECK_DECLS([strdup])
AC_CHECK_FUNCS([_strdup])
AM_CONDITIONAL(HAVE_STRDUP, test "x$ac_cv_have_decl_strdup" = "xyes" -o "x$ac_cv_func__strdup" = "xyes")
dnl Check for getline()
AC_CHECK_FUNCS([getline])
AM_CONDITIONAL(HAVE_GETLINE, test "x$ac_cv_func_getline" = "xyes")
dnl Check for mkstemp
AC_CHECK_FUNCS([mkstemp])
@ -69,9 +85,9 @@ AC_CHECK_MEMBERS([struct itimerspec.it_interval, struct itimerspec.it_value],
#endif /* HAVE_PTHREAD */
])
dnl Check if types timer_t/clockid_t are defined. If not, we need to define
dnl it in libs/gst/check/libcheck/ibcompat.h. Note the optional inclusion of
dnl pthread.h. On MinGW(-w64), the pthread.h file contains the
dnl Check if types timer_t/clockid_t are defined. If not, we need to define it
dnl in libs/gst/check/libcheck/libcompat/libcompat.h. Note the optional
dnl inclusion of pthread.h. On MinGW(-w64), the pthread.h file contains the
dnl timer_t/clockid_t definitions.
AC_CHECK_TYPE(timer_t, [], [
AC_DEFINE([timer_t], [int], [timer_t])

View file

@ -152,6 +152,8 @@ if cc.has_function('gmtime_r', prefix : '#include<time.h>')
endif
if cc.has_function('localtime_r', prefix : '#include<time.h>')
cdata.set('HAVE_LOCALTIME_R', 1)
# Needed by libcheck
cdata.set('HAVE_DECL_LOCALTIME_R', 1)
endif
if cc.has_function('sigaction', prefix : '#include<signal.h>')
cdata.set('HAVE_SIGACTION', 1)
@ -230,19 +232,20 @@ else
endif
# -------------------------------------------------------------------------------------
# config.h things needed by libcheck (FIXME: move into the libcheck meson.build) (tpm)
# config.h things needed by libcheck
# -------------------------------------------------------------------------------------
# FIXME: check if it is _getpid or getpid on windows (tpm)
if cc.has_function('getpid', prefix : '#include <sys/types.h>\n#include <unistd.h>')
cdata.set('HAVE_GETPID', 1)
elif cc.has_function('_getpid', prefix : '#include <process.h>')
cdata.set('HAVE__GETPID', 1)
cdata.set('HAVE__GETPID', 1) # Windows (MSVC)
endif
# FIXME: check for _strdup() but how/where and with what includes? (windows?) (tpm)
if cc.has_function('strdup', prefix : '#include <string.h>')
cdata.set('HAVE_DECL_STRDUP', 1)
elif cc.has_function('_strdup', prefix : '#include <string.h>')
cdata.set('HAVE__STRDUP', 1)
cdata.set('HAVE__STRDUP', 1) # Windows (MSVC)
endif
if cc.has_function('getline', prefix : '#include <stdio.h>')
cdata.set('HAVE_GETLINE', 1)
endif
if cc.has_function('mkstemp', prefix : '#include <stdlib.h>')
cdata.set('HAVE_MKSTEMP', 1)
@ -256,12 +259,27 @@ endif
if cc.has_function('alarm', prefix : '#include <unistd.h>')
cdata.set('HAVE_ALARM', 1)
endif
if cc.has_function('localtime_r', prefix : '#include <time.h>')
cdata.set('HAVE_DECL_LOCALTIME_R', 1)
if cc.has_function('gettimeofday', prefix : '#include <sys/time.h>')
cdata.set('HAVE_GETTIMEOFDAY', 1)
endif
if cc.has_function('strsignal', prefix : '#include <string.h>')
cdata.set('HAVE_DECL_STRSIGNAL', 1)
endif
# Check for availability of types
if not cc.has_type('clockid_t', prefix : '#include <time.h>')
cdata.set('clockid_t', 'int')
endif
if not cc.has_type('timer_t', prefix : '#include <time.h>')
cdata.set('timer_t', 'int')
endif
if not cc.has_members('struct timespec', 'tv_sec', 'tv_nsec',
prefix : '#include <time.h>')
cdata.set('STRUCT_TIMESPEC_DEFINITION_MISSING', 1)
endif
if not cc.has_members('struct itimerspec', 'it_interval', 'it_value',
prefix : '#include <time.h>')
cdata.set('STRUCT_ITIMERSPEC_DEFINITION_MISSING', 1)
endif
# Platform deps; only ws2_32 and execinfo for now
platform_deps = []
@ -318,7 +336,9 @@ else
endif
mathlib = cc.find_library('m', required : false)
rt_lib = cc.find_library('rt', required : false) # clock_gettime
# Needed for timer_create/settime/delete
# Also provides clock_gettime in glibc < 2.17
rt_lib = cc.find_library('rt', required : false)
gir = find_program('g-ir-scanner', required : false)
gnome = import('gnome')