1 /* x86 calling conventions checking. */
4 Copyright 2000, 2001 Free Software Foundation, Inc.
6 This file is part of the GNU MP Library.
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
13 The GNU MP Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
28 int calling_conventions_save_ebx;
29 int calling_conventions_save_esi;
30 int calling_conventions_save_edi;
31 int calling_conventions_save_ebp;
32 int calling_conventions_retaddr;
33 int calling_conventions_retval;
41 } calling_conventions_fenv;
42 int calling_conventions_ebx;
43 int calling_conventions_esi;
44 int calling_conventions_edi;
45 int calling_conventions_ebp;
46 int calling_conventions_eflags;
48 /* expected values, as per x86call.asm */
49 #define VALUE_EBX 0x01234567
50 #define VALUE_ESI 0x89ABCDEF
51 #define VALUE_EDI 0xFEDCBA98
52 #define VALUE_EBP 0x76543210
54 #define DIR_BIT(eflags) (((eflags) & (1<<10)) != 0)
57 /* Return 1 if ok, 0 if not */
60 calling_conventions_check (void)
62 const char *header = "Violated calling conventions:\n";
65 #define CHECK(callreg, regstr, value) \
66 if (callreg != value) \
68 printf ("%s %s got 0x%08X want 0x%08X\n", \
69 header, regstr, callreg, value); \
74 CHECK (calling_conventions_ebx, "ebx", VALUE_EBX);
75 CHECK (calling_conventions_esi, "esi", VALUE_ESI);
76 CHECK (calling_conventions_edi, "edi", VALUE_EDI);
77 CHECK (calling_conventions_ebp, "ebp", VALUE_EBP);
79 if (DIR_BIT (calling_conventions_eflags) != 0)
81 printf ("%s eflags dir bit got %d want 0\n",
82 header, DIR_BIT (calling_conventions_eflags));
87 if ((calling_conventions_fenv.tag & 0xFFFF) != 0xFFFF)
89 printf ("%s fpu tags got 0x%X want 0xFFFF\n",
90 header, calling_conventions_fenv.tag & 0xFFFF);