1
dnl Copyright (C) 1993-2006 Free Software Foundation, Inc.
2
dnl This file is free software, distributed under the terms of the GNU
3
dnl General Public License. As a special exception to the GNU General
4
dnl Public License, this file may be distributed as part of a program
5
dnl that contains a configuration script generated by Autoconf, under
6
dnl the same distribution terms as the rest of that program.
8
dnl From Bruno Haible, Marcus Daniels.
12
AC_DEFUN([CL_CODEEXEC],
13
[AC_CACHE_CHECK([whether code in malloc'ed memory is executable], cl_cv_codeexec, [
14
dnl The test below does not work on host=hppa*-hp-hpux* because on this system
15
dnl function pointers are actually pointers into(!) a two-pointer struct.
16
dnl The test below does not work on host=rs6000-*-* because on this system
17
dnl function pointers are actually pointers to a three-pointer struct.
19
hpux*) cl_cv_codeexec="guessing yes" ;;
21
case "$host_cpu_abi"-"$host_os" in
22
# On host=rs6000-*-aix3.2.5 malloc'ed memory is indeed not executable.
23
powerpc-aix*) cl_cv_codeexec="guessing no" ;;
25
AC_TRY_RUN(GL_NOCRASH[
26
#include <sys/types.h>
27
/* declare malloc() */
29
int fun () { return 31415926; }
32
{long size = (char*)&main - (char*)&fun;
33
char* funcopy = (char*) malloc(size);
35
for (i = 0; i < size; i++) { funcopy[i] = ((char*)&fun)[i]; }
36
exit(!((*(int(*)())funcopy)() == 31415926));
37
}}], cl_cv_codeexec=yes, cl_cv_codeexec=no, cl_cv_codeexec="guessing yes")
43
case "$cl_cv_codeexec" in
44
*yes) AC_DEFINE(CODE_EXECUTABLE) ;;