Re: [Mono-dev] use locale_charset() from iconv instead of use nl_langinfo (CODESET)

2010-10-21 Thread Robert Nagy
Does anyone care?

On (2010-10-19 13:31), Robert Nagy wrote:
 Hi
 
 Someone please have a look at http://github.com/mono/mono/pull/9
 
 
 Use locale_charset() from iconv which will use nl_langinfo (CODESET) anyways 
 but it will do canonicalization so we will get the correct charset name, 
 because nl_langinfo (CODESET) can return different things on different 
 systems. This at least fixes OpenBSD.
 
 Without this building mono will end up in an exception because it's going to 
 try to open codepage 646 instead of ascii because g_get_charset() returns the 
 wrong one.
 
 The testcode linked to system glib and eglib:
 (t500 robert 17418)$ ./char-glib; ./char-eglib
 
 ascii
 646
 
 ___
 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


[Mono-dev] use locale_charset() from iconv instead of use nl_langinfo (CODESET)

2010-10-19 Thread Robert Nagy
Hi

Someone please have a look at http://github.com/mono/mono/pull/9


Use locale_charset() from iconv which will use nl_langinfo (CODESET) anyways 
but it will do canonicalization so we will get the correct charset name, 
because nl_langinfo (CODESET) can return different things on different systems. 
This at least fixes OpenBSD.

Without this building mono will end up in an exception because it's going to 
try to open codepage 646 instead of ascii because g_get_charset() returns the 
wrong one.

The testcode linked to system glib and eglib:
(t500 robert 17418)$ ./char-glib; ./char-eglib

ascii
646

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


Re: [Mono-dev] UnixUserInfo issues in OpenBSD

2010-10-18 Thread Robert Nagy
Of course you do, that has nothing to do with the issue you
see now. 

On (2010-10-18 11:54), pablosantosl...@terra.es wrote:
 Hi,
 
 I got the same issue (Mono/C#) running as root.
 
 On 18/10/2010 0:44, Robert Nagy wrote:
  Ignore that diff i just sent, it's stupid, i did not read
  the code correctly. Working on something that fixes the problem
  correctly.
  
  On (2010-10-18 00:22), Robert Nagy wrote:
  You get errno 13 (EACCES) because you are not running it as root
  and getpwnam_r will try to give you struct passwd which inludes
  the encrypted password of the user so errno will be set to EACCES,
  but the other fields will be set.
 
  According to the comment in mph.h getpnam_r only returns ERANGE on
  linux and -1 on Mac OS, bt errno == ERANGE was wrong anyways.
  On OpenBSD we return 1 until everything is okay and then we return 0.
  The following diff fixes OpenBSD and Mac OS too.
 
  diff --git a/support/mph.h b/support/mph.h
  index 8a61999..08ce5ea 100644
  --- a/support/mph.h
  +++ b/support/mph.h
  @@ -198,8 +198,8 @@ recheck_range (int ret)
   {
  if (ret == ERANGE)
  return 1;
  -   if (ret == -1)
  -   return errno == ERANGE;
  +   if (ret != 0)
  +   return errno = ERANGE;
  return 0;
   }
   
  On (2010-10-13 12:56), Jonathan Pryor wrote:
  On Wed, 2010-10-13 at 16:38 +0200, pablosantosl...@terra.es wrote:
  This is what I get:
 
  $ ./a.out tester
  # checking return value 1; errno=13
 
  That's...horribly wrong.
 
  First, what's errno=13?  (i.e. what EVALUE is 13?  I'm sure OpenBSD has
  different values than Linux does.)
 
  Regardless, OpenBSD doesn't appear to be conforming to the standard
  here:
 
  
  http://www.opengroup.org/onlinepubs/009695399/functions/getpwnam_r.html
 
  If successful, the getpwnam_r() function shall return zero;
  otherwise, an error number shall be returned to indicate the
  error. 
 
  The value '1' is likely not the correct errno for ERANGE (Under Linux,
  EPERM has the value 1), and since the return value isn't -1
  recheck_range() won't check errno against ERANGE either.
 
  However, this does point out a bug in MonoPosixHelper: if getpwnam_r()
  returns non-zero it should treat it as an error, which is clearly not
  happening here (and is why we're printing garbage data to the screen).
 
  This would only marginally help you, though, as it would result in no
  users being found, ever.
 
  The fundamental problem is that Mono_Posix_Syscall_getpwnam_r()'s logic
  for checking for ERANGE (so it'll resize the buffer and try the call
  again) is failing under OpenBSD, and from what I can see here the
  problem is within OpenBSD, not MonoPosixHelper.
 
  Patches welcome to properly support OpenBSD. :-)
 
   - Jon
 
 
  ___
  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
  ___
  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
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] UnixUserInfo issues in OpenBSD

2010-10-17 Thread Robert Nagy
I am going to have a look at this.

On (2010-10-13 12:56), Jonathan Pryor wrote:
 On Wed, 2010-10-13 at 16:38 +0200, pablosantosl...@terra.es wrote:
  This is what I get:
  
  $ ./a.out tester
  # checking return value 1; errno=13
 
 That's...horribly wrong.
 
 First, what's errno=13?  (i.e. what EVALUE is 13?  I'm sure OpenBSD has
 different values than Linux does.)
 
 Regardless, OpenBSD doesn't appear to be conforming to the standard
 here:
 
 
 http://www.opengroup.org/onlinepubs/009695399/functions/getpwnam_r.html
 
 If successful, the getpwnam_r() function shall return zero;
 otherwise, an error number shall be returned to indicate the
 error. 
 
 The value '1' is likely not the correct errno for ERANGE (Under Linux,
 EPERM has the value 1), and since the return value isn't -1
 recheck_range() won't check errno against ERANGE either.
 
 However, this does point out a bug in MonoPosixHelper: if getpwnam_r()
 returns non-zero it should treat it as an error, which is clearly not
 happening here (and is why we're printing garbage data to the screen).
 
 This would only marginally help you, though, as it would result in no
 users being found, ever.
 
 The fundamental problem is that Mono_Posix_Syscall_getpwnam_r()'s logic
 for checking for ERANGE (so it'll resize the buffer and try the call
 again) is failing under OpenBSD, and from what I can see here the
 problem is within OpenBSD, not MonoPosixHelper.
 
 Patches welcome to properly support OpenBSD. :-)
 
  - Jon
 
 
 ___
 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] UnixUserInfo issues in OpenBSD

2010-10-17 Thread Robert Nagy
You get errno 13 (EACCES) because you are not running it as root
and getpwnam_r will try to give you struct passwd which inludes
the encrypted password of the user so errno will be set to EACCES,
but the other fields will be set.

According to the comment in mph.h getpnam_r only returns ERANGE on
linux and -1 on Mac OS, bt errno == ERANGE was wrong anyways.
On OpenBSD we return 1 until everything is okay and then we return 0.
The following diff fixes OpenBSD and Mac OS too.

diff --git a/support/mph.h b/support/mph.h
index 8a61999..08ce5ea 100644
--- a/support/mph.h
+++ b/support/mph.h
@@ -198,8 +198,8 @@ recheck_range (int ret)
 {
if (ret == ERANGE)
return 1;
-   if (ret == -1)
-   return errno == ERANGE;
+   if (ret != 0)
+   return errno = ERANGE;
return 0;
 }
 
On (2010-10-13 12:56), Jonathan Pryor wrote:
 On Wed, 2010-10-13 at 16:38 +0200, pablosantosl...@terra.es wrote:
  This is what I get:
  
  $ ./a.out tester
  # checking return value 1; errno=13
 
 That's...horribly wrong.
 
 First, what's errno=13?  (i.e. what EVALUE is 13?  I'm sure OpenBSD has
 different values than Linux does.)
 
 Regardless, OpenBSD doesn't appear to be conforming to the standard
 here:
 
 
 http://www.opengroup.org/onlinepubs/009695399/functions/getpwnam_r.html
 
 If successful, the getpwnam_r() function shall return zero;
 otherwise, an error number shall be returned to indicate the
 error. 
 
 The value '1' is likely not the correct errno for ERANGE (Under Linux,
 EPERM has the value 1), and since the return value isn't -1
 recheck_range() won't check errno against ERANGE either.
 
 However, this does point out a bug in MonoPosixHelper: if getpwnam_r()
 returns non-zero it should treat it as an error, which is clearly not
 happening here (and is why we're printing garbage data to the screen).
 
 This would only marginally help you, though, as it would result in no
 users being found, ever.
 
 The fundamental problem is that Mono_Posix_Syscall_getpwnam_r()'s logic
 for checking for ERANGE (so it'll resize the buffer and try the call
 again) is failing under OpenBSD, and from what I can see here the
 problem is within OpenBSD, not MonoPosixHelper.
 
 Patches welcome to properly support OpenBSD. :-)
 
  - Jon
 
 
 ___
 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] UnixUserInfo issues in OpenBSD

2010-10-17 Thread Robert Nagy
Ignore that diff i just sent, it's stupid, i did not read
the code correctly. Working on something that fixes the problem
correctly.

