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
This commit is contained in:
Richard Frith-Macdonald 2006-01-10 10:29:11 +00:00
parent dc79072c9f
commit 06981169ed
19 changed files with 105 additions and 62 deletions

View file

@ -1,3 +1,28 @@
2006-01-10 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <rfm@gnu.org>
* Source/win32/GSRunLoopCtxt.m: Apply patch by Jeremy Bettis with

View file

@ -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";

View file

@ -1248,7 +1248,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
- (void*) nativeHandle
{
return (void*)descriptor;
return (void*)(intptr_t)descriptor;
}
// Synchronous I/O operations

View file

@ -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)

View file

@ -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 <NSObject> 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

View file

@ -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);
}

View file

@ -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."];

View file

@ -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];
}
/**

View file

@ -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();

View file

@ -1445,7 +1445,7 @@ static unsigned wordAlign;
{
if (handle->recvPort == recvSelf)
{
fds[(*count)++] = (int)sock;
fds[(*count)++] = (int)(intptr_t)sock;
}
}
NSEndMapTableEnumeration(&me);

View file

@ -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;
}
/**

View file

@ -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);
}

View file

@ -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;
}
/** <init /> <override-subclass />

View file

@ -1919,7 +1919,7 @@ static unsigned wordAlign;
{
if (handle->recvPort == recvSelf)
{
fds[(*count)++] = (SOCKET)sock;
fds[(*count)++] = (int)(intptr_t)sock;
}
}
NSEndMapTableEnumeration(&me);

View file

@ -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];
/*

View file

@ -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<RunLoopEvents>)self
forMode: [m objectAtIndex: i]];

View file

@ -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;
}

View file

@ -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++;
}
}

View file

@ -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);