Skip to content

Commit

Permalink
mmalloc: check for mach_error_string
Browse files Browse the repository at this point in the history
Change-Id: Ib4e2164bb836f31cec68d697802be4c0c9970395
  • Loading branch information
cooljeanius committed Sep 19, 2024
1 parent be1ae9f commit a17b559
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/attach.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/check-sup.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/detach.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/keys.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/malloc-sup.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mcalloc.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mfree.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mmalloc.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mmap-sup.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mmcheck.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mmemalign.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mmstats.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mmtrace.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mrealloc.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/mvalloc.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/pagecheck-sup.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mmalloc/clang_static_analysis/sbrk-sup.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/mmalloc/config.h.in

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 51 additions & 6 deletions src/mmalloc/configure
Original file line number Diff line number Diff line change
Expand Up @@ -7143,12 +7143,6 @@ if test "x$ac_cv_header_stddef_h" = xyes
then :
printf "%s\n" "#define HAVE_STDDEF_H 1" >>confdefs.h

fi
ac_fn_c_check_header_compile "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default"
if test "x$ac_cv_header_stdio_h" = xyes
then :
printf "%s\n" "#define HAVE_STDIO_H 1" >>confdefs.h

fi
ac_fn_c_check_header_compile "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_mman_h" = xyes
Expand Down Expand Up @@ -7618,6 +7612,28 @@ esac
fi
;;
esac
fi
## One other mach one:
ac_fn_c_check_type "$LINENO" "mach_error_t" "ac_cv_type_mach_error_t" "
#if defined(HAVE_MACH_MACH_ERROR_H) || defined(__MACH__) || defined(__APPLE__)
# include <mach/mach_error.h>
#else
# if defined(HAVE_MACH_ERROR_H) || defined(__NeXT__)
# include <mach/error.h>
# else
# if defined(__GNUC__) && !defined(__STRICT_ANSI__)
# warning \"conftest for mach_error_t wants a mach error header.\"
# endif /* __GNUC__ && !defined(__STRICT_ANSI__) */
# endif /* HAVE_MACH_ERROR_H */
#endif /* HAVE_MACH_MACH_ERROR_H || __MACH__ || __APPLE__ */
"
if test "x$ac_cv_type_mach_error_t" = xyes
then :

printf "%s\n" "#define HAVE_MACH_ERROR_T 1" >>confdefs.h


fi

ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
Expand Down Expand Up @@ -8062,6 +8078,12 @@ if test "x$ac_cv_func_lseek" = xyes
then :
printf "%s\n" "#define HAVE_LSEEK 1" >>confdefs.h

fi
ac_fn_c_check_func "$LINENO" "mach_error_string" "ac_cv_func_mach_error_string"
if test "x$ac_cv_func_mach_error_string" = xyes
then :
printf "%s\n" "#define HAVE_MACH_ERROR_STRING 1" >>confdefs.h

fi
ac_fn_c_check_func "$LINENO" "mach_vm_region" "ac_cv_func_mach_vm_region"
if test "x$ac_cv_func_mach_vm_region" = xyes
Expand Down Expand Up @@ -8205,6 +8227,29 @@ fi
printf "%s\n" "#define HAVE_DECL_GETENV $ac_have_decl" >>confdefs.h


ac_fn_check_decl "$LINENO" "mach_error_string" "ac_cv_have_decl_mach_error_string" "
#if defined(HAVE_MACH_MACH_ERROR_H) || defined(__MACH__) || defined(__APPLE__)
# include <mach/mach_error.h>
#else
# if defined(HAVE_MACH_ERROR_H) || defined(__NeXT__)
# include <mach/error.h>
# else
# if defined(__GNUC__) && !defined(__STRICT_ANSI__)
# warning \"conftest for mach_error_string wants a mach error header.\"
# endif /* __GNUC__ && !defined(__STRICT_ANSI__) */
# endif /* HAVE_MACH_ERROR_H */
#endif /* HAVE_MACH_MACH_ERROR_H || __MACH__ || __APPLE__ */
" "$ac_c_undeclared_builtin_options" "CFLAGS"
if test "x$ac_cv_have_decl_mach_error_string" = xyes
then :
ac_have_decl=1
else case e in #(
e) ac_have_decl=0 ;;
esac
fi
printf "%s\n" "#define HAVE_DECL_MACH_ERROR_STRING $ac_have_decl" >>confdefs.h



