From 32da3507554f505a978cc1dc5effb059294fccce Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Tue, 4 Oct 2005 11:54:03 +0000 Subject: [PATCH] Attempted fix for systems where sizeof(int) < sizeof(void*) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21770 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 ++++++++++ Source/GSTcpPort.m | 12 +++++++----- Source/NSCallBacks.m | 2 +- Source/NSMessagePort.m | 20 +++++++++++--------- Source/NSMessagePortNameServer.m | 4 ++-- Source/NSSocketPort.m | 17 +++++++++-------- Source/win32/GSRunLoopCtxt.m | 6 +++--- 7 files changed, 43 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f5b7620e..9b4db3597 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-10-04 Richard Frith-Macdonald + + * Source/GSTcpPort.m: + * Source/NSCallBacks.m: + * Source/NSMessagePort.m: + * Source/NSMessagePortNameServer.m: + * Source/NSSocketPort.m: + * Source/win32/GSRunLoopCtxt.m: + Attempt to deal with systems where sizeof(int) < sizeof(void*) + 2005-10-01 David Ayers * Source/NSString: (dataUsingEncoding:allowLossyConversion:): diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index 77f8af0db..d52ee8519 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -1596,7 +1596,7 @@ static unsigned wordAlign; - (void) getFds: (SOCKET*)fds count: (int*)count { NSMapEnumerator me; - SOCKET sock; + void *sock; GSTcpHandle *handle; id recvSelf; @@ -1623,11 +1623,11 @@ static unsigned wordAlign; */ recvSelf = GS_GC_HIDE(self); me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &sock, (void**)&handle)) { if (handle->recvPort == recvSelf) { - fds[(*count)++] = sock; + fds[(*count)++] = (SOCKET)sock; } } NSEndMapTableEnumeration(&me); @@ -1638,6 +1638,7 @@ static unsigned wordAlign; { NSMapEnumerator me; SOCKET sock; + void *dummy; #ifndef BROKEN_SO_REUSEADDR int opt = 1; #endif @@ -1648,7 +1649,7 @@ static unsigned wordAlign; * Enumerate all our socket handles, and look for one with port. */ me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &dummy, (void**)&handle)) { if ([handle recvPort] == recvPort) { @@ -1663,7 +1664,8 @@ static unsigned wordAlign; * Not found ... create a new handle. */ handle = nil; - if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) + sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC); + if (sock == INVALID_SOCKET) { NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); } diff --git a/Source/NSCallBacks.m b/Source/NSCallBacks.m index c25be755a..8be24c002 100644 --- a/Source/NSCallBacks.m +++ b/Source/NSCallBacks.m @@ -67,7 +67,7 @@ _NS_int_release(void *table, void* i) NSString * _NS_int_describe(void *table, void* i) { - return [NSString stringWithFormat: @"%d", i]; + return [NSString stringWithFormat: @"%d", (int)i]; } /** For owned `void *' **/ diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index f7a692f1d..c1767280c 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -1150,7 +1150,7 @@ static Class messagePortClass; static void clean_up_sockets(void) { NSMessagePort *port; - NSData *name; + NSData *name; NSMapEnumerator mEnum; BOOL unknownThread = GSRegisterCurrentThread(); CREATE_AUTORELEASE_POOL(arp); @@ -1385,8 +1385,8 @@ static int unique_index = 0; - (void) getFds: (int*)fds count: (int*)count { NSMapEnumerator me; - int sock; - GSMessageHandle *handle; + void *sock; + GSMessageHandle *handle; id recvSelf; M_LOCK(myLock); @@ -1412,11 +1412,11 @@ static int unique_index = 0; */ recvSelf = GS_GC_HIDE(self); me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &sock, (void**)&handle)) { if (handle->recvPort == recvSelf) { - fds[(*count)++] = sock; + fds[(*count)++] = (int)sock; } } NSEndMapTableEnumeration(&me); @@ -1426,7 +1426,7 @@ static int unique_index = 0; - (id) conversation: (NSPort*)recvPort { NSMapEnumerator me; - int sock; + void *dummy; GSMessageHandle *handle = nil; M_LOCK(myLock); @@ -1434,7 +1434,7 @@ static int unique_index = 0; * Enumerate all our socket handles, and look for one with port. */ me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &dummy, (void**)&handle)) { if ([handle recvPort] == recvPort) { @@ -1454,6 +1454,7 @@ static int unique_index = 0; { NSMapEnumerator me; int sock; + void *dummy; #ifndef BROKEN_SO_REUSEADDR int opt = 1; #endif @@ -1464,7 +1465,7 @@ static int unique_index = 0; * Enumerate all our socket handles, and look for one with port. */ me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &dummy, (void**)&handle)) { if ([handle recvPort] == recvPort) { @@ -1479,7 +1480,8 @@ static int unique_index = 0; * Not found ... create a new handle. */ handle = nil; - if ((sock = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0) + sock = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC); + if (sock < 0) { NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); } diff --git a/Source/NSMessagePortNameServer.m b/Source/NSMessagePortNameServer.m index 3992b5e40..c3c401fae 100644 --- a/Source/NSMessagePortNameServer.m +++ b/Source/NSMessagePortNameServer.m @@ -80,8 +80,8 @@ static NSMapTable portToNamesMap; static void clean_up_names(void) { NSMapEnumerator mEnum; - NSMessagePort *port; - NSString *name; + NSMessagePort *port; + NSString *name; BOOL unknownThread = GSRegisterCurrentThread(); CREATE_AUTORELEASE_POOL(arp); diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index 7b092af97..badd0e9f5 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -1794,7 +1794,7 @@ static unsigned wordAlign; - (void) getFds: (int*)fds count: (int*)count { NSMapEnumerator me; - WSAEVENT event; + void *event; SOCKET fd; GSTcpHandle *handle; id recvSelf; @@ -1822,7 +1822,7 @@ static unsigned wordAlign; */ recvSelf = GS_GC_HIDE(self); me = NSEnumerateMapTable(events); - while (NSNextMapEnumeratorPair(&me, (void*)&event, (void*)&fd)) + while (NSNextMapEnumeratorPair(&me, &event, (void**)&fd)) { handle = (GSTcpHandle*)NSMapGet(handles, (void*)(gsaddr)fd); if (handle->recvPort == recvSelf && handle->inReplyMode == NO) @@ -1837,7 +1837,7 @@ static unsigned wordAlign; - (void) getFds: (int*)fds count: (int*)count { NSMapEnumerator me; - SOCKET sock; + void *sock; GSTcpHandle *handle; id recvSelf; @@ -1864,11 +1864,11 @@ static unsigned wordAlign; */ recvSelf = GS_GC_HIDE(self); me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &sock, (void**)&handle)) { if (handle->recvPort == recvSelf) { - fds[(*count)++] = sock; + fds[(*count)++] = (SOCKET)sock; } } NSEndMapTableEnumeration(&me); @@ -1879,7 +1879,7 @@ static unsigned wordAlign; - (id) conversation: (NSPort*)recvPort { NSMapEnumerator me; - SOCKET sock; + void *dummy; GSTcpHandle *handle = nil; M_LOCK(myLock); @@ -1887,7 +1887,7 @@ static unsigned wordAlign; * Enumerate all our socket handles, and look for one with port. */ me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &dummy, (void**)&handle)) { if ([handle recvPort] == recvPort) { @@ -1907,6 +1907,7 @@ static unsigned wordAlign; { NSMapEnumerator me; SOCKET sock; + void *dummy; #ifndef BROKEN_SO_REUSEADDR int opt = 1; #endif @@ -1917,7 +1918,7 @@ static unsigned wordAlign; * Enumerate all our socket handles, and look for one with port. */ me = NSEnumerateMapTable(handles); - while (NSNextMapEnumeratorPair(&me, (void*)&sock, (void*)&handle)) + while (NSNextMapEnumeratorPair(&me, &dummy, (void**)&handle)) { if ([handle recvPort] == recvPort) { diff --git a/Source/win32/GSRunLoopCtxt.m b/Source/win32/GSRunLoopCtxt.m index de912e296..957897858 100644 --- a/Source/win32/GSRunLoopCtxt.m +++ b/Source/win32/GSRunLoopCtxt.m @@ -135,7 +135,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = HANDLE *handleArray; int num_handles; unsigned i; - HANDLE handle; + void *handle; int wait_timeout; DWORD wait_return; BOOL do_wait; @@ -215,9 +215,9 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = hEnum = NSEnumerateMapTable(handleMap); i = 0; - while (NSNextMapEnumeratorPair(&hEnum, (void**)&handle, (void**)&watcher)) + while (NSNextMapEnumeratorPair(&hEnum, &handle, (void**)&watcher)) { - handleArray[i++] = handle; + handleArray[i++] = (HANDLE)handle; } do_wait = YES;