~ubuntu-branches/debian/squeeze/ffcall/squeeze

« back to all changes in this revision

Viewing changes to ffcall/m4/ffcall-codeexec.m4

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2010-06-26 15:29:30 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100626152930-c09y01gk3szcnykn
Tags: 1.10+cvs20100619-2
Ship to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
7
 
 
8
 
dnl From Bruno Haible, Marcus Daniels.
9
 
 
10
 
AC_PREREQ(2.13)
11
 
 
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.
18
 
case "$host_os" in
19
 
  hpux*) cl_cv_codeexec="guessing yes" ;;
20
 
  *)
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" ;;
24
 
  *)
25
 
AC_TRY_RUN(GL_NOCRASH[
26
 
#include <sys/types.h>
27
 
/* declare malloc() */
28
 
#include <stdlib.h>
29
 
int fun () { return 31415926; }
30
 
int main ()
31
 
{ nocrash_init();
32
 
 {long size = (char*)&main - (char*)&fun;
33
 
  char* funcopy = (char*) malloc(size);
34
 
  int i;
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")
38
 
  ;;
39
 
esac
40
 
  ;;
41
 
esac
42
 
])
43
 
case "$cl_cv_codeexec" in
44
 
  *yes) AC_DEFINE(CODE_EXECUTABLE) ;;
45
 
  *no)  ;;
46
 
esac
47
 
])