mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
generalize define from __MINGW32__ to __MINGW__
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30001 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
97653c21a2
commit
f784646663
51 changed files with 404 additions and 350 deletions
|
@ -52,19 +52,19 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
#define close closesocket
|
||||
#else
|
||||
#include <sys/param.h> /* for MAXHOSTNAMELEN */
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h> /* for inet_ntoa() */
|
||||
#endif /* !__MINGW32__ */
|
||||
#endif /* !__MINGW__ */
|
||||
#include <errno.h>
|
||||
#include <string.h> /* for strchr() */
|
||||
#include <ctype.h> /* for strchr() */
|
||||
#include <fcntl.h>
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
#include <winsock2.h>
|
||||
#include <wininet.h>
|
||||
#include <process.h>
|
||||
|
@ -101,7 +101,7 @@
|
|||
#define SOCKET_ERROR -1
|
||||
#define INVALID_SOCKET -1
|
||||
|
||||
#endif /* !__MINGW32__ */
|
||||
#endif /* !__MINGW__ */
|
||||
|
||||
/*
|
||||
* Largest chunk of data possible in DO
|
||||
|
@ -202,7 +202,7 @@ typedef enum {
|
|||
unsigned nItems; /* Number of items to be read. */
|
||||
GSHandleState state; /* State of the handle. */
|
||||
unsigned int addrNum; /* Address number within host. */
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
WSAEVENT event; /* Win32 event associated to socket */
|
||||
WSAEVENT eventTemp; /* Win32 event for asynchronous */
|
||||
@public
|
||||
|
@ -223,7 +223,7 @@ typedef enum {
|
|||
+ (GSTcpHandle*) handleWithDescriptor: (SOCKET)d;
|
||||
- (BOOL) connectToPort: (NSSocketPort*)aPort beforeDate: (NSDate*)when;
|
||||
- (int) descriptor;
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
- (int) eventHandle;
|
||||
#endif
|
||||
- (void) invalidate;
|
||||
|
@ -369,13 +369,13 @@ static Class runLoopClass;
|
|||
+ (GSTcpHandle*) handleWithDescriptor: (SOCKET)d
|
||||
{
|
||||
GSTcpHandle *handle;
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
unsigned long dummy;
|
||||
#else
|
||||
int e;
|
||||
#endif /* __MINGW32__ */
|
||||
#endif /* __MINGW__ */
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
WSAEVENT ev;
|
||||
int rc;
|
||||
#endif
|
||||
|
@ -385,7 +385,7 @@ static Class runLoopClass;
|
|||
NSLog(@"illegal descriptor (%d) for Tcp Handle", d);
|
||||
return nil;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
dummy = 1;
|
||||
if (ioctlsocket(d, FIONBIO, &dummy) == SOCKET_ERROR)
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ static Class runLoopClass;
|
|||
d, [NSError _last]);
|
||||
return nil;
|
||||
}
|
||||
#else /* !__MINGW32__ */
|
||||
#else /* !__MINGW__ */
|
||||
if ((e = fcntl(d, F_GETFL, 0)) >= 0)
|
||||
{
|
||||
e |= NBLK_OPT;
|
||||
|
@ -416,7 +416,7 @@ static Class runLoopClass;
|
|||
handle->wMsgs = [NSMutableArray new];
|
||||
handle->myLock = [GSLazyRecursiveLock new];
|
||||
handle->valid = YES;
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
ev = (WSAEVENT)CreateEvent(NULL,NO,NO,NULL);
|
||||
if (ev == WSA_INVALID_EVENT)
|
||||
{
|
||||
|
@ -437,7 +437,7 @@ static Class runLoopClass;
|
|||
{
|
||||
if (self == [GSTcpHandle class])
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
|
||||
|
@ -538,7 +538,7 @@ static Class runLoopClass;
|
|||
if (connect(desc, (struct sockaddr*)&sockAddr, sizeof(sockAddr))
|
||||
== SOCKET_ERROR)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
if (WSAGetLastError() != WSAEWOULDBLOCK)
|
||||
#else
|
||||
if (errno != EINPROGRESS)
|
||||
|
@ -565,7 +565,7 @@ static Class runLoopClass;
|
|||
|
||||
state = GS_H_TRYCON;
|
||||
l = [NSRunLoop currentRunLoop];
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
NSAssert(event != WSA_INVALID_EVENT, @"Socket without win32 event!");
|
||||
[l addEvent: (void*)(uintptr_t)event
|
||||
type: ET_HANDLE
|
||||
|
@ -603,7 +603,7 @@ static Class runLoopClass;
|
|||
M_LOCK(myLock);
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
[l removeEvent: (void*)(uintptr_t)event
|
||||
type: ET_HANDLE
|
||||
forMode: NSConnectionReplyMode
|
||||
|
@ -694,7 +694,7 @@ static Class runLoopClass;
|
|||
return desc;
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
- (int) eventHandle
|
||||
{
|
||||
return (int) (size_t) event;
|
||||
|
@ -719,7 +719,7 @@ static Class runLoopClass;
|
|||
|
||||
valid = NO;
|
||||
l = [runLoopClass currentRunLoop];
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
[l removeEvent: (void*)(uintptr_t)event
|
||||
type: ET_HANDLE
|
||||
forMode: nil
|
||||
|
@ -741,7 +741,7 @@ static Class runLoopClass;
|
|||
NSDebugMLLog(@"GSTcpHandle", @"invalidated 0x%x", self);
|
||||
[[self recvPort] removeHandle: self];
|
||||
[[self sendPort] removeHandle: self];
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
WSACloseEvent(event);
|
||||
event = WSA_INVALID_EVENT;
|
||||
#endif
|
||||
|
@ -808,12 +808,12 @@ static Class runLoopClass;
|
|||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
else if (WSAGetLastError()!= WSAEINTR
|
||||
&& WSAGetLastError()!= WSAEWOULDBLOCK)
|
||||
#else
|
||||
else if (errno != EINTR && errno != EAGAIN)
|
||||
#endif /* !__MINGW32__ */
|
||||
#endif /* !__MINGW__ */
|
||||
{
|
||||
NSDebugMLLog(@"GSTcpHandle",
|
||||
@"read failed - %@ on 0x%p", [NSError _last], self);
|
||||
|
@ -1162,23 +1162,23 @@ static Class runLoopClass;
|
|||
res = send(desc, b + wLength, l - wLength, 0);
|
||||
if (res < 0)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
if (WSAGetLastError()!= WSAEINTR
|
||||
&& WSAGetLastError()!= WSAEWOULDBLOCK)
|
||||
#else
|
||||
if (errno != EINTR && errno != EAGAIN)
|
||||
#endif /* !__MINGW32__ */
|
||||
#endif /* !__MINGW__ */
|
||||
{
|
||||
NSLog(@"write attempt failed - %@", [NSError _last]);
|
||||
[self invalidate];
|
||||
return;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW__
|
||||
if (WSAGetLastError()== WSAEWOULDBLOCK)
|
||||
{
|
||||
readyToSend = NO;
|
||||
}
|
||||
#endif /* !__MINGW32__ */
|
||||
#endif /* !__MINGW__ */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1223,7 +1223,7 @@ static Class runLoopClass;
|
|||
extra: (void*)extra
|
||||
forMode: (NSString*)mode
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
WSANETWORKEVENTS ocurredEvents;
|
||||
#else
|
||||
#endif
|
||||
|
@ -1235,7 +1235,7 @@ static Class runLoopClass;
|
|||
{
|
||||
NSRunLoop *l = [runLoopClass currentRunLoop];
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
[l removeEvent: data
|
||||
type: ET_HANDLE
|
||||
forMode: mode
|
||||
|
@ -1255,7 +1255,7 @@ static Class runLoopClass;
|
|||
|
||||
M_LOCK(myLock);
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
if (WSAEnumNetworkEvents(desc, event, &ocurredEvents)==SOCKET_ERROR)
|
||||
{
|
||||
NSLog(@"Error getting event type %d", WSAGetLastError());
|
||||
|
@ -1352,7 +1352,7 @@ static Class runLoopClass;
|
|||
|
||||
IF_NO_GC(RETAIN(self);)
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
NSAssert(event != WSA_INVALID_EVENT, @"Socket without win32 event!");
|
||||
[l addEvent: (void*)(uintptr_t)event
|
||||
type: ET_HANDLE
|
||||
|
@ -1387,7 +1387,7 @@ static Class runLoopClass;
|
|||
&& [when timeIntervalSinceNow] > 0)
|
||||
{
|
||||
M_UNLOCK(myLock);
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
if (readyToSend)
|
||||
{
|
||||
[self receivedEventWrite];
|
||||
|
@ -1402,7 +1402,7 @@ static Class runLoopClass;
|
|||
M_LOCK(myLock);
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
[l removeEvent: (void*)(uintptr_t)event
|
||||
type: ET_HANDLE
|
||||
forMode: NSConnectionReplyMode
|
||||
|
@ -1583,7 +1583,7 @@ static Class tcpPortClass;
|
|||
port->address = [addr copy];
|
||||
port->handles = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 0);
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
port->eventListener = WSA_INVALID_EVENT;
|
||||
port->events = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSIntMapValueCallBacks, 0);
|
||||
|
@ -1679,7 +1679,7 @@ static Class tcpPortClass;
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
int rc;
|
||||
#endif
|
||||
/*
|
||||
|
@ -1689,7 +1689,7 @@ static Class tcpPortClass;
|
|||
*/
|
||||
port->listener = desc;
|
||||
port->portNum = GSSwapBigI16ToHost(sockaddr.sin_port);
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
port->eventListener = (WSAEVENT)CreateEvent(NULL,NO,NO,NULL);
|
||||
if (port->eventListener == WSA_INVALID_EVENT)
|
||||
{
|
||||
|
@ -1775,7 +1775,7 @@ static Class tcpPortClass;
|
|||
handle->recvPort = GS_GC_HIDE(self);
|
||||
}
|
||||
NSMapInsert(handles, (void*)(uintptr_t)[handle descriptor], (void*)handle);
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
NSMapInsert(events, (void*)(uintptr_t)[handle eventHandle],
|
||||
(void*)(uintptr_t)[handle descriptor]);
|
||||
#endif
|
||||
|
@ -1827,7 +1827,7 @@ static Class tcpPortClass;
|
|||
* This is a callback method used by the NSRunLoop class to determine which
|
||||
* descriptors to watch for the port.
|
||||
*/
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
- (void) getFds: (int*)fds count: (int*)count
|
||||
{
|
||||
NSMapEnumerator me;
|
||||
|
@ -2072,7 +2072,7 @@ static Class tcpPortClass;
|
|||
{
|
||||
(void) close(listener);
|
||||
listener = -1;
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
WSACloseEvent(eventListener);
|
||||
eventListener = WSA_INVALID_EVENT;
|
||||
#endif
|
||||
|
@ -2089,7 +2089,7 @@ static Class tcpPortClass;
|
|||
[handle invalidate];
|
||||
}
|
||||
}
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
if (events != 0)
|
||||
{
|
||||
NSFreeMapTable(events);
|
||||
|
@ -2132,7 +2132,7 @@ static Class tcpPortClass;
|
|||
extra: (void*)extra
|
||||
forMode: (NSString*)mode
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
WSAEVENT event = (WSAEVENT)extra;
|
||||
SOCKET desc;
|
||||
#else
|
||||
|
@ -2143,7 +2143,7 @@ static Class tcpPortClass;
|
|||
NSDebugMLLog(@"NSPort", @"received %s event %p on 0x%x",
|
||||
type == ET_RPORT ? "read" : "write", extra, self);
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
if (event == eventListener)
|
||||
#else
|
||||
if (desc == listener)
|
||||
|
@ -2163,7 +2163,7 @@ static Class tcpPortClass;
|
|||
|
||||
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
|
||||
sizeof(status));
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
// reset associated event with new socket
|
||||
WSAEventSelect(desc, eventListener, 0);
|
||||
#endif
|
||||
|
@ -2184,7 +2184,7 @@ static Class tcpPortClass;
|
|||
else
|
||||
{
|
||||
M_LOCK(myLock);
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
desc = (SOCKET)NSMapGet(events, (void*)(uintptr_t)event);
|
||||
#endif
|
||||
handle = (GSTcpHandle*)NSMapGet(handles, (void*)(uintptr_t)desc);
|
||||
|
@ -2194,7 +2194,7 @@ static Class tcpPortClass;
|
|||
{
|
||||
const char *t;
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
if (type == ET_HANDLE) t = "winhandle";
|
||||
#else
|
||||
if (type == ET_RDESC) t = "rdesc";
|
||||
|
@ -2267,7 +2267,7 @@ static Class tcpPortClass;
|
|||
handle->recvPort = nil;
|
||||
}
|
||||
NSMapRemove(handles, (void*)(uintptr_t)[handle descriptor]);
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW__)
|
||||
NSMapRemove(events, (void*)(uintptr_t)[handle eventHandle]);
|
||||
#endif
|
||||
if (((int) listener) < 0 && NSCountMapTable(handles) == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue