Debian Codegraph @

m4/pma.m4

raw
1 dnl Decide whether or not to use the persistent memory allocator
2 dnl
3 dnl Copyright (C) 2022, 2023, 2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 AC_DEFUN([GAWK_USE_PERSISTENT_MALLOC],
9 [
10 AC_REQUIRE([AX_CHECK_COMPILE_FLAG])
11 AC_CHECK_SIZEOF([void *])
12 use_persistent_malloc=no
13 if test "$SKIP_PERSIST_MALLOC" = no && test $ac_cv_sizeof_void_p -eq 8
14 then
15 AC_CHECK_FUNC([mmap])
16 AC_CHECK_FUNC([munmap])
17 if test $ac_cv_func_mmap = yes && test $ac_cv_func_munmap = yes
18 then
19 use_persistent_malloc=yes
20 case $host_os in
21 linux-*)
22 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
23 #include <sys/personality.h>
24 int x = ADDR_NO_RANDOMIZE;
25 ]], [[]])],[have_addr_no_randomize=yes],[have_addr_no_randomize=no])
26 ;;
27 *darwin*)
28 true # On macos we no longer need -no-pie
29 ;;
30 *cygwin* | *CYGWIN* | *solaris2.11* | freebsd13.* | openbsd7.* )
31 true # nothing to do, exes on these systems are not PIE
32 ;;
33 # Other OS's go here...
34 *)
35 # For now, play it safe
36 use_persistent_malloc=no
37
38 # Allow override for testing on new systems
39 if test "$REALLY_USE_PERSIST_MALLOC" != ""
40 then
41 use_persistent_malloc=yes
42 fi
43 ;;
44 esac
45 else
46 use_persistent_malloc=no
47 fi
48 fi
49
50 AM_CONDITIONAL([USE_PERSISTENT_MALLOC], [test "$use_persistent_malloc" = "yes"])
51 AM_CONDITIONAL([HAVE_ADDR_NO_RANDOMIZE], [test "$have_addr_no_randomize" = "yes"])
52
53 if test "$use_persistent_malloc" = "yes"
54 then
55 AC_DEFINE(USE_PERSISTENT_MALLOC, 1, [Define to 1 if we can use the pma allocator])
56 fi
57 if test "$have_addr_no_randomize" = "yes"
58 then
59 AC_DEFINE(HAVE_ADDR_NO_RANDOMIZE, 1, [Define to 1 if we have ADDR_NO_RANDOMIZE value])
60 fi
61 ])