MemoryBarrier patch for dbus windows port built with mingw

Mark Mikofski bwanamarko at yahoo.com
Mon Jun 25 11:00:24 PDT 2012


In order to compile dbus-1.6.0 using mingw32/msys on Windows XP SP3 (x86) you will need the following patch, courtesy of Brad Pitcher [1], because there is no MemoryBarrier macro in mingw, which is a known issue reported OPEN on the mingw32 sf.netsite [2] and WONTFIX in dbus Bugzilla [3]. It is fairly clear that this issue will not be addressed by dbus, and dbus developers appear to recommend mingw-w64 instead of ming32.



--- a/dbus-1.6.0\dbus\dbus-sysdeps-win.c
+++ b/dbus-1.6.0\dbus\dbus-sysdeps-win.c
@@ -54,6 +54,13 @@
 #include <windows.h>
 #include <ws2tcpip.h>
 #include <wincrypt.h>
+
+__CRT_INLINE VOID MemoryBarrier(VOID)
+{
+  LONG Barrier = 0;
+  __asm__ __volatile__("xchgl %%eax,%0 "
+    :"=r" (Barrier));
+}
 
 /* Declarations missing in mingw's headers */
 extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR  StringSid, PSID *Sid);

Some other patches, message threads, issues and links are posted below.

[1] https://bitbucket.org/bradpitcher/mingw-cross-env/src/5f91fb4e0199/src/dbus-1-fixes.patch - patch by Brad Pitcher (2012-09-23)
[2] https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3420424&group_id=2435 - mingw bug 3420424 on sf.net by Ernie Boyd (2011-10-07)
[3] https://bugs.freedesktop.org/show_bug.cgi?id=41423 - dbus Bugzilla Bug 41423 - MemoryBarrier only available on Vista+ 

[4] http://hg.savannah.gnu.org/hgweb/mingw-cross-env/rev/8bfc6d601bb1 - patch supplied by Mark Brand (2012-09-23)
[5] http://lists.gnu.org/archive/html/mingw-cross-env-list/2011-09/msg00033.html - thread started by Mark Brand (2012-09-23)
[6] http://lists-archives.com/mingw-users/15935-missing-definition-of-memorybarrier.html - link to original patch (broken in Mark Brand's thread)
[7] https://bitbucket.org/vog/mingw-cross-env/src/906c0415cdb8/src/dbus-1-fixes.patch - original fork of mingw-cross-env by Volker Grabsch
[8] https://github.com/mxe/mxe - currently mingw-cross-env has been renamed mxe (M cross environment)
[9] http://mingw-w64.sourceforge.net/ - mingw-w64 project page


Thanks,
Mark Mikofski
poquitopicante.blogspot.com
breakingbytes.blogspot.com
www.breaking-bytes.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20120625/9df9d039/attachment.html>


More information about the dbus mailing list