unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Amatus <c11h15no2@yahoo.com>
To: bug-guile@gnu.org
Subject: [PATCH] get_thread_stack_base for FreeBSD
Date: Sat, 8 Mar 2008 16:07:43 -0800 (PST)	[thread overview]
Message-ID: <425072.2349.qm@web30001.mail.mud.yahoo.com> (raw)

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

From: David Barksdale <amatus@gnu.org>

This change adds get_thread_stack_base support for FreeBSD.

--
This patch was generated against guile-1.8.4

************************************************************
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use of the information contained within this email or attachments is strictly prohibited.
************************************************************


      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

[-- Attachment #2: 2978506763-guile-1.8.4-get_thread_stack_base.patch --]
[-- Type: application/octet-stream, Size: 3966 bytes --]

diff -rupN guile-1.8.4.orig/config.h.in guile-1.8.4/config.h.in
--- guile-1.8.4.orig/config.h.in	2008-02-16 16:12:15.000000000 -0600
+++ guile-1.8.4/config.h.in	2008-03-08 17:34:40.229216282 -0600
@@ -432,9 +432,15 @@ Boston, MA 02110-1301, USA.
 /* Define to 1 if you have the `pthread_get_stackaddr_np' function. */
 #undef HAVE_PTHREAD_GET_STACKADDR_NP
 
+/* Define to 1 if you have the `pthread_attr_get_np' function. */
+#undef HAVE_PTHREAD_ATTR_GET_NP
+
 /* Define to 1 if you have the <pthread.h> header file. */
 #undef HAVE_PTHREAD_H
 
+/* Define to 1 if you have the <pthread_np.h> header file. */
+#undef HAVE_PTHREAD_NP_H
+
 /* Define to 1 if you have the `pthread_sigmask' function. */
 #undef HAVE_PTHREAD_SIGMASK
 
diff -rupN guile-1.8.4.orig/configure.in guile-1.8.4/configure.in
--- guile-1.8.4.orig/configure.in	2008-02-16 17:15:18.000000000 -0600
+++ guile-1.8.4/configure.in	2008-03-08 17:34:20.980031818 -0600
@@ -692,10 +692,11 @@ AC_CHECK_FUNCS([DINFINITY DQNAN cexp chs
 #   sys/param.h - not in mingw
 #   pthread.h - only available with pthreads.  ACX_PTHREAD doesn't
 #       check this specifically, we need it for the timespec test below.
+#   pthread_np.h - available on FreeBSD
 #   sethostname - the function itself check because it's not in mingw,
 #       the DECL is checked because Solaris 10 doens't have in any header
 #
-AC_CHECK_HEADERS(crypt.h netdb.h pthread.h sys/param.h sys/resource.h sys/file.h)
+AC_CHECK_HEADERS(crypt.h netdb.h pthread.h pthread_np.h sys/param.h sys/resource.h sys/file.h)
 AC_CHECK_FUNCS(chroot flock getlogin cuserid getpriority setpriority getpass sethostname gethostname)
 AC_CHECK_DECLS([sethostname])
 
@@ -1185,9 +1186,11 @@ case "$with_threads" in
     #         all; not present on MacOS X or Solaris 10
     #     pthread_get_stackaddr_np - "np" meaning "non portable" says it
     #         all; specific to MacOS X
+    #     pthread_attr_get_np - "np" meaning "non portable" says it
+    #         all; specific to FreeBSD
     #     pthread_sigmask - not available on mingw
     #
-    AC_CHECK_FUNCS(pthread_attr_getstack pthread_getattr_np pthread_get_stackaddr_np pthread_sigmask)
+    AC_CHECK_FUNCS(pthread_attr_getstack pthread_getattr_np pthread_get_stackaddr_np pthread_attr_get_np pthread_sigmask)
 
     # On past versions of Solaris, believe 8 through 10 at least, you
     # had to write "pthread_once_t foo = { PTHREAD_ONCE_INIT };".
diff -rupN guile-1.8.4.orig/libguile/pthread-threads.h guile-1.8.4/libguile/pthread-threads.h
--- guile-1.8.4.orig/libguile/pthread-threads.h	2007-10-10 11:58:57.000000000 -0500
+++ guile-1.8.4/libguile/pthread-threads.h	2008-03-08 17:36:35.943388334 -0600
@@ -26,6 +26,9 @@
 */
 
 #include <pthread.h>
+#if HAVE_PTHREAD_NP_H
+# include <pthread_np.h>
+#endif
 #include <sched.h>
 
 /* Threads 
diff -rupN guile-1.8.4.orig/libguile/threads.c guile-1.8.4/libguile/threads.c
--- guile-1.8.4.orig/libguile/threads.c	2007-10-02 11:38:40.000000000 -0500
+++ guile-1.8.4/libguile/threads.c	2008-03-08 17:37:16.099795084 -0600
@@ -593,7 +593,7 @@ scm_i_init_thread_for_guile (SCM_STACKIT
 
 #if SCM_USE_PTHREAD_THREADS
 
-#if HAVE_PTHREAD_ATTR_GETSTACK && HAVE_PTHREAD_GETATTR_NP
+#if HAVE_PTHREAD_ATTR_GETSTACK && (HAVE_PTHREAD_GETATTR_NP || HAVE_PTHREAD_ATTR_GET_NP)
 /* This method for GNU/Linux and perhaps some other systems.
    It's not for MacOS X or Solaris 10, since pthread_getattr_np is not
    available on them.  */
@@ -606,8 +606,15 @@ get_thread_stack_base ()
   void *start, *end;
   size_t size;
 
+#if HAVE_PTHREAD_ATTR_GET_NP
+  pthread_attr_init (&attr);
+  pthread_attr_get_np (pthread_self (), &attr);
+  pthread_attr_getstack (&attr, &start, &size);
+  pthread_attr_destroy (&attr);
+#elif HAVE_PTHREAD_GETATTR_NP
   pthread_getattr_np (pthread_self (), &attr);
   pthread_attr_getstack (&attr, &start, &size);
+#endif
   end = (char *)start + size;
 
   /* XXX - pthread_getattr_np from LinuxThreads does not seem to work

             reply	other threads:[~2008-03-09  0:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-09  0:07 Amatus [this message]
2008-03-11 14:52 ` [PATCH] get_thread_stack_base for FreeBSD Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=425072.2349.qm@web30001.mail.mud.yahoo.com \
    --to=c11h15no2@yahoo.com \
    --cc=amatus@gnu.org \
    --cc=bug-guile@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).