On (2010-10-18 00:22), Robert Nagy wrote:
 You get errno 13 (EACCES) because you are not running it as root
 and getpwnam_r will try to give you struct passwd which inludes
 the encrypted password of the user so errno will be set to EACCES,
 but the other fields will be set.
 
 According to the comment in mph.h getpnam_r only returns ERANGE on
 linux and -1 on Mac OS, bt errno == ERANGE was wrong anyways.
 On OpenBSD we return 1 until everything is okay and then we return 0.
 The following diff fixes OpenBSD and Mac OS too.
 
 diff --git a/support/mph.h b/support/mph.h
 index 8a61999..08ce5ea 100644
 --- a/support/mph.h
 +++ b/support/mph.h
 @@ -198,8 +198,8 @@ recheck_range (int ret)
  {
 if (ret == ERANGE)
 return 1;
 -   if (ret == -1)
 -   return errno == ERANGE;
 +   if (ret != 0)
 +   return errno = ERANGE;
 return 0;
  }
  
 On (2010-10-13 12:56), Jonathan Pryor wrote:
  On Wed, 2010-10-13 at 16:38 +0200, pablosantosl...@terra.es wrote:
   This is what I get:
   
   $ ./a.out tester
   # checking return value 1; errno=13
  
  That's...horribly wrong.
  
  First, what's errno=13?  (i.e. what EVALUE is 13?  I'm sure OpenBSD has
  different values than Linux does.)
  
  Regardless, OpenBSD doesn't appear to be conforming to the standard
  here:
  
  
  http://www.opengroup.org/onlinepubs/009695399/functions/getpwnam_r.html
  
  If successful, the getpwnam_r() function shall return zero;
  otherwise, an error number shall be returned to indicate the
  error. 
  
  The value '1' is likely not the correct errno for ERANGE (Under Linux,
  EPERM has the value 1), and since the return value isn't -1
  recheck_range() won't check errno against ERANGE either.
  
  However, this does point out a bug in MonoPosixHelper: if getpwnam_r()
  returns non-zero it should treat it as an error, which is clearly not
  happening here (and is why we're printing garbage data to the screen).
  
  This would only marginally help you, though, as it would result in no
  users being found, ever.
  
  The fundamental problem is that Mono_Posix_Syscall_getpwnam_r()'s logic
  for checking for ERANGE (so it'll resize the buffer and try the call
  again) is failing under OpenBSD, and from what I can see here the
  problem is within OpenBSD, not MonoPosixHelper.
  
  Patches welcome to properly support OpenBSD. :-)
  
   - Jon
  
  
  ___
  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
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] unbreak build on OpenBSD/amd64

2010-05-13 Thread Robert Nagy
Hey

No UCONTEXT_GREGS on OpenBSD.

Index: mono/mini/exceptions-amd64.c
===
--- mono/mini/exceptions-amd64.c(revision 157293)
+++ mono/mini/exceptions-amd64.c(working copy)
@@ -686,7 +686,7 @@
 gboolean
 mono_arch_handle_exception (void *sigctx, gpointer obj, gboolean test_only)
 {
-#if defined(MONO_ARCH_USE_SIGACTION)
+#if defined(MONO_ARCH_USE_SIGACTION)  defined(UCONTEXT_GREGS)
/*
 * Handling the exception in the signal handler is problematic, since 
the original
 * signal is disabled, and we could run arbitrary code though the 
debugger. So
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] eglib patch to make it build on OpenBSD

2010-04-28 Thread Robert Nagy
Hi

diff is attached
Index: eglib/configure.ac
===
--- eglib/configure.ac  (revision 156280)
+++ eglib/configure.ac  (working copy)
@@ -56,6 +56,10 @@
 i*86-*-darwin*)
 ORDER=G_LITTLE_ENDIAN
 ;;
+*-*-openbsd*)
+CFLAGS=$CFLAGS -pthread
+LDFLAGS=$LDFLAGS -pthread
+;;
 esac
 
 AC_SUBST(ORDER)
Index: eglib/src/gspawn.c
===
--- eglib/src/gspawn.c  (revision 156280)
+++ eglib/src/gspawn.c  (working copy)
@@ -71,6 +71,8 @@
  */
 gchar ***_NSGetEnviron();
 #define environ (*_NSGetEnviron())
+#else
+extern char **environ;
 #endif
 
 static int
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] backport of some openbsd stuff to 2.6

2010-04-27 Thread Robert Nagy
Hi

The attached diff backports some missing stuff from HEAD to branch_2_6
that was probably forgotten to be commited when we worked on it because
some parts of it are in already.
It also fixed a null pointer reference that was fixed in HEAD too,
the other changes are OpenBSD only.
Please commit.
Index: mono/metadata/threadpool.c
===
--- mono/metadata/threadpool.c  (revision 156177)
+++ mono/metadata/threadpool.c  (working copy)
@@ -527,7 +527,8 @@
 
for (i = 1; i  allocated; i++) {
pfd = pfds [i];
-   if (pfd-fd == -1 || pfd-fd == 
data-newpfd-fd)
+   if (pfd-fd == -1 || data-newpfd == NULL ||
+   pfd-fd == data-newpfd-fd)
break;
}
 
Index: mono/mini/mini-amd64.h
===
--- mono/mini/mini-amd64.h  (revision 156177)
+++ mono/mini/mini-amd64.h  (working copy)
@@ -254,10 +254,6 @@
 
 #endif
 
-#ifdef __OpenBSD__
-#undef MONO_ARCH_USE_SIGACTION
-#endif
-
 #endif /* PLATFORM_WIN32 */
 
 #if defined (__NetBSD__)
@@ -282,8 +278,12 @@
 
 #define MONO_ARCH_NOMAP32BIT
 
-#elif defined (__FreeBSD__) || defined (__OpenBSD__)
+#elif defined (__OpenBSD__)
 
+#define MONO_ARCH_NOMAP32BIT
+
+#elif defined (__FreeBSD__)
+
 #define REG_RAX 7
 #define REG_RCX 4
 #define REG_RDX 3
Index: mono/mini/exceptions-amd64.c
===
--- mono/mini/exceptions-amd64.c(revision 156177)
+++ mono/mini/exceptions-amd64.c(working copy)
@@ -711,7 +711,7 @@
return TRUE;
 }
 
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION)  defined(UCONTEXT_GREGS)
 static inline guint64*
 gregs_from_ucontext (ucontext_t *ctx)
 {
@@ -721,7 +721,7 @@
 void
 mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 {
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION)  defined(UCONTEXT_GREGS)
ucontext_t *ctx = (ucontext_t*)sigctx;
 
 guint64 *gregs = gregs_from_ucontext (ctx);
@@ -739,6 +739,22 @@
mctx-r13 = gregs [REG_R13];
mctx-r14 = gregs [REG_R14];
mctx-r15 = gregs [REG_R15];
+#elif defined(MONO_ARCH_USE_SIGACTION)
+   ucontext_t *ctx = (ucontext_t*)sigctx;
+
+   mctx-rax = UCONTEXT_REG_RAX (ctx);
+   mctx-rbx = UCONTEXT_REG_RBX (ctx);
+   mctx-rcx = UCONTEXT_REG_RCX (ctx);
+   mctx-rdx = UCONTEXT_REG_RDX (ctx);
+   mctx-rbp = UCONTEXT_REG_RBP (ctx);
+   mctx-rsp = UCONTEXT_REG_RSP (ctx);
+   mctx-rsi = UCONTEXT_REG_RSI (ctx);
+   mctx-rdi = UCONTEXT_REG_RDI (ctx);
+   mctx-rip = UCONTEXT_REG_RIP (ctx);
+   mctx-r12 = UCONTEXT_REG_R12 (ctx);
+   mctx-r13 = UCONTEXT_REG_R13 (ctx);
+   mctx-r14 = UCONTEXT_REG_R14 (ctx);
+   mctx-r15 = UCONTEXT_REG_R15 (ctx);
 #else
MonoContext *ctx = (MonoContext *)sigctx;
 
@@ -761,7 +777,7 @@
 void
 mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 {
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION)  defined(UCONTEXT_GREGS)
ucontext_t *ctx = (ucontext_t*)sigctx;
 
 guint64 *gregs = gregs_from_ucontext (ctx);
@@ -779,6 +795,22 @@
gregs [REG_R13] = mctx-r13;
gregs [REG_R14] = mctx-r14;
gregs [REG_R15] = mctx-r15;
+#elif defined(MONO_ARCH_USE_SIGACTION)
+   ucontext_t *ctx = (ucontext_t*)sigctx;
+
+   UCONTEXT_REG_RAX (ctx) = mctx-rax;
+   UCONTEXT_REG_RBX (ctx) = mctx-rbx;
+   UCONTEXT_REG_RCX (ctx) = mctx-rcx;
+   UCONTEXT_REG_RDX (ctx) = mctx-rdx;
+   UCONTEXT_REG_RBP (ctx) = mctx-rbp;
+   UCONTEXT_REG_RSP (ctx) = mctx-rsp;
+   UCONTEXT_REG_RSI (ctx) = mctx-rsi;
+   UCONTEXT_REG_RDI (ctx) = mctx-rdi;
+   UCONTEXT_REG_RIP (ctx) = mctx-rip;
+   UCONTEXT_REG_R12 (ctx) = mctx-r12;
+   UCONTEXT_REG_R13 (ctx) = mctx-r13;
+   UCONTEXT_REG_R14 (ctx) = mctx-r14;
+   UCONTEXT_REG_R15 (ctx) = mctx-r15;
 #else
MonoContext *ctx = (MonoContext *)sigctx;
 
@@ -801,14 +833,16 @@
 gpointer
 mono_arch_ip_from_context (void *sigctx)
 {
-   
-#ifdef MONO_ARCH_USE_SIGACTION
-
+#if defined(MONO_ARCH_USE_SIGACTION)  defined(UCONTEXT_GREGS)
ucontext_t *ctx = (ucontext_t*)sigctx;
 
 guint64 *gregs = gregs_from_ucontext (ctx);
 
return (gpointer)gregs [REG_RIP];
+#elif defined(MONO_ARCH_USE_SIGACTION)
+   ucontext_t *ctx = (ucontext_t*)sigctx;
+
+   return (gpointer)UCONTEXT_REG_RIP (ctx);
 #else
MonoContext *ctx = sigctx;
return (gpointer)ctx-rip;
@@ -865,7 +899,7 @@
 void
 mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, 
gboolean stack_ovf)
 {
-#ifdef MONO_ARCH_USE_SIGACTION
+#if defined(MONO_ARCH_USE_SIGACTION)  defined(UCONTEXT_GREGS)
MonoException *exc = NULL;
ucontext_t 

[Mono-dev] shut gcc up + add string.h for memmove(3) + don't compile ipaddress_to_struct_in6_addr() when it's not needed

2010-04-24 Thread Robert Nagy
Hey

boehm-gc.c: string.h is needed for memmove(3)
socket-io.c: ipaddress_to_struct_in6_addr() is only needed when 
defined(HAVE_STRUCT_IP_MREQN) || defined(HAVE_STRUCT_IP_MREQ)
method-to-ir.c: make gcc shut up because it thinks that code will never be 
reached
Index: mono/metadata/boehm-gc.c
===
--- mono/metadata/boehm-gc.c(revision 156047)
+++ mono/metadata/boehm-gc.c(working copy)
@@ -5,6 +5,7 @@
  * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  */
 
+#include string.h
 #include config.h
 #define GC_I_HIDE_POINTERS
 #include mono/metadata/gc-internal.h
Index: mono/metadata/socket-io.c
===
--- mono/metadata/socket-io.c   (revision 156047)
+++ mono/metadata/socket-io.c   (working copy)
@@ -1944,7 +1944,6 @@

return(inaddr);
 }
-#endif
 
 #ifdef AF_INET6
 static struct in6_addr ipaddress_to_struct_in6_addr(MonoObject *ipaddr)
@@ -1971,6 +1970,7 @@
return(in6addr);
 }
 #endif /* AF_INET6 */
