File: smallstruct.m4

package info (click to toggle)
ffcall 2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,808 kB
  • sloc: asm: 43,409; ansic: 23,224; sh: 5,383; makefile: 1,517; cpp: 2
file content (66 lines) | stat: -rw-r--r-- 3,105 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
dnl -*- Autoconf -*-
dnl Copyright (C) 1993-2017 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License as published by the Free Software Foundation;
dnl either version 2 of the License, or (at your option) any later version.
dnl As a special exception to the GNU General Public License, this file
dnl may be distributed as part of a program that contains a configuration
dnl script generated by Autoconf, under the same distribution terms as
dnl the rest of that program.

dnl From Bruno Haible, Marcus Daniels, Sam Steingold.

AC_PREREQ([2.13])

AC_DEFUN([SSR_DOC],[whether small structs are returned in registers])
AC_DEFUN([FFCALL_SMALL_STRUCT_RETURN],
[
  AC_REQUIRE([AC_CANONICAL_HOST])
  AC_REQUIRE([gl_HOST_CPU_C_ABI])
  AC_CACHE_CHECK([SSR_DOC], [ffcall_cv_c_struct_return_small],
    [AC_TRY_RUN(GL_NOCRASH
       [typedef struct { long x; } foo;
        long y;
        foo foofun () { foo f; f.x = y; return f; }
        long (*fun) () = (long (*) ()) foofun;
        int main()
        { nocrash_init();
          y = 37; if ((*fun)() != 37) return 1;
          y = 55; if ((*fun)() != 55) return 1;
          return 0;
        }
       ],
       [ffcall_cv_c_struct_return_small=yes],
       [ffcall_cv_c_struct_return_small=no],
       [dnl When cross-compiling, guess depending on the ABI.
        dnl If we don't know, don't assume anything. There are even weirder
        dnl return value passing conventions than pcc.
        case "$HOST_CPU_C_ABI" in
          alpha)               ffcall_cv_c_struct_return_small="guessing no" ;;
          arm | armhf | arm64) ffcall_cv_c_struct_return_small="guessing yes" ;;
          hppa | hppa64)       ffcall_cv_c_struct_return_small="guessing yes" ;;
          i386)
            case "$host_os" in
              cygwin* | darwin* | mingw*) ffcall_cv_c_struct_return_small="guessing yes" ;;
              linux* | solaris*)          ffcall_cv_c_struct_return_small="guessing no" ;;
              *)                          ffcall_cv_c_struct_return_small="guessing no" ;;
            esac
            ;;
          ia64)                ffcall_cv_c_struct_return_small="guessing yes" ;;
          mips | mipsn32)      ffcall_cv_c_struct_return_small="guessing no" ;;
          mips64)              ffcall_cv_c_struct_return_small="guessing yes" ;;
          powerpc | powerpc64) ffcall_cv_c_struct_return_small="guessing no" ;;
          powerpc64-elfv2)     ffcall_cv_c_struct_return_small="guessing yes" ;;
          s390 | s390x)        ffcall_cv_c_struct_return_small="guessing no" ;;
          sparc)               ffcall_cv_c_struct_return_small="guessing no" ;;
          sparc64)             ffcall_cv_c_struct_return_small="guessing yes" ;;
          x86_64)              ffcall_cv_c_struct_return_small="guessing yes" ;;
          *)                   ffcall_cv_c_struct_return_small="guessing no" ;;
        esac
       ])
    ])
  case "$ffcall_cv_c_struct_return_small" in
    *yes) AC_DEFINE([__SMALL_STRUCT_RETURN__], [], SSR_DOC) ;;
    *no) ;;
  esac
])