[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r8855 - in /libdfp/trunk: Makefile.in tests/README tests/TODO tests/test-param.c



Author: ryanarn
Date: Fri Aug 21 08:48:57 2009
New Revision: 8855

Log:
2009-08-21  Ryan S. Arnold  <rsa@xxxxxxxxxx>

	* Makefile.in: Added test-param to libdfp_tests.
	* tests/TODO: New file.
	* tests/README: N/A.
	* tests/test-param.c: New test to verify integrity of parameters that
	are spilled to the stack on being passed to a new function.

Added:
    libdfp/trunk/tests/TODO
    libdfp/trunk/tests/test-param.c
Modified:
    libdfp/trunk/Makefile.in
    libdfp/trunk/tests/README

Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Fri Aug 21 08:48:57 2009
@@ -253,7 +253,7 @@
 
 GLIBC_LIBS := $(glibc_builddir)/libc.so $(glibc_builddir)/math/libm.so $(glibc_builddir)/nptl/libpthread.so
 
-libdfp_tests = test-printf
+libdfp_tests = test-printf test-param
 
 # Explicitly link against the uninstalled GLIBC and the Libdfp.so.1 we just
 # built.

Modified: libdfp/trunk/tests/README
==============================================================================
--- libdfp/trunk/tests/README (original)
+++ libdfp/trunk/tests/README Fri Aug 21 08:48:57 2009
@@ -1,1 +1,2 @@
 In order to debug do the following:
+

Added: libdfp/trunk/tests/TODO
==============================================================================
--- libdfp/trunk/tests/TODO (added)
+++ libdfp/trunk/tests/TODO Fri Aug 21 08:48:57 2009
@@ -1,0 +1,4 @@
+
+
+test-param.c: Have it automate checking the return values and use scaffold.c
+for outputting failure cases.

Added: libdfp/trunk/tests/test-param.c
==============================================================================
--- libdfp/trunk/tests/test-param.c (added)
+++ libdfp/trunk/tests/test-param.c Fri Aug 21 08:48:57 2009
@@ -1,0 +1,76 @@
+/* Test parameter passing compliance with the ABI.
+
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This file is part of the Decimal Floating Point C Library.
+
+   Author(s): Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+   The Decimal Floating Point C Library is free software; you can
+   redistribute it and/or modify it under the terms of the GNU Lesser
+   General Public License version 2.1.
+
+   The Decimal Floating Point C Library is distributed in the hope that
+   it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+   the GNU Lesser General Public License version 2.1 for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License version 2.1 along with the Decimal Floating Point C Library;
+   if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+   Suite 330, Boston, MA 02111-1307 USA.
+
+   Please see libdfp/COPYING.txt for more information.  */
+
+#ifndef __STDC_WANT_DEC_FP__
+#define __STDC_WANT_DEC_FP__
+#endif
+
+#include <stdio.h>
+#include <float.h>
+
+/* This testcase is designed to test that the compiler is satisfying the
+ * conditions of the ABI with regard to spilling of _Decimal* type parameters
+ * to the stack.  In other words, we verify the integrity of the data after a
+ * function call where parameters are spilled.  This should be tested for both
+ * hard and soft dfp.  */
+
+/* char * should ref a 14 byte char array, +0,000,000E+0\0  */
+extern char * decoded32 (_Decimal32, char*);
+/* char * should ref a 26 byte char array, +0,000,000,000,000,000E+0\0  */
+extern char * decoded64 (_Decimal64, char*);
+/* char * should ref a 50 byte char array, *
+ * +0,000,000,000,000,000,000,000,000,000,000,000E+0\0  */
+extern char * decoded128 (_Decimal128, char*);
+
+typedef struct sparm {
+  _Decimal32 df;
+  _Decimal64 dd;
+  _Decimal128 dl;
+} sparm_t;
+
+/* Test parameter spilling.  */
+int func(_Decimal128 d128, _Decimal64 d64, _Decimal32 d32, struct sparm *s,
+struct sparm *t, _Decimal32 e32, _Decimal64 e64, _Decimal64 z64, _Decimal128 e128, _Decimal64 f64, _Decimal128 f128)
+{
+  volatile _Decimal128 z;
+  volatile _Decimal128 y;
+  z = e128;
+  y = f128;
+  return 0;
+}
+
+int main() {
+  int x;
+  struct sparm s, t;
+  char buf[256];
+  _Decimal32 d32,e32 = 4.44444DF;
+  _Decimal64 d64,e64,f64 = 9.99999DD;
+  _Decimal128 d128,e128 = 1.0DL;
+  _Decimal128 f128 = 2.0DL;
+
+  x = func(d128,d64,d32,&s,&t,e32,e64,e64,e128,f64,f128);
+  decoded128(e128,&buf[0]);
+  printf("%s\n",buf);
+  return 0;
+}