unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Add stack base support for Mac OS X
@ 2006-12-26 10:41 Heikki Lindholm
  2006-12-26 19:45 ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Heikki Lindholm @ 2006-12-26 10:41 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

This patch adds support for getting the stack base (and hence also 
scm_init_guile()) on OS X. Tested only in one particular case I needed. 
The patch is against the 1.8.1 release.

-- Heikki Lindholm

[-- Attachment #2: guile-1.8.1-MacOSX-stackbase-061226.patch --]
[-- Type: text/plain, Size: 886 bytes --]

--- ../guile-1.8.1.orig/libguile/threads.c	2006-07-29 21:00:17.000000000 +0300
+++ ./libguile/threads.c	2006-12-26 12:37:51.000000000 +0200
@@ -571,14 +571,17 @@
 }
 
 #if SCM_USE_PTHREAD_THREADS
-/* pthread_getattr_np not available on MacOS X and Solaris 10. */
-#if HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP
+/* pthread_getattr_np not available on Solaris 10. */
+#if (HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP) || defined(__APPLE__)
 
 #define HAVE_GET_THREAD_STACK_BASE
 
 static SCM_STACKITEM *
 get_thread_stack_base ()
 {
+#if defined(__APPLE__)
+  return pthread_get_stackaddr_np (pthread_self ());
+#else /* !defined(__APPLE__) */
   pthread_attr_t attr;
   void *start, *end;
   size_t size;
@@ -604,6 +607,7 @@
       return end;
 #endif
     }
+#endif /* defined(__APPLE__) */
 }
 
 #endif /* HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP */

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add stack base support for Mac OS X
  2006-12-26 10:41 [PATCH] Add stack base support for Mac OS X Heikki Lindholm
@ 2006-12-26 19:45 ` Kevin Ryde
  2006-12-26 21:14   ` Heikki Lindholm
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2006-12-26 19:45 UTC (permalink / raw)
  Cc: guile-devel

Heikki Lindholm <holindho@cs.helsinki.fi> writes:
>
> This patch adds support for getting the stack base (and hence also
> scm_init_guile()) on OS X. Tested only in one particular case I
> needed.

Beaut.

> -/* pthread_getattr_np not available on MacOS X and Solaris 10. */
> -#if HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP
> +/* pthread_getattr_np not available on Solaris 10. */
> +#if (HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP) || defined(__APPLE__)

But hard-coding system names is bad.

> +  return pthread_get_stackaddr_np (pthread_self ());

Is this the operative feature, a pthread_get_stackaddr_np available?


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add stack base support for Mac OS X
  2006-12-26 19:45 ` Kevin Ryde
@ 2006-12-26 21:14   ` Heikki Lindholm
  2006-12-26 22:04     ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Heikki Lindholm @ 2006-12-26 21:14 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde kirjoitti:
> Heikki Lindholm <holindho@cs.helsinki.fi> writes:
> 
>>This patch adds support for getting the stack base (and hence also
>>scm_init_guile()) on OS X. Tested only in one particular case I
>>needed.
> 
> 
> Beaut.
> 
> 
>>-/* pthread_getattr_np not available on MacOS X and Solaris 10. */
>>-#if HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP
>>+/* pthread_getattr_np not available on Solaris 10. */
>>+#if (HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP) || defined(__APPLE__)
> 
> 
> But hard-coding system names is bad.

Yes, but it would look worse had I tried to make it autoconf'ed with my 
limited experience. Maybe someone else can fill in that part.

> 
>>+  return pthread_get_stackaddr_np (pthread_self ());
> 
> 
> Is this the operative feature, a pthread_get_stackaddr_np available?

Uh, say what?

-- Heikki Lindholm


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add stack base support for Mac OS X
  2006-12-26 21:14   ` Heikki Lindholm
@ 2006-12-26 22:04     ` Kevin Ryde
  2006-12-26 22:24       ` Heikki Lindholm
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2006-12-26 22:04 UTC (permalink / raw)
  Cc: guile-devel

Heikki Lindholm <holindho@cs.helsinki.fi> writes:
>
> Uh, say what?

Do you have a pointer to the docs of pthread_get_stackaddr_np on
macos?  I stuck it in a search somewhere at developer.apple but drew a
blank.

In any case I'll add this if it looks right, thanks.

+#elif HAVE_PTHREAD_GET_STACKADDR_NP
+/* This method for MacOS X.  */
+#define HAVE_GET_THREAD_STACK_BASE
+static SCM_STACKITEM *
+get_thread_stack_base ()
+{
+  return pthread_get_stackaddr_np (pthread_self ());
+}
+


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add stack base support for Mac OS X
  2006-12-26 22:04     ` Kevin Ryde
@ 2006-12-26 22:24       ` Heikki Lindholm
  2006-12-26 22:43         ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Heikki Lindholm @ 2006-12-26 22:24 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde kirjoitti:
> Heikki Lindholm <holindho@cs.helsinki.fi> writes:
> 
>>Uh, say what?
> 
> 
> Do you have a pointer to the docs of pthread_get_stackaddr_np on
> macos?  I stuck it in a search somewhere at developer.apple but drew a
> blank.

Couldn't find any docs, either. No man page or anything. Xcode 
documentation suggests this as a possible replacement of a deprecated 
Mac OS function, but that's all. So, I wouldn't bet it works the same on 
all the platforms where it (possibly) exists.

-- Heikki Lindholm


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add stack base support for Mac OS X
  2006-12-26 22:24       ` Heikki Lindholm
@ 2006-12-26 22:43         ` Kevin Ryde
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Ryde @ 2006-12-26 22:43 UTC (permalink / raw)
  Cc: guile-devel

Heikki Lindholm <holindho@cs.helsinki.fi> writes:
>
> I wouldn't bet it works the same on all the platforms where it
> (possibly) exists.

But it's always funny how programmers ape each other in func names and
interfaces, the same ideas sort of spread. :)

I checked in some changes, have a go at a nightly snapshot tomorrow or
when it updates.  Or the cvs if you're brave.  The 1.8 cvs branch in
both cases (not the cvs head).


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-12-26 22:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-26 10:41 [PATCH] Add stack base support for Mac OS X Heikki Lindholm
2006-12-26 19:45 ` Kevin Ryde
2006-12-26 21:14   ` Heikki Lindholm
2006-12-26 22:04     ` Kevin Ryde
2006-12-26 22:24       ` Heikki Lindholm
2006-12-26 22:43         ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).