[BACK]Return to x86check.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / tests

Annotation of OpenXM_contrib/gmp/tests/x86check.c, Revision 1.1.1.1

1.1       ohara       1: /* x86 calling conventions checking. */
                      2:
                      3: /*
                      4: Copyright 2000, 2001 Free Software Foundation, Inc.
                      5:
                      6: This file is part of the GNU MP Library.
                      7:
                      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 2.1 of the License, or (at your
                     11: option) any later version.
                     12:
                     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.
                     17:
                     18: You should have received a copy of the GNU Lesser General Public License
                     19: along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
                     20: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     21: MA 02111-1307, USA.
                     22: */
                     23:
                     24: #include <stdio.h>
                     25: #include "gmp.h"
                     26: #include "gmp-impl.h"
                     27: #include "tests.h"
                     28:
                     29:
                     30: /* temporaries */
                     31: int  calling_conventions_save_ebx;
                     32: int  calling_conventions_save_esi;
                     33: int  calling_conventions_save_edi;
                     34: int  calling_conventions_save_ebp;
                     35: int  calling_conventions_retaddr;
                     36: int  calling_conventions_retval;
                     37:
                     38: /* values to check */
                     39: struct {
                     40:   unsigned  control;
                     41:   unsigned  status;
                     42:   unsigned  tag;
                     43:   unsigned  other[4];
                     44: } calling_conventions_fenv;
                     45: int  calling_conventions_ebx;
                     46: int  calling_conventions_esi;
                     47: int  calling_conventions_edi;
                     48: int  calling_conventions_ebp;
                     49: int  calling_conventions_eflags;
                     50:
                     51: /* expected values, as per x86call.asm */
                     52: #define VALUE_EBX   0x01234567
                     53: #define VALUE_ESI   0x89ABCDEF
                     54: #define VALUE_EDI   0xFEDCBA98
                     55: #define VALUE_EBP   0x76543210
                     56:
                     57: #define DIR_BIT(eflags)   (((eflags) & (1<<10)) != 0)
                     58:
                     59:
                     60: /* Return 1 if ok, 0 if not */
                     61:
                     62: int
                     63: calling_conventions_check (void)
                     64: {
                     65:   const char  *header = "Violated calling conventions:\n";
                     66:   int  ret = 1;
                     67:
                     68: #define CHECK(callreg, regstr, value)                   \
                     69:   if (callreg != value)                                 \
                     70:     {                                                   \
                     71:       printf ("%s   %s  got 0x%08X want 0x%08X\n",      \
                     72:               header, regstr, callreg, value);          \
                     73:       header = "";                                      \
                     74:       ret = 0;                                          \
                     75:     }
                     76:
                     77:   CHECK (calling_conventions_ebx, "ebx", VALUE_EBX);
                     78:   CHECK (calling_conventions_esi, "esi", VALUE_ESI);
                     79:   CHECK (calling_conventions_edi, "edi", VALUE_EDI);
                     80:   CHECK (calling_conventions_ebp, "ebp", VALUE_EBP);
                     81:
                     82:   if (DIR_BIT (calling_conventions_eflags) != 0)
                     83:     {
                     84:       printf ("%s   eflags dir bit  got %d want 0\n",
                     85:               header, DIR_BIT (calling_conventions_eflags));
                     86:       header = "";
                     87:       ret = 0;
                     88:     }
                     89:
                     90:   if ((calling_conventions_fenv.tag & 0xFFFF) != 0xFFFF)
                     91:     {
                     92:       printf ("%s   fpu tags  got 0x%X want 0xFFFF\n",
                     93:               header, calling_conventions_fenv.tag & 0xFFFF);
                     94:       header = "";
                     95:       ret = 0;
                     96:     }
                     97:
                     98:   return ret;
                     99: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>