summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-11-15 15:06:51 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-11-15 15:06:51 +0000
commit9826b83826190e514ed115e15691ca015780f9bc (patch)
treee6ede7a76c2edc14ff3025fbc0fb65757327cde0 /os
parentcecb668149e1956fb29bc89855182349122e2f4e (diff)
Bufzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802 Added
mingw (Win32) port
Diffstat (limited to 'os')
-rw-r--r--os/WaitFor.c18
-rw-r--r--os/access.c17
-rw-r--r--os/connection.c4
-rw-r--r--os/io.c4
-rw-r--r--os/log.c9
-rw-r--r--os/osdep.h3
-rw-r--r--os/utils.c8
-rw-r--r--os/xdmcp.c18
8 files changed, 65 insertions, 16 deletions
diff --git a/os/WaitFor.c b/os/WaitFor.c
index 4c4628552..20a8b6c38 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -222,7 +222,11 @@ WaitForSomething(int *pClientsReady)
{
i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
}
+#ifndef WIN32
selecterr = errno;
+#else
+ selecterr = WSAGetLastError();
+#endif
WakeupHandler(i, (pointer)&LastSelectMask);
#ifdef XTESTEXT1
if (playback_on) {
@@ -244,18 +248,30 @@ WaitForSomething(int *pClientsReady)
return 0;
if (i < 0)
{
+#ifndef WIN32
if (selecterr == EBADF) /* Some client disconnected */
+#else
+ if (selecterr == WSAENOTSOCK) /* Some client disconnected */
+#endif
{
CheckConnections ();
if (! XFD_ANYSET (&AllClients))
return 0;
}
+#ifndef WIN32
else if (selecterr == EINVAL)
+#else
+ else if (selecterr == WSAEINVAL)
+#endif
{
FatalError("WaitForSomething(): select: errno=%d\n",
selecterr);
- }
+ }
+#ifndef WIN32
else if (selecterr != EINTR)
+#else
+ else if (selecterr != WSAEINTR)
+#endif
{
ErrorF("WaitForSomething(): select: errno=%d\n",
selecterr);
diff --git a/os/access.c b/os/access.c
index 421ed771f..d687e3515 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1,5 +1,5 @@
/* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
-/* $XdotOrg: xc/programs/Xserver/os/access.c,v 1.5 2004/07/17 01:13:31 alanc Exp $ */
+/* $XdotOrg: xc/programs/Xserver/os/access.c,v 1.6 2004/10/17 10:46:14 herrb Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -531,7 +531,14 @@ DefineSelf (int fd)
int family;
register HOST *host;
+#ifndef WIN32
struct utsname name;
+#else
+ struct {
+ char nodename[512];
+ } name;
+#endif
+
register struct hostent *hp;
union {
@@ -555,8 +562,12 @@ DefineSelf (int fd)
* see), whereas gethostname() kindly truncates it for me.
*/
#ifndef QNX4
+#ifndef WIN32
uname(&name);
#else
+ gethostname(name.nodename, sizeof(name.nodename));
+#endif
+#else
/* QNX4's uname returns node number in name.nodename, not the hostname
have to overwrite it */
char hname[1024];
@@ -1849,6 +1860,10 @@ ConvertAddr (
return FamilyLocal;
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
case AF_INET:
+#ifdef WIN32
+ if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr)
+ return FamilyLocal;
+#endif
*len = sizeof (struct in_addr);
*addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
return FamilyInternet;
diff --git a/os/connection.c b/os/connection.c
index 137ff050d..9948ce80c 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -202,6 +202,10 @@ int *ConnectionTranslation = NULL;
* This is clearly boggus and another form of storage which doesn't use the fd
* as a direct index should really be implemented for NT.
*/
+#undef MAXSOCKS
+#define MAXSOCKS 500
+#undef MAXSELECT
+#define MAXSELECT 500
#define MAXFD 500
#endif
diff --git a/os/io.c b/os/io.c
index 956a53300..75aebcb5e 100644
--- a/os/io.c
+++ b/os/io.c
@@ -94,6 +94,7 @@ CallbackListPtr FlushCallback;
* systems are broken and return EWOULDBLOCK when they should return EAGAIN
*/
#ifndef __UNIXOS2__
+#ifndef WIN32
#if defined(EAGAIN) && defined(EWOULDBLOCK)
#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK)
#else
@@ -103,6 +104,9 @@ CallbackListPtr FlushCallback;
#define ETEST(err) (err == EWOULDBLOCK)
#endif
#endif
+#else /* WIN32 The socket errorcodes differ from the normal errors*/
+#define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK)
+#endif
#else /* __UNIXOS2__ Writing to full pipes may return ENOSPC */
#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK || err == ENOSPC)
#endif
diff --git a/os/log.c b/os/log.c
index 1794919a1..1608fb72e 100644
--- a/os/log.c
+++ b/os/log.c
@@ -89,6 +89,11 @@ OR PERFORMANCE OF THIS SOFTWARE.
#include "site.h"
#include "opaque.h"
+#ifdef WIN32
+#include <process.h>
+#define getpid(x) _getpid(x)
+#endif
+
#ifdef DDXOSVERRORF
void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL;
@@ -191,7 +196,9 @@ LogInit(const char *fname, const char *backup)
if (saveBuffer && bufferSize > 0) {
fwrite(saveBuffer, bufferPos, 1, logFile);
fflush(logFile);
+#ifndef WIN32
fsync(fileno(logFile));
+#endif
}
}
@@ -263,8 +270,10 @@ LogVWrite(int verb, const char *f, va_list args)
fwrite(tmpBuffer, len, 1, logFile);
if (logFlush) {
fflush(logFile);
+#ifndef WIN32
if (logSync)
fsync(fileno(logFile));
+#endif
}
} else if (needBuffer) {
/*
diff --git a/os/osdep.h b/os/osdep.h
index 2b9eb5674..4ab988057 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -260,6 +260,9 @@ extern OsCommPtr AvailableInput;
extern WorkQueuePtr workQueue;
/* added by raphael */
+#ifdef WIN32
+typedef long int fd_mask;
+#endif
#define ffs mffs
extern int mffs(fd_mask);
diff --git a/os/utils.c b/os/utils.c
index 454f90145..69729c61d 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.8 2004/09/24 02:11:14 gisburn Exp $ */
+/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.9 2004/09/29 04:17:44 gisburn Exp $ */
/* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */
/*
@@ -81,7 +81,9 @@ OR PERFORMANCE OF THIS SOFTWARE.
#undef _POSIX_SOURCE
#endif
#endif
+#ifndef WIN32
#include <sys/wait.h>
+#endif
#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4)
#include <sys/resource.h>
#endif
@@ -1974,7 +1976,11 @@ Fclose(pointer iop)
/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
#ifndef CHECK_EUID
+#ifndef WIN32
#define CHECK_EUID 1
+#else
+#define CHECK_EUID 0
+#endif
#endif
/*
diff --git a/os/xdmcp.c b/os/xdmcp.c
index d0f73513a..6cf792937 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.2 2004/04/23 19:54:28 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.3 2004/07/20 15:15:13 ago Exp $ */
/* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */
/*
* Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
@@ -17,17 +17,7 @@
/* $XFree86: xc/programs/Xserver/os/xdmcp.c,v 3.31 2003/12/30 21:24:32 herrb Exp $ */
#ifdef WIN32
-/* avoid conflicting definitions */
-#define BOOL wBOOL
-#define ATOM wATOM
-#define FreeResource wFreeResource
-#include <winsock.h>
-#undef BOOL
-#undef ATOM
-#undef FreeResource
-#undef CreateWindowA
-#undef RT_FONT
-#undef RT_CURSOR
+#include <Xwinsock.h>
#endif
#include "Xos.h"
@@ -1548,7 +1538,9 @@ get_addr_by_name(
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
_Xgethostbynameparams hparams;
#endif
-
+#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+ _XSERVTransWSAStartup();
+#endif
if (!(hep = _XGethostbyname(namestr, hparams)))
{
FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);