mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 13:36:39 +00:00
check: Don't check for malloc/realloc and try to fallback
When malloc is not available, this will set #define malloc rpl_malloc which is implemented only inside libcheck, and not everything will link to libcheck. We don't really need to care too much about how malloc is implemented and we don't care about platforms that don't implement malloc.
This commit is contained in:
parent
958d791d3c
commit
e60bd6c662
7 changed files with 10 additions and 123 deletions
|
@ -441,8 +441,6 @@
|
|||
#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
|
||||
|
|
|
@ -30,29 +30,10 @@ 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
|
||||
|
@ -95,5 +76,5 @@ 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
|
||||
# See libcompat/libcompat.h
|
||||
libcheckinternal_la_CFLAGS += -DHAVE_SNPRINTF -DHAVE_VSNPRINTF -DHAVE_MALLOC -DHAVE_REALLOC
|
||||
|
|
|
@ -11,6 +11,12 @@ those in the lib/ directory upstream.
|
|||
lib/snprintf.c was omitted since we don't run on any platforms that don't
|
||||
provide snprintf and the upstream implementation is ~2000 lines.
|
||||
|
||||
lib/malloc.c and lib/realloc.c were omitted since we were doing fine without
|
||||
them and it does a #define malloc rpl_malloc on Android because the malloc
|
||||
shipped with Bionic is not GNU-compliant. rpl_malloc is provided by libcheck,
|
||||
but not everything in gstreamer links against libcheck. We also don't care
|
||||
about this.
|
||||
|
||||
Steps to sync with upstream:
|
||||
|
||||
1. Clone libcheck from the above git repository
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
|
@ -27,14 +27,6 @@ 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
|
||||
|
@ -68,6 +60,6 @@ libcheck = static_library('check',
|
|||
dependencies : [rt_lib, mathlib],
|
||||
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'],
|
||||
# replacements since we don't check for or define these. See libcompat.h
|
||||
['-DHAVE_VSNPRINTF', '-DHAVE_SNPRINTF', '-DHAVE_MALLOC', '-DHAVE_REALLOC'],
|
||||
pic: true)
|
||||
|
|
|
@ -18,11 +18,6 @@ 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")
|
||||
|
|
Loading…
Reference in a new issue