diff --git a/ChangeLog b/ChangeLog index a699b8ed3..28b8b8153 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2001-05-31 Adam Fedor + + * Headers/gnustep/base/NSObjCRuntime.h (GSLastErrorStr): Define new + OS-independant strerror like function. + * Source/GSFormat.m: Use it. + * Source/GSTcpPort.m, Source/NSData.m, Source/NSDistributedLock.m, + Source/NSFileManager.m, Source/NSPipe.m, Source/NSRunLoop.m, + Source/NSTask.m, Source/UnixFileHandle.m, Source/WindowsFileHandle.m: + Likewise. + * Source/NSObjCRuntime.m (GSLastErrorStr): New function + (suggestion from "Michael Scheibler" ). + + * Headers/gnustep/base/behavior.h: Include objc-class.h on + NeXT_RUNTIME. + * Headers/gnustep/base/objc-gnu2next.h: New inline functions. + * Source/NSDistantObject.m (-selectorTypeForProxy): Simplify + NeXT_RUNTIME implementation. + 2001-05-29 Adam Fedor * Version: 1.0.1 diff --git a/Headers/gnustep/base/NSObjCRuntime.h b/Headers/gnustep/base/NSObjCRuntime.h index af6d8f014..861a76805 100644 --- a/Headers/gnustep/base/NSObjCRuntime.h +++ b/Headers/gnustep/base/NSObjCRuntime.h @@ -165,6 +165,9 @@ NSZone *GSObjCZone(NSObject *obj); */ void *_fastMallocBuffer(unsigned size); +/* Getting a system error message on a variety of systems */ +GS_EXPORT const char *GSLastErrorStr(long error_id); + #endif #endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/Headers/gnustep/base/behavior.h b/Headers/gnustep/base/behavior.h index bb450b5c6..873e24c3e 100644 --- a/Headers/gnustep/base/behavior.h +++ b/Headers/gnustep/base/behavior.h @@ -26,6 +26,7 @@ #if NeXT_RUNTIME #include +#include #else #include #endif diff --git a/Headers/gnustep/base/objc-gnu2next.h b/Headers/gnustep/base/objc-gnu2next.h index 2aff3e07b..5a2a06692 100644 --- a/Headers/gnustep/base/objc-gnu2next.h +++ b/Headers/gnustep/base/objc-gnu2next.h @@ -41,6 +41,7 @@ typedef void(*apply_t)(void); /* function pointer */ #define TypedStream void* #define class_pointer isa +typedef struct objc_super Super; #define class_create_instance(CLASS) class_createInstance(CLASS, 0) @@ -113,6 +114,18 @@ class_is_class(Class class) return CLS_ISCLASS(class); } +static inline IMP +method_get_imp(Method method) +{ + return (method!=METHOD_NULL)?method->method_imp:(IMP)0; +} + +static inline BOOL +object_is_instance(id object) +{ + return (object!=nil)&&CLS_ISCLASS(object->class_pointer); +} + /* ** Hook functions for memory allocation and disposal. ** This makes it easy to substitute garbage collection systems diff --git a/Source/GSFormat.m b/Source/GSFormat.m index 3467c5235..bd4e163c2 100644 --- a/Source/GSFormat.m +++ b/Source/GSFormat.m @@ -1672,7 +1672,7 @@ NSDictionary *locale) LABEL (form_strerror): /* Print description of error ERRNO. */ string = - (unichar *) strerror(save_errno); + (unichar *) GSLastErrorStr(save_errno); is_long = 0; /* This is no wide-char string. */ goto LABEL (print_string); LABEL (form_character): diff --git a/Source/GSMime.m b/Source/GSMime.m index ca4a2be07..d646d4cf3 100644 --- a/Source/GSMime.m +++ b/Source/GSMime.m @@ -36,6 +36,7 @@ #include #include #include +#include static NSCharacterSet *specials = nil; diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index 18e65b1a4..acc914201 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -397,7 +397,7 @@ static Class runLoopClass; dummy = 1; if (ioctlsocket(d, FIONBIO, &dummy) < 0) { - NSLog(@"unable to set non-blocking mode - %s", strerror(errno)); + NSLog(@"unable to set non-blocking mode - %s", GSLastErrorStr(errno)); return nil; } #else /* !__MINGW__ */ @@ -406,14 +406,14 @@ static Class runLoopClass; e |= NBLK_OPT; if (fcntl(d, F_SETFL, e) < 0) { - NSLog(@"unable to set non-blocking mode - %s", strerror(errno)); + NSLog(@"unable to set non-blocking mode - %s", GSLastErrorStr(errno)); return nil; } } #endif else { - NSLog(@"unable to get non-blocking mode - %s", strerror(errno)); + NSLog(@"unable to get non-blocking mode - %s", GSLastErrorStr(errno)); return nil; } handle = (GSTcpHandle*)NSAllocateObject(self,0,NSDefaultMallocZone()); @@ -521,7 +521,7 @@ static Class runLoopClass; { NSLog(@"unable to make connection to %s:%d - %s", inet_ntoa(sockAddr.sin_addr), - GSSwapBigI16ToHost(sockAddr.sin_port), strerror(errno)); + GSSwapBigI16ToHost(sockAddr.sin_port), GSLastErrorStr(errno)); if (addrNum < [addrs count]) { BOOL result; @@ -762,7 +762,7 @@ static Class runLoopClass; { NSDebugMLLog(@"GSTcpHandle", @"read failed - %s on 0x%x in thread 0x%x", - strerror(errno), self, GSCurrentThread()); + GSLastErrorStr(errno), self, GSCurrentThread()); DO_UNLOCK(myLock); [self invalidate]; return; @@ -1021,7 +1021,7 @@ static Class runLoopClass; && res != 0) { state = GS_H_UNCON; - NSLog(@"connect attempt failed - %s", strerror(res)); + NSLog(@"connect attempt failed - %s", GSLastErrorStr(res)); } else { @@ -1041,7 +1041,7 @@ static Class runLoopClass; else { state = GS_H_UNCON; - NSLog(@"connect write attempt failed - %s", strerror(errno)); + NSLog(@"connect write attempt failed - %s", GSLastErrorStr(errno)); } RELEASE(d); } @@ -1074,7 +1074,7 @@ static Class runLoopClass; { if (errno != EINTR && errno != EAGAIN) { - NSLog(@"write attempt failed - %s", strerror(errno)); + NSLog(@"write attempt failed - %s", GSLastErrorStr(errno)); DO_UNLOCK(myLock); [self invalidate]; return; @@ -1426,33 +1426,33 @@ static Class tcpPortClass; } else if ((desc = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); DESTROY(port); } else if (setsockopt(desc, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, sizeof(reuse)) < 0) { (void) close(desc); - NSLog(@"unable to set reuse on socket - %s", strerror(errno)); + NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno)); DESTROY(port); } else if (bind(desc, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) { NSLog(@"unable to bind to port %s:%d - %s", - inet_ntoa(sockaddr.sin_addr), number, strerror(errno)); + inet_ntoa(sockaddr.sin_addr), number, GSLastErrorStr(errno)); (void) close(desc); DESTROY(port); } else if (listen(desc, 5) < 0) { - NSLog(@"unable to listen on port - %s", strerror(errno)); + NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); (void) close(desc); DESTROY(port); } else if (getsockname(desc, (struct sockaddr*)&sockaddr, &i) < 0) { - NSLog(@"unable to get socket name - %s", strerror(errno)); + NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); (void) close(desc); DESTROY(port); } @@ -1643,18 +1643,18 @@ static Class tcpPortClass; if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); } else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt, sizeof(opt)) < 0) { (void)close(sock); - NSLog(@"unable to set reuse on socket - %s", strerror(errno)); + NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno)); } else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil) { (void)close(sock); - NSLog(@"unable to create GSTcpHandle - %s", strerror(errno)); + NSLog(@"unable to create GSTcpHandle - %s", GSLastErrorStr(errno)); } else { diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index cdf66cd25..e6c4f0c43 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -36,6 +36,7 @@ #include #include #include +#include // Absolute Gregorian date for NSDate reference date Jan 01 2001 // diff --git a/Source/NSData.m b/Source/NSData.m index ae5400f7c..02bfd4e48 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -170,7 +170,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone) { CloseHandle(fh); NSLog(@"Malloc failed for file (%s) of length %d - %s", - thePath, fileLength, strerror(errno)); + thePath, fileLength, GSLastErrorStr(errno)); return NO; } if (!ReadFile(fh, tmp, fileLength, &got, 0)) @@ -200,7 +200,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone) if (theFile == NULL) /* We failed to open the file. */ { - NSDebugLog(@"Open (%s) attempt failed - %s", thePath, strerror(errno)); + NSDebugLog(@"Open (%s) attempt failed - %s", thePath, GSLastErrorStr(errno)); goto failure; } @@ -210,7 +210,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone) c = fseek(theFile, 0L, SEEK_END); if (c != 0) { - NSLog(@"Seek to end of file failed - %s", strerror(errno)); + NSLog(@"Seek to end of file failed - %s", GSLastErrorStr(errno)); goto failure; } @@ -221,7 +221,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone) fileLength = ftell(theFile); if (fileLength == -1) { - NSLog(@"Ftell failed - %s", strerror(errno)); + NSLog(@"Ftell failed - %s", GSLastErrorStr(errno)); goto failure; } @@ -233,7 +233,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone) if (tmp == 0) { NSLog(@"Malloc failed for file of length %d- %s", - fileLength, strerror(errno)); + fileLength, GSLastErrorStr(errno)); goto failure; } @@ -244,14 +244,14 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone) c = fseek(theFile, 0L, SEEK_SET); if (c != 0) { - NSLog(@"Fseek to start of file failed - %s", strerror(errno)); + NSLog(@"Fseek to start of file failed - %s", GSLastErrorStr(errno)); goto failure; } c = fread(tmp, 1, fileLength, theFile); if (c != fileLength) { - NSLog(@"read of file contents failed - %s", strerror(errno)); + NSLog(@"read of file contents failed - %s", GSLastErrorStr(errno)); goto failure; } @@ -714,7 +714,7 @@ failure: strcat(thePath, "XXXXXX"); if ((desc = mkstemp(thePath)) < 0) { - NSLog(@"mkstemp (%s) failed - %s", thePath, strerror(errno)); + NSLog(@"mkstemp (%s) failed - %s", thePath, GSLastErrorStr(errno)); goto failure; } mask = umask(0); @@ -740,7 +740,7 @@ failure: strcat(thePath, "XXXXXX"); if (mktemp(thePath) == 0) { - NSLog(@"mktemp (%s) failed - %s", thePath, strerror(errno)); + NSLog(@"mktemp (%s) failed - %s", thePath, GSLastErrorStr(errno)); goto failure; } } @@ -756,7 +756,7 @@ failure: if (theFile == NULL) /* Something went wrong; we weren't * even able to open the file. */ { - NSLog(@"Open (%s) failed - %s", thePath, strerror(errno)); + NSLog(@"Open (%s) failed - %s", thePath, GSLastErrorStr(errno)); goto failure; } @@ -768,7 +768,7 @@ failure: if (c < [self length]) /* We failed to write everything for * some reason. */ { - NSLog(@"Fwrite (%s) failed - %s", thePath, strerror(errno)); + NSLog(@"Fwrite (%s) failed - %s", thePath, GSLastErrorStr(errno)); goto failure; } @@ -779,7 +779,7 @@ failure: * closing the file, but we got here, * so we need to deal with it. */ { - NSLog(@"Fclose (%s) failed - %s", thePath, strerror(errno)); + NSLog(@"Fclose (%s) failed - %s", thePath, GSLastErrorStr(errno)); goto failure; } #endif @@ -804,7 +804,7 @@ failure: if (c != 0) /* Many things could go wrong, I guess. */ { NSLog(@"Rename ('%s' to '%s') failed - %s", - thePath, theRealPath, strerror(errno)); + thePath, theRealPath, GSLastErrorStr(errno)); goto failure; } @@ -2387,7 +2387,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) fd = open(thePath, O_RDONLY); if (fd < 0) { - NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] unable to open %s - %s", thePath, strerror(errno)); + NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] unable to open %s - %s", thePath, GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -2395,7 +2395,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) length = lseek(fd, 0, SEEK_END); if (length < 0) { - NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] unable to seek to eof %s - %s", thePath, strerror(errno)); + NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] unable to seek to eof %s - %s", thePath, GSLastErrorStr(errno)); close(fd); RELEASE(self); return nil; @@ -2403,7 +2403,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) /* Position at start of file. */ if (lseek(fd, 0, SEEK_SET) != 0) { - NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] unable to seek to sof %s - %s", thePath, strerror(errno)); + NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] unable to seek to sof %s - %s", thePath, GSLastErrorStr(errno)); close(fd); RELEASE(self); return nil; @@ -2411,7 +2411,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) bytes = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0); if (bytes == MAP_FAILED) { - NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] mapping failed for %s - %s", thePath, strerror(errno)); + NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] mapping failed for %s - %s", thePath, GSLastErrorStr(errno)); close(fd); RELEASE(self); self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; @@ -2439,14 +2439,14 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmctl(shmid, IPC_STAT, &buf) < 0) NSLog(@"[NSDataShared -dealloc] shared memory control failed - %s", - strerror(errno)); + GSLastErrorStr(errno)); else if (buf.shm_nattch == 1) if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ NSLog(@"[NSDataShared -dealloc] shared memory delete failed - %s", - strerror(errno)); + GSLastErrorStr(errno)); if (shmdt(bytes) < 0) NSLog(@"[NSDataShared -dealloc] shared memory detach failed - %s", - strerror(errno)); + GSLastErrorStr(errno)); bytes = 0; length = 0; shmid = -1; @@ -2463,7 +2463,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmid == -1) /* Created memory? */ { NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %s", - bufferSize, strerror(errno)); + bufferSize, GSLastErrorStr(errno)); RELEASE(self); self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; return [self initWithBytes: aBuffer length: bufferSize]; @@ -2473,7 +2473,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (bytes == (void*)-1) { NSLog(@"[-initWithBytes:length:] shared mem attach failed for %u - %s", - bufferSize, strerror(errno)); + bufferSize, GSLastErrorStr(errno)); bytes = 0; RELEASE(self); self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; @@ -2491,7 +2491,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) shmid = anId; if (shmctl(shmid, IPC_STAT, &buf) < 0) { - NSLog(@"[NSDataShared -initWithShmID:length:] shared memory control failed - %s", strerror(errno)); + NSLog(@"[NSDataShared -initWithShmID:length:] shared memory control failed - %s", GSLastErrorStr(errno)); RELEASE(self); /* Unable to access memory. */ return nil; } @@ -2505,7 +2505,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (bytes == (void*)-1) { NSLog(@"[NSDataShared -initWithShmID:length:] shared memory attach failed - %s", - strerror(errno)); + GSLastErrorStr(errno)); bytes = 0; RELEASE(self); /* Unable to attach to memory. */ return nil; @@ -2615,7 +2615,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) bytes = NSZoneMalloc(zone, size); if (bytes == 0) { - NSLog(@"[NSMutableDataMalloc -initWithCapacity:] out of memory for %u bytes - %s", size, strerror(errno)); + NSLog(@"[NSMutableDataMalloc -initWithCapacity:] out of memory for %u bytes - %s", size, GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -3087,12 +3087,12 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) struct shmid_ds buf; if (shmctl(shmid, IPC_STAT, &buf) < 0) - NSLog(@"[NSMutableDataShared -dealloc] shared memory control failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -dealloc] shared memory control failed - %s", GSLastErrorStr(errno)); else if (buf.shm_nattch == 1) if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ - NSLog(@"[NSMutableDataShared -dealloc] shared memory delete failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -dealloc] shared memory delete failed - %s", GSLastErrorStr(errno)); if (shmdt(bytes) < 0) - NSLog(@"[NSMutableDataShared -dealloc] shared memory detach failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -dealloc] shared memory detach failed - %s", GSLastErrorStr(errno)); bytes = 0; length = 0; capacity = 0; @@ -3120,7 +3120,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_ACCESS); if (shmid == -1) /* Created memory? */ { - NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory get failed for %u - %s", bufferSize, strerror(errno)); + NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory get failed for %u - %s", bufferSize, GSLastErrorStr(errno)); RELEASE(self); self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; return [self initWithCapacity: bufferSize]; @@ -3130,7 +3130,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) e = errno; if (bytes == (void*)-1) { - NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory attach failed for %u - %s", bufferSize, strerror(e)); + NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory attach failed for %u - %s", bufferSize, GSLastErrorStr(e)); bytes = 0; RELEASE(self); self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; @@ -3149,7 +3149,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) shmid = anId; if (shmctl(shmid, IPC_STAT, &buf) < 0) { - NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory control failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory control failed - %s", GSLastErrorStr(errno)); RELEASE(self); /* Unable to access memory. */ return nil; } @@ -3162,7 +3162,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) bytes = shmat(shmid, 0, 0); if (bytes == (void*)-1) { - NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory attach failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory attach failed - %s", GSLastErrorStr(errno)); bytes = 0; RELEASE(self); /* Unable to attach to memory. */ return nil; @@ -3184,7 +3184,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (newid == -1) /* Created memory? */ [NSException raise: NSMallocException format: @"Unable to create shared memory segment - %s.", - strerror(errno)]; + GSLastErrorStr(errno)]; tmp = shmat(newid, 0, 0); if ((int)tmp == -1) /* Attached memory? */ [NSException raise: NSMallocException @@ -3195,12 +3195,12 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) struct shmid_ds buf; if (shmctl(shmid, IPC_STAT, &buf) < 0) - NSLog(@"[NSMutableDataShared -setCapacity:] shared memory control failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -setCapacity:] shared memory control failed - %s", GSLastErrorStr(errno)); else if (buf.shm_nattch == 1) if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ - NSLog(@"[NSMutableDataShared -setCapacity:] shared memory delete failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -setCapacity:] shared memory delete failed - %s", GSLastErrorStr(errno)); if (shmdt(bytes) < 0) /* Detach memory. */ - NSLog(@"[NSMutableDataShared -setCapacity:] shared memory detach failed - %s", strerror(errno)); + NSLog(@"[NSMutableDataShared -setCapacity:] shared memory detach failed - %s", GSLastErrorStr(errno)); } bytes = tmp; shmid = newid; diff --git a/Source/NSDebug.m b/Source/NSDebug.m index 01d4c1a50..dc7611b7d 100644 --- a/Source/NSDebug.m +++ b/Source/NSDebug.m @@ -31,21 +31,6 @@ #include #include -#ifndef HAVE_STRERROR -const char* -strerror(int eno) -{ - extern char* sys_errlist[]; - extern int sys_nerr; - - if (eno < 0 || eno >= sys_nerr) - { - return("unknown error number"); - } - return(sys_errlist[eno]); -} -#endif - typedef struct { Class class; /* The following are used for statistical info */ diff --git a/Source/NSDistantObject.m b/Source/NSDistantObject.m index 7ee22a646..ea6a0740a 100644 --- a/Source/NSDistantObject.m +++ b/Source/NSDistantObject.m @@ -898,20 +898,10 @@ static inline BOOL class_is_kind_of (Class self, Class aClassObject) - (const char *) selectorTypeForProxy: (SEL)selector { #if NeXT_RUNTIME - { - elt e; - const char *t; - e = coll_hash_value_for_key(_method_types, selector); - t = e.char_ptr_u; - if (!t) - { - /* This isn't what we want, unless the remote machine has - the same architecture as us. */ - t = [connection _typeForSelector:selector remoteTarget:target]; - coll_hash_add(&_method_types, (void*)selector, t); - } - return t; - } + /* This isn't what we want, unless the remote machine has + the same architecture as us. */ + t = [_connection typeForSelector:selector remoteTarget:target]; + return t; #else /* NeXT_runtime */ return sel_get_type (selector); #endif diff --git a/Source/NSDistributedLock.m b/Source/NSDistributedLock.m index d1ea4ec92..c8aa3d9c2 100644 --- a/Source/NSDistributedLock.m +++ b/Source/NSDistributedLock.m @@ -46,7 +46,7 @@ if ([fileManager removeFileAtPath: _lockPath handler: nil] == NO) [NSException raise: NSGenericException format: @"Failed to remove lock directory '%@' - %s", - _lockPath, strerror(errno)]; + _lockPath, GSLastErrorStr(errno)]; RELEASE(_lockTime); _lockTime = nil; } @@ -139,7 +139,7 @@ if (locked == NO) { NSLog(@"Failed to create lock directory '%@' - %s", - _lockPath, strerror(errno)); + _lockPath, GSLastErrorStr(errno)); } } } @@ -180,7 +180,7 @@ if ([fileManager removeFileAtPath: _lockPath handler: nil] == NO) [NSException raise: NSGenericException format: @"Failed to remove lock directory '%@' - %s", - _lockPath, strerror(errno)]; + _lockPath, GSLastErrorStr(errno)]; } else NSLog(@"lock '%@' already broken and in use again\n", _lockPath); diff --git a/Source/NSException.m b/Source/NSException.m index 35d811a1b..3ea574fdb 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -29,7 +29,7 @@ #include #include #include - +#include #include // for getenv() static void diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index bb11e747c..22cb0c82a 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -323,7 +323,7 @@ static NSFileManager* defaultManager = nil; NSString *s; s = [NSString stringWithFormat: @"Could not create '%s' - '%s'", - dirpath, strerror(errno)]; + dirpath, GSLastErrorStr(errno)]; ASSIGN(_lastError, s); return NO; } @@ -565,7 +565,7 @@ static NSFileManager* defaultManager = nil; info = [[NSMutableDictionary alloc] initWithCapacity: 3]; [info setObject: path forKey: @"Path"]; - [info setObject: [NSString stringWithCString: strerror(errno)] + [info setObject: [NSString stringWithCString: GSLastErrorStr(errno)] forKey: @"Error"]; result = [handler fileManager: self shouldProceedAfterError: info]; @@ -609,7 +609,7 @@ static NSFileManager* defaultManager = nil; info = [[NSMutableDictionary alloc] initWithCapacity: 3]; [info setObject: path forKey: @"Path"]; - [info setObject: [NSString stringWithCString: strerror(errno)] + [info setObject: [NSString stringWithCString: GSLastErrorStr(errno)] forKey: @"Error"]; result = [handler fileManager: self shouldProceedAfterError: info]; @@ -1415,7 +1415,7 @@ static SEL swfsSel = 0; else { NSLog(@"Failed to recurse into directory '%@' - %s", - path, strerror(errno)); + path, GSLastErrorStr(errno)); } return self; @@ -1555,7 +1555,7 @@ static SEL swfsSel = 0; else { NSLog(@"Failed to recurse into directory '%s' - %s", - _current_file_path, strerror(errno)); + _current_file_path, GSLastErrorStr(errno)); } } } diff --git a/Source/NSNumberFormatter.m b/Source/NSNumberFormatter.m index 52555babd..f847d334e 100644 --- a/Source/NSNumberFormatter.m +++ b/Source/NSNumberFormatter.m @@ -268,3 +268,5 @@ { ASSIGN(_minimum, aMinimum); } + +@end diff --git a/Source/NSObjCRuntime.m b/Source/NSObjCRuntime.m index 4ccff143a..213ed647e 100644 --- a/Source/NSObjCRuntime.m +++ b/Source/NSObjCRuntime.m @@ -26,6 +26,7 @@ #include #include #include +#include NSString * NSStringFromSelector(SEL aSelector) @@ -143,3 +144,45 @@ GSSetInstanceVariable(id obj, NSString *iVarName, const void *data) memcpy(((void*)obj) + offset, data, size); return YES; } + +/* Getting a system error message on a variety of systems */ +#ifdef __MINGW__ +LPTSTR GetErrorMsg(DWORD msgId) +{ + LPVOID lpMsgBuf; + + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, msgId, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR)&lpMsgBuf, 0, NULL); + + return (LPTSTR)lpMsgBuf; +} +#else +#ifndef HAVE_STRERROR +const char* +strerror(int eno) +{ + extern char* sys_errlist[]; + extern int sys_nerr; + + if (eno < 0 || eno >= sys_nerr) + { + return("unknown error number"); + } + return(sys_errlist[eno]); +} +#endif +#endif /* __MINGW__ */ + +const char *GSLastErrorStr(long error_id) +{ +#ifdef __MINGW__ + return GetErrorMsg(GetLastError()); +#else + return strerror(error_id); +#endif +} diff --git a/Source/NSPipe.m b/Source/NSPipe.m index b7f0505d8..d1c812020 100644 --- a/Source/NSPipe.m +++ b/Source/NSPipe.m @@ -59,7 +59,7 @@ } else { - NSLog(@"Failed to create pipe ... %s", strerror(errno)); + NSLog(@"Failed to create pipe ... %s", GSLastErrorStr(errno)); DESTROY(self); } #else diff --git a/Source/NSProxy.m b/Source/NSProxy.m index c32fdad22..c92f205bd 100644 --- a/Source/NSProxy.m +++ b/Source/NSProxy.m @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index 614d67399..692873d02 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -1220,7 +1220,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks = /* xxx We can do something with exception_fds, instead of aborting here. */ NSLog (@"select() error in -acceptInputForMode:beforeDate: '%s'", - strerror(errno)); + GSLastErrorStr(errno)); abort (); } } diff --git a/Source/NSTask.m b/Source/NSTask.m index c584b332e..8ccabb7a9 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -1082,7 +1082,7 @@ GSCheckTasks() if (result < 0) { NSLog(@"waitpid %d, result %d, error %s", - _taskId, result, strerror(errno)); + _taskId, result, GSLastErrorStr(errno)); [self _terminatedChild: -1]; } else if (result == _taskId || (result > 0 && errno == 0)) @@ -1112,7 +1112,7 @@ GSCheckTasks() #ifdef WAITDEBUG else NSLog(@"waitpid %d, result %d, error %s", - _taskId, result, strerror(errno)); + _taskId, result, GSLastErrorStr(errno)); #endif } } diff --git a/Source/NSThread.m b/Source/NSThread.m index 06748dc83..616bd246f 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -38,7 +38,7 @@ static Class threadClass = Nil; #ifndef NO_GNUSTEP -#ifndef HAVE_OBJC_THREAD_ADD +#if !defined(HAVE_OBJC_THREAD_ADD) && !defined(NeXT_RUNTIME) /* We need to access these private vars in the objc runtime - because the objc runtime's API is not enough powerful for the GNUstep extensions we want to add. */ diff --git a/Source/UnixFileHandle.m b/Source/UnixFileHandle.m index 260ee607e..4b024284c 100644 --- a/Source/UnixFileHandle.m +++ b/Source/UnixFileHandle.m @@ -256,7 +256,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -268,7 +268,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { NSLog(@"unable to make connection to %s:%d - %s", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), strerror(errno)); + GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -306,7 +306,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -322,7 +322,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { NSLog(@"unable to make connection to %s:%d - %s", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), strerror(errno)); + GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -361,7 +361,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -372,7 +372,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), strerror(errno)); + GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); (void) close(net); RELEASE(self); return nil; @@ -380,7 +380,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (listen(net, 5) < 0) { - NSLog(@"unable to listen on port - %s", strerror(errno)); + NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); (void) close(net); RELEASE(self); return nil; @@ -388,7 +388,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (getsockname(net, (struct sockaddr*)&sin, &size) < 0) { - NSLog(@"unable to get socket name - %s", strerror(errno)); + NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); (void) close(net); RELEASE(self); return nil; @@ -531,7 +531,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (fstat(desc, &sbuf) < 0) { - NSLog(@"unable to get status of descriptor - %s", strerror(errno)); + NSLog(@"unable to get status of descriptor - %s", GSLastErrorStr(errno)); RELEASE(self); return nil; } @@ -706,7 +706,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return d; } @@ -729,7 +729,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return d; } @@ -752,7 +752,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } [d setLength: got]; } @@ -775,7 +775,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } while (len > 0 && got > 0); @@ -808,7 +808,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to write to descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } @@ -897,7 +897,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return (unsigned long long)result; } @@ -912,7 +912,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return (unsigned long long)result; } @@ -927,7 +927,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } @@ -1231,7 +1231,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Accept attempt failed - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1276,7 +1276,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Read attempt failed - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; [self postReadNotification]; } @@ -1319,7 +1319,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: - @"Write attempt failed - %s", strerror(errno)]; + @"Write attempt failed - %s", GSLastErrorStr(errno)]; [info setObject: s forKey: GSFileHandleNotificationError]; [self postWriteNotification]; } @@ -1345,7 +1345,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Connect attempt failed - %s", - strerror(result)]; + GSLastErrorStr(result)]; [info setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1397,12 +1397,12 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) e &= ~NBLK_OPT; if (fcntl(descriptor, F_SETFL, e) < 0) - NSLog(@"unable to set non-blocking mode - %s", strerror(errno)); + NSLog(@"unable to set non-blocking mode - %s", GSLastErrorStr(errno)); else isNonBlocking = flag; } else - NSLog(@"unable to get non-blocking mode - %s", strerror(errno)); + NSLog(@"unable to get non-blocking mode - %s", GSLastErrorStr(errno)); } - (NSString*) socketAddress @@ -1485,7 +1485,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return d; } @@ -1520,7 +1520,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } [d setLength: got]; } @@ -1550,7 +1550,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } while (len > 0 && got > 0); @@ -1586,7 +1586,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return d; } @@ -1615,7 +1615,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Accept attempt failed - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1667,7 +1667,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Read attempt failed - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; [self postReadNotification]; } @@ -1719,7 +1719,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: - @"Write attempt failed - %s", strerror(errno)]; + @"Write attempt failed - %s", GSLastErrorStr(errno)]; [info setObject: s forKey: GSFileHandleNotificationError]; [self postWriteNotification]; } @@ -1745,7 +1745,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Connect attempt failed - %s", - strerror(result)]; + GSLastErrorStr(result)]; [info setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1832,7 +1832,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSLog(@"Want X509 Lookup Error"); break; case SSL_ERROR_SYSCALL: - NSLog(@"Syscall Error - %s", strerror(errno)); + NSLog(@"Syscall Error - %s", GSLastErrorStr(errno)); break; case SSL_ERROR_SSL: NSLog(@"SSL Error: really helpful"); @@ -1930,7 +1930,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to write to descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } @end diff --git a/Source/WindowsFileHandle.m b/Source/WindowsFileHandle.m index 5db96e8f1..ad684b6ee 100644 --- a/Source/WindowsFileHandle.m +++ b/Source/WindowsFileHandle.m @@ -192,7 +192,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); [self release]; return nil; } @@ -204,7 +204,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { NSLog(@"unable to make connection to %s:%d - %s", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), strerror(errno)); + GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); [self release]; return nil; } @@ -242,7 +242,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); [self release]; return nil; } @@ -258,7 +258,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { NSLog(@"unable to make connection to %s:%d - %s", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), strerror(errno)); + GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); [self release]; return nil; } @@ -297,7 +297,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %s", strerror(errno)); + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); [self release]; return nil; } @@ -308,7 +308,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), strerror(errno)); + GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); (void) close(net); [self release]; return nil; @@ -316,7 +316,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (listen(net, 5) < 0) { - NSLog(@"unable to listen on port - %s", strerror(errno)); + NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); (void) close(net); [self release]; return nil; @@ -324,7 +324,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (getsockname(net, (struct sockaddr*)&sin, &size) < 0) { - NSLog(@"unable to get socket name - %s", strerror(errno)); + NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); (void) close(net); [self release]; return nil; @@ -467,7 +467,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (fstat(desc, &sbuf) < 0) { - NSLog(@"unable to get status of descriptor - %s", strerror(errno)); + NSLog(@"unable to get status of descriptor - %s", GSLastErrorStr(errno)); [self release]; return nil; } @@ -645,7 +645,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return d; } @@ -668,7 +668,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return d; } @@ -691,7 +691,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } [d setLength: got]; } @@ -714,7 +714,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } while (len > 0 && got > 0); @@ -747,7 +747,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"unable to write to descriptor - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } @@ -836,7 +836,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return (unsigned long long)result; } @@ -851,7 +851,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } return (unsigned long long)result; } @@ -866,7 +866,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; } } @@ -1166,7 +1166,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Accept attempt failed - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1211,7 +1211,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Read attempt failed - %s", - strerror(errno)]; + GSLastErrorStr(errno)]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; [self postReadNotification]; } @@ -1254,7 +1254,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: - @"Write attempt failed - %s", strerror(errno)]; + @"Write attempt failed - %s", GSLastErrorStr(errno)]; [info setObject: s forKey: GSFileHandleNotificationError]; [self postWriteNotification]; } @@ -1280,7 +1280,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) NSString *s; s = [NSString stringWithFormat: @"Connect attempt failed - %s", - strerror(result)]; + GSLastErrorStr(result)]; [info setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1329,7 +1329,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) { if (ioctlsocket(descriptor, FIONBIO, &dummy) < 0) { - NSLog(@"unable to set non-blocking mode - %s", strerror(errno)); + NSLog(@"unable to set non-blocking mode - %s", GSLastErrorStr(errno)); } } } diff --git a/Source/objc-load.m b/Source/objc-load.m index e1c036703..0273e41d7 100644 --- a/Source/objc-load.m +++ b/Source/objc-load.m @@ -32,7 +32,9 @@ #include #include #include +#ifndef NeXT_RUNTIME #include +#endif #include #include #include @@ -66,7 +68,9 @@ static BOOL dynamic_loaded; void (*_objc_load_load_callback)(Class, Category*) = 0; /* List of modules we have loaded (by handle) */ +#ifndef NeXT_RUNTIME static struct objc_list *dynamic_handles = NULL; +#endif /* Check to see if there are any undefined symbols. Print them out. */ @@ -173,7 +177,9 @@ objc_load_module( __objc_dynamic_error(errorStream, "Error (objc-load)"); return 1; } +#ifndef NeXT_RUNTIME dynamic_handles = list_cons(handle, dynamic_handles); +#endif /* If there are any undefined symbols, we can't load the bundle */ if (objc_check_undefineds(errorStream)) {