dnl Copyright (C) 1993-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
AC_PREREQ(2.13)
AC_DEFUN([CL_PCC_STRUCT_RETURN],
[AC_CACHE_CHECK([for pcc non-reentrant struct return convention], cl_cv_c_struct_return_static, [
save_CFLAGS="$CFLAGS"
test $CC_GCC = true && CFLAGS="$CFLAGS -O0"
AC_TRY_RUN([typedef struct { int a; int b; int c; int d; int e; } foo;
foo foofun () { static foo foopi = {3141,5926,5358,9793,2385}; return foopi; }
foo* (*fun) () = (foo* (*) ()) foofun;
int main()
{ foo foo1;
foo* fooptr1;
foo foo2;
foo* fooptr2;
foo1 = foofun(); fooptr1 = (*fun)(&foo1);
foo2 = foofun(); fooptr2 = (*fun)(&foo2);
exit(!(fooptr1 == fooptr2 && fooptr1->c == 5358));
}], cl_cv_c_struct_return_static=yes, rm -f core
cl_cv_c_struct_return_static=no,
dnl When cross-compiling, don't assume anything.
dnl There are even weirder return value passing conventions than pcc.
cl_cv_c_struct_return_static="guessing no")
CFLAGS="$save_CFLAGS"
])
case "$cl_cv_c_struct_return_static" in
*yes) AC_DEFINE(__PCC_STRUCT_RETURN__) ;;
*no) ;;
esac
])