[rkward-cvs] SF.net SVN: rkward:[2515] trunk/rkward/rkward/rbackend

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Jun 3 09:18:53 UTC 2009


Revision: 2515
          http://rkward.svn.sourceforge.net/rkward/?rev=2515&view=rev
Author:   tfry
Date:     2009-06-03 09:18:53 +0000 (Wed, 03 Jun 2009)

Log Message:
-----------
some more files compile on windows

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rembedinternal.cpp
    trunk/rkward/rkward/rbackend/rembedinternal.h
    trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp
    trunk/rkward/rkward/rbackend/rthread.cpp

Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp	2009-06-02 18:26:59 UTC (rev 2514)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp	2009-06-03 09:18:53 UTC (rev 2515)
@@ -72,8 +72,12 @@
 
 	extern int R_interrupts_pending;
 #	warning Or is it UserBreak?
+	void RK_scheduleIntr () {
+		R_interrupts_pending = 1;
+	}
+
 	void RK_doIntr () {
-		R_interrupts_pending = 1;
+		RK_scheduleIntr ();
 		R_CheckUserInterrupt ();
 	}
 

Modified: trunk/rkward/rkward/rbackend/rembedinternal.h
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.h	2009-06-02 18:26:59 UTC (rev 2514)
+++ trunk/rkward/rkward/rbackend/rembedinternal.h	2009-06-03 09:18:53 UTC (rev 2515)
@@ -23,6 +23,12 @@
 #include <QMap>
 #include <QVariant>
 
+#ifdef Q_WS_WIN
+extern "C" {
+	void RK_scheduleIntr();
+}
+#endif
+
 /** This struct is used to pass the standard callbacks from R to the main thread (if needed; some are handled in the backend thread). Note that for the callbacks that need to be passed to the main
 thread, we can be quite wasteful both in terms of cycles and memory, since these are usually
 requests for user interaction. Hence we use a QVariantMap to accommodate all the different needed

Modified: trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp	2009-06-02 18:26:59 UTC (rev 2514)
+++ trunk/rkward/rkward/rbackend/rkpthreadsupport.cpp	2009-06-03 09:18:53 UTC (rev 2515)
@@ -2,7 +2,7 @@
                           rkpthreadsupport  -  description
                              -------------------
     begin                : Fri Feb 23 2007
-    copyright            : (C) 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -22,7 +22,12 @@
 #include <qstring.h>
 #include "../debug.h"
 
-#include <pthread.h>
+#ifdef Q_WS_WIN
+#	include <windows.h>
+#	include <stdint.h>	// for uintptr_t
+#else
+#	include <pthread.h>
+#endif
 #ifdef HAVE_PTHREAD_NP_H
 #	include <pthread_np.h>
 #endif
@@ -45,6 +50,22 @@
 #elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
 	*size = pthread_get_stacksize_np (pthread_self ());
 	*base = pthread_get_stackaddr_np (pthread_self ());
+#elif defined Q_WS_WIN
+// This section (up to #endif) copied almost verbatim from R src/gnuwin32/system.c:
+/*  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
+ *  Copyright (C) 1997--2007  Robert Gentleman, Ross Ihaka and the
+ *                            R Development Core Team */
+	{
+		MEMORY_BASIC_INFORMATION buf;
+		uintptr_t bottom, top;
+		
+		VirtualQuery(reference, &buf, sizeof(buf));
+		bottom = (uintptr_t) buf.AllocationBase;
+		top = (uintptr_t) buf.BaseAddress + buf.RegionSize;
+
+		*base = (void*) top;
+		*size = (size_t) (top - bottom);
+	}
 #else
 #	warning Cannot determine the stack limits of a pthread on this system
 #	warning R C stack checking will be disabled

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2009-06-02 18:26:59 UTC (rev 2514)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2009-06-03 09:18:53 UTC (rev 2515)
@@ -35,8 +35,10 @@
 #include <QList>
 #include <QFileInfo>
 
-#include <signal.h>		// needed for pthread_kill
-#include <pthread.h>		// seems to be needed at least on FreeBSD
+#ifndef Q_WS_WIN
+#	include <signal.h>		// needed for pthread_kill
+#	include <pthread.h>		// seems to be needed at least on FreeBSD
+#endif
 
 #define MAX_BUF_LENGTH 4000
 
@@ -57,15 +59,12 @@
 }
 
 void RThread::interruptProcessing (bool interrupt) {
-// TODO: find a good #ifdef to use the uncommented version below, if on a system without pthreads
-	if (interrupt) {
-		pthread_kill ((pthread_t) thread_id, SIGINT);
-	}
-/*	if (interrupt) {
-		R_interrupts_pending = 1;
-	} else {
-		R_interrupts_pending = 0;
-	} */
+	if (!interrupt) return;
+#ifdef Q_WS_WIN
+	RK_scheduleIntr ();
+#else
+	pthread_kill ((pthread_t) thread_id, SIGINT);
+#endif
 }
 
 void RThread::run () {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list