#define DoSleep( n ) if( (n) != 0 ) Sleep( (n) );
+int flock(int f, int code);
+#define LOCK_EX 2
+
#else
#define DoSleep( n ) if( (n) >= 0) sleep(n)
#include <richedit.h>\r
#include <mmsystem.h>\r
#include <ctype.h>\r
+#include <io.h>\r
\r
#if __GNUC__\r
#include <errno.h>\r
{ // [HGM] wrapper needed because handles must not be passed through back-end\r
EngineOptionsPopup(savedHwnd, cps);\r
}\r
+\r
+int flock(int fid, int code)\r
+{\r
+ HANDLE hFile = (HANDLE) _get_osfhandle(fid);\r
+ OVERLAPPED ov;\r
+ ov.hEvent = NULL;\r
+ ov.Offset = 0;\r
+ ov.OffsetHigh = 0;\r
+ switch(code) {\r
+ case 1: LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK, 0, 1024, 0, &ov); break; // LOCK_SH\r
+ case 2: LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK, 0, 1024, 0, &ov); break; // LOCK_EX\r
+ case 3: UnlockFileEx(hFile, 0, 1024, 0, &ov); break; // LOCK_UN\r
+ default: return -1;\r
+ }\r
+ return 0;\r
+}\r