{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether sbrk must be declared" >&5
Expand Down
35 changes: 31 additions & 4 deletions src/mmalloc/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ AC_REQUIRE_HEADER_STDC
AC_CHECK_HEADERS([AvailabilityMacros.h db.h errno.h fcntl.h \
ipc/ipc_types.h limits.h mach/error.h mach/mach.h \
mach/mach_error.h mach/mach_port.h mach/mach_vm.h \
mach/port.h mach/vm_region.h stddef.h stdio.h \
sys/mman.h])dnl
mach/port.h mach/vm_region.h stddef.h sys/mman.h])dnl

# Checks for typedefs, structures, and compiler characteristics.
AC_C_BIGENDIAN
Expand Down Expand Up @@ -197,6 +196,20 @@ AC_CHECK_TYPES([port_t],[],[
# warning "This conftest for port_t expects <mach/port.h> to be included."
# endif /* __GNUC__ && !__STRICT_ANSI__ */
#endif /* HAVE_MACH_PORT_H */
])dnl
## One other mach one:
AC_CHECK_TYPES([mach_error_t],[],[],[
#if defined(HAVE_MACH_MACH_ERROR_H) || defined(__MACH__) || defined(__APPLE__)
# include <mach/mach_error.h>
#else
# if defined(HAVE_MACH_ERROR_H) || defined(__NeXT__)
# include <mach/error.h>
# else
# if defined(__GNUC__) && !defined(__STRICT_ANSI__)
# warning "conftest for mach_error_t wants a mach error header."
# endif /* __GNUC__ && !defined(__STRICT_ANSI__) */
# endif /* HAVE_MACH_ERROR_H */
#endif /* HAVE_MACH_MACH_ERROR_H || __MACH__ || __APPLE__ */
])dnl
AC_TYPE_INTPTR_T
AC_TYPE_INT32_T
Expand All @@ -214,10 +227,24 @@ AC_FUNC_MMAP
# Checks for other functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([close lseek mach_vm_region memmove memset msync munmap \
sbrk strerror vm_region])dnl
AC_CHECK_FUNCS([close lseek mach_error_string mach_vm_region memmove memset \
msync munmap sbrk strerror vm_region])dnl
AC_CHECK_DECLS_ONCE([getenv])dnl

AC_CHECK_DECLS([mach_error_string],[],[],[
#if defined(HAVE_MACH_MACH_ERROR_H) || defined(__MACH__) || defined(__APPLE__)
# include <mach/mach_error.h>
#else
# if defined(HAVE_MACH_ERROR_H) || defined(__NeXT__)
# include <mach/error.h>
# else
# if defined(__GNUC__) && !defined(__STRICT_ANSI__)
# warning "conftest for mach_error_string wants a mach error header."
# endif /* __GNUC__ && !defined(__STRICT_ANSI__) */
# endif /* HAVE_MACH_ERROR_H */
#endif /* HAVE_MACH_MACH_ERROR_H || __MACH__ || __APPLE__ */
])dnl

BFD_NEED_DECLARATION([sbrk])dnl
BFD_NEED_DECLARATION([getpagesize])dnl

Expand Down
7 changes: 7 additions & 0 deletions src/mmalloc/pagecheck-sup.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ typedef vm_offset_t vm_address_t;
# if defined(__GNUC__) && !defined(__STRICT_ANSI__)
# warning "pagecheck-sup.c expects a mach error header to be included."
# endif /* __GNUC__ && !defined(__STRICT_ANSI__) */
# if !defined(_MACH_ERROR_) && \
(!defined(HAVE_DECL_MACH_ERROR_STRING) || !HAVE_DECL_MACH_ERROR_STRING)
# if !defined(HAVE_MACH_ERROR_T) && !defined(mach_error_t)
typedef kern_return_t mach_error_t;
# endif /* !HAVE_MACH_ERROR_T && !mach_error_t */
char *mach_error_string(mach_error_t error_value);
# endif /* !_MACH_ERROR_ && !HAVE_DECL_MACH_ERROR_STRING */
# endif /* HAVE_MACH_ERROR_H */
#endif /* HAVE_MACH_MACH_ERROR_H || __MACH__ || __APPLE__ */

Expand Down

0 comments on commit a17b559

Please sign in to comment.