+#endif
 
 void ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal(SOCKET sock, 
gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 
int_val, gint32 *error)
 {
Index: mono/mini/method-to-ir.c
===
--- mono/mini/method-to-ir.c(revision 156047)
+++ mono/mini/method-to-ir.c(working copy)
@@ -10313,14 +10313,15 @@
case OP_LSHR:
case OP_LSHL:
case OP_LSHR_UN:
+   return -1;
 #endif
 #if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_DIV)
case OP_IDIV:
case OP_IDIV_UN:
case OP_IREM:
case OP_IREM_UN:
+   return -1;
 #endif
-   return -1;
default:
return mono_op_to_op_imm (opcode);
}
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] sys/param.h and sys/types.h dependencies in configure.in

2010-04-24 Thread Robert Nagy
Hi

The diff reorders the check for sys/param.h and adds dependencies
for it for several headers so the checks won't fail because of
undefined stuff.
It also adds sys/types.h for the if.h check because that's needed
there too.
Index: configure.in
===
--- configure.in(revision 156047)
+++ configure.in(working copy)
@@ -362,8 +362,14 @@
 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
 
 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h sys/utime.h 
semaphore.h sys/un.h linux/rtc.h sys/syscall.h sys/mkdev.h sys/uio.h)
-AC_CHECK_HEADERS(sys/user.h sys/socket.h sys/ipc.h sys/sem.h sys/utsname.h 
alloca.h ucontext.h pwd.h sys/select.h netinet/tcp.h netinet/in.h unistd.h 
sys/types.h link.h asm/sigcontext.h)
+AC_CHECK_HEADERS(sys/param.h sys/socket.h sys/ipc.h sys/sem.h sys/utsname.h 
alloca.h ucontext.h pwd.h sys/select.h netinet/tcp.h netinet/in.h unistd.h 
sys/types.h link.h asm/sigcontext.h)
 
+AC_CHECK_HEADERS(sys/user.h, [], [],
+[
+#ifdef HAVE_SYS_PARAM_H
+# include sys/param.h
+#endif
+])
 
 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
 if test x$have_zlib = xyes; then
