Re: [Mono-dev] Embedding w/ Config Errors | No Entry Assembly

2009-09-08 Thread Matthew Metnetsky
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Robert Jordan wrote:
 Add an entry point to your assembly:
 
 class EntryPoint { static void Main () {} }
 
 Then compile the assembly with /target:exe (you can rename it to .dll
 after the compilation).
 
 Then call mono_jit_exec () somewhere after mono_jit_init ()
 and before calling other methods. See main_function () in
 one of Mono's embedding samples:
 
 http://anonsvn.mono-project.com/viewvc/trunk/mono/samples/embed/teste.c?view=markup

Robert,

Thanks for the help, it worked like a charm! Calling an apple an orange
is weird, but in this case it does make sense.

Regards,

~ Matthew
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqmVHgACgkQLrcoBjlTBf3R3wCdHjgb6UeHYh3TVbNndE2HIpNo
aLoAnjc/DDok5s537T9wie1ZwWbIH32w
=xoBP
-END PGP SIGNATURE-
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Gmcs fails with errors, but no error messages

2009-09-08 Thread Marek Safar
Hi,


 Thanks for the response, but that doesn't give any more information.

 Do you think running in gdb would help?

Could you give it a try with revision newer than r141469.

Thanks
Marek



 On 9/2/09 1:38 AM, Marek Safar marek.sa...@seznam.cz wrote:

  Hi,
  I have a csproj which builds successfully under gmcs r136341, but which
  fails under later versions including gmcs r141081. With the latest 
 version
  of gmcs, I get the following failure, but no description of the issue:
 
   Compilation failed: 2 error(s), 0 warnings
  ws1048:~ tom.philpot$
 
 
  Building the same project in Monodevelop gives the following error
  description:
  /var/folders/4M/4Mzzhf4qH-S3b733dx5BflaDzvM/-Tmp-/tmp61fbc732.tmp
 
  When I look for this file, it  is missing.
 
  In short, there are two orthogonal issues: 1) gmcs is failing on 
 code that
  previously worked and 2) gmcs is not reporting errors when it is 
 failing in
  this case.
 
  Any tips on how I can debug this would be appreciated.
   
  Try to run gmcs with --fatal option
 
  Marek


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Unsafe struct array reading

2009-09-08 Thread pablosantosl...@terra.es
Hi all,

I'm looking for a way to read and write array of structs from a file
(byte array).

I've the code (below) to read *one*, but I don't know how to map an
entire array.

I know there's a thousand of ways to do it with Streams, but the point
is for performance reasons I need to load them all on a single step (as
you'd do with C and fread).

Thank you

pablo



using System;
using System.Runtime.InteropServices;

namespace structIO
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct YourStruct
{
public int First;
public long Second;
public double Third;

public static unsafe byte[] YourStructToBytes(YourStruct s, int
arrayLen)
{
byte[] arr = new byte[sizeof(YourStruct) * arrayLen];

fixed( byte* parr = arr )
{
* ((YourStruct * )parr) = s;
}

return arr;
}

public static unsafe YourStruct BytesToYourStruct(byte[] arr,
int arrayLen)
{
if( arr.Length  (sizeof(YourStruct)*arrayLen) )
throw new ArgumentException();

YourStruct s;

fixed( byte* parr = arr )
{
s = *((YourStruct * )parr);
}

return s;

}
}

class structIOTest
{
public static void Main(string[] args)
{
YourStruct[] array = new YourStruct[10];

for( int i = 0; i  array.Length; ++i )
{
array[i].First = 10;
array[i].Second = (long) 10;
array[i].Third = (double) 10;
}

byte[] data = YourStruct.YourStructToBytes(array[0],
array.Length);

YourStruct result = YourStruct.BytesToYourStruct(data, 1);

}
}
}

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Gtk depends on Winforms ¿?

2009-09-08 Thread Mike Kestner
On Sat, 2009-09-05 at 09:15 +0200, Christian Hoff wrote:

  In Windows I use 'mkbundle' [1]
 
 We should probably put that code in a try-block. What do you think, Mike?

My question would be, what do you do in the catch block?  

The winforms reflection thing is a huge hack, we know that, and the
poster is tripping over it because of using mkbundle instead of
depending on mono or .Net.

We could also take the stance that if somebody wants to do this sort of
minimal packaging, they are required to add an artificial ref to swf to
ensure it gets bundled.  But they won't have any clue that's required if
we just silently fallback to unthemed windows when we can't find swf.

According to Robert Jordan on this thread, it's a PeekMessage/GetMessage
loop that's required to happen before the first handle is created.  We
should try a pinvoke solution like that and see if it works so we can
remove the hack altogether instead of figuring out ways to make the hack
more palatable.

Mike

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [patch] coreclr fix for internal calls

2009-09-08 Thread Stefanos A.
Την Tue, 08 Sep 2009 17:23:19 +0300,ο(η) Sebastien Pouliot  
sebastien.poul...@gmail.com έγραψε:

 Here's a patch to throw SecurityException (unlike p/invokes  
 MethodAccessException) for internal calls defined outside platform code.

This question doesn't really belong to this list, but is it possible to  
create and run user code using icall instructions (e.g. via  
DynamicMethod)? What constitutes 'platform code'?
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [patch] coreclr fix for internal calls

2009-09-08 Thread Sebastien Pouliot
On Tue, 2009-09-08 at 18:01 +0300, Stefanos A. wrote:
 Την Tue, 08 Sep 2009 17:23:19 +0300,ο(η) Sebastien Pouliot  
 sebastien.poul...@gmail.com έγραψε:
 
  Here's a patch to throw SecurityException (unlike p/invokes  
  MethodAccessException) for internal calls defined outside platform code.
 
 This question doesn't really belong to this list, but is it possible to  
 create and run user code using icall instructions (e.g. via  
 DynamicMethod)? 

Sorry but I'm not sure I understand your question. icalls are not
instructions but code that resides in the runtime itself (i.e. no
managed code part of the class libraries).

 What constitutes 'platform code'?

It's [moon|silver]light specific and it represent the code that is part
of (and shipped with) the browser plugin (i.e. not the user code).

http://www.mono-project.com/Moonlight2CoreCLR#Platform_Code

Sebastien

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] [patch] coreclr fix for internal calls

2009-09-08 Thread Sebastien Pouliot
Hello,

Here's a patch to throw SecurityException (unlike p/invokes
MethodAccessException) for internal calls defined outside platform code. The
patch also tries to reduce some code duplication for other coreclr
exceptions thrown inside mini/method-to-ir.c

Sebastien

p.s. the test cases (moonlight unit tests) also show a difference between
[s]mcs and csc - not sure what the specs are (if any) for this case but I do
prefer smcs behavior :)
Index: mono/mini/method-to-ir.c
===
--- mono/mini/method-to-ir.c	(revision 141511)
+++ mono/mini/method-to-ir.c	(working copy)
@@ -4603,57 +4603,28 @@
 }
 
 static MonoMethod*
-method_access_exception (void)
+throw_exception (void)
 {
 	static MonoMethod *method = NULL;
 
 	if (!method) {
 		MonoSecurityManager *secman = mono_security_manager_get_methods ();
-		method = mono_class_get_method_from_name (secman-securitymanager,
-			  MethodAccessException, 2);
+		method = mono_class_get_method_from_name (secman-securitymanager, ThrowException, 1);
 	}
 	g_assert (method);
 	return method;
 }
 
 static void
-emit_throw_method_access_exception (MonoCompile *cfg, MonoMethod *caller, MonoMethod *callee,
-MonoBasicBlock *bblock, unsigned char *ip)
+emit_throw_exception (MonoCompile *cfg, MonoException *ex)
 {
-	MonoMethod *thrower = method_access_exception ();
-	MonoInst *args [2];
+	MonoMethod *thrower = throw_exception ();
+	MonoInst *args [1];
 
-	EMIT_NEW_METHODCONST (cfg, args [0], caller);
-	EMIT_NEW_METHODCONST (cfg, args [1], callee);
+	EMIT_NEW_PCONST (cfg, args [0], ex);
 	mono_emit_method_call (cfg, thrower, args, NULL);
 }
 
-static MonoMethod*
-field_access_exception (void)
-{
-	static MonoMethod *method = NULL;
-
-	if (!method) {
-		MonoSecurityManager *secman = mono_security_manager_get_methods ();
-		method = mono_class_get_method_from_name (secman-securitymanager,
-			  FieldAccessException, 2);
-	}
-	g_assert (method);
-	return method;
-}
-
-static void
-emit_throw_field_access_exception (MonoCompile *cfg, MonoMethod *caller, MonoClassField *field,
-MonoBasicBlock *bblock, unsigned char *ip)
-{
-	MonoMethod *thrower = field_access_exception ();
-	MonoInst *args [2];
-
-	EMIT_NEW_METHODCONST (cfg, args [0], caller);
-	EMIT_NEW_METHODCONST (cfg, args [1], field);
-	mono_emit_method_call (cfg, thrower, args, NULL);
-}
-
 /*
  * Return the original method is a wrapper is specified. We can only access 
  * the custom attributes from the original method.
@@ -4687,7 +4658,7 @@
 
 	/* caller is Critical! only SafeCritical and Critical callers can access the field, so we throw if caller is Transparent */
 	if (mono_security_core_clr_method_level (caller, TRUE) == MONO_SECURITY_CORE_CLR_TRANSPARENT)
-		emit_throw_field_access_exception (cfg, caller, field, bblock, ip);
+		emit_throw_exception (cfg, mono_get_exception_field_access ());
 }
 
 static void
@@ -4705,7 +4676,7 @@
 
 	/* caller is Critical! only SafeCritical and Critical callers can call it, so we throw if the caller is Transparent */
 	if (mono_security_core_clr_method_level (caller, TRUE) == MONO_SECURITY_CORE_CLR_TRANSPARENT)
-		emit_throw_method_access_exception (cfg, caller, callee, bblock, ip);
+		emit_throw_exception (cfg, mono_get_exception_method_access ());
 }
 
 /*
@@ -5641,12 +5612,20 @@
 	}
 
 	if (mono_security_get_mode () == MONO_SECURITY_MODE_CORE_CLR) {
+		/* check if this is native code, e.g. an icall or a p/invoke */
 		if (method-wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) {
 			MonoMethod *wrapped = mono_marshal_method_from_wrapper (method);
-			if (wrapped  (wrapped-flags  METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
-if (!(method-klass  method-klass-image 
-		mono_security_core_clr_is_platform_image (method-klass-image))) {
-	emit_throw_method_access_exception (cfg, method, wrapped, bblock, ip);
+			if (wrapped) {
+gboolean pinvk = (wrapped-flags  METHOD_ATTRIBUTE_PINVOKE_IMPL);
+gboolean icall = (wrapped-iflags  METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL);
+
+/* if this ia a native call then it can only be JITted from platform code */
+if ((icall || pinvk)  method-klass  method-klass-image) {
+	if (!mono_security_core_clr_is_platform_image (method-klass-image)) {
+		MonoException *ex = icall ? mono_get_exception_security () : 
+			mono_get_exception_method_access ();
+		emit_throw_exception (cfg, ex);
+	}
 }
 			}
 		}
Index: mono/mini/ChangeLog
===
--- mono/mini/ChangeLog	(revision 141511)
+++ mono/mini/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2009-09-08  Sebastien Pouliot  sebast...@ximian.com
+
+	* method-to-ir.c: For CoreCLR throw a SecurityException if an 
+	internal call is defined outside platform code. Reduce code 
+	duplication with existing [Method|Field]AccessException
+
 2009-09-08  Zoltan Varga  var...@gmail.com
 
 	* cpu-x86.md mini-x86.c: Remove more unused opcodes.
Index: 

Re: [Mono-dev] [patch] coreclr fix for internal calls

2009-09-08 Thread Stefanos A.
Την Tue, 08 Sep 2009 16:48:05 +0300,ο(η) Sebastien Pouliot  
sebastien.poul...@gmail.com έγραψε:

 On Tue, 2009-09-08 at 18:01 +0300, Stefanos A. wrote:
 Την Tue, 08 Sep 2009 17:23:19 +0300,ο(η) Sebastien Pouliot
 sebastien.poul...@gmail.com έγραψε:

  Here's a patch to throw SecurityException (unlike p/invokes
  MethodAccessException) for internal calls defined outside platform  
 code.

 This question doesn't really belong to this list, but is it possible to
 create and run user code using icall instructions (e.g. via
 DynamicMethod)?

 Sorry but I'm not sure I understand your question. icalls are not
 instructions but code that resides in the runtime itself (i.e. no
 managed code part of the class libraries).

Oops, mixed with 'calli' instructions. My bad.


 What constitutes 'platform code'?

 It's [moon|silver]light specific and it represent the code that is part
 of (and shipped with) the browser plugin (i.e. not the user code).

 http://www.mono-project.com/Moonlight2CoreCLR#Platform_Code

Thanks!
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Unsafe struct array reading

2009-09-08 Thread pablosantosl...@terra.es




Great! 

Now, could you share some code about how to do it? :-P

Thanks,

pablo

Miguel de Icaza wrote:

  Hello,

  
  
I'm looking for a way to read and write array of structs from a file
(byte array).

  
  
If you use the proper packing and do not care about breaking across
endian systems, you can always just write the entire array of structures
out and read them back in using unsafe pointers.

miguel


  



___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Compacting GC

2009-09-08 Thread pablosantosl...@terra.es
Hi there!

Is is possible to try the upcoming compacting GC? Is it in a status
close to be usable?

Thanks,

pablo
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Unsafe struct array reading

2009-09-08 Thread Miguel de Icaza
Hello,

 I'm looking for a way to read and write array of structs from a file
 (byte array).

If you use the proper packing and do not care about breaking across
endian systems, you can always just write the entire array of structures
out and read them back in using unsafe pointers.

miguel

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] An asynchronous System.Runtime.Remoting.Channels.Tcp

2009-09-08 Thread Miguel de Icaza
Hello,

I like this patch very much, and I like that the way to enable it is
through the new run_async configuration option.

My only feedback is that I believe this is a nice enough feature
that it deserves at least:

* A blog entry announcing it, linking to:

* A page on the Wiki with an explanation of what it does,
  and how to use it.

Miguel.

 Hi all
 
 Attached is a patch to add an optional asynchronous path for the TCP  
 remoting channel server.
 
 The main benefit we see with this change is in reliability; when a  
 single server is servicing many clients at once (we test with over  
 100) with large data transfers the standard synchronous channel will  
 often drop connections.  We tracked this down to the Accept() call in  
 TcpServerChannel.cs not being able to get to incoming connections  
 quickly enough.
 
 I was hoping that throughput of large transfers might be improved by  
 using the threadpool's asynchronous sockets support, but it turns out  
 that performance is pretty much the same as the current implementation.
 
 Any comments/suggestions for improvement?
 
 - Dick
 
 
 ___
 Mono-devel-list mailing list
 Mono-devel-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-devel-list

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Unsafe struct array reading

2009-09-08 Thread Miguel de Icaza
Hello,

   Something like this:

   unsafe {
byte [] copy = new byte [8192];

fixed (byte *p = (byte *) ( struct [0])){
for (int i = 0; i  8192; i++
copy [i] = p [i];
}

filestream.Write (copy, 256);
   }


 Great! 
 
 Now, could you share some code about how to do it? :-P
 
 Thanks,
 
 pablo
 
 Miguel de Icaza wrote: 
  Hello,
  

   I'm looking for a way to read and write array of structs from a file
   (byte array).
   
  
  If you use the proper packing and do not care about breaking across
  endian systems, you can always just write the entire array of structures
  out and read them back in using unsafe pointers.
  
  miguel
  
  


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Mono SVN doesn't build on Mac OSX Snow Leopard

2009-09-08 Thread Tom Philpot
The primary reason seems to be that the default version of gcc on Snow
Leopard, 4.2.1,  no longer defines __i386__. gcc 4.2.1 defines __x86_64__.

I started down the path of modifying some of the #defines to correctly
target DARWIN and use __x86_64__, but I ran into trouble building
aot-runtime.c because mini.h wanted to use the -x86 sources not the amd64
sources.

Has anyone else tried to build Mono from SVN on Snow Leopard?

Thanks,
Tom




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Mono SVN doesn't build on Mac OSX Snow Leopard

2009-09-08 Thread Geoff Norton
I have some experimental patches for amd64-darwin-mono, but not ready  
yet.  For now you should set the CFLAGS=-m32

-g

On 8-Sep-09, at 8:14 PM, Tom Philpot wrote:

 The primary reason seems to be that the default version of gcc on Snow
 Leopard, 4.2.1,  no longer defines __i386__. gcc 4.2.1 defines  
 __x86_64__.

 I started down the path of modifying some of the #defines to correctly
 target DARWIN and use __x86_64__, but I ran into trouble building
 aot-runtime.c because mini.h wanted to use the -x86 sources not the  
 amd64
 sources.

 Has anyone else tried to build Mono from SVN on Snow Leopard?

 Thanks,
 Tom




 ___
 Mono-devel-list mailing list
 Mono-devel-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-devel-list

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list