clisp-cvs Digest, Vol 42, Issue 20

View: New views
3 Messages — Rating Filter:   Alert me  

clisp-cvs Digest, Vol 42, Issue 20

by clisp-cvs-request :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Send clisp-cvs mailing list submissions to
        clisp-cvs@...

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/clisp-cvs
or, via email, send a message with subject or body 'help' to
        clisp-cvs-request@...

You can reach the person managing the list at
        clisp-cvs-owner@...

When replying, please edit your Subject line so it is more specific
than "Re: Contents of clisp-cvs digest..."


CLISP CVS commits for today

Today's Topics:

   1. clisp/src ChangeLog, 1.7171, 1.7172 control.d, 1.167, 1.168
      eval.d, 1.272, 1.273 (Vladimir Tzankov)
   2. clisp/src ChangeLog, 1.7172, 1.7173 spvw.d, 1.515, 1.516
      xthread.d, 1.32, 1.33 zthread.d, 1.70, 1.71 (Vladimir Tzankov)
   3. clisp/src ChangeLog,1.7173,1.7174 time.d,1.76,1.77
      (Vladimir Tzankov)


----------------------------------------------------------------------

Message: 1
Date: Sun, 25 Oct 2009 13:44:57 +0000
From: Vladimir Tzankov <vtz@...>
Subject: clisp/src ChangeLog, 1.7171, 1.7172 control.d, 1.167, 1.168
        eval.d, 1.272, 1.273
To: clisp-cvs@...
Message-ID: <E1N23Oz-0003o3-8g@...>

Update of /cvsroot/clisp/clisp/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14586/src

Modified Files:
        ChangeLog control.d eval.d
Log Message:
[MULTITHREAD]: do not allocate per thread value cells for locally declared special variables


Index: eval.d
===================================================================
RCS file: /cvsroot/clisp/clisp/src/eval.d,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -d -r1.272 -r1.273
--- eval.d 15 Oct 2009 20:53:21 -0000 1.272
+++ eval.d 25 Oct 2009 13:44:54 -0000 1.273
@@ -6422,17 +6422,6 @@
     CASE cod_bind: {            /* (BIND n) */
       var uintL n;
       U_operand(n);
-#if defined(MULTITHREAD)
-      var Symbol sym=TheSymbol(TheCclosure(closure)->clos_consts[n]);
-      if (sym->tls_index == SYMBOL_TLS_INDEX_NONE && !special_var_p(sym)) {
-        /* if it is special - it may be special global (i.e.*features*) so
-           we do not want to make it per thread. */
-        pushSTACK(value1);
-        add_per_thread_special_var(TheCclosure(closure)->clos_consts[n]);
-        value1 = popSTACK();
-        closure = *closureptr; /* restore from stack in case of GC */
-      }
-#endif
       dynamic_bind(TheCclosure(closure)->clos_consts[n],value1);
     } goto next_byte;
     CASE cod_unbind1:           /* (UNBIND1) */

Index: control.d
===================================================================
RCS file: /cvsroot/clisp/clisp/src/control.d,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -d -r1.167 -r1.168
--- control.d 8 Oct 2009 14:57:28 -0000 1.167
+++ control.d 25 Oct 2009 13:44:54 -0000 1.168
@@ -480,22 +480,6 @@
             /* store special-declared symbol in stack: */
             pushSTACK(specdecl); /* SPECDECL as "value" */
             pushSTACK_symbolwithflags(declsym,0); /* Symbol inactive */
-            #if defined(MULTITHREAD)
-             /* this is locally declared special variable. make it per thread
-                if not already.*/
-             if (TheSymbol(declsym)->tls_index == SYMBOL_TLS_INDEX_NONE) {
-               /* this call is may gc now */
-               pushSTACK(value1); pushSTACK(value2);          /* save */
-               pushSTACK(caller); pushSTACK(varspecs);        /* save */
-               pushSTACK(declarations); pushSTACK(declspecs); /* save */
-               pushSTACK(declspec);                           /* save */
-               add_per_thread_special_var(declsym);
-               declspec = popSTACK();
-               declspecs = popSTACK(); declarations = popSTACK(); /* restore */
-               varspecs = popSTACK(); caller = popSTACK();        /* restore */
-               value2 = popSTACK(); value1 = popSTACK();          /* restore */
-             }
-            #endif
             check_STACK();
             spec_count++;
           }

Index: ChangeLog
===================================================================
RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v
retrieving revision 1.7171
retrieving revision 1.7172
diff -u -d -r1.7171 -r1.7172
--- ChangeLog 21 Oct 2009 19:01:24 -0000 1.7171
+++ ChangeLog 25 Oct 2009 13:44:53 -0000 1.7172
@@ -1,3 +1,10 @@
+2009-10-25  Vladimir Tzankov  <vtzankov@...>
+
+ * control.d (make_variable_frame) [MULTITHREAD]: do not allocate per
+ thread value cells for locally declared special variables
+ * eval.d (interpret_bytecode_) [MULTITHREAD]: ditto for cod_bind -
+ the code here was plain wrong
+
 2009-10-21  Vladimir Tzankov  <vtzankov@...>
 
  [MULTITHREAD]: handle SIGWINCH signal




------------------------------

Message: 2
Date: Sun, 25 Oct 2009 13:51:37 +0000
From: Vladimir Tzankov <vtz@...>
Subject: clisp/src ChangeLog, 1.7172, 1.7173 spvw.d, 1.515, 1.516
        xthread.d, 1.32, 1.33 zthread.d, 1.70, 1.71
To: clisp-cvs@...
Message-ID: <E1N23VR-0003yf-Cw@...>

Update of /cvsroot/clisp/clisp/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15265/src

Modified Files:
        ChangeLog spvw.d xthread.d zthread.d
Log Message:
[WIN32_THREADS]: use thread safe C run-time (CRT)


Index: spvw.d
===================================================================
RCS file: /cvsroot/clisp/clisp/src/spvw.d,v
retrieving revision 1.515
retrieving revision 1.516
diff -u -d -r1.515 -r1.516
--- spvw.d 21 Oct 2009 19:01:24 -0000 1.515
+++ spvw.d 25 Oct 2009 13:51:35 -0000 1.516
@@ -3649,7 +3649,8 @@
 #if defined(MULTITHREAD)
 /* UP: main_actions() replacement in MT.
  > param: clisp_thread_t structure of the first lisp thread */
-local void* mt_main_actions (void *param) {
+local THREADPROC_SIGNATURE mt_main_actions (void *param)
+{
   #if USE_CUSTOM_TLS == 2
   tse __tse_entry;
   tse *__thread_tse_entry=&__tse_entry;

Index: zthread.d
===================================================================
RCS file: /cvsroot/clisp/clisp/src/zthread.d,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- zthread.d 26 Jul 2009 22:11:40 -0000 1.70
+++ zthread.d 25 Oct 2009 13:51:35 -0000 1.71
@@ -157,7 +157,7 @@
 }
 
 /* All newly created threads start here.*/
-local /*maygc*/ void *thread_stub(void *arg)
+local THREADPROC_SIGNATURE thread_stub(void *arg)
 {
   #if USE_CUSTOM_TLS == 2
   tse __tse_entry;

Index: ChangeLog
===================================================================
RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v
retrieving revision 1.7172
retrieving revision 1.7173
diff -u -d -r1.7172 -r1.7173
--- ChangeLog 25 Oct 2009 13:44:53 -0000 1.7172
+++ ChangeLog 25 Oct 2009 13:51:35 -0000 1.7173
@@ -1,5 +1,17 @@
 2009-10-25  Vladimir Tzankov  <vtzankov@...>
 
+ [WIN32_THREADS]: use thread safe C run-time (CRT)
+ * xthread.d (xthread_create): use _beginthreadex() for thread creation.
+ close returned handle immediately in order to prevent leaks
+ (xthread_exit): use _endthreadex() - releases per thread allocated
+ resources
+ (THREADPROC_SIGNATURE): add. specify correct calling convention and
+ return type of start thread procedure
+ * spvw.d (mt_main_actions): use THREADPROC_SIGNATURE
+ * zthread.d (thread_stub): ditto
+
+2009-10-25  Vladimir Tzankov  <vtzankov@...>
+
  * control.d (make_variable_frame) [MULTITHREAD]: do not allocate per
  thread value cells for locally declared special variables
  * eval.d (interpret_bytecode_) [MULTITHREAD]: ditto for cod_bind -

Index: xthread.d
===================================================================
RCS file: /cvsroot/clisp/clisp/src/xthread.d,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- xthread.d 17 Sep 2009 14:41:23 -0000 1.32
+++ xthread.d 25 Oct 2009 13:51:35 -0000 1.33
@@ -101,6 +101,8 @@
 #include <pthread.h>
 #include <sched.h>
 
+#define THREADPROC_SIGNATURE void *
+
 #define xthread_t  pthread_t
 #define xcondition_t  pthread_cond_t
 #define xthread_key_t  pthread_key_t
@@ -151,8 +153,10 @@
 
 /* include <windows.h>  -- already included by win32.d */
 #define MAX_SEMAPHORE_COUNT  0x7fff
+/* thread procedure return type and calling convention */
+#define THREADPROC_SIGNATURE unsigned WINAPI
 
-#define xthread_t DWORD
+#define xthread_t unsigned
 /* this is inefficient implementation of condition variables on win32.
    TODO: make it better */
 typedef struct _xcondition {
@@ -168,8 +172,8 @@
 #define xthread_self()  GetCurrentThreadId()
 /* xthread_create() should return 0 on success */
 #define xthread_create(thread,startroutine,arg,stacksize)                       \
-  (!CreateThread(NULL,stacksize,(LPTHREAD_START_ROUTINE)startroutine,(LPVOID)arg,0,thread))
-#define xthread_exit(v)  ExitThread((DWORD)(v))
+  (!CloseHandle((HANDLE)_beginthreadex(NULL,stacksize,startroutine,(LPVOID)arg,0,thread)))
+#define xthread_exit(v)  _endthreadex((DWORD)(v))
 #define xthread_yield()  Sleep(0)
 #define xthread_equal(t1,t2)  ((t1)==(t2))
 /* xthread_sigmask() and xthread_signal() are not needed here */




------------------------------

Message: 3
Date: Sun, 25 Oct 2009 14:01:18 +0000
From: Vladimir Tzankov <vtz@...>
Subject: clisp/src ChangeLog,1.7173,1.7174 time.d,1.76,1.77
To: clisp-cvs@...
Message-ID: <E1N23ep-0004Fk-0M@...>

Update of /cvsroot/clisp/clisp/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16160/src

Modified Files:
        ChangeLog time.d
Log Message:
(seconds_west) [MULTITHREAD]: use reentrant functions for getting time (localtime_r, gmtime_r)


Index: ChangeLog
===================================================================
RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v
retrieving revision 1.7173
retrieving revision 1.7174
diff -u -d -r1.7173 -r1.7174
--- ChangeLog 25 Oct 2009 13:51:35 -0000 1.7173
+++ ChangeLog 25 Oct 2009 14:01:16 -0000 1.7174
@@ -1,5 +1,10 @@
 2009-10-25  Vladimir Tzankov  <vtzankov@...>
 
+ * time.d (seconds_west) [MULTITHREAD]: use reentrant functions for
+ getting time (localtime_r, gmtime_r)
+
+2009-10-25  Vladimir Tzankov  <vtzankov@...>
+
  [WIN32_THREADS]: use thread safe C run-time (CRT)
  * xthread.d (xthread_create): use _beginthreadex() for thread creation.
  close returned handle immediately in order to prevent leaks

Index: time.d
===================================================================
RCS file: /cvsroot/clisp/clisp/src/time.d,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- time.d 8 Oct 2009 14:57:29 -0000 1.76
+++ time.d 25 Oct 2009 14:01:16 -0000 1.77
@@ -401,15 +401,32 @@
 #if defined(UNIX) || defined(WIN32)
 local sintL seconds_west (time_t *now, int *isdst) {
   /* localtime() and gmtime() may return the same location,
-     so we have to copy the rerned structure contents: */
+     so we have to copy the returned structure contents: */
+#if !defined(MULTITHREAD) || defined(WIN32)
+  /* on win32 localtime() and gmtime() are thread safe
+     (and mingw uses them) */
+  #define LOCALTIME_R(timer,result) do {  \
+    struct tm *now_ = localtime(timer);   \
+    if (now_ == NULL) OS_error(); else *result = *now_; } while (0)
+  #define GMTIME_R(timer,result) do {  \
+    struct tm *now_ = gmtime(timer);   \
+    if (now_ == NULL) OS_error(); else *result = *now_; } while (0)
+#else
+  #define LOCALTIME_R(timer,result) do {               \
+    if (NULL == localtime_r(timer,result)) OS_error(); \
+  } while(0)
+  #define GMTIME_R(timer,result) do {             \
+    if (NULL == gmtime_r(timer,result)) OS_error(); \
+  } while(0);
+#endif
   var struct tm now_local;
   var struct tm now_gm;
   begin_system_call();
-  { struct tm *now_ = localtime(now);
-    if (now_ == NULL) OS_error(); else now_local = *now_; }
-  { struct tm *now_ = gmtime(now);
-    if (now_ == NULL) OS_error(); else now_gm = *now_; }
+  LOCALTIME_R(now,&now_local);
+  GMTIME_R(now,&now_gm);
   end_system_call();
+#undef LOCATIME_R
+#undef GMTIME_R
   /* note that secondswest is NOT the same as
           mktime(&now_gm) - mktime(&now_local);
      during DST */




------------------------------

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference

------------------------------

_______________________________________________
clisp-cvs mailing list
clisp-cvs@...
https://lists.sourceforge.net/lists/listinfo/clisp-cvs


End of clisp-cvs Digest, Vol 42, Issue 20
*****************************************

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
clisp-devel mailing list
clisp-devel@...
https://lists.sourceforge.net/lists/listinfo/clisp-devel

Re: clisp-cvs Digest, Vol 42, Issue 20

by Sam Steingold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> (seconds_west) [MULTITHREAD]: use reentrant functions for getting time (localtime_r, gmtime_r)

is the assumption that if MULTITHREAD is defined than localtime_r & gmtime_r
are present reasonable?
shouldn't we check for them in configure?

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
clisp-devel mailing list
clisp-devel@...
https://lists.sourceforge.net/lists/listinfo/clisp-devel

Re: clisp-cvs Digest, Vol 42, Issue 20

by Vladimir Tzankov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/26/09, Sam Steingold <sds@...> wrote:
>> (seconds_west) [MULTITHREAD]: use reentrant functions for getting time
>> (localtime_r, gmtime_r)
>
> is the assumption that if MULTITHREAD is defined than localtime_r & gmtime_r
> are present reasonable?
> shouldn't we check for them in configure?

We can use mutex/spinlock to guard around non thread-safe crt
functions but I think it's safe/normal to assume re-entrant C run-time
on platforms where MT is used.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
clisp-devel mailing list
clisp-devel@...
https://lists.sourceforge.net/lists/listinfo/clisp-devel