[prev in list] [next in list] [prev in thread] [next in thread]
List: mono-patches
Subject: [Mono-patches] r109385 - in trunk/gert/standalone: . bug413621
From: "Gert Driesen (gert.driesen () pandora ! be)"
Date: 2008-07-31 19:53:05
Message-ID: 20080731195305.3A7509472C () mono-cvs ! ximian ! com
[Download RAW message or body]
Author: gert
Date: 2008-07-31 15:53:05 -0400 (Thu, 31 Jul 2008)
New Revision: 109385
Added:
trunk/gert/standalone/bug413621/
trunk/gert/standalone/bug413621/NativeD.cs
trunk/gert/standalone/bug413621/NativeF.cs
trunk/gert/standalone/bug413621/complex.cc
trunk/gert/standalone/bug413621/default.build
Log:
Added test for bug #413621.
Added: trunk/gert/standalone/bug413621/NativeD.cs
===================================================================
--- trunk/gert/standalone/bug413621/NativeD.cs 2008-07-31 19:49:37 UTC (rev 109384)
+++ trunk/gert/standalone/bug413621/NativeD.cs 2008-07-31 19:53:05 UTC (rev 109385)
@@ -0,0 +1,30 @@
+using System;
+using System.Runtime.InteropServices;
+
+public class TestNative
+{
+ [DllImport ("complex")]
+ private static extern unsafe void addComplexD (int l, void* x, DComplex y, void* \
z); +
+ internal struct DComplex
+ {
+ public double real;
+ public double imag;
+ public DComplex (double _re, double _im)
+ { real = _re; imag = _im; }
+ }
+
+ public static unsafe void Main (string [] args)
+ {
+ DComplex xD = new DComplex (42, 42);
+ DComplex [] xxD = new DComplex [10], yyD = new DComplex [10];
+
+ for (int i = 0; i < xxD.Length; i++) xxD [i] = new DComplex ((double) i, (double) \
2 * i); +
+ fixed (void* xxd = xxD, yyd = yyD)
+ addComplexD (xxD.Length, xxd, xD, yyd);
+
+ fixed (void* xxd = xxD, yyd = yyD)
+ addComplexD (xxD.Length, xxd, xD, yyd);
+ }
+}
Property changes on: trunk/gert/standalone/bug413621/NativeD.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/gert/standalone/bug413621/NativeF.cs
===================================================================
--- trunk/gert/standalone/bug413621/NativeF.cs 2008-07-31 19:49:37 UTC (rev 109384)
+++ trunk/gert/standalone/bug413621/NativeF.cs 2008-07-31 19:53:05 UTC (rev 109385)
@@ -0,0 +1,30 @@
+using System;
+using System.Runtime.InteropServices;
+
+public class TestNative
+{
+ [DllImport ("complex")]
+ private static extern unsafe void addComplexS (int l, void* x, FComplex y, void* \
z); +
+ internal struct FComplex
+ {
+ public float real;
+ public float imag;
+ public FComplex (float _re, float _im)
+ { real = _re; imag = _im; }
+ }
+
+ public static unsafe void Main (string [] args)
+ {
+ FComplex xF = new FComplex ((float) 41, (float) 41);
+ FComplex [] xxF = new FComplex [10], yyF = new FComplex [10];
+
+ for (int i = 0; i < xxF.Length; i++) xxF [i] = new FComplex ((float) i, (float) 2 \
* i); +
+ fixed (void* xxf = xxF, yyf = yyF)
+ addComplexS (xxF.Length, xxf, xF, yyf);
+
+ fixed (void* xxf = xxF, yyf = yyF)
+ addComplexS (xxF.Length, xxf, xF, yyf);
+ }
+}
Property changes on: trunk/gert/standalone/bug413621/NativeF.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/gert/standalone/bug413621/complex.cc
===================================================================
--- trunk/gert/standalone/bug413621/complex.cc 2008-07-31 19:49:37 UTC (rev 109384)
+++ trunk/gert/standalone/bug413621/complex.cc 2008-07-31 19:53:05 UTC (rev 109385)
@@ -0,0 +1,16 @@
+#include <complex>
+using namespace std;
+typedef complex<double> dcomplex;
+typedef complex<float> fcomplex;
+
+extern "C" void addComplexS(int l, fcomplex* x, fcomplex y, fcomplex* z)
+{
+ for(int i = 0; i < l; i++)
+ z[i] = x[i] + y;
+}
+
+extern "C" void addComplexD(int l, dcomplex* x, dcomplex y, dcomplex* z)
+{
+ for(int i = 0; i < l; i++)
+ z[i] = x[i] + y;
+}
Added: trunk/gert/standalone/bug413621/default.build
===================================================================
--- trunk/gert/standalone/bug413621/default.build 2008-07-31 19:49:37 UTC (rev \
109384)
+++ trunk/gert/standalone/bug413621/default.build 2008-07-31 19:53:05 UTC (rev \
109385) @@ -0,0 +1,57 @@
+<project name="bug399048" default="rebuild">
+ <include buildfile="../../build/common.build" />
+
+ <property name="frameworks" value="mono-1.0,mono-2.0,net-1.1,net-2.0" />
+
+ <target name="clean">
+ <delete>
+ <fileset>
+ <include name="libcomplex.o" />
+ <include name="libcomplex.so" />
+ <include name="out" />
+ <include name="NativeD.exe" />
+ <include name="NativeF.exe" />
+ </fileset>
+ </delete>
+ </target>
+
+ <target name="compile-libcomplex" if="${platform::is-unix()}">
+ <exec program="g++">
+ <arg value="-g" />
+ <arg value="-c" />
+ <arg value="-fPIC" />
+ <arg file="complex.cc" />
+ </exec>
+ <exec program="g++">
+ <arg value="-shared" />
+ <arg value="-o" />
+ <arg file="libcomplex.so" />
+ <arg file="libcomplex.o" />
+ </exec>
+ </target>
+
+ <target name="compile-natived" depends="init,compile-libcomplex" \
if="${platform::is-unix()}"> + <csc target="exe" define="${csc.defines}" \
output="NativeD.exe" unsafe="true" warnaserror="true" warninglevel="4"> + <sources>
+ <include name="NativeD.cs" />
+ </sources>
+ </csc>
+ </target>
+
+ <target name="compile-nativef" depends="init,compile-libcomplex" \
if="${platform::is-unix()}"> + <csc target="exe" define="${csc.defines}" \
output="NativeF.exe" unsafe="true" warnaserror="true" warninglevel="4"> + <sources>
+ <include name="NativeF.cs" />
+ </sources>
+ </csc>
+ </target>
+
+ <target name="compile" depends="compile-natived,compile-nativef" />
+
+ <target name="run-test" depends="compile" if="${platform::is-unix()}">
+ <exec program="NativeD.exe" managed="strict" output="out" />
+ <fail if="${file::exists('out')}" />
+ <exec program="NativeF.exe" managed="strict" output="out" />
+ <fail if="${file::exists('out')}" />
+ </target>
+</project>
Property changes on: trunk/gert/standalone/bug413621/default.build
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Mono-patches maillist - Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic