Hi,

It seems that localtime() in mingw may actually be thread safe
already? I couldn't find confirmation though.
http://sources.redhat.com/ml/pthreads-win32/2005/msg00011.html

Regarding strtok_r, the only reference to openimageio seems to be the
embedded ptex library. I've attached a patch that replaces it.

Brecht.

2011/9/12 Αντώνης Ρυακιωτάκης <[email protected]>:
> Hi everyone, I ve been working on getting cycles compile with MinGW lately.
> I've managed to get the compilation part right but I still run into linking
> issues: boost and openimageio. I have managed to get boost to compile under
> MinGW and got rid of the boost link errors but openimageio still has some
> problems. There are a few problems internal to MinGW: the lack of strtok_r
> function and localtime_r functions. So far I have made some progress
> substituting those with the strtok and localtime variants but since the
> former are supposed to be thread safe and the latter are not this does not
> look good. In addition, strtok_r is needed by ptex too so it will cause
> trouble when merging ptex too. It actually made me switch off ptex in onion
> GSOC project during the summer when on MinGW. So I thought I would ask for
> opinions on the matter.
> _______________________________________________
> Bf-committers mailing list
> [email protected]
> http://lists.blender.org/mailman/listinfo/bf-committers
>
diff --git a/src/ptex.imageio/ptex/PtexCache.cpp b/src/ptex.imageio/ptex/PtexCache.cpp
index 7794a21..1e71cdb 100644
--- a/src/ptex.imageio/ptex/PtexCache.cpp
+++ b/src/ptex.imageio/ptex/PtexCache.cpp
@@ -224,12 +224,20 @@ public:
 	// split into dirs
 	_searchdirs.clear();
 	char* buff = strdup(path);
-	char* pos = 0;
-	char* token = strtok_r(buff, ":", &pos);
-	while (token) {
+	char* pos = buff;
+
+	do {
+		char *token = pos;
+		pos = strstr(pos, ":");
+
+		if (pos) {
+			pos[0] = '\0';
+			pos++;
+		}
+
 	    if (token[0]) _searchdirs.push_back(token);
-	    token = strtok_r(0, ":", &pos);
-	}
+	} while(pos);
+
 	free(buff);
     }
 
_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to