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

« back to all changes in this revision

Viewing changes to m4/pccstruct.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 -*- Autoconf -*-
 
2
dnl Copyright (C) 1993-2009 Free Software Foundation, Inc.
 
3
dnl This file is free software, distributed under the terms of the GNU
 
4
dnl General Public License.  As a special exception to the GNU General
 
5
dnl Public License, this file may be distributed as part of a program
 
6
dnl that contains a configuration script generated by Autoconf, under
 
7
dnl the same distribution terms as the rest of that program.
 
8
 
 
9
dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
 
10
 
 
11
AC_PREREQ(2.13)
 
12
 
 
13
AC_DEFUN([PCCSR_DOC],[for pcc non-reentrant struct return convention])
 
14
AC_DEFUN([FFCALL_PCC_STRUCT_RETURN],[dnl
 
15
AC_CACHE_CHECK(PCCSR_DOC, ffcall_cv_c_struct_return_static, [dnl
 
16
save_CFLAGS="$CFLAGS"
 
17
test $CC_GCC = true && CFLAGS="$CFLAGS -O0"
 
18
AC_TRY_RUN(GL_NOCRASH[
 
19
typedef struct { int a; int b; int c; int d; int e; } foo;
 
20
foo foofun () { static foo foopi = {3141,5926,5358,9793,2385}; return foopi; }
 
21
foo* (*fun) () = (foo* (*) ()) foofun;
 
22
int main()
 
23
{ nocrash_init();
 
24
 {foo foo1;
 
25
  foo* fooptr1;
 
26
  foo foo2;
 
27
  foo* fooptr2;
 
28
  foo1 = foofun(); fooptr1 = (*fun)(&foo1);
 
29
  foo2 = foofun(); fooptr2 = (*fun)(&foo2);
 
30
  return !(fooptr1 == fooptr2 && fooptr1->c == 5358);
 
31
}}], ffcall_cv_c_struct_return_static=yes, ffcall_cv_c_struct_return_static=no,
 
32
dnl When cross-compiling, don't assume anything.
 
33
dnl There are even weirder return value passing conventions than pcc.
 
34
ffcall_cv_c_struct_return_static="guessing no")
 
35
CFLAGS="$save_CFLAGS"
 
36
])
 
37
case "$ffcall_cv_c_struct_return_static" in
 
38
  *yes) AC_DEFINE([__PCC_STRUCT_RETURN__], [], PCCSR_DOC) ;;
 
39
  *no) ;;
 
40
esac
 
41
])