@@ -1578,7 +1584,15 @@
dnl *** Checks for SIOCGIFCONF ***
dnl **
AC_CHECK_HEADERS(sys/ioctl.h)
-   AC_CHECK_HEADERS(net/if.h)
+   AC_CHECK_HEADERS(net/if.h, [], [],
+   [
+   #ifdef HAVE_SYS_TYPES_H
+   # include sys/types.h
+   #endif
+   #ifdef HAVE_SYS_SOCKET_H
+   # include sys/socket.h
+   #endif
+   ])
AC_MSG_CHECKING(for ifreq)
AC_TRY_COMPILE([
#include stdio.h
@@ -1641,8 +1655,12 @@
AC_CHECK_HEADERS(sys/vfstab.h)
AC_CHECK_HEADERS(sys/xattr.h)
AC_CHECK_HEADERS(sys/mman.h)
-   AC_CHECK_HEADERS(sys/param.h)
-   AC_CHECK_HEADERS(sys/mount.h)
+   AC_CHECK_HEADERS(sys/mount.h, [], [],
+   [
+   #ifdef HAVE_SYS_PARAM_H
+   # include sys/param.h
+   #endif
+   ])
AC_CHECK_FUNCS(confstr)
AC_CHECK_FUNCS(seekdir telldir)
AC_CHECK_FUNCS(getdomainname)
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Make System.IO.Ports work on UNIX systems other than Linux

2010-04-22 Thread Robert Nagy
Can someone please have a look at this?

On (2010-04-20 23:26), Robert Nagy wrote:
 Hi
 
 The attached diff makes SerialPort.GetPortNames() work on
 all Unix systems other than Linux too, because ttyS* and
 ttyUSB* is linux specific and on *BSD the serial ports are
 tty[0-9]+.
 (I've tested this code on Linux and it should also support
 ttySG0 (SGI running Linux (ia64)).
 
 The other way would be to add a different platform id for 
 *BSDs.
 
 Comments? (My C# is not good :)) 

 Index: class/System/System.IO.Ports/SerialPort.cs
 ===
 --- class/System/System.IO.Ports/SerialPort.cs(revision 155801)
 +++ class/System/System.IO.Ports/SerialPort.cs(working copy)
 @@ -24,6 +24,7 @@
  using System.ComponentModel;
  using System.Diagnostics;
  using System.Text;
 +using System.Text.RegularExpressions;
  using System.Runtime.InteropServices;
  using Microsoft.Win32;
  
 @@ -525,10 +526,18 @@
   // Are we on Unix?
   if (p == 4 || p == 128 || p == 6) {
   string[] ttys = Directory.GetFiles(/dev/, 
 tty*);
 + Regex lnx = new 
 Regex(@^\/dev\/tty(S(G)?|USB)[0-9]+$);
 + Regex rem = new 
 Regex(@^\/dev\/tty(U)?[0-9]+$);
 +
   foreach (string dev in ttys) {
 - if (dev.StartsWith(/dev/ttyS) || 
 dev.StartsWith(/dev/ttyUSB))
 - serial_ports.Add(dev);
 + if (lnx.Match(dev).Success)
 + rem = lnx;
 + serial_ports.Add(dev);
   }
 + for (int i = serial_ports.Count - 1; i = 0; 
 i--) {
 + if (!rem.Match(serial_ports[i]).Success)
 + serial_ports.RemoveAt(i);
 + }
   } else {
   using (RegistryKey subkey = 
 Registry.LocalMachine.OpenSubKey(HARDWARE\\DEVICEMAP\\SERIALCOMM))
   {

 ___
 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] Make System.IO.Ports work on UNIX systems other than Linux

2010-04-22 Thread Robert Nagy
Hey

Basically on linux ttyS* and ttyUSB* is used for serial device names, but this
is not the case for *BSD, Solaris and probably OS X.
On these systems tty[0-9]+ or ttyU[0-9]+ is used so the current code ony works 
on
linux.

What my diff does is that it gets the list of all tty devices from /dev and
if it finds only one ttyS* device which is only the linux case it will remove 
all
the tty[0-9]+ and ttyU[0-9]+ devices from the list. If it does not find it then
we it removes everything except for tty[0-9]+ ttyU[0-9]+.

So my diff will produce this list on *BSD:
/dev/tty00
/dev/tty01
/dev/tty02
/dev/tty03
/dev/ttyU0
/dev/ttyU1
/dev/ttyU2
/dev/ttyU3

And this on a linux system:
/dev/ttyS0
/dev/ttyS1
/dev/ttyS2
/dev/ttyS3

On (2010-04-22 13:26), Miguel de Icaza wrote:
 Hello,
 
 The attached diff makes SerialPort.GetPortNames() work on
  all Unix systems other than Linux too, because ttyS* and
  ttyUSB* is linux specific and on *BSD the serial ports are
  tty[0-9]+.
  (I've tested this code on Linux and it should also support
  ttySG0 (SGI running Linux (ia64)).
 
 
 I am not sure why you swap lnx with rem and remove items from the list on a
 second pass.
 
 Perhaps you can explain the rationale and the naming of the devices on each
 of the systems that you tested this on?
 
 I would also rather not use regexps there.
 
 Miguel.
 
 
  The other way would be to add a different platform id for
  *BSDs.
 
  Comments? (My C# is not good :))
 
  ___
  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


[Mono-dev] Make System.IO.Ports work on UNIX systems other than Linux

2010-04-20 Thread Robert Nagy
Hi

The attached diff makes SerialPort.GetPortNames() work on
all Unix systems other than Linux too, because ttyS* and
ttyUSB* is linux specific and on *BSD the serial ports are
tty[0-9]+.
(I've tested this code on Linux and it should also support
ttySG0 (SGI running Linux (ia64)).

The other way would be to add a different platform id for 
*BSDs.

Comments? (My C# is not good :)) 
Index: class/System/System.IO.Ports/SerialPort.cs
===
--- class/System/System.IO.Ports/SerialPort.cs  (revision 155801)
+++ class/System/System.IO.Ports/SerialPort.cs  (working copy)
@@ -24,6 +24,7 @@
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Runtime.InteropServices;
 using Microsoft.Win32;
 
@@ -525,10 +526,18 @@
// Are we on Unix?
if (p == 4 || p == 128 || p == 6) {
string[] ttys = Directory.GetFiles(/dev/, 
tty*);
+   Regex lnx = new 
Regex(@^\/dev\/tty(S(G)?|USB)[0-9]+$);
+   Regex rem = new 
Regex(@^\/dev\/tty(U)?[0-9]+$);
+
foreach (string dev in ttys) {
-   if (dev.StartsWith(/dev/ttyS) || 
dev.StartsWith(/dev/ttyUSB))
-   serial_ports.Add(dev);
+   if (lnx.Match(dev).Success)
+   rem = lnx;
+   serial_ports.Add(dev);
}
+   for (int i = serial_ports.Count - 1; i = 0; 
i--) {
+   if (!rem.Match(serial_ports[i]).Success)
+   serial_ports.RemoveAt(i);
+   }
} else {
using (RegistryKey subkey = 
Registry.LocalMachine.OpenSubKey(HARDWARE\\DEVICEMAP\\SERIALCOMM))
{
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Get the correct stackbottom in boehm-gc.c on OpenBSD

2010-04-16 Thread Robert Nagy
Please commit to trunk and branch-2-6 too.
Thanks
Index: metadata/boehm-gc.c
===
--- metadata/boehm-gc.c (revision 155566)
+++ metadata/boehm-gc.c (working copy)
@@ -85,6 +85,17 @@
}
 #elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP)  
defined(HAVE_PTHREAD_GET_STACKADDR_NP)
GC_stackbottom = (char*)pthread_get_stackaddr_np (pthread_self 
());
+#elif defined(__OpenBSD__)
+#  include pthread_np.h
+   {
+   stack_t ss;
+   int rslt;
+
+   rslt = pthread_stackseg_np(pthread_self(), ss);
+   g_assert (rslt == 0);
+
+   GC_stackbottom = (char*)ss.ss_sp;
+   }
 #else
{
int dummy;
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Set the stacksize on OpenBSD just like the way that we do for other BSDs too.

2010-04-13 Thread Robert Nagy
Please commit to trunk and branch-2-6 too.
Thanks

Index: io-layer/collection.c
===
--- io-layer/collection.c   (revision 155314)
+++ io-layer/collection.c   (working copy)
@@ -60,7 +60,7 @@
 
 #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE
 if (set_stacksize == 0) {
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
 ret = pthread_attr_setstacksize (attr, 65536);
 #else
 ret = pthread_attr_setstacksize (attr, PTHREAD_STACK_MIN);
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] switch gensources.sh in the 2.6 branch to /bin/sh (HEAD is /bin/sh already)

2010-04-09 Thread Robert Nagy
Index: mcs/tools/gensources.sh
===
--- mcs/tools/gensources.sh (revision 155127)
+++ mcs/tools/gensources.sh (working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 includefile=$1
 excludefile=$2
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] System.Core/Test/System.Linq.Expressions/ExpressionTest_Lambda.cs misplaced #endif

2010-04-08 Thread Robert Nagy
Index: class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Lambda.cs
===
--- class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Lambda.cs 
(revision 155030)
+++ class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Lambda.cs 
(working copy)
@@ -280,6 +280,6 @@
 
Assert.AreEqual (ExpressionType.Constant, q.NodeType);
}
+#endif
}
-#endif
 }
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] some sysctl fixes for OpenBSD

2010-04-08 Thread Robert Nagy
Hey

Yeah we have been using it for quiet some time now. Both 2.6.3 and svn HEAD
works just fine now.

On (2010-04-08 12:51), pablosantosl...@terra.es wrote:
 Robert,
 
 I tried to reach you using your email but I get tons of errors.
 
 Are you able to build latest Mono on OpenBSD now? Are you going to
 maintain it?
 
 Thanks,
 
 pablo
 
 On 08/04/2010 10:42, Robert Nagy wrote:
  Hey
  
  The following diff removes the XXX hacks from the io-layer OpenBSD
  specific code and and support for get_process_name_from_proc() too.
  It also makes mono-proclib to use the correct kinfo struct.
   
  Index: mono/io-layer/processes.c
  ===
  --- mono/io-layer/processes.c   (revision 155030)
  +++ mono/io-layer/processes.c   (working copy)
  @@ -1533,7 +1533,7 @@
  name[2] = KERN_PROC_ALL;
  name[3] = 0;
  name[4] = sizeof(struct kinfo_proc2);
  -   name[5] = 400; /* XXX */
  +   name[5] = 0;
   #else
  struct kinfo_proc *result;
  static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
  @@ -1543,7 +1543,7 @@
  
  result = NULL;
  done = FALSE;
  -   
  +
  do {
  proclength = 0;
   #if defined(__OpenBSD__)
  @@ -1558,7 +1558,11 @@
   
  if (result == NULL)
  return FALSE;
  -   
  +
  +#if defined(__OpenBSD__)   
  +   name[5] = (int)(proclength / sizeof(struct 
  kinfo_proc2));
  +#endif
  +
  err = sysctl ((int *) name, size, result, proclength, 
  NULL, 0);
   
  if (err == 0) 
  @@ -2224,10 +2228,12 @@
   
   static gchar *get_process_name_from_proc (pid_t pid)
   {
  +#if !defined(__OpenBSD__)
  +   FILE *fp;
  gchar *filename = NULL;
  +   gchar buf[256];
  +#endif
  gchar *ret = NULL;
  -   gchar buf[256];
  -   FILE *fp;
   
   #if defined(PLATFORM_SOLARIS)
  filename = g_strdup_printf (/proc/%d/psinfo, pid);
  @@ -2248,6 +2254,40 @@
  proc_name (pid, buf, sizeof(buf));
  if (strlen (buf)  0)
  ret = g_strdup (buf);
  +#elif defined(__OpenBSD__)
  +   int mib [6];
  +   size_t size;
  +   struct kinfo_proc2 *pi;
  +
  +   mib [0] = CTL_KERN;
  +   mib [1] = KERN_PROC2;
  +   mib [2] = KERN_PROC_PID;
  +   mib [3] = pid;
  +   mib [4] = sizeof(struct kinfo_proc2);
  +   mib [5] = 0;
  +
  +retry:
  +   if (sysctl(mib, 6, NULL, size, NULL, 0)  0)
  +   return(ret);
  +
  +   if ((pi = malloc(size)) == NULL)
  +   return(ret);
  +
  +   mib[5] = (int)(size / sizeof(struct kinfo_proc2));
  +
  +   if ((sysctl (mib, 6, pi, size, NULL, 0)  0) ||
  +   (size != sizeof (struct kinfo_proc2))) {
  +   if (errno == ENOMEM) {
  +   free(pi);
  +   goto retry;
  +   }
  +   return(ret);
  +   }
  +
  +   if (strlen (pi-p_comm)  0)
  +   ret = g_strdup (pi-p_comm);
  +
  +   free(pi);
   #else
  memset (buf, '\0', sizeof(buf));
  filename = g_strdup_printf (/proc/%d/exe, pid);
  Index: mono/utils/mono-proclib.c
  ===
  --- mono/utils/mono-proclib.c   (revision 155030)
  +++ mono/utils/mono-proclib.c   (working copy)
  @@ -22,8 +22,13 @@
   #include sys/user.h
   #endif
   #ifdef HAVE_STRUCT_KINFO_PROC_KP_PROC
  -#define kinfo_pid_member kp_proc.p_pid
  -#define kinfo_name_member kp_proc.p_comm
  +#  ifdef KERN_PROC2
  +#define kinfo_pid_member p_pid
  +#define kinfo_name_member p_comm
  +#  else
  +#define kinfo_pid_member kp_proc.p_pid
  +#define kinfo_name_member kp_proc.p_comm
  +#  endif
   #else
   #define kinfo_pid_member ki_pid
   #define kinfo_name_member ki_comm
  @@ -46,11 +51,12 @@
   #ifdef KERN_PROC2
  int mib [6];
  size_t data_len = sizeof (struct kinfo_proc2) * 400;
  +   struct kinfo_proc2 *processes = malloc (data_len);
   #else
  int mib [4];
  size_t data_len = sizeof (struct kinfo_proc) * 400;
  +   struct kinfo_proc *processes = malloc (data_len);
   #endif /* KERN_PROC2 */
  -   struct kinfo_proc *processes = malloc (data_len);
  void **buf = NULL;
   
  if (size)
  @@ -181,11 +187,12 @@
   #ifdef KERN_PROC2
  int mib [6];
  size_t data_len = sizeof (struct kinfo_proc2);
  +   struct kinfo_proc2 processi;
   #else
  int mib [4];
  size_t data_len = sizeof (struct kinfo_proc);
  +   struct kinfo_proc processi;
   #endif /* KERN_PROC2 */
  -   struct kinfo_proc processi;
   
  memset (buf, 0, len);
   
  ___
  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
___
Mono-devel

[Mono-dev] use sysctl for get_boot_time() on *BSD systems and Mac OS X

2010-04-08 Thread Robert Nagy
Tested on OpenBSD and FreeBSD.

Index: mono/utils/mono-time.c
===
--- mono/utils/mono-time.c  (revision 155053)
+++ mono/utils/mono-time.c  (working copy)
@@ -57,12 +57,32 @@
 #include sys/time.h
 #endif
 
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || 
defined(__NetBSD__)
+#include sys/param.h
+#include sys/sysctl.h
+#endif
+
 #include time.h
 
 static gint64
 get_boot_time (void)
 {
-   /* FIXME: use sysctl (kern.boottime) on OSX */
+#if defined(PLATFORM_MACOSX) || defined(__FreeBSD__) || defined(__OpenBSD__) 
|| defined(__NetBSD__)
+   int mib [2];
+   size_t size;
+   time_t now;
+   struct timeval boottime;
+
+   (void)time(now);
+
+   mib [0] = CTL_KERN;
+   mib [1] = KERN_BOOTTIME;
+
+   size = sizeof(boottime);
+
+   if (sysctl(mib, 2, boottime, size, NULL, 0) != -1)
+   return (gint64)((now - boottime.tv_sec) * MTICKS_PER_SEC);
+#else
FILE *uptime = fopen (/proc/uptime, r);
if (uptime) {
double upt;
@@ -73,6 +93,7 @@
}
fclose (uptime);
}
+#endif
/* a made up uptime of 300 seconds */
return (gint64)300 * MTICKS_PER_SEC;
 }
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] use sysctl for get_boot_time() on *BSD systems and Mac OS X

2010-04-08 Thread Robert Nagy
My previous diffs for the 2.6 branch:

Index: mono/io-layer/processes.c
===
--- mono/io-layer/processes.c   (revision 155084)
+++ mono/io-layer/processes.c   (working copy)
@@ -1533,7 +1533,7 @@
name[2] = KERN_PROC_ALL;
name[3] = 0;
name[4] = sizeof(struct kinfo_proc2);
-   name[5] = 400; /* XXX */
+   name[5] = 0;
 #else
struct kinfo_proc *result;
static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
@@ -1543,7 +1543,7 @@

result = NULL;
done = FALSE;
-   
+
do {
proclength = 0;
 #if defined(__OpenBSD__)
@@ -1558,7 +1558,11 @@
 
if (result == NULL)
return FALSE;
-   
+
+#if defined(__OpenBSD__)   
+   name[5] = (int)(proclength / sizeof(struct 
kinfo_proc2));
+#endif
+
err = sysctl ((int *) name, size, result, proclength, 
NULL, 0);
 
if (err == 0) 
@@ -2224,10 +2228,12 @@
 
 static gchar *get_process_name_from_proc (pid_t pid)
 {
+#if !defined(__OpenBSD__)
+   FILE *fp;
gchar *filename = NULL;
+   gchar buf[256];
+#endif
gchar *ret = NULL;
-   gchar buf[256];
-   FILE *fp;
 
 #if defined(PLATFORM_SOLARIS)
filename = g_strdup_printf (/proc/%d/psinfo, pid);
@@ -2250,6 +2256,40 @@
 #  endif
if (strlen (buf)  0)
ret = g_strdup (buf);
+#elif defined(__OpenBSD__)
+   int mib [6];
+   size_t size;
+   struct kinfo_proc2 *pi;
+
+   mib [0] = CTL_KERN;
+   mib [1] = KERN_PROC2;
+   mib [2] = KERN_PROC_PID;
+   mib [3] = pid;
+   mib [4] = sizeof(struct kinfo_proc2);
+   mib [5] = 0;
+
+retry:
+   if (sysctl(mib, 6, NULL, size, NULL, 0)  0)
+   return(ret);
+
+   if ((pi = malloc(size)) == NULL)
+   return(ret);
+
+   mib[5] = (int)(size / sizeof(struct kinfo_proc2));
+
+   if ((sysctl (mib, 6, pi, size, NULL, 0)  0) ||
+   (size != sizeof (struct kinfo_proc2))) {
+   if (errno == ENOMEM) {
+   free(pi);
+   goto retry;
+   }
+   return(ret);
+   }
+
+   if (strlen (pi-p_comm)  0)
+   ret = g_strdup (pi-p_comm);
+
+   free(pi);
 #else
memset (buf, '\0', sizeof(buf));
filename = g_strdup_printf (/proc/%d/exe, pid);
Index: mono/utils/mono-time.c
===
--- mono/utils/mono-time.c  (revision 155084)
+++ mono/utils/mono-time.c  (working copy)
@@ -57,12 +57,32 @@
 #include sys/time.h
 #endif
 
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || 
defined(__NetBSD__)
+#include sys/param.h
+#include sys/sysctl.h
+#endif
+
 #include time.h
 
 static gint64
 get_boot_time (void)
 {
-   /* FIXME: use sysctl (kern.boottime) on OSX */
+#if defined(PLATFORM_MACOSX) || defined(__FreeBSD__) || defined(__OpenBSD__) 
|| defined(__NetBSD__)
+   int mib [2];
+   size_t size;
+   time_t now;
+   struct timeval boottime;
+
+   (void)time(now);
+
+   mib [0] = CTL_KERN;
+   mib [1] = KERN_BOOTTIME;
+
+   size = sizeof(boottime);
+
+   if (sysctl(mib, 2, boottime, size, NULL, 0) != -1)
+   return (gint64)((now - boottime.tv_sec) * MTICKS_PER_SEC);
+#else
FILE *uptime = fopen (/proc/uptime, r);
if (uptime) {
double upt;
@@ -73,6 +93,7 @@
}
fclose (uptime);
}
+#endif
/* a made up uptime of 300 seconds */
return (gint64)300 * MTICKS_PER_SEC;
 }
Index: mono/utils/mono-proclib.c
===
--- mono/utils/mono-proclib.c   (revision 155084)
+++ mono/utils/mono-proclib.c   (working copy)
@@ -22,8 +22,13 @@
 #include sys/user.h
 #endif
 #ifdef HAVE_STRUCT_KINFO_PROC_KP_PROC
-#define kinfo_pid_member kp_proc.p_pid
-#define kinfo_name_member kp_proc.p_comm
+#  ifdef KERN_PROC2
+#define kinfo_pid_member p_pid
+#define kinfo_name_member p_comm
+#  else
+#define kinfo_pid_member kp_proc.p_pid
+#define kinfo_name_member kp_proc.p_comm
+#  endif
 #else
 #define kinfo_pid_member ki_pid
 #define kinfo_name_member ki_comm
@@ -46,11 +51,12 @@
 #ifdef KERN_PROC2
int mib [6];
size_t data_len = sizeof (struct kinfo_proc2) * 400;
+   struct kinfo_proc2 *processes = malloc (data_len);
 #else
int mib [4];
size_t data_len = sizeof (struct kinfo_proc) * 400;
+   struct kinfo_proc *processes = malloc (data_len);
 #endif /* KERN_PROC2 */
-   struct kinfo_proc *processes = malloc (data_len);
void **buf = NULL;
 
if (size)
@@ -181,11 +187,12 @@
 #ifdef KERN_PROC2
int mib [6];
size_t data_len = sizeof (struct 

[Mono-dev] Include pthread.h in mono/utils/gc_wrapper.h and kill bash in web/mono-build.sh

2010-04-04 Thread Robert Nagy
Index: mono/utils/gc_wrapper.h
===
--- mono/utils/gc_wrapper.h (revision 154762)
+++ mono/utils/gc_wrapper.h (working copy)
@@ -33,6 +33,14 @@
 #   endif
 #  endif
 
+   /*
+* In the case of multithreaded code, gc.h should be included
+* after the threads header file, and after defining GC_THREADS.
+*/
+#  if defined(HAVE_PTHREAD_H)
+#  include pthread.h
+#  endif
+#  define GC_THREADS
 #  ifdef HAVE_GC_GC_H
 #  include gc/gc.h
 #  include gc/gc_typed.h
Index: web/mono-build.sh
===
--- web/mono-build.sh   (revision 154762)
+++ web/mono-build.sh   (working copy)
@@ -1,4 +1,4 @@
-#! /usr/bin/env bash
+#!/bin/sh
 
 # Script to automate the building of mono and its dependencies.
 # Relies on wget being installed (could make it fall back to using
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] fix load_modules() on OpenBSD

2010-04-04 Thread Robert Nagy
Hi

Zoltan, can you please commit the following fix because I've fucked the
start and end addresses up. It also adds a debug printf. 

Thanks

Index: io-layer/processes.c
===
--- io-layer/processes.c(revision 154762)
+++ io-layer/processes.c(working copy)
@@ -1901,7 +1901,6 @@
 #include link.h
 static int load_modules_callback (struct dl_phdr_info *info, size_t size, void 
*ptr)
 {
-
if (size  offsetof (struct dl_phdr_info, dlpi_phnum)
+ sizeof (info-dlpi_phnum))
return (-1);
@@ -1928,21 +1927,22 @@
return (ret);
 
for (i = 0; i  dlarray-len; i++) {
-   int j;
-   char *end = NULL;
-
struct dl_phdr_info *info = g_ptr_array_index (dlarray, i);
-   for (j = 0; j  info-dlpi_phnum; j++)
-   end = (char *)(info-dlpi_addr + 
info-dlpi_phdr[j].p_vaddr);
 
mod = g_new0 (WapiProcModule, 1);
-   mod-address_start = GINT_TO_POINTER(info-dlpi_addr);
-   mod-address_end = end;
+   mod-address_start = (gpointer)(info-dlpi_addr + 
info-dlpi_phdr[0].p_vaddr);
+   mod-address_end = (gpointer)(info-dlpi_addr +
+   info-dlpi_phdr[info-dlpi_phnum - 
1].p_vaddr);
mod-perms = g_strdup (r--p);
mod-address_offset = 0;
mod-inode = (ino_t) i;
mod-filename = g_strdup (info-dlpi_name); 
 
+#ifdef DEBUG
+   g_message (%s: inode=%d, filename=%s, address_start=%p, 
address_end=%p, __func__,
+  mod-inode, mod-filename, mod-address_start, 
mod-address_end);
+#endif
+
free(info);
 
if (g_slist_find_custom (ret, mod, find_procmodule) == NULL) {
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] -lgc is needed in ldflags if using boehm-gc

2010-04-04 Thread Robert Nagy
Hey

-lgc has to be added to libmono_ldflags for example to get it in
the pkg-config file so that mkbundle and others will work.

Index: configure.in
===
--- configure.in(revision 154771)
+++ configure.in(working copy)
@@ -834,6 +834,7 @@
AC_SUBST(HAVE_BOEHM_GC)
LIBGC_LIBS=-lgc $libdl
LIBGC_STATIC_LIBS=$LIBGC_LIBS
+   libmono_ldflags=$libmono_ldflags -lgc
 
# AC_CHECK_FUNCS does not work for some reason...
AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc=yes,,$libdl)
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH v3 2/7] mini: Disable soft debugger when not using sigaction

2010-04-04 Thread Robert Nagy
That will kill softdebug support everywhere where MONO_ARCH_USE_SIGACTION
is not defined. That includes OpenBSD and FreeBSD.

On (2010-04-05 01:52), Andreas Färber wrote:
 The x86 soft debugger depends on siginfo_t outside Windows. So if we're
 neither building for Windows nor using SA_SIGINFO-style signal handlers,
 don't enable the soft debugger. Fixes the build on Haiku.
 
 Cc: Zoltan Varga var...@gmail.com
 
 v2 - v3:
 * Enable the soft debugger for Windows as well (uses different code path).
   Pointed out by Zoltan Varga.
 
 v1 - v2:
 * Instead of disabling siginfo_t code inside the soft debugger,
   disable the soft debugger itself.
 
 This commit is licensed under the MIT X11 license.
 ---
  mono/mini/ChangeLog  |7 +++
  mono/mini/mini-x86.h |4 
  2 files changed, 11 insertions(+), 0 deletions(-)
 
 diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog
 index 9aced04..2d9bab6 100755
 --- a/mono/mini/ChangeLog
 +++ b/mono/mini/ChangeLog
 @@ -1,3 +1,10 @@
 +2010-04-04  Andreas Faerber  andreas.faer...@web.de
 +
 + * mini-x86.h: Only enable soft debugger when using sigaction or on
 + Windows. Fixes build on Haiku (lacks siginfo_t).
 +
 + Code is contributed under MIT/X11 license.
 +
  2010-04-02  Andreas Faerber  andreas.faer...@web.de
  
   * mini.h, mini-x86.h: Suppress sigaction for Haiku, add support for
 diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h
 index 30c8d06..f3680d0 100644
 --- a/mono/mini/mini-x86.h
 +++ b/mono/mini/mini-x86.h
 @@ -294,7 +294,11 @@ typedef struct {
  #define MONO_ARCH_GSHARED_SUPPORTED 1
  #define MONO_ARCH_HAVE_LLVM_IMT_TRAMPOLINE 1
  #define MONO_ARCH_LLVM_SUPPORTED 1
 +
 +#if defined(MONO_ARCH_USE_SIGACTION) || defined(TARGET_WIN32)
  #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
 +#endif
 +
  #define MONO_ARCH_HAVE_FIND_JIT_INFO_EXT 1
  #define MONO_ARCH_HAVE_EXCEPTIONS_INIT 1
  #define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
 -- 
 1.7.0.4.297.g6555b1
 
 ___
 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] [PATCH v3 2/7] mini: Disable soft debugger when not using sigaction

2010-04-04 Thread Robert Nagy
Bah nevermind. Ignore my previous mail please, I was on drugs...

On (2010-04-05 02:01), Robert Nagy wrote:
 That will kill softdebug support everywhere where MONO_ARCH_USE_SIGACTION
 is not defined. That includes OpenBSD and FreeBSD.
 
 On (2010-04-05 01:52), Andreas Färber wrote:
  The x86 soft debugger depends on siginfo_t outside Windows. So if we're
  neither building for Windows nor using SA_SIGINFO-style signal handlers,
  don't enable the soft debugger. Fixes the build on Haiku.
  
  Cc: Zoltan Varga var...@gmail.com
  
  v2 - v3:
  * Enable the soft debugger for Windows as well (uses different code path).
Pointed out by Zoltan Varga.
  
  v1 - v2:
  * Instead of disabling siginfo_t code inside the soft debugger,
disable the soft debugger itself.
  
  This commit is licensed under the MIT X11 license.
  ---
   mono/mini/ChangeLog  |7 +++
   mono/mini/mini-x86.h |4 
   2 files changed, 11 insertions(+), 0 deletions(-)
  
  diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog
  index 9aced04..2d9bab6 100755
  --- a/mono/mini/ChangeLog
  +++ b/mono/mini/ChangeLog
  @@ -1,3 +1,10 @@
  +2010-04-04  Andreas Faerber  andreas.faer...@web.de
  +
  +   * mini-x86.h: Only enable soft debugger when using sigaction or on
  +   Windows. Fixes build on Haiku (lacks siginfo_t).
  +
  +   Code is contributed under MIT/X11 license.
  +
   2010-04-02  Andreas Faerber  andreas.faer...@web.de
   
  * mini.h, mini-x86.h: Suppress sigaction for Haiku, add support for
  diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h
  index 30c8d06..f3680d0 100644
  --- a/mono/mini/mini-x86.h
  +++ b/mono/mini/mini-x86.h
  @@ -294,7 +294,11 @@ typedef struct {
   #define MONO_ARCH_GSHARED_SUPPORTED 1
   #define MONO_ARCH_HAVE_LLVM_IMT_TRAMPOLINE 1
   #define MONO_ARCH_LLVM_SUPPORTED 1
  +
  +#if defined(MONO_ARCH_USE_SIGACTION) || defined(TARGET_WIN32)
   #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
  +#endif
  +
   #define MONO_ARCH_HAVE_FIND_JIT_INFO_EXT 1
   #define MONO_ARCH_HAVE_EXCEPTIONS_INIT 1
   #define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
  -- 
  1.7.0.4.297.g6555b1
  
  ___
  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
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Define GC_OPENBSD_THREADS instead of GC_FREEBSD_THREADS in configure.in

2010-04-03 Thread Robert Nagy
Can someone commit this please?

On (2010-04-01 20:11), Robert Nagy wrote:
 This is an updated version that uses boehm as the default gc and
 disables sigaltstack because it seems a wee bit buggy on openbsd.
 
 Index: configure.in
 ===
 --- configure.in(revision 154650)
 +++ configure.in(working copy)
 @@ -151,7 +151,7 @@
 ;;
 *-*-*openbsd*)
 host_win32=no
 -   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS 
 -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
 +   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS 
 -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
 if test x$disable_munmap != xyes; then
 CPPFLAGS=$CPPFLAGS -DUSE_MUNMAP
 fi
 @@ -161,7 +161,9 @@
 need_link_unlink=yes
 AC_DEFINE(PTHREAD_POINTER_ID)
 libdl=
 +   gc_default=boehm
 libgc_threads=pthreads
 +   with_sigaltstack=no
 use_sigposix=yes
 ;;
 
 On (2010-04-01 18:37), Robert Nagy wrote:
  Index: configure.in
  ===
  --- configure.in(revision 154650)
  +++ configure.in(working copy)
  @@ -151,7 +151,7 @@
  ;;
  *-*-*openbsd*)
  host_win32=no
  -   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS 
  -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
  +   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS 
  -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
  if test x$disable_munmap != xyes; then
  CPPFLAGS=$CPPFLAGS -DUSE_MUNMAP
  fi
  ___
  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
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Better way of getting stack size and base on OpenBSD

2010-04-03 Thread Robert Nagy
Hi

I've attached two diffs, one of them was sent to the list previously.

The first diff fixes the wrong indentation that was commited earlier
and implements load_modules() for OpenBSD. It also uses kill() to
determinate if a process is running instead of the non-standard /proc.
The second one implements a better way of getting the stack size and
base on OpenBSD.
All these changes are OpenBSD only and other platforms will not be
affected. Please commit both of the patches because redoing them
all the time because of other changes in the tree kills all the fun.

Thanks
Index: io-layer/processes.c
===
--- io-layer/processes.c(revision 154756)
+++ io-layer/processes.c(working copy)
@@ -81,8 +81,10 @@
 
 static guint32 process_wait (gpointer handle, guint32 timeout);
 
+#if !defined(__OpenBSD__)
 static FILE *
 open_process_map (int pid, const char *mode);
+#endif
 
 struct _WapiHandleOps _wapi_process_ops = {
NULL,   /* close_shared */
@@ -1522,16 +1524,16 @@
guint32 count, fit, i, j;
gint32 err;
gboolean done;
-   size_t proclength, size;
+   size_t proclength, size;
 #if defined(__OpenBSD__)
-   struct kinfo_proc2 *result;
-   int name[6];
-   name[0] = CTL_KERN;
-   name[1] = KERN_PROC2;
-   name[2] = KERN_PROC_ALL;
-   name[3] = 0;
-   name[4] = sizeof(struct kinfo_proc2);
-   name[5] = 400; /* XXX */
+   struct kinfo_proc2 *result;
+   int name[6];
+   name[0] = CTL_KERN;
+   name[1] = KERN_PROC2;
+   name[2] = KERN_PROC_ALL;
+   name[3] = 0;
+   name[4] = sizeof(struct kinfo_proc2);
+   name[5] = 400; /* XXX */
 #else
struct kinfo_proc *result;
static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
@@ -1545,11 +1547,11 @@
do {
proclength = 0;
 #if defined(__OpenBSD__)
-   size = (sizeof(name) / sizeof(*name));
+   size = (sizeof(name) / sizeof(*name));
 #else
-   size = (sizeof(name) / sizeof(*name)) - 1;
+   size = (sizeof(name) / sizeof(*name)) - 1;
 #endif
-   err = sysctl ((int *)name, size, NULL, proclength, NULL, 0);
+   err = sysctl ((int *)name, size, NULL, proclength, NULL, 0);
 
if (err == 0) {
result = malloc (proclength);
@@ -1557,7 +1559,7 @@
if (result == NULL)
return FALSE;

-   err = sysctl ((int *) name, size, result, proclength, 
NULL, 0);
+   err = sysctl ((int *) name, size, result, proclength, 
NULL, 0);
 
if (err == 0) 
done = TRUE;
@@ -1575,14 +1577,14 @@
}   
 
 #if defined(__OpenBSD__)
-   count = proclength / sizeof(struct kinfo_proc2);
+   count = proclength / sizeof(struct kinfo_proc2);
 #else
count = proclength / sizeof(struct kinfo_proc);
 #endif
fit = len / sizeof(guint32);
for (i = 0, j = 0; j fit  i  count; i++) {
 #if defined(__OpenBSD__)
-   pids [j++] = result [i].p_pid;
+   pids [j++] = result [i].p_pid;
 #else
pids [j++] = result [i].kp_proc.p_pid;
 #endif
@@ -1677,8 +1679,12 @@
  process_open_compare,
  GUINT_TO_POINTER (pid), NULL, TRUE);
if (handle == 0) {
+#if defined(__OpenBSD__)
+   if ((kill(pid, 0) == 0) || (errno == EPERM)) {
+#else
gchar *dir = g_strdup_printf (/proc/%d, pid);
if (!access (dir, F_OK)) {
+#endif
/* Return a pseudo handle for processes we
 * don't have handles for
 */
@@ -1891,6 +1897,67 @@

return(ret);
 }
+#elif defined(__OpenBSD__)
+#include link.h
+static int load_modules_callback (struct dl_phdr_info *info, size_t size, void 
*ptr)
+{
+
+   if (size  offsetof (struct dl_phdr_info, dlpi_phnum)
+   + sizeof (info-dlpi_phnum))
+   return (-1);
+
+   struct dl_phdr_info *cpy = calloc(1, sizeof(struct dl_phdr_info));
+   if (!cpy)
+   return (-1);
+
+   memcpy(cpy, info, sizeof(*info));
+
+   g_ptr_array_add ((GPtrArray *)ptr, cpy);
+
+   return (0);
+}
+
+static GSList *load_modules (void)
+{
+   GSList *ret = NULL;
+   WapiProcModule *mod;
+   GPtrArray *dlarray = g_ptr_array_new();
+   int i;
+
+   if (dl_iterate_phdr(load_modules_callback, dlarray)  0)
+   return (ret);
+
+   for (i = 0; i  dlarray-len; i++) {
+   int j;
+   char *end = NULL;
+
+   struct dl_phdr_info *info = g_ptr_array_index (dlarray, i);
+   for (j = 0; j  info-dlpi_phnum; j++)
+ 

Re: [Mono-dev] Remove bash dependency from a couple of scripts

2010-04-02 Thread Robert Nagy
It's a version of pdksh that was developed within the openbsd tree.
Indeed there are more bash scripts there that can be switched.

If they did not work with Solaris' /bin/sh then the scripts has to be
fixed instead of hardcoding bash.

On (2010-04-02 13:48), Andreas Färber wrote:
 Hi,
 
 Am 01.04.2010 um 18:36 schrieb Robert Nagy:
 
 This is the first bucket of of diffs that are meant to remove the
 hardcoded bash depencendy. On !GNU systems bash is either not
 installed
 or it's path is not /bin. Most of the scripts in mono will just work
 with a posix shell so use that instead because that's available
 everywhere.
 
 Some of the scripts did not work with Solaris' /bin/sh earlier.
 Which shell is /bin/sh on OpenBSD?
 
 [...]
 Index: web/mono-build.sh
 ===
 --- web/mono-build.sh   (revision 154650)
 +++ web/mono-build.sh   (working copy)
 @@ -1,4 +1,4 @@
 -#! /usr/bin/env bash
 +#!/bin/sh
 
 That's a particular nasty use of bash: it assumes /usr to exist,
 which is not the case on BeOS-derived platforms.
 There's another occurrence inside mcs:
 
 Index: tools/gensources.sh
 ===
 --- tools/gensources.sh   (revision 154572)
 +++ tools/gensources.sh   (working copy)
 @@ -1,4 +1,4 @@
 -#!/usr/bin/env bash
 +#!/bin/sh
 
  includefile=$1
  excludefile=$2
 
 Regards,
 Andreas
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Implement OpenBSD specific sysctl in EnumProcesses()

2010-04-02 Thread Robert Nagy
Hi

This diff extends the MACOSX code that uses sysctl
already, but ours is a wee bit different.

Index: mono/io-layer/processes.c
===
--- mono/io-layer/processes.c   (revision 154739)
+++ mono/io-layer/processes.c   (working copy)
@@ -35,10 +35,12 @@
 #include sys/resource.h
 #endif
 
-#ifdef PLATFORM_MACOSX
+#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__)
 #include sys/proc.h
 #include sys/sysctl.h
-#include sys/utsname.h
+#  if !defined(__OpenBSD__)
+#include sys/utsname.h
+#  endif
 #endif
 
 #ifdef PLATFORM_SOLARIS
@@ -1513,16 +1515,27 @@
 }
 #endif /* UNUSED_CODE */
 
-#ifdef PLATFORM_MACOSX
+#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__)
 
 gboolean EnumProcesses (guint32 *pids, guint32 len, guint32 *needed)
 {
guint32 count, fit, i, j;
gint32 err;
gboolean done;
+   size_t proclength, size;
+#if defined(__OpenBSD__)
+   struct kinfo_proc2 *result;
+   int name[6];
+   name[0] = CTL_KERN;
+   name[1] = KERN_PROC2;
+   name[2] = KERN_PROC_ALL;
+   name[3] = 0;
+   name[4] = sizeof(struct kinfo_proc2);
+   name[5] = 400; /* XXX */
+#else
struct kinfo_proc *result;
-   size_t proclength;
static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
+#endif

mono_once (process_current_once, process_set_current);

@@ -1531,14 +1544,20 @@

do {
proclength = 0;
-   err = sysctl ((int *)name, (sizeof(name) / sizeof(*name)) - 1, 
NULL, proclength, NULL, 0);
+#if defined(__OpenBSD__)
+   size = (sizeof(name) / sizeof(*name));
+#else
+   size = (sizeof(name) / sizeof(*name)) - 1;
+#endif
+   err = sysctl ((int *)name, size, NULL, proclength, NULL, 0);
 
if (err == 0) {
result = malloc (proclength);
+
if (result == NULL)
return FALSE;

-   err = sysctl ((int *) name, (sizeof(name) / 
sizeof(*name)) - 1, result, proclength, NULL, 0);
+   err = sysctl ((int *) name, size, result, proclength, 
NULL, 0);
 
if (err == 0) 
done = TRUE;
@@ -1554,11 +1573,19 @@
}
return(FALSE);
}   
-   
+
+#if defined(__OpenBSD__)
+   count = proclength / sizeof(struct kinfo_proc2);
+#else
count = proclength / sizeof(struct kinfo_proc);
+#endif
fit = len / sizeof(guint32);
for (i = 0, j = 0; j fit  i  count; i++) {
+#if defined(__OpenBSD__)
+   pids [j++] = result [i].p_pid;
+#else
pids [j++] = result [i].kp_proc.p_pid;
+#endif
}
free (result);
result = NULL;
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Don't use non-standard /proc dir just to find out if a process is running

2010-04-02 Thread Robert Nagy
Hi

/proc is totally non-standard so I think this should be switched to
use kill to determinate if a process is running because since kill(2)
is POSIX we can rely on it basically everywhere.
In case of EPERM it's still okay to find the process because
we are not actually signalling the pid we are just asking kill() to
do error checking.

Index: io-layer/processes.c
===
--- io-layer/processes.c(revision 154739)
+++ io-layer/processes.c(working copy)
@@ -1650,11 +1650,13 @@
  process_open_compare,
  GUINT_TO_POINTER (pid), NULL, TRUE);
if (handle == 0) {
-   gchar *dir = g_strdup_printf (/proc/%d, pid);
-   if (!access (dir, F_OK)) {
-   /* Return a pseudo handle for processes we
-* don't have handles for
-*/
+   /*
+* Ignore EPERM so that even if the sending process is not the
+* superuser and its' effective user ID does not match the
+* effective user ID of the receiving process, we can safely
+* return.
+*/
+   if ((kill(pid, 0) == 0) || (errno == EPERM)) {
return GINT_TO_POINTER (_WAPI_PROCESS_UNHANDLED + pid);
} else {
 #ifdef DEBUG
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Implement stuff to make process name lookup work

2010-04-02 Thread Robert Nagy
Implement get_processname_from_proc() for OpenBSD

Index: io-layer/processes.c
===
--- io-layer/processes.c(revision 154749)
+++ io-layer/processes.c(working copy)
@@ -2153,10 +2153,12 @@
 
 static gchar *get_process_name_from_proc (pid_t pid)
 {
-   gchar *filename = NULL;
gchar *ret = NULL;
+#if !defined(__OpenBSD__)
gchar buf[256];
+   gchar *filename = NULL;
FILE *fp;
+#endif
 
 #if defined(PLATFORM_SOLARIS)
filename = g_strdup_printf (/proc/%d/psinfo, pid);
@@ -2172,6 +2174,22 @@
fclose (fp);
}
g_free (filename);
+#elif defined(__OpenBSD__)
+   int res;
+   int mib [6];
+   struct kinfo_proc2 result;
+   size_t data_len = sizeof (struct kinfo_proc2);
+
+   mib [0] = CTL_KERN;
+   mib [1] = KERN_PROC2;
+   mib [2] = KERN_PROC_PID;
+   mib [3] = pid;
+   mib [4] = sizeof(struct kinfo_proc2);
+   mib [5] = 400; /* XXX */
+
+   res = sysctl (mib, 6, result, data_len, NULL, 0);
+   if (res == 0)
+   ret = g_strdup (result.p_comm);
 #elif defined(PLATFORM_MACOSX)
memset (buf, '\0', sizeof(buf));
proc_name (pid, buf, sizeof(buf));
@@ -2242,7 +2260,9 @@
gchar *procname_ext = NULL;
glong len;
gsize bytes;
+#if !defined(__OpenBSD__)
FILE *fp;
+#endif
GSList *mods = NULL;
WapiProcModule *found_module;
guint32 count;
@@ -2285,6 +2305,14 @@
 #ifdef PLATFORM_MACOSX
{
mods = load_modules ();
+#elif defined(__OpenBSD__)
+   {
+   if (module == NULL  base == TRUE) {
+   procname_ext = get_process_name_from_proc (pid);
+   } else {
+   g_free (proc_name);
+   return(0);
+   }
 #else
if ((fp = open_process_map (pid, r)) == NULL) {
if (errno == EACCES  module == NULL  base == TRUE) {
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Define GC_OPENBSD_THREADS instead of GC_FREEBSD_THREADS in configure.in

2010-04-01 Thread Robert Nagy
Index: configure.in
===
--- configure.in(revision 154650)
+++ configure.in(working copy)
@@ -151,7 +151,7 @@
;;
*-*-*openbsd*)
host_win32=no
-   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS 
-DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
+   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS 
-DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
if test x$disable_munmap != xyes; then
CPPFLAGS=$CPPFLAGS -DUSE_MUNMAP
fi
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] trunk build failure with system gc

2010-04-01 Thread Robert Nagy
mono-gc.h is incosistent with mono-gc.c about these definitions,
so i've synced mono-gc.h to mono-gc.c

Index: mono/metadata/mono-gc.h
===
--- mono/metadata/mono-gc.h (revision 154650)
+++ mono/metadata/mono-gc.h (working copy)
@@ -13,8 +13,8 @@
 intmono_gc_max_generation  (void);
 intmono_gc_get_generation  (MonoObject *object);
 intmono_gc_collection_count (int generation);
-int64_t mono_gc_get_used_size   (void);
-int64_t mono_gc_get_heap_size   (void);
+gint64 mono_gc_get_used_size   (void);
+gint64 mono_gc_get_heap_size   (void);
 intmono_gc_invoke_finalizers (void);
 
 MONO_END_DECLS
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Add OpenBSD to the list of definitions in tests/libtest.c

2010-04-01 Thread Robert Nagy
Index: mono/tests/libtest.c
===
--- mono/tests/libtest.c(revision 154650)
+++ mono/tests/libtest.c(working copy)
@@ -3191,7 +3191,7 @@
  * mono_method_get_unmanaged_thunk tests
  */
 
-#if defined(__GNUC__)  ((defined(__i386__)  (defined(__linux__) || defined 
(__APPLE__)) || defined (__FreeBSD__)) || (defined(__ppc__)  
defined(__APPLE__)))
+#if defined(__GNUC__)  ((defined(__i386__)  (defined(__linux__) || defined 
(__APPLE__)) || defined (__FreeBSD__) || defined (__OpenBSD__)) || 
(defined(__ppc__)  defined(__APPLE__)))
 #define ALIGN(size) __attribute__ ((aligned(size)))
 #else
 #define ALIGN(size)
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Define GC_OPENBSD_THREADS instead of GC_FREEBSD_THREADS in configure.in

2010-04-01 Thread Robert Nagy
This is an updated version that uses boehm as the default gc and
disables sigaltstack because it seems a wee bit buggy on openbsd.

Index: configure.in
===
--- configure.in(revision 154650)
+++ configure.in(working copy)
@@ -151,7 +151,7 @@
;;
*-*-*openbsd*)
host_win32=no
-   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS 
-DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
+   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS 
-DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
if test x$disable_munmap != xyes; then
CPPFLAGS=$CPPFLAGS -DUSE_MUNMAP
fi
@@ -161,7 +161,9 @@
need_link_unlink=yes
AC_DEFINE(PTHREAD_POINTER_ID)
libdl=
+   gc_default=boehm
libgc_threads=pthreads
+   with_sigaltstack=no
use_sigposix=yes
;;

On (2010-04-01 18:37), Robert Nagy wrote:
 Index: configure.in
 ===
 --- configure.in(revision 154650)
 +++ configure.in(working copy)
 @@ -151,7 +151,7 @@
 ;;
 *-*-*openbsd*)
 host_win32=no
 -   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS 
 -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
 +   CPPFLAGS=$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS 
 -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP
 if test x$disable_munmap != xyes; then
 CPPFLAGS=$CPPFLAGS -DUSE_MUNMAP
 fi
 ___
 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