summaryrefslogtreecommitdiff
path: root/os/utils.c
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-08-28 19:04:48 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2018-08-28 19:04:48 +0100
commit7d416f031b61d6d6be376ba45018b135505980a7 (patch)
tree5b9ff59013b179636e98955f2e844c9bd37e3786 /os/utils.c
parentb561176bffc9fda559c121ce639bee78c3ab2d8f (diff)
parent7d0f997a4b8e1b62c9b82e9b10934a6c55a6eb48 (diff)
Merge branch 'cygwin-patches-for-1.20' into cygwin-release-1.20xserver-cygwin-1.20.1-1
Diffstat (limited to 'os/utils.c')
-rw-r--r--os/utils.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/os/utils.c b/os/utils.c
index a04cc7da7..eb2c3b8e8 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -55,11 +55,10 @@ OR PERFORMANCE OF THIS SOFTWARE.
#ifdef __CYGWIN__
#include <stdlib.h>
#include <signal.h>
-/*
- Sigh... We really need a prototype for this to know it is stdcall,
- but #include-ing <windows.h> here is not a good idea...
-*/
-__stdcall unsigned long GetTickCount(void);
+#define _WIN32_WINNT 0x0600
+#include <X11/Xwindows.h>
+#include <assert.h> /* defines made by windows.h prevent misc.h from including assert.h */
+#undef WIN32 /* for the benefit of the conditionals in this file */
#endif
#if defined(WIN32) && !defined(__CYGWIN__)
@@ -249,7 +248,7 @@ UnlockServer(void)
{}
#else /* LOCK_SERVER */
static Bool StillLocking = FALSE;
-static char LockFile[PATH_MAX];
+static char lockFile[PATH_MAX];
Bool nolock = FALSE;
/*
@@ -276,10 +275,10 @@ LockServer(void)
len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
strlen(LOCK_TMP_PREFIX);
len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
- if (len > sizeof(LockFile))
+ if (len > sizeof(lockFile))
FatalError("Display name `%s' is too long\n", port);
(void) sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
- (void) sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+ (void) sprintf(lockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
/*
* Create a temporary file containing our PID. Attempt three times
@@ -322,7 +321,7 @@ LockServer(void)
i = 0;
haslock = 0;
while ((!haslock) && (i++ < 3)) {
- haslock = (link(tmp, LockFile) == 0);
+ haslock = (link(tmp, lockFile) == 0);
if (haslock) {
/*
* We're done.
@@ -333,17 +332,17 @@ LockServer(void)
/*
* Read the pid from the existing file
*/
- lfd = open(LockFile, O_RDONLY | O_NOFOLLOW);
+ lfd = open(lockFile, O_RDONLY | O_NOFOLLOW);
if (lfd < 0) {
unlink(tmp);
- FatalError("Can't read lock file %s\n", LockFile);
+ FatalError("Can't read lock file %s\n", lockFile);
}
pid_str[0] = '\0';
if (read(lfd, pid_str, 11) != 11) {
/*
* Bogus lock file.
*/
- unlink(LockFile);
+ unlink(lockFile);
close(lfd);
continue;
}
@@ -360,7 +359,7 @@ LockServer(void)
/*
* Stale lock file.
*/
- unlink(LockFile);
+ unlink(lockFile);
continue;
}
else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
@@ -371,13 +370,13 @@ LockServer(void)
FatalError
("Server is already active for display %s\n%s %s\n%s\n",
port, "\tIf this server is no longer running, remove",
- LockFile, "\tand start again.");
+ lockFile, "\tand start again.");
}
}
}
unlink(tmp);
if (!haslock)
- FatalError("Could not create server lock file: %s\n", LockFile);
+ FatalError("Could not create server lock file: %s\n", lockFile);
StillLocking = FALSE;
}
@@ -393,7 +392,7 @@ UnlockServer(void)
if (!StillLocking) {
- (void) unlink(LockFile);
+ (void) unlink(lockFile);
}
}
#endif /* LOCK_SERVER */
@@ -449,7 +448,7 @@ GetTimeInMillis(void)
CARD64
GetTimeInMicros(void)
{
- return (CARD64) GetTickCount() * 1000;
+ return (CARD64) GetTickCount64() * 1000;
}
#else
CARD32