mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-08 17:22:05 +03:00
malloc-h: Fix compilation errors in C++ mode on Android.
* lib/malloc.in.h: Don't include <stdlib.h>, except on Solaris and on HP-UX. Include <stddef.h>. Make _GL_ATTRIBUTE_DEALLOC_FREE work (code snippet copied from string.in.h and wchar.in.h). * m4/malloc_h.m4 (gl_MALLOC_H_REQUIRE_DEFAULTS): Invoke gl_STDLIB_H_REQUIRE_DEFAULTS. * modules/malloc-h (Depends-on): Add stddef, stdlib. (Makefile.am): Substitute GNULIB_FREE_POSIX and REPLACE_FREE.
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2023-01-09 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
malloc-h: Fix compilation errors in C++ mode on Android.
|
||||||
|
* lib/malloc.in.h: Don't include <stdlib.h>, except on Solaris and on
|
||||||
|
HP-UX. Include <stddef.h>. Make _GL_ATTRIBUTE_DEALLOC_FREE work (code
|
||||||
|
snippet copied from string.in.h and wchar.in.h).
|
||||||
|
* m4/malloc_h.m4 (gl_MALLOC_H_REQUIRE_DEFAULTS): Invoke
|
||||||
|
gl_STDLIB_H_REQUIRE_DEFAULTS.
|
||||||
|
* modules/malloc-h (Depends-on): Add stddef, stdlib.
|
||||||
|
(Makefile.am): Substitute GNULIB_FREE_POSIX and REPLACE_FREE.
|
||||||
|
|
||||||
2023-01-09 Bruno Haible <bruno@clisp.org>
|
2023-01-09 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
gettime: Fix compilation error in C++ mode on Android.
|
gettime: Fix compilation error in C++ mode on Android.
|
||||||
|
@@ -46,15 +46,60 @@
|
|||||||
#ifndef _@GUARD_PREFIX@_MALLOC_H
|
#ifndef _@GUARD_PREFIX@_MALLOC_H
|
||||||
#define _@GUARD_PREFIX@_MALLOC_H
|
#define _@GUARD_PREFIX@_MALLOC_H
|
||||||
|
|
||||||
/* Solaris declares memalign() in <stdlib.h>, not in <malloc.h>.
|
/* Solaris declares memalign() in <stdlib.h>, not in <malloc.h>. */
|
||||||
Also get size_t and free(). */
|
#if defined __sun || defined __hpux
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Get size_t. */
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||||
|
|
||||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
|
||||||
|
been included yet. */
|
||||||
|
#if @GNULIB_FREE_POSIX@
|
||||||
|
# if (@REPLACE_FREE@ && !defined free \
|
||||||
|
&& !(defined __cplusplus && defined GNULIB_NAMESPACE))
|
||||||
|
/* We can't do '#define free rpl_free' here. */
|
||||||
|
_GL_EXTERN_C void rpl_free (void *);
|
||||||
|
# undef _GL_ATTRIBUTE_DEALLOC_FREE
|
||||||
|
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
|
||||||
|
# else
|
||||||
|
# if defined _MSC_VER && !defined free
|
||||||
|
_GL_EXTERN_C
|
||||||
|
# if defined _DLL
|
||||||
|
__declspec (dllimport)
|
||||||
|
# endif
|
||||||
|
void __cdecl free (void *);
|
||||||
|
# else
|
||||||
|
# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
|
||||||
|
_GL_EXTERN_C void free (void *) throw ();
|
||||||
|
# else
|
||||||
|
_GL_EXTERN_C void free (void *);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if defined _MSC_VER && !defined free
|
||||||
|
_GL_EXTERN_C
|
||||||
|
# if defined _DLL
|
||||||
|
__declspec (dllimport)
|
||||||
|
# endif
|
||||||
|
void __cdecl free (void *);
|
||||||
|
# else
|
||||||
|
# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
|
||||||
|
_GL_EXTERN_C void free (void *) throw ();
|
||||||
|
# else
|
||||||
|
_GL_EXTERN_C void free (void *);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Declare overridden functions. */
|
/* Declare overridden functions. */
|
||||||
|
|
||||||
#if @GNULIB_MEMALIGN@
|
#if @GNULIB_MEMALIGN@
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# malloc_h.m4 serial 4
|
# malloc_h.m4 serial 5
|
||||||
dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
|
dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
@@ -51,6 +51,8 @@ AC_DEFUN([gl_MALLOC_H_REQUIRE_DEFAULTS],
|
|||||||
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMALIGN])
|
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMALIGN])
|
||||||
])
|
])
|
||||||
m4_require(GL_MODULE_INDICATOR_PREFIX[_MALLOC_H_MODULE_INDICATOR_DEFAULTS])
|
m4_require(GL_MODULE_INDICATOR_PREFIX[_MALLOC_H_MODULE_INDICATOR_DEFAULTS])
|
||||||
|
dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
|
||||||
|
gl_STDLIB_H_REQUIRE_DEFAULTS
|
||||||
AC_REQUIRE([gl_MALLOC_H_DEFAULTS])
|
AC_REQUIRE([gl_MALLOC_H_DEFAULTS])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@@ -10,6 +10,8 @@ gen-header
|
|||||||
include_next
|
include_next
|
||||||
snippet/c++defs
|
snippet/c++defs
|
||||||
snippet/warn-on-use
|
snippet/warn-on-use
|
||||||
|
stddef
|
||||||
|
stdlib
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
gl_MALLOC_H
|
gl_MALLOC_H
|
||||||
@@ -29,8 +31,10 @@ malloc.h: malloc.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
|
|||||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||||
-e 's|@''NEXT_MALLOC_H''@|$(NEXT_MALLOC_H)|g' \
|
-e 's|@''NEXT_MALLOC_H''@|$(NEXT_MALLOC_H)|g' \
|
||||||
|
-e 's/@''GNULIB_FREE_POSIX''@/$(GNULIB_FREE_POSIX)/g' \
|
||||||
-e 's/@''GNULIB_MEMALIGN''@/$(GNULIB_MEMALIGN)/g' \
|
-e 's/@''GNULIB_MEMALIGN''@/$(GNULIB_MEMALIGN)/g' \
|
||||||
-e 's|@''HAVE_MEMALIGN''@|$(HAVE_MEMALIGN)|g' \
|
-e 's|@''HAVE_MEMALIGN''@|$(HAVE_MEMALIGN)|g' \
|
||||||
|
-e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
|
||||||
-e 's|@''REPLACE_MEMALIGN''@|$(REPLACE_MEMALIGN)|g' \
|
-e 's|@''REPLACE_MEMALIGN''@|$(REPLACE_MEMALIGN)|g' \
|
||||||
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||||
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
|
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
|
||||||
|
Reference in New Issue
Block a user