From f57ca76cba03fa0ae8cf3174326f7b7181b92670 Mon Sep 17 00:00:00 2001 From: CaS Date: Tue, 10 Jan 2006 10:29:11 +0000 Subject: [PATCH] Fixes for 64bit systems .. mostly cosmetic avoidance of compiler warnings. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22282 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 25 ++++++++++++++++++ Source/Additions/GSXML.m | 27 ++++++++++--------- Source/GSFileHandle.m | 2 +- Source/NSAutoreleasePool.m | 2 +- Source/NSCallBacks.m | 10 +++---- Source/NSConnection.m | 10 ++++--- Source/NSData.m | 2 +- Source/NSDictionary.m | 2 +- Source/NSDistantObject.m | 4 +-- Source/NSMessagePort.m | 2 +- Source/NSObject.m | 2 +- Source/NSProtocolChecker.m | 4 +-- Source/NSProxy.m | 2 +- Source/NSSocketPort.m | 2 +- Source/NSTask.m | 8 +++--- Source/NSThread.m | 2 +- Source/NSZone.m | 3 ++- Source/unix/GSRunLoopCtxt.m | 52 +++++++++++++++++++++++-------------- Tools/gdomap.c | 6 ++--- 19 files changed, 105 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index d311659d1..34ca6a9bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2006-01-10 Richard Frith-Macdonald + + * Source/GSFileHandle.m: + * Source/NSAutoreleasePool.m: + * Source/NSCallBacks.m: + * Source/NSConnection.m: + * Source/NSData.m: + * Source/NSDictionary.m: + * Source/NSDistantObject.m: + * Source/NSMessagePort.m: + * Source/NSObject.m: + * Source/NSProtocolChecker.m: + * Source/NSProxy.m: + * Source/NSSocketPort.m: + * Source/NSTask.m: + * Source/NSThread.m: + * Source/NSZone.m: + * Source/Additions/GSXML.m: + * Source/unix/GSRunLoopCtxt.m: + Add explicit casts to avoid compiler warnings where we are on a + processor where the size of an integer is not the same as the size + of a pointer. + * Tools/gdomap.c: + Add type casts to fix comparisons on 64bit processor + 2006-01-09 Richard Frith-Macdonald * Source/win32/GSRunLoopCtxt.m: Apply patch by Jeremy Bettis with diff --git a/Source/Additions/GSXML.m b/Source/Additions/GSXML.m index 1ec21255d..84e7e6316 100644 --- a/Source/Additions/GSXML.m +++ b/Source/Additions/GSXML.m @@ -250,7 +250,7 @@ static NSMapTable *attrNames = 0; { if ([desc isEqual: val] == YES) { - return (int)key; + return (int)(intptr_t)key; } } return -1; @@ -258,7 +258,7 @@ static NSMapTable *attrNames = 0; + (NSString*) descriptionFromType: (int)type { - NSString *desc = (NSString*)NSMapGet(attrNames, (void*)type); + NSString *desc = (NSString*)NSMapGet(attrNames, (void*)(intptr_t)type); return desc; } @@ -270,8 +270,9 @@ static NSMapTable *attrNames = 0; - (NSString*) typeDescription { - NSString *desc = (NSString*)NSMapGet(attrNames, (void*)[self type]); + NSString *desc; + desc = (NSString*)NSMapGet(attrNames, (void*)(intptr_t)[self type]); if (desc == nil) { desc = @"Unknown attribute type"; @@ -415,7 +416,7 @@ static NSMapTable *attrNames = 0; - (unsigned) hash { - return (((unsigned)lib) >> 3); + return (((unsigned)(uintptr_t)lib) >> 3); } - (id) init @@ -561,7 +562,7 @@ static NSMapTable *nsNames = 0; */ + (NSString*) descriptionFromType: (int)type { - NSString *desc = (NSString*)NSMapGet(nsNames, (void*)type); + NSString *desc = (NSString*)NSMapGet(nsNames, (void*)(intptr_t)type); return desc; } @@ -599,7 +600,7 @@ static NSMapTable *nsNames = 0; { if ([desc isEqual: val] == YES) { - return (int)key; + return (int)(intptr_t)key; } } return -1; @@ -618,7 +619,7 @@ static NSMapTable *nsNames = 0; - (unsigned) hash { - return (((unsigned)lib) >> 3); + return (((unsigned)(uintptr_t)lib) >> 3); } /** @@ -692,8 +693,9 @@ static NSMapTable *nsNames = 0; */ - (NSString*) typeDescription { - NSString *desc = (NSString*)NSMapGet(nsNames, (void*)[self type]); + NSString *desc; + desc = (NSString*)NSMapGet(nsNames, (void*)(intptr_t)[self type]); if (desc == nil) { desc = @"Unknown namespace type"; @@ -738,7 +740,7 @@ static NSMapTable *nodeNames = 0; */ + (NSString*) descriptionFromType: (int)type { - NSString *desc = (NSString*)NSMapGet(nodeNames, (void*)type); + NSString *desc = (NSString*)NSMapGet(nodeNames, (void*)(intptr_t)type); return desc; } @@ -826,7 +828,7 @@ static NSMapTable *nodeNames = 0; { if ([desc isEqual: val] == YES) { - return (int)key; + return (int)(intptr_t)key; } } return -1; @@ -1077,7 +1079,7 @@ static NSMapTable *nodeNames = 0; - (unsigned) hash { - return (((unsigned)lib) >> 3); + return (((unsigned)(uintptr_t)lib) >> 3); } - (id) init @@ -1546,8 +1548,9 @@ static NSMapTable *nodeNames = 0; */ - (NSString*) typeDescription { - NSString *desc = (NSString*)NSMapGet(nodeNames, (void*)[self type]); + NSString *desc; + desc = (NSString*)NSMapGet(nodeNames, (void*)(intptr_t)[self type]); if (desc == nil) { desc = @"Unknown node type"; diff --git a/Source/GSFileHandle.m b/Source/GSFileHandle.m index b62422427..f557138b0 100644 --- a/Source/GSFileHandle.m +++ b/Source/GSFileHandle.m @@ -1248,7 +1248,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; - (void*) nativeHandle { - return (void*)descriptor; + return (void*)(intptr_t)descriptor; } // Synchronous I/O operations diff --git a/Source/NSAutoreleasePool.m b/Source/NSAutoreleasePool.m index 0e44c6e3d..e3c5858d1 100644 --- a/Source/NSAutoreleasePool.m +++ b/Source/NSAutoreleasePool.m @@ -354,7 +354,7 @@ static IMP initImp; { id anObject = objects[i]; Class c = GSObjCClass(anObject); - unsigned hash = (((unsigned)c) >> 3) & 0x0f; + unsigned hash = (((unsigned)(uintptr_t)c) >> 3) & 0x0f; objects[i] = nil; if (classes[hash] != c) diff --git a/Source/NSCallBacks.m b/Source/NSCallBacks.m index 8be24c002..be4b19f5b 100644 --- a/Source/NSCallBacks.m +++ b/Source/NSCallBacks.m @@ -43,7 +43,7 @@ unsigned int _NS_int_hash(void *table, void* i) { - return (unsigned int) i; + return (unsigned)(uintptr_t)i; } BOOL @@ -67,7 +67,7 @@ _NS_int_release(void *table, void* i) NSString * _NS_int_describe(void *table, void* i) { - return [NSString stringWithFormat: @"%d", (int)i]; + return [NSString stringWithFormat: @"%d", (int)(intptr_t)i]; } /** For owned `void *' **/ @@ -76,7 +76,7 @@ unsigned int _NS_owned_void_p_hash(void *table, void *p) { /* P may be aligned, so we need to compensate. */ - return ((unsigned int)p)/4; + return ((unsigned)(uintptr_t)p)/4; } BOOL @@ -177,7 +177,7 @@ _NS_id_describe(void *table, id o) unsigned int _NS_non_owned_void_p_hash(void *table, void *p) { - return ((unsigned int)p)/4; + return ((unsigned)(uintptr_t)p)/4; } BOOL @@ -209,7 +209,7 @@ _NS_non_owned_void_p_describe(void *table, void *p) unsigned int _NS_int_p_hash(void *table, int *p) { - return ((unsigned int)p)/4; + return ((unsigned)(uintptr_t)p)/4; } BOOL diff --git a/Source/NSConnection.m b/Source/NSConnection.m index fb57c984c..2f7c1f8c4 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -618,7 +618,9 @@ static NSLock *cached_proxies_gate = nil; if ([item countdown] == NO) { NSDistantObject *obj = [item obj]; - NSMapRemove(targetToCached, (void*)((ProxyStruct*)obj)->_handle); + + NSMapRemove(targetToCached, + (void*)(uintptr_t)((ProxyStruct*)obj)->_handle); } } if ([cached_locals count] == 0) @@ -3185,7 +3187,7 @@ static void callEncoder (DOContext *ctxt) repeats: YES]; } item = [CachedLocalObject newWithObject: prox time: 5]; - NSMapInsert(targetToCached, (void*)target, item); + NSMapInsert(targetToCached, (void*)(uintptr_t)target, item); M_UNLOCK(cached_proxies_gate); RELEASE(item); if (debug_connection > 3) @@ -3276,7 +3278,7 @@ static void callEncoder (DOContext *ctxt) CachedLocalObject *cached; M_LOCK(cached_proxies_gate); - cached = NSMapGet (targetToCached, (void*)target); + cached = NSMapGet (targetToCached, (void*)(uintptr_t)target); if (cached != nil) { proxy = [cached obj]; @@ -3286,7 +3288,7 @@ static void callEncoder (DOContext *ctxt) */ ASSIGN(((ProxyStruct*)proxy)->_connection, self); [self addLocalObject: proxy]; - NSMapRemove(targetToCached, (void*)target); + NSMapRemove(targetToCached, (void*)(uintptr_t)target); if (debug_connection > 3) NSLog(@"target (0x%x) moved from cache", target); } diff --git a/Source/NSData.m b/Source/NSData.m index 58ea47b44..b54b972c1 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -3758,7 +3758,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) size, GSLastErrorStr(errno)]; } tmp = shmat(newid, 0, 0); - if ((int)tmp == -1) /* Attached memory? */ + if ((intptr_t)tmp == -1) /* Attached memory? */ { [NSException raise: NSMallocException format: @"Unable to attach to shared memory segment."]; diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index d73b02cc8..2b6c9f4ac 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -837,7 +837,7 @@ compareIt(id o1, id o2, void* context) struct foo *f = (struct foo*)context; o1 = (*f->i)(f->d, @selector(objectForKey:), o1); o2 = (*f->i)(f->d, @selector(objectForKey:), o2); - return (int)[o1 performSelector: f->s withObject: o2]; + return (int)(intptr_t)[o1 performSelector: f->s withObject: o2]; } /** diff --git a/Source/NSDistantObject.m b/Source/NSDistantObject.m index ece45a432..71e03e5fd 100644 --- a/Source/NSDistantObject.m +++ b/Source/NSDistantObject.m @@ -699,7 +699,7 @@ enum proxyLocation * (implemented in NSObject.m) to examine the protocol contents * without sending any ObjectiveC message to it. */ - if ((int)GSObjCClass(_protocol) == 0x2) + if ((uintptr_t)GSObjCClass(_protocol) == 0x2) { extern struct objc_method_description* GSDescriptionForInstanceMethod(); @@ -711,7 +711,7 @@ enum proxyLocation } if (mth == 0) { - if ((int)GSObjCClass(_protocol) == 0x2) + if ((uintptr_t)GSObjCClass(_protocol) == 0x2) { extern struct objc_method_description* GSDescriptionForClassMethod(); diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index 94d4a1056..bb28b6aef 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -1445,7 +1445,7 @@ static unsigned wordAlign; { if (handle->recvPort == recvSelf) { - fds[(*count)++] = (int)sock; + fds[(*count)++] = (int)(intptr_t)sock; } } NSEndMapTableEnumeration(&me); diff --git a/Source/NSObject.m b/Source/NSObject.m index 28b270b40..e891b8cdf 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -1660,7 +1660,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel) * In the absence of detailed information, pick a reasonable value * assuming the object will be aligned to an eight byte boundary. */ - return (unsigned)self >> 3; + return (unsigned)(uintptr_t)self >> 3; } /** diff --git a/Source/NSProtocolChecker.m b/Source/NSProtocolChecker.m index 33df06a55..641c26911 100644 --- a/Source/NSProtocolChecker.m +++ b/Source/NSProtocolChecker.m @@ -88,7 +88,7 @@ */ if (GSObjCIsInstance(_myTarget)) { - if ((int)GSObjCClass(_myProtocol) == 0x2) + if ((uintptr_t)GSObjCClass(_myProtocol) == 0x2) { mth = GSDescriptionForInstanceMethod(_myProtocol, aSelector); } @@ -99,7 +99,7 @@ } else { - if ((int)GSObjCClass(_myProtocol) == 0x2) + if ((uintptr_t)GSObjCClass(_myProtocol) == 0x2) { mth = GSDescriptionForClassMethod(_myProtocol, aSelector); } diff --git a/Source/NSProxy.m b/Source/NSProxy.m index da9b25792..1a56166d8 100644 --- a/Source/NSProxy.m +++ b/Source/NSProxy.m @@ -312,7 +312,7 @@ extern BOOL __objc_responds_to(id, SEL); * In the absence of detailed information, pick a reasonable value * assuming the object will be aligned to an eight byte boundary. */ - return ((unsigned)self)>>3; + return ((unsigned)(uintptr_t)self)>>3; } /** diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index 82f8067ff..b4449a6e0 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -1919,7 +1919,7 @@ static unsigned wordAlign; { if (handle->recvPort == recvSelf) { - fds[(*count)++] = (SOCKET)sock; + fds[(*count)++] = (int)(intptr_t)sock; } } NSEndMapTableEnumeration(&me); diff --git a/Source/NSTask.m b/Source/NSTask.m index 3117a5105..acd8d28ae 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -279,7 +279,7 @@ pty_slave(const char* name) - (void) gcFinalize { [tasksLock lock]; - NSMapRemove(activeTasks, (void*)_taskId); + NSMapRemove(activeTasks, (void*)(intptr_t)_taskId); [tasksLock unlock]; } @@ -890,7 +890,7 @@ pty_slave(const char* name) - (void) _terminatedChild: (int)status { [tasksLock lock]; - NSMapRemove(activeTasks, (void*)_taskId); + NSMapRemove(activeTasks, (void*)(intptr_t)_taskId); [tasksLock unlock]; _terminationStatus = status; _hasCollected = YES; @@ -1260,7 +1260,7 @@ GSCheckTasks() NSTask *t; [tasksLock lock]; - t = (NSTask*)NSMapGet(activeTasks, (void*)result); + t = (NSTask*)NSMapGet(activeTasks, (void*)(intptr_t)result); [tasksLock unlock]; if (t != nil) { @@ -1491,7 +1491,7 @@ GSCheckTasks() ASSIGN(_launchPath, lpath); // Actual path used. [tasksLock lock]; - NSMapInsert(activeTasks, (void*)_taskId, (void*)self); + NSMapInsert(activeTasks, (void*)(intptr_t)_taskId, (void*)self); [tasksLock unlock]; /* diff --git a/Source/NSThread.m b/Source/NSThread.m index 5bc3cd0ae..d3a375229 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -828,7 +828,7 @@ static NSDate *theFuture; } for (i = 0; i < count; i++) { - [loop addEvent: (void*)inputFd + [loop addEvent: (void*)(intptr_t)inputFd type: ET_RDESC watcher: (id)self forMode: [m objectAtIndex: i]]; diff --git a/Source/NSZone.m b/Source/NSZone.m index 0779a9513..08fa0a340 100644 --- a/Source/NSZone.m +++ b/Source/NSZone.m @@ -103,7 +103,8 @@ void * GSOutOfMemory(size_t size, BOOL retry) { - fprintf(stderr, "GSOutOfMemory ... wanting %u bytes.\n", size); + fprintf(stderr, "GSOutOfMemory ... wanting %lu bytes.\n", + (unsigned long)size); return 0; } diff --git a/Source/unix/GSRunLoopCtxt.m b/Source/unix/GSRunLoopCtxt.m index ccb78a486..3a27ef3c6 100644 --- a/Source/unix/GSRunLoopCtxt.m +++ b/Source/unix/GSRunLoopCtxt.m @@ -267,21 +267,21 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) switch (info->type) { case ET_EDESC: - fd = (int)info->data; + fd = (int)(intptr_t)info->data; setPollfd(fd, POLLPRI, self); - NSMapInsert(_efdMap, (void*)fd, info); + NSMapInsert(_efdMap, (void*)(intptr_t)fd, info); break; case ET_RDESC: - fd = (int)info->data; + fd = (int)(intptr_t)info->data; setPollfd(fd, POLLIN, self); - NSMapInsert(_rfdMap, (void*)fd, info); + NSMapInsert(_rfdMap, (void*)(intptr_t)fd, info); break; case ET_WDESC: - fd = (int)info->data; + fd = (int)(intptr_t)info->data; setPollfd(fd, POLLOUT, self); - NSMapInsert(_wfdMap, (void*)fd, info); + NSMapInsert(_wfdMap, (void*)(intptr_t)fd, info); break; case ET_RPORT: @@ -312,7 +312,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) fd = port_fd_array[port_fd_count]; setPollfd(fd, POLLIN, self); NSMapInsert(_rfdMap, - (void*)port_fd_array[port_fd_count], info); + (void*)(intptr_t)port_fd_array[port_fd_count], info); } } break; @@ -421,7 +421,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) */ if (pollfds[fdIndex].revents & (POLLPRI|POLLERR|POLLHUP|POLLNVAL)) { - watcher = (GSRunLoopWatcher*)NSMapGet(_efdMap, (void*)fd); + watcher + = (GSRunLoopWatcher*)NSMapGet(_efdMap, (void*)(intptr_t)fd); if (watcher != nil && watcher->_invalidated == NO) { i = [contexts count]; @@ -429,7 +430,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) { GSRunLoopCtxt *c = [contexts objectAtIndex: i]; - if (c != self) [c endEvent: (void*)fd type: ET_EDESC]; + if (c != self) + { + [c endEvent: (void*)(intptr_t)fd type: ET_EDESC]; + } } /* * The watcher is still valid - so call its @@ -448,7 +452,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) } if (pollfds[fdIndex].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL)) { - watcher = (GSRunLoopWatcher*)NSMapGet(_wfdMap, (void*)fd); + watcher + = (GSRunLoopWatcher*)NSMapGet(_wfdMap, (void*)(intptr_t)fd); if (watcher != nil && watcher->_invalidated == NO) { i = [contexts count]; @@ -456,7 +461,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) { GSRunLoopCtxt *c = [contexts objectAtIndex: i]; - if (c != self) [c endEvent: (void*)fd type: ET_WDESC]; + if (c != self) + { + [c endEvent: (void*)(intptr_t)fd type: ET_WDESC]; + } } /* * The watcher is still valid - so call its @@ -475,7 +483,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) } if (pollfds[fdIndex].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) { - watcher = (GSRunLoopWatcher*)NSMapGet(_rfdMap, (void*)fd); + watcher + = (GSRunLoopWatcher*)NSMapGet(_rfdMap, (void*)(intptr_t)fd); if (watcher != nil && watcher->_invalidated == NO) { i = [contexts count]; @@ -483,7 +492,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) { GSRunLoopCtxt *c = [contexts objectAtIndex: i]; - if (c != self) [c endEvent: (void*)fd type: ET_RDESC]; + if (c != self) + { + [c endEvent: (void*)(intptr_t)fd type: ET_RDESC]; + } } /* * The watcher is still valid - so call its @@ -586,29 +598,29 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) switch (info->type) { case ET_EDESC: - fd = (int)info->data; + fd = (int)(intptr_t)info->data; if (fd > fdEnd) fdEnd = fd; FD_SET (fd, &exception_fds); - NSMapInsert(_efdMap, (void*)fd, info); + NSMapInsert(_efdMap, (void*)(intptr_t)fd, info); num_inputs++; break; case ET_RDESC: - fd = (int)info->data; + fd = (int)(intptr_t)info->data; if (fd > fdEnd) fdEnd = fd; FD_SET (fd, &read_fds); - NSMapInsert(_rfdMap, (void*)fd, info); + NSMapInsert(_rfdMap, (void*)(intptr_t)fd, info); num_inputs++; break; case ET_WDESC: - fd = (int)info->data; + fd = (int)(intptr_t)info->data; if (fd > fdEnd) fdEnd = fd; FD_SET (fd, &write_fds); - NSMapInsert(_wfdMap, (void*)fd, info); + NSMapInsert(_wfdMap, (void*)(intptr_t)fd, info); num_inputs++; break; @@ -642,7 +654,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) if (fd > fdEnd) fdEnd = fd; NSMapInsert(_rfdMap, - (void*)port_fd_array[port_fd_count], info); + (void*)(intptr_t)port_fd_array[port_fd_count], info); num_inputs++; } } diff --git a/Tools/gdomap.c b/Tools/gdomap.c index a1b78f5b1..9d98f7b3e 100644 --- a/Tools/gdomap.c +++ b/Tools/gdomap.c @@ -1553,12 +1553,12 @@ load_iface(const char* from) bcok[interfaces] = 0; bcst[interfaces].s_addr = inet_addr("0.0.0.0"); } - if (addr[interfaces].s_addr == (unsigned long)-1) + if (addr[interfaces].s_addr == (uint32_t)-1) { sprintf(ebuf, "'%s' is not as valid address", buf); gdomap_log(LOG_ERR); } - else if (mask[interfaces].s_addr == (unsigned long)-1) + else if (mask[interfaces].s_addr == (uint32_t)-1) { sprintf(ebuf, "'%s' is not as valid netmask", ptr); gdomap_log(LOG_ERR); @@ -4499,7 +4499,7 @@ printf( prb = (plentry*)malloc(sizeof(plentry)); memset((char*)prb, '\0', sizeof(plentry)); prb->addr.s_addr = inet_addr(buf); - if (prb->addr.s_addr == (unsigned long)-1) + if (prb->addr.s_addr == (uint32_t)-1) { fprintf(stderr, "'%s' is not as valid address\n", buf); free(prb);