Merge from 0.6.5

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6040 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2000-02-19 00:40:47 +00:00
parent 5276d1b6c2
commit fb65f2b8b6
36 changed files with 1074 additions and 479 deletions

View file

@ -205,10 +205,8 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
case _C_UINT: info = _GSC_UINT | _GSC_S_INT; break;
case _C_LNG: info = _GSC_LNG | _GSC_S_LNG; break;
case _C_ULNG: info = _GSC_ULNG | _GSC_S_LNG; break;
#ifdef _C_LNG_LNG
case _C_LNG_LNG: info = _GSC_LNG_LNG | _GSC_S_LNG_LNG; break;
case _C_ULNG_LNG: info = _GSC_ULNG_LNG | _GSC_S_LNG_LNG; break;
#endif
case _C_FLT: info = _GSC_FLT; break;
case _C_DBL: info = _GSC_DBL; break;
default: info = _GSC_NONE; break;
@ -537,7 +535,6 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
(*_serImp)(_dst, serSel, (void*)buf, @encode(unsigned long), nil);
return;
#ifdef _C_LNG_LNG
case _C_LNG_LNG:
(*_tagImp)(_dst, tagSel, _GSC_LNG_LNG | _GSC_S_LNG_LNG);
(*_serImp)(_dst, serSel, (void*)buf, @encode(long long), nil);
@ -548,7 +545,6 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
(*_serImp)(_dst, serSel, (void*)buf, @encode(unsigned long long), nil);
return;
#endif
case _C_FLT:
(*_tagImp)(_dst, tagSel, _GSC_FLT);
(*_serImp)(_dst, serSel, (void*)buf, @encode(float), nil);

View file

@ -745,6 +745,11 @@ static NSString *indentStrings[] = {
(*appImp)(result, appSel, @")");
}
- (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile
{
return [[self description] writeToFile: path atomically: useAuxiliaryFile];
}
@end
@ -846,11 +851,6 @@ static NSString *indentStrings[] = {
initWithCapacity: numItems]);
}
- (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile
{
return [[self description] writeToFile: path atomically: useAuxiliaryFile];
}
/* Override our superclass's designated initializer to go our's */
- (id) initWithObjects: (id*)objects count: (unsigned)count
{

View file

@ -33,7 +33,7 @@
/* Key for thread dictionary. */
static NSString *dict_key = @"_NSAssertionHandler";
+ (NSAssertionHandler *)currentHandler
+ (NSAssertionHandler*)currentHandler
{
NSMutableDictionary *dict;
NSAssertionHandler *handler;
@ -48,10 +48,10 @@ static NSString *dict_key = @"_NSAssertionHandler";
return handler;
}
- (void)handleFailureInFunction:(NSString *)functionName
file:(NSString *)fileName
lineNumber:(int)line
description:(NSString *)format,...
- (void) handleFailureInFunction: (NSString*)functionName
file: (NSString*)fileName
lineNumber: (int)line
description: (NSString*)format,...
{
id message;
va_list ap;
@ -59,8 +59,8 @@ static NSString *dict_key = @"_NSAssertionHandler";
va_start(ap, format);
message =
[NSString
stringWithFormat: @"Assertion failed in %@, file %@:%d. %@",
functionName, fileName, line, format];
stringWithFormat: @"%@:%d Assertion failed in %@. %@",
fileName, line, functionName, format];
NSLogv(message, ap);
va_end(ap);
@ -81,9 +81,9 @@ static NSString *dict_key = @"_NSAssertionHandler";
va_start(ap, format);
message =
[NSString
stringWithFormat: @"Assertion failed in %s, method %s, file %@:%d. %@",
object_get_class_name(object), sel_get_name(aSelector),
fileName, line, format];
stringWithFormat: @"%@:%d Assertion failed in %s, method %s. %@",
fileName, line, object_get_class_name(object), sel_get_name(aSelector),
format];
NSLogv(message, ap);
[NSException raise: NSInternalInconsistencyException

View file

@ -1,9 +1,10 @@
/* GNUStep callback functions prototypes.
* Copyright (C) 1996 Free Software Foundation, Inc.
* Copyright(C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Feb 13 23:10:29 EST 1996
* Updated: Tue Feb 13 23:10:29 EST 1996
* Updated: Mon Feb 7 10:25:00 GMT 2000
* Serial: 96.02.13.01
*
* This file is part of the GNUstep Base Library.
@ -11,7 +12,7 @@
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* version 2 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -36,47 +37,47 @@
/** For `int's **/
unsigned int _NS_int_hash (void *table, int i);
BOOL _NS_int_is_equal (void *table, int i, int j);
void _NS_int_retain (void *table, int i);
void _NS_int_release (void *table, int i);
NSString *_NS_int_describe (void *table, int i);
unsigned int _NS_int_hash(void *table, int i);
BOOL _NS_int_is_equal(void *table, int i, int j);
void _NS_int_retain(void *table, int i);
void _NS_int_release(void *table, int i);
NSString *_NS_int_describe(void *table, int i);
/** For owned `void *' **/
unsigned int _NS_owned_void_p_hash (void *table, void *p);
BOOL _NS_owned_void_p_is_equal (void *table, void *p, void *q);
void _NS_owned_void_p_retain (void *table, void *p);
void _NS_owned_void_p_release (void *table, void *p);
NSString *_NS_owned_void_p_describe (void *table, void *p);
unsigned int _NS_owned_void_p_hash(void *table, void *p);
BOOL _NS_owned_void_p_is_equal(void *table, void *p, void *q);
void _NS_owned_void_p_retain(void *table, void *p);
void _NS_owned_void_p_release(void *table, void *p);
NSString *_NS_owned_void_p_describe(void *table, void *p);
/** For non-retained Objective-C objects **/
unsigned int _NS_non_retained_id_hash (void *table, id <NSObject> o);
BOOL _NS_non_retained_id_is_equal (void *table, id <NSObject> o, id <NSObject> p);
void _NS_non_retained_id_retain (void *table, id <NSObject> o);
void _NS_non_retained_id_release (void *table, id <NSObject> o);
NSString *_NS_non_retained_id_describe (void *table, id <NSObject> o);
unsigned int _NS_non_retained_id_hash(void *table, id <NSObject> o);
BOOL _NS_non_retained_id_is_equal(void *table, id <NSObject> o, id <NSObject> p);
void _NS_non_retained_id_retain(void *table, id <NSObject> o);
void _NS_non_retained_id_release(void *table, id <NSObject> o);
NSString *_NS_non_retained_id_describe(void *table, id <NSObject> o);
/** For (retainable) objects **/
unsigned int _NS_id_hash (void *table, id <NSObject> o);
BOOL _NS_id_is_equal (void *table, id <NSObject> o, id <NSObject> p);
void _NS_id_retain (void *table, id <NSObject> o);
void _NS_id_release (void *table, id <NSObject> o);
NSString *_NS_id_describe (void *table, id <NSObject> o);
/** For(retainable) objects **/
unsigned int _NS_id_hash(void *table, id <NSObject> o);
BOOL _NS_id_is_equal(void *table, id <NSObject> o, id <NSObject> p);
void _NS_id_retain(void *table, id <NSObject> o);
void _NS_id_release(void *table, id <NSObject> o);
NSString *_NS_id_describe(void *table, id <NSObject> o);
/** For (non-owned) `void *' **/
unsigned int _NS_non_owned_void_p_hash (void *table, void *p);
BOOL _NS_non_owned_void_p_is_equal (void *table, void *p, void *q);
void _NS_non_owned_void_p_retain (void *table, void *p);
void _NS_non_owned_void_p_release (void *table, void *p);
NSString *_NS_non_owned_void_p_describe (void *table, void *p);
/** For(non-owned) `void *' **/
unsigned int _NS_non_owned_void_p_hash(void *table, void *p);
BOOL _NS_non_owned_void_p_is_equal(void *table, void *p, void *q);
void _NS_non_owned_void_p_retain(void *table, void *p);
void _NS_non_owned_void_p_release(void *table, void *p);
NSString *_NS_non_owned_void_p_describe(void *table, void *p);
/** For pointers to structures and `int *' **/
unsigned int _NS_int_p_hash (void *table, int *p);
BOOL _NS_int_p_is_equal (void *table, int *p, int *q);
void _NS_int_p_retain (void *table, int *p);
void _NS_int_p_release (void *table, int *p);
NSString *_NS_int_p_describe (void *table, int *p);
unsigned int _NS_int_p_hash(void *table, int *p);
BOOL _NS_int_p_is_equal(void *table, int *p, int *q);
void _NS_int_p_retain(void *table, int *p);
void _NS_int_p_release(void *table, int *p);
NSString *_NS_int_p_describe(void *table, int *p);
#endif /* __NSCallBacks_h_OBJECTS_INCLUDE **/

View file

@ -1,9 +1,10 @@
/* GNUStep callback functions. Implicitly required by the standard.
* Copyright (C) 1996 Free Software Foundation, Inc.
* Copyright(C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Feb 13 23:10:29 EST 1996
* Updated: Wed Mar 20 19:53:48 EST 1996
* Updated: Mon Feb 7 10:25:00 GMT 2000
* Serial: 96.03.20.02
*
* This file is part of the GNUstep Base Library.
@ -11,7 +12,7 @@
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* version 2 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -36,58 +37,58 @@
/** For `int's **/
unsigned int
_NS_int_hash (void *table, int i)
_NS_int_hash(void *table, int i)
{
return (unsigned int) i;
}
BOOL
_NS_int_is_equal (void *table, int i, int j)
_NS_int_is_equal(void *table, int i, int j)
{
return (i == j) ? YES : NO;
}
void
_NS_int_retain (void *table, int i)
_NS_int_retain(void *table, int i)
{
return;
}
void
_NS_int_release (void *table, int i)
_NS_int_release(void *table, int i)
{
return;
}
NSString *
_NS_int_describe (void *table, int i)
_NS_int_describe(void *table, int i)
{
return [NSString stringWithFormat:@"%d", i];
return [NSString stringWithFormat: @"%d", i];
}
/** For owned `void *' **/
unsigned int
_NS_owned_void_p_hash (void *table, void *p)
_NS_owned_void_p_hash(void *table, void *p)
{
/* P may be aligned, so we need to compensate. */
return ((unsigned int)p)/4;
}
BOOL
_NS_owned_void_p_is_equal (void *table, void *p, void *q)
_NS_owned_void_p_is_equal(void *table, void *p, void *q)
{
return (p == q) ? YES : NO;
}
void
_NS_owned_void_p_retain (void *table, void *p)
_NS_owned_void_p_retain(void *table, void *p)
{
return;
}
void
_NS_owned_void_p_release (void *table, void *p)
_NS_owned_void_p_release(void *table, void *p)
{
if (p != 0)
free(p);
@ -95,139 +96,139 @@ _NS_owned_void_p_release (void *table, void *p)
}
NSString *
_NS_owned_void_p_describe (void *table, void *p)
_NS_owned_void_p_describe(void *table, void *p)
{
return [NSString stringWithFormat:@"%#x", p];
return [NSString stringWithFormat: @"%#x", p];
}
/** For non-retained Objective-C objects **/
unsigned int
_NS_non_retained_id_hash (void *table, id <NSObject> o)
_NS_non_retained_id_hash(void *table, id <NSObject> o)
{
return [o hash];
}
BOOL
_NS_non_retained_id_is_equal (void *table, id <NSObject> o, id <NSObject> p)
_NS_non_retained_id_is_equal(void *table, id <NSObject> o, id <NSObject> p)
{
return [o isEqual:p];
return [o isEqual: p];
}
void
_NS_non_retained_id_retain (void *table, id <NSObject> o)
_NS_non_retained_id_retain(void *table, id <NSObject> o)
{
return;
}
void
_NS_non_retained_id_release (void *table, id <NSObject> o)
_NS_non_retained_id_release(void *table, id <NSObject> o)
{
return;
}
NSString *
_NS_non_retained_id_describe (void *table, id <NSObject> o)
_NS_non_retained_id_describe(void *table, id <NSObject> o)
{
return [o description];
}
/** For (retainable) objects **/
/** For(retainable) objects **/
unsigned int
_NS_id_hash (void *table, id <NSObject> o)
_NS_id_hash(void *table, id <NSObject> o)
{
return [o hash];
}
BOOL
_NS_id_is_equal (void *table, id <NSObject> o, id <NSObject> p)
_NS_id_is_equal(void *table, id <NSObject> o, id <NSObject> p)
{
return [o isEqual:p];
return [o isEqual: p];
}
void
_NS_id_retain (void *table, id <NSObject> o)
_NS_id_retain(void *table, id <NSObject> o)
{
IF_NO_GC(RETAIN(o));
return;
}
void
_NS_id_release (void *table, id <NSObject> o)
_NS_id_release(void *table, id <NSObject> o)
{
RELEASE(o);
return;
}
NSString *
_NS_id_describe (void *table, id <NSObject> o)
_NS_id_describe(void *table, id <NSObject> o)
{
return [o description];
}
/** For (non-owned) `void *' **/
/** For(non-owned) `void *' **/
unsigned int
_NS_non_owned_void_p_hash (void *table, void *p)
_NS_non_owned_void_p_hash(void *table, void *p)
{
return ((unsigned int)p)/4;
}
BOOL
_NS_non_owned_void_p_is_equal (void *table, void *p, void *q)
_NS_non_owned_void_p_is_equal(void *table, void *p, void *q)
{
return (p == q) ? YES : NO;
}
void
_NS_non_owned_void_p_retain (void *table, void *p)
_NS_non_owned_void_p_retain(void *table, void *p)
{
return;
}
void
_NS_non_owned_void_p_release (void *table, void *p)
_NS_non_owned_void_p_release(void *table, void *p)
{
return;
}
NSString *
_NS_non_owned_void_p_describe (void *table, void *p)
_NS_non_owned_void_p_describe(void *table, void *p)
{
return [NSString stringWithFormat:@"%0x", p];
return [NSString stringWithFormat: @"%0x", p];
}
/** For pointers to structures and `int *' **/
unsigned int
_NS_int_p_hash (void *table, int *p)
_NS_int_p_hash(void *table, int *p)
{
return ((unsigned int)p)/4;
}
BOOL
_NS_int_p_is_equal (void *table, int *p, int *q)
_NS_int_p_is_equal(void *table, int *p, int *q)
{
return (p == q) ? YES : NO;
}
void
_NS_int_p_retain (void *table, int *p)
_NS_int_p_retain(void *table, int *p)
{
return;
}
void
_NS_int_p_release (void *table, int *p)
_NS_int_p_release(void *table, int *p)
{
return;
}
NSString *
_NS_int_p_describe (void *table, int *p)
_NS_int_p_describe(void *table, int *p)
{
/* Is this useful? */
return [NSString stringWithFormat:@"%d (%#x)", *p, p];
return [NSString stringWithFormat: @"%d(%#x)", *p, p];
}

View file

@ -615,14 +615,16 @@ failure:
if ([mgr fileExistsAtPath: path])
{
att = [[mgr fileAttributesAtPath:path traverseLink:YES] mutableCopy];
att = [[mgr fileAttributesAtPath: path
traverseLink: YES] mutableCopy];
IF_NO_GC(TEST_AUTORELEASE(att));
}
c = rename(thePath, theRealPath);
if (c != 0) /* Many things could go wrong, I guess. */
{
NSLog(@"Rename (%s) failed - %s", thePath, strerror(errno));
NSLog(@"Rename ('%s' to '%s') failed - %s",
thePath, theRealPath, strerror(errno));
goto failure;
}
@ -656,6 +658,13 @@ failure:
/* Just in case the failure action needs to be changed. */
failure:
/*
* Attempt to tidy up by removing temporary file on failure.
*/
if (useAuxiliaryFile)
{
unlink(thePath);
}
return NO;
}
@ -837,7 +846,6 @@ failure:
*(unsigned long*)data = NSSwapBigLongToHost(nl);
return;
}
#ifdef _C_LNG_LNG
case _C_LNG_LNG:
case _C_ULNG_LNG:
{
@ -849,7 +857,6 @@ failure:
*(unsigned long long*)data = NSSwapBigLongLongToHost(nl);
return;
}
#endif
case _C_FLT:
{
NSSwappedFloat nf;
@ -1420,7 +1427,6 @@ failure:
[self appendBytes: &nl length: sizeof(unsigned long)];
return;
}
#ifdef _C_LNG_LNG
case _C_LNG_LNG:
case _C_ULNG_LNG:
{
@ -1430,7 +1436,6 @@ failure:
[self appendBytes: &nl length: sizeof(unsigned long long)];
return;
}
#endif
case _C_FLT:
{
NSSwappedFloat nf = NSSwapHostFloatToBig(*(float*)data);
@ -1903,7 +1908,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
*(unsigned long*)data = NSSwapBigLongToHost(nl);
return;
}
#ifdef _C_LNG_LNG
case _C_LNG_LNG:
case _C_ULNG_LNG:
{
@ -1913,7 +1917,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
*(unsigned long long*)data = NSSwapBigLongLongToHost(nl);
return;
}
#endif
case _C_FLT:
{
NSSwappedFloat nf;
@ -2836,7 +2839,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
(*appendImp)(self, appendSel, &nl, sizeof(unsigned long));
return;
}
#ifdef _C_LNG_LNG
case _C_LNG_LNG:
case _C_ULNG_LNG:
{
@ -2846,7 +2848,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
(*appendImp)(self, appendSel, &nl, sizeof(unsigned long long));
return;
}
#endif
case _C_FLT:
{
NSSwappedFloat nf = NSSwapHostFloatToBig(*(float*)data);

View file

@ -1,5 +1,5 @@
/* Debugging utilities for GNUStep and OpenStep
Copyright (C) 1997,1999 Free Software Foundation, Inc.
Copyright (C) 1997,1999,2000 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Date: August 1997
@ -23,6 +23,10 @@
#include <config.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSString.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSNotificationQueue.h>
#include <Foundation/NSThread.h>
#ifndef HAVE_STRERROR
const char*
@ -53,11 +57,47 @@ static table_entry* the_table = 0;
static BOOL debug_allocation = NO;
static NSLock *uniqueLock;
static const char* _GSDebugAllocationList(BOOL difference);
static const char* _GSDebugAllocationListAll();
@interface GSDebugAlloc : NSObject
+ (void) initialize;
+ (void) _becomeThreaded: (NSNotification*)notification;
@end
@implementation GSDebugAlloc
+ (void) initialize
{
if ([NSThread isMultiThreaded])
{
[self _becomeThreaded: nil];
}
else
{
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(_becomeThreaded:)
name: NSWillBecomeMultiThreadedNotification
object: nil];
}
}
+ (void) _becomeThreaded: (NSNotification*)notification
{
uniqueLock = [NSRecursiveLock new];
}
@end
BOOL
GSDebugAllocationActive(BOOL active)
{
BOOL old = debug_allocation;
[GSDebugAlloc class]; /* Ensure thread support is working */
debug_allocation = active;
return old;
}
@ -73,11 +113,17 @@ GSDebugAllocationAdd(Class c)
{
if (the_table[i].class == c)
{
if (uniqueLock != nil)
[uniqueLock lock];
the_table[i].count++;
the_table[i].total++;
if (uniqueLock != nil)
[uniqueLock unlock];
return;
}
}
if (uniqueLock != nil)
[uniqueLock lock];
if (num_classes >= table_size)
{
int more = table_size + 128;
@ -87,6 +133,8 @@ GSDebugAllocationAdd(Class c)
if (tmp == 0)
{
if (uniqueLock != nil)
[uniqueLock unlock];
return; /* Argh */
}
if (the_table)
@ -101,6 +149,8 @@ GSDebugAllocationAdd(Class c)
the_table[num_classes].lastc = 0;
the_table[num_classes].total = 1;
num_classes++;
if (uniqueLock != nil)
[uniqueLock unlock];
}
}
@ -127,16 +177,28 @@ GSDebugAllocationCount(Class c)
*/
const char*
GSDebugAllocationList(BOOL difference)
{
const char *ans;
if (debug_allocation == NO)
{
return "Debug allocation system is not active!\n";
}
if (uniqueLock != nil)
[uniqueLock lock];
ans = _GSDebugAllocationList(difference);
if (uniqueLock != nil)
[uniqueLock unlock];
return ans;
}
static const char*
_GSDebugAllocationList(BOOL difference)
{
int pos = 0;
int i;
static int siz = 0;
static char *buf = 0;
if (debug_allocation == NO)
{
return "Debug allocation system is not active!\n";
}
for (i = 0; i < num_classes; i++)
{
int val = the_table[i].count;
@ -161,6 +223,7 @@ GSDebugAllocationList(BOOL difference)
return "I can find NO allocated object!\n";
}
}
pos++;
if (pos > siz)
@ -192,7 +255,7 @@ GSDebugAllocationList(BOOL difference)
if (val != 0)
{
sprintf(&buf[pos], "%s\t%d\n", the_table[i].class->name, val);
sprintf(&buf[pos], "%d\t%s\n", val, the_table[i].class->name);
pos += strlen(&buf[pos]);
}
}
@ -202,16 +265,28 @@ GSDebugAllocationList(BOOL difference)
const char*
GSDebugAllocationListAll()
{
const char *ans;
if (debug_allocation == NO)
{
return "Debug allocation system is not active!\n";
}
if (uniqueLock != nil)
[uniqueLock lock];
ans = _GSDebugAllocationListAll();
if (uniqueLock != nil)
[uniqueLock unlock];
return ans;
}
static const char*
_GSDebugAllocationListAll()
{
int pos = 0;
int i;
static int siz = 0;
static char *buf = 0;
if (debug_allocation == NO)
{
return "Debug allocation system is not active!\n";
}
for (i = 0; i < num_classes; i++)
{
int val = the_table[i].total;
@ -250,7 +325,7 @@ GSDebugAllocationListAll()
if (val != 0)
{
sprintf(&buf[pos], "%s\t%d\n", the_table[i].class->name, val);
sprintf(&buf[pos], "%d\t%s\n", val, the_table[i].class->name);
pos += strlen(&buf[pos]);
}
}
@ -269,7 +344,11 @@ GSDebugAllocationRemove(Class c)
{
if (the_table[i].class == c)
{
if (uniqueLock != nil)
[uniqueLock lock];
the_table[i].count--;
if (uniqueLock != nil)
[uniqueLock unlock];
return;
}
}

View file

@ -41,7 +41,7 @@ static Class NSFileHandle_concrete_class = nil;
}
}
+ (void)_setConcreteClass:(Class)c
+ (void)_setConcreteClass: (Class)c
{
NSFileHandle_concrete_class = c;
}
@ -51,29 +51,29 @@ static Class NSFileHandle_concrete_class = nil;
return NSFileHandle_concrete_class;
}
+ allocWithZone:(NSZone*)z
+ allocWithZone: (NSZone*)z
{
return NSAllocateObject ([self _concreteClass], 0, z);
}
// Allocating and Initializing a FileHandle Object
+ (id)fileHandleForReadingAtPath:(NSString*)path
+ (id)fileHandleForReadingAtPath: (NSString*)path
{
return [[[[self _concreteClass] alloc]
initForReadingAtPath:path] autorelease];
initForReadingAtPath: path] autorelease];
}
+ (id)fileHandleForWritingAtPath:(NSString*)path
+ (id)fileHandleForWritingAtPath: (NSString*)path
{
return [[[[self _concreteClass] alloc]
initForWritingAtPath:path] autorelease];
initForWritingAtPath: path] autorelease];
}
+ (id)fileHandleForUpdatingAtPath:(NSString*)path
+ (id)fileHandleForUpdatingAtPath: (NSString*)path
{
return [[[[self _concreteClass] alloc]
initForUpdatingAtPath:path] autorelease];
initForUpdatingAtPath: path] autorelease];
}
+ (id)fileHandleWithStandardError
@ -100,27 +100,27 @@ static Class NSFileHandle_concrete_class = nil;
initWithNullDevice] autorelease];
}
- (id)initWithFileDescriptor:(int)desc
- (id)initWithFileDescriptor: (int)desc
{
return [self initWithFileDescriptor:desc closeOnDealloc:NO];
return [self initWithFileDescriptor: desc closeOnDealloc: NO];
}
- (id)initWithFileDescriptor:(int)desc closeOnDealloc:(BOOL)flag
- (id)initWithFileDescriptor: (int)desc closeOnDealloc: (BOOL)flag
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return nil;
}
- (id)initWithNativeHandle:(void*)hdl
- (id)initWithNativeHandle: (void*)hdl
{
return [self initWithNativeHandle:hdl closeOnDealloc:NO];
return [self initWithNativeHandle: hdl closeOnDealloc: NO];
}
// This is the designated initializer.
- (id)initWithNativeHandle:(void*)hdl closeOnDealloc:(BOOL)flag
- (id)initWithNativeHandle: (void*)hdl closeOnDealloc: (BOOL)flag
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return nil;
}
@ -128,13 +128,13 @@ static Class NSFileHandle_concrete_class = nil;
- (int)fileDescriptor
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return -1;
}
- (void*)nativeHandle
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return 0;
}
@ -142,68 +142,68 @@ static Class NSFileHandle_concrete_class = nil;
- (NSData*)availableData
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return nil;
}
- (NSData*)readDataToEndOfFile
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return nil;
}
- (NSData*)readDataOfLength:(unsigned int)len
- (NSData*)readDataOfLength: (unsigned int)len
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return nil;
}
- (void)writeData:(NSData*)item
- (void)writeData: (NSData*)item
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
// Asynchronous I/O operations
- (void)acceptConnectionInBackgroundAndNotifyForModes:(NSArray*)modes
- (void)acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)acceptConnectionInBackgroundAndNotify
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)readInBackgroundAndNotifyForModes:(NSArray*)modes
- (void)readInBackgroundAndNotifyForModes: (NSArray*)modes
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)readInBackgroundAndNotify
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)readToEndOfFileInBackgroundAndNotifyForModes:(NSArray*)modes
- (void)readToEndOfFileInBackgroundAndNotifyForModes: (NSArray*)modes
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)readToEndOfFileInBackgroundAndNotify
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)waitForDataInBackgroundAndNotifyForModes:(NSArray*)modes
- (void)waitForDataInBackgroundAndNotifyForModes: (NSArray*)modes
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)waitForDataInBackgroundAndNotify
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
@ -211,19 +211,19 @@ static Class NSFileHandle_concrete_class = nil;
- (unsigned long long)offsetInFile
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return 0;
}
- (unsigned long long)seekToEndOfFile
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return 0;
}
- (void)seekToFileOffset:(unsigned long long)pos
- (void)seekToFileOffset: (unsigned long long)pos
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
@ -231,17 +231,17 @@ static Class NSFileHandle_concrete_class = nil;
- (void)closeFile
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)synchronizeFile
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)truncateFileAtOffset:(unsigned long long)pos
- (void)truncateFileAtOffset: (unsigned long long)pos
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
@ -277,52 +277,52 @@ NSString* NSFileHandleOperationException =
@implementation NSFileHandle (GNUstepExtensions)
+ (id)fileHandleAsClientAtAddress:(NSString*)address
service:(NSString*)service
protocol:(NSString*)protocol
+ (id)fileHandleAsClientAtAddress: (NSString*)address
service: (NSString*)service
protocol: (NSString*)protocol
{
return [[[[self _concreteClass] alloc]
initAsClientAtAddress:address
service:service
protocol:protocol] autorelease];
initAsClientAtAddress: address
service: service
protocol: protocol] autorelease];
}
+ (id)fileHandleAsClientInBackgroundAtAddress:(NSString*)address
service:(NSString*)service
protocol:(NSString*)protocol
+ (id)fileHandleAsClientInBackgroundAtAddress: (NSString*)address
service: (NSString*)service
protocol: (NSString*)protocol
{
return [[[[self _concreteClass] alloc]
initAsClientInBackgroundAtAddress:address
service:service
protocol:protocol
forModes:nil] autorelease];
initAsClientInBackgroundAtAddress: address
service: service
protocol: protocol
forModes: nil] autorelease];
}
+ (id)fileHandleAsClientInBackgroundAtAddress:(NSString*)address
service:(NSString*)service
protocol:(NSString*)protocol
forModes:(NSArray*)modes
+ (id)fileHandleAsClientInBackgroundAtAddress: (NSString*)address
service: (NSString*)service
protocol: (NSString*)protocol
forModes: (NSArray*)modes
{
return [[[[self _concreteClass] alloc]
initAsClientInBackgroundAtAddress:address
service:service
protocol:protocol
forModes:modes] autorelease];
initAsClientInBackgroundAtAddress: address
service: service
protocol: protocol
forModes: modes] autorelease];
}
+ (id)fileHandleAsServerAtAddress:(NSString*)address
service:(NSString*)service
protocol:(NSString*)protocol
+ (id)fileHandleAsServerAtAddress: (NSString*)address
service: (NSString*)service
protocol: (NSString*)protocol
{
return [[[[self _concreteClass] alloc]
initAsServerAtAddress:address
service:service
protocol:protocol] autorelease];
initAsServerAtAddress: address
service: service
protocol: protocol] autorelease];
}
- (BOOL)readInProgress
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return NO;
}
@ -341,19 +341,19 @@ NSString* NSFileHandleOperationException =
return nil;
}
- (void)writeInBackgroundAndNotify:(NSData*)item forModes:(NSArray*)modes
- (void)writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (void)writeInBackgroundAndNotify:(NSData*)item;
- (void)writeInBackgroundAndNotify: (NSData*)item;
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
}
- (BOOL)writeInProgress
{
[self subclassResponsibility:_cmd];
[self subclassResponsibility: _cmd];
return NO;
}

View file

@ -910,7 +910,7 @@ static NSNotificationCenter *default_center = nil;
/*
* If this is a recursive posting of a notification, the array will already
* be in use, so we restrict our operation to array indices beyond the end
* of those used by the posting that cuased this one.
* of those used by the posting that caused this one.
*/
arrayBase = GSIArrayCount(a);
@ -1053,7 +1053,7 @@ static NSNotificationCenter *default_center = nil;
/*
* Post the notification to all the observers of NAME, except those
* observers with a non-nill OBJECT that doesn't match the
* observers with a non-nil OBJECT that doesn't match the
* notification's OBJECT).
*/
if (n_name)

View file

@ -443,7 +443,7 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
}
- (void) enqueueNotification: (NSNotification*)notification
postingStyle: (NSPostingStyle)postingStyle
postingStyle: (NSPostingStyle)postingStyle
{
[self enqueueNotification: notification
postingStyle: postingStyle
@ -453,9 +453,9 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
}
- (void) enqueueNotification: (NSNotification*)notification
postingStyle: (NSPostingStyle)postingStyle
coalesceMask: (NSNotificationCoalescing)coalesceMask
forModes: (NSArray*)modes
postingStyle: (NSPostingStyle)postingStyle
coalesceMask: (NSNotificationCoalescing)coalesceMask
forModes: (NSArray*)modes
{
if (coalesceMask != NSNotificationNoCoalescing)
[self dequeueNotificationsMatching: notification

View file

@ -1011,6 +1011,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
- (void) acceptInputForMode: (NSString*)mode
beforeDate: limit_date
{
extern BOOL GSCheckTasks();
NSTimeInterval ti;
struct timeval timeout;
void *select_timeout;
@ -1053,6 +1054,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
/* The LIMIT_DATE has already past; return immediately without
polling any inputs. */
[self _checkPerformers];
GSNotifyASAP();
if (debug_run_loop)
printf ("\tNSRunLoop limit date past, returning\n");
_current_mode = saved_mode;
@ -1147,9 +1149,12 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
read_fds = fds;
exception_fds = fds;
/* Detect if the NSRunLoop is idle, and if necessary - dispatch the
notifications from NSNotificationQueue's idle queue? */
if (num_inputs == 0 && GSNotifyMore())
/*
* If there are notifications in the 'idle' queue, we try an instantaneous
* select so that, if there is no input pending, we can service the queue.
* Similarly, if a task has completed, we need to deliver it's notifications.
*/
if (GSCheckTasks() || GSNotifyMore())
{
timeout.tv_sec = 0;
timeout.tv_usec = 0;
@ -1168,6 +1173,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
{
if (errno == EINTR)
{
GSCheckTasks();
select_return = 0;
}
else

View file

@ -67,31 +67,47 @@ static NSMapTable *activeTasks = 0;
@implementation NSTask
static BOOL hadChildSignal = NO;
static void handleSignal(int sig)
{
int result;
int status;
hadChildSignal = YES;
}
do
BOOL
GSCheckTasks()
{
BOOL found = NO;
if (hadChildSignal)
{
result = waitpid(-1, &status, WNOHANG);
if (result > 0)
{
if (WIFEXITED(status))
{
NSTask *t;
int result;
int status;
[tasksLock lock];
t = (NSTask*)NSMapGet(activeTasks, (void*)result);
[tasksLock unlock];
if (t)
{
[t _terminatedChild: WEXITSTATUS(status)];
}
}
}
hadChildSignal = NO;
do
{
result = waitpid(-1, &status, WNOHANG);
if (result > 0)
{
if (WIFEXITED(status))
{
NSTask *t;
[tasksLock lock];
t = (NSTask*)NSMapGet(activeTasks, (void*)result);
[tasksLock unlock];
if (t)
{
[t _terminatedChild: WEXITSTATUS(status)];
found = YES;
}
}
}
}
while (result > 0);
}
while (result > 0);
return found;
}
+ (void) initialize

View file

@ -64,10 +64,8 @@ typeToName1(char type)
case _C_UINT: return "unsigned int";
case _C_LNG: return "long";
case _C_ULNG: return "unsigned long";
#ifdef _C_LNG_LNG
case _C_LNG_LNG: return "long long";
case _C_ULNG_LNG: return "unsigned long long";
#endif
case _C_FLT: return "float";
case _C_DBL: return "double";
case _C_PTR: return "pointer";
@ -110,10 +108,8 @@ typeToName2(char type)
case _GSC_UINT: return "unsigned int";
case _GSC_LNG: return "long";
case _GSC_ULNG: return "unsigned long";
#ifdef _GSC_LNG_LNG
case _GSC_LNG_LNG: return "long long";
case _GSC_ULNG_LNG: return "unsigned long long";
#endif
case _GSC_FLT: return "float";
case _GSC_DBL: return "double";
case _GSC_PTR: return "pointer";

View file

@ -154,8 +154,8 @@ struct _nfree_block_struct
};
struct _ffree_block_unpadded {
size_t size;
struct _ffree_block_struct *next;
size_t size;
struct _ffree_block_struct *next;
};
#define FFCPAD sizeof(struct _ffree_block_unpadded)
@ -169,20 +169,20 @@ struct _ffree_block_struct
struct _ffree_free_link_unpadded
{
size_t size;
ff_link *prev;
ff_link *next;
size_t back; /* Back link at end of 'dead' block. */
size_t size;
ff_link *prev;
ff_link *next;
size_t back; /* Back link at end of 'dead' block. */
};
#define FFDPAD sizeof(struct _ffree_free_link_unpadded)
struct _ffree_free_link
{
size_t size;
ff_link *prev;
ff_link *next;
size_t back;
char padding[ALIGN - ((FFDPAD % ALIGN) ? (FFDPAD % ALIGN) : ALIGN)];
size_t size;
ff_link *prev;
ff_link *next;
size_t back;
char padding[ALIGN - ((FFDPAD % ALIGN) ? (FFDPAD % ALIGN) : ALIGN)];
};
/* NSZone structure for freeable zones. */
@ -220,123 +220,124 @@ roundupto (size_t n, size_t base)
static inline void*
chunkToPointer(ff_block *chunk)
{
return (void*)(&chunk[1]);
return (void*)(&chunk[1]);
}
static inline ff_block*
pointerToChunk(void* ptr)
{
return &(((ff_block*)ptr)[-1]);
return &(((ff_block*)ptr)[-1]);
}
static inline size_t
chunkIsLive(ff_block* ptr)
{
return ptr->size & LIVE;
return ptr->size & LIVE;
}
static inline size_t
chunkIsInUse(ff_block* ptr)
{
return ptr->size & INUSE;
return ptr->size & INUSE;
}
static inline size_t
chunkIsPrevInUse(ff_block* ptr)
{
return ptr->size & PREVUSE;
return ptr->size & PREVUSE;
}
static inline size_t
chunkSize(ff_block* ptr)
{
return ptr->size & ~SIZE_BITS;
return ptr->size & ~SIZE_BITS;
}
static inline void
chunkClrInUse(ff_block* ptr)
{
ptr->size &= ~INUSE;
ptr->size &= ~INUSE;
}
static inline size_t
chunkClrLive(ff_block* ptr)
{
return ptr->size &= ~LIVE;
return ptr->size &= ~LIVE;
}
static inline void
chunkClrPrevInUse(ff_block* ptr)
{
ptr->size &= ~PREVUSE;
ptr->size &= ~PREVUSE;
}
static inline void
chunkSetInUse(ff_block* ptr)
{
ptr->size |= INUSE;
ptr->size |= INUSE;
}
static inline size_t
chunkSetLive(ff_block* ptr)
{
return ptr->size |= LIVE;
return ptr->size |= LIVE;
}
static inline void
chunkSetPrevInUse(ff_block* ptr)
{
ptr->size |= PREVUSE;
ptr->size |= PREVUSE;
}
static inline void
chunkSetSize(ff_block* ptr, size_t size)
{
ptr->size = size;
ptr->size = size;
}
static inline ff_block*
chunkNext(ff_block *ptr)
{
return (ff_block*) ((void*)ptr+chunkSize(ptr));
return (ff_block*) ((void*)ptr+chunkSize(ptr));
}
static inline void
chunkMakeLink(ff_block *ptr)
{
NSAssert(!chunkIsInUse(ptr), NSInternalInconsistencyException);
NSAssert(!chunkIsLive(ptr), NSInternalInconsistencyException);
(&(chunkNext(ptr)->size))[-1] = chunkSize(ptr);
NSAssert(!chunkIsInUse(ptr), NSInternalInconsistencyException);
NSAssert(!chunkIsLive(ptr), NSInternalInconsistencyException);
(&(chunkNext(ptr)->size))[-1] = chunkSize(ptr);
}
static inline ff_block*
chunkChop(ff_block *ptr, size_t size)
{
ff_block *remainder;
size_t left = chunkSize(ptr)-size;
ff_block *remainder;
size_t left = chunkSize(ptr)-size;
NSAssert((chunkSize(ptr) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(chunkSize(ptr) > size, NSInternalInconsistencyException);
remainder = (ff_block*)((void*)ptr+size);
chunkSetSize(remainder, left | PREVUSE);
chunkMakeLink(remainder);
chunkSetSize(ptr, size | chunkIsPrevInUse(ptr) | INUSE);
return remainder;
NSAssert((chunkSize(ptr) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(chunkSize(ptr) > size, NSInternalInconsistencyException);
remainder = (ff_block*)((void*)ptr+size);
chunkSetSize(remainder, left | PREVUSE);
chunkMakeLink(remainder);
chunkSetSize(ptr, size | chunkIsPrevInUse(ptr) | INUSE);
return remainder;
}
static inline ff_block*
chunkPrev(ff_block *ptr)
{
size_t offset;
ff_block *prev;
size_t offset;
ff_block *prev;
NSAssert(!chunkIsPrevInUse(ptr), NSInternalInconsistencyException);
offset = (&(ptr->size))[-1];
NSAssert(offset > 0 && (offset % MINCHUNK) == 0, NSInternalInconsistencyException);
prev = (ff_block*)((void*)ptr-offset);
NSAssert(chunkSize(prev) == offset, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(prev), NSInternalInconsistencyException);
return prev;
NSAssert(!chunkIsPrevInUse(ptr), NSInternalInconsistencyException);
offset = (&(ptr->size))[-1];
NSAssert(offset > 0 && (offset % MINCHUNK) == 0,
NSInternalInconsistencyException);
prev = (ff_block*)((void*)ptr-offset);
NSAssert(chunkSize(prev) == offset, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(prev), NSInternalInconsistencyException);
return prev;
}
/* NSZone structure for nonfreeable zones. */
@ -412,21 +413,23 @@ static NSZone *zone_list = 0;
inline NSZone*
NSZoneFromPointer(void *ptr)
{
NSZone *zone;
NSZone *zone;
if (ptr == 0) return 0;
if (ptr == 0) return 0;
/*
* See if we can find the zone in our list of all zones.
*/
[gnustep_global_lock lock];
for (zone = zone_list; zone != 0; zone = zone->next) {
if ((zone->lookup)(zone, ptr) == YES) {
break;
/*
* See if we can find the zone in our list of all zones.
*/
[gnustep_global_lock lock];
for (zone = zone_list; zone != 0; zone = zone->next)
{
if ((zone->lookup)(zone, ptr) == YES)
{
break;
}
}
[gnustep_global_lock unlock];
return (zone == 0) ? __nszone_private_hidden_default_zone : zone;
[gnustep_global_lock unlock];
return (zone == 0) ? __nszone_private_hidden_default_zone : zone;
}
static inline void
@ -463,17 +466,19 @@ default_realloc (NSZone *zone, void *ptr, size_t size)
{
void *mem;
if (size == 0) {
objc_free(ptr);
return NULL;
}
if (ptr == 0) {
mem = objc_malloc(size);
if (mem == NULL)
[NSException raise: NSMallocException
format: @"Default zone has run out of memory"];
return mem;
}
if (size == 0)
{
objc_free(ptr);
return NULL;
}
if (ptr == 0)
{
mem = objc_malloc(size);
if (mem == NULL)
[NSException raise: NSMallocException
format: @"Default zone has run out of memory"];
return mem;
}
mem = objc_realloc(ptr, size);
if (mem == NULL)
[NSException raise: NSMallocException
@ -492,7 +497,7 @@ default_recycle (NSZone *zone)
{
/* Recycle the default zone? Thou hast got to be kiddin'. */
[NSException raise: NSGenericException
format: @"Trying to recycle default zone"];
format: @"Trying to recycle default zone"];
}
static BOOL
@ -500,7 +505,7 @@ default_check (NSZone *zone)
{
/* We can't check memory managed by objc_malloc(). */
[NSException raise: NSGenericException
format: @"No checking for default zone"];
format: @"No checking for default zone"];
return NO;
}
@ -518,7 +523,7 @@ default_stats (NSZone *zone)
/* We can't obtain statistics from the memory managed by objc_malloc(). */
[NSException raise: NSGenericException
format: @"No statistics for default zone"];
format: @"No statistics for default zone"];
return dummy;
}
@ -559,7 +564,8 @@ fmalloc (NSZone *zone, size_t size)
ptr_buf[i] = ptr_buf[bufsize];
NSAssert(chunkIsInUse(chunkhead), NSInternalInconsistencyException);
NSAssert((chunkSize(chunkhead) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert((chunkSize(chunkhead) % MINCHUNK) == 0,
NSInternalInconsistencyException);
}
else
{
@ -583,16 +589,18 @@ fmalloc (NSZone *zone, size_t size)
objc_mutex_unlock(zptr->lock);
if (zone->name != nil)
[NSException raise: NSMallocException
format: @"Zone %s has run out of memory",
format: @"Zone %s has run out of memory",
[zone->name cString]];
else
[NSException raise: NSMallocException
format: @"Out of memory"];
format: @"Out of memory"];
}
NSAssert(chunkIsInUse(chunkhead), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunkNext(chunkhead)), NSInternalInconsistencyException);
NSAssert((chunkSize(chunkhead) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunkNext(chunkhead)),
NSInternalInconsistencyException);
NSAssert((chunkSize(chunkhead) % MINCHUNK) == 0,
NSInternalInconsistencyException);
}
chunkhead->next = (ff_block*)(chunkToPointer(chunkhead)+size);
*((char*)chunkhead->next) = (char)42;
@ -617,7 +625,8 @@ frealloc (NSZone *zone, void *ptr, size_t size)
ff_block *chunkhead, *slack;
void *result;
NSAssert(ptr == NULL || NSZoneFromPointer(ptr) == zone, NSInternalInconsistencyException);
NSAssert(ptr == NULL || NSZoneFromPointer(ptr) == zone,
NSInternalInconsistencyException);
if (ptr == NULL)
return fmalloc(zone, size);
chunkhead = pointerToChunk(ptr);
@ -680,11 +689,11 @@ frealloc (NSZone *zone, void *ptr, size_t size)
objc_mutex_unlock(zptr->lock);
if (zone->name != nil)
[NSException raise: NSMallocException
format: @"Zone %s has run out of memory",
format: @"Zone %s has run out of memory",
[zone->name cString]];
else
[NSException raise: NSMallocException
format: @"Out of memory"];
format: @"Out of memory"];
}
memcpy((void*)(&newchunk[1]), (void*)(&chunkhead[1]), realsize-FBSZ);
add_buf(zptr, chunkhead);
@ -900,19 +909,21 @@ inconsistent: // Jump here if an inconsistency was found.
static BOOL
flookup (NSZone *zone, void *ptr)
{
ffree_zone *zptr = (ffree_zone*)zone;
ff_block *block;
BOOL found = NO;
objc_mutex_lock(zptr->lock);
for (block = zptr->blocks; block != NULL; block = block->next) {
if (ptr >= (void*)block && ptr < (void*)chunkNext(block)) {
found = YES;
break;
ffree_zone *zptr = (ffree_zone*)zone;
ff_block *block;
BOOL found = NO;
objc_mutex_lock(zptr->lock);
for (block = zptr->blocks; block != NULL; block = block->next)
{
if (ptr >= (void*)block && ptr < (void*)chunkNext(block))
{
found = YES;
break;
}
}
objc_mutex_unlock(zptr->lock);
return found;
objc_mutex_unlock(zptr->lock);
return found;
}
/* Obtain statistics about the zone. Doesn't have to be particularly
@ -1071,7 +1082,8 @@ get_chunk (ffree_zone *zone, size_t size)
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(size < chunkSize(chunk), NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0,
NSInternalInconsistencyException);
take_chunk(zone, chunk);
slack = chunkChop(chunk, size);
@ -1088,7 +1100,8 @@ get_chunk (ffree_zone *zone, size_t size)
NSAssert((chunksize % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunkNext(chunk)), NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunkNext(chunk)),
NSInternalInconsistencyException);
take_chunk(zone, chunk);
if (chunksize > size)
@ -1103,14 +1116,16 @@ get_chunk (ffree_zone *zone, size_t size)
ff_block *nextchunk = chunkNext(chunk);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(!chunkIsPrevInUse(nextchunk), NSInternalInconsistencyException);
NSAssert(!chunkIsPrevInUse(nextchunk),
NSInternalInconsistencyException);
NSAssert(chunksize == size, NSInternalInconsistencyException);
chunkSetInUse(chunk);
chunkSetPrevInUse(nextchunk);
}
}
NSAssert(chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunkNext(chunk)), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunkNext(chunk)),
NSInternalInconsistencyException);
return chunk;
}
@ -1156,7 +1171,8 @@ put_chunk (ffree_zone *zone, ff_block *chunk)
size_t class = segindex(size);
ff_link *links = (ff_link*)chunk;
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0,
NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunkNext(chunk)), NSInternalInconsistencyException);
@ -1164,7 +1180,8 @@ put_chunk (ffree_zone *zone, ff_block *chunk)
chunkMakeLink(chunk);
if (zone->segtaillist[class] == NULL)
{
NSAssert(zone->segheadlist[class] == NULL, NSInternalInconsistencyException);
NSAssert(zone->segheadlist[class] == NULL,
NSInternalInconsistencyException);
zone->segheadlist[class] = zone->segtaillist[class] = links;
links->prev = links->next = NULL;
@ -1173,7 +1190,8 @@ put_chunk (ffree_zone *zone, ff_block *chunk)
{
ff_link *prevlink = zone->segtaillist[class];
NSAssert(zone->segheadlist[class] != NULL, NSInternalInconsistencyException);
NSAssert(zone->segheadlist[class] != NULL,
NSInternalInconsistencyException);
links->next = NULL;
links->prev = prevlink;
@ -1192,7 +1210,8 @@ add_buf (ffree_zone *zone, ff_block *chunk)
NSAssert(bufsize < BUFFER, NSInternalInconsistencyException);
NSAssert(chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0,
NSInternalInconsistencyException);
NSAssert(chunkSize(chunk) >= MINCHUNK, NSInternalInconsistencyException);
zone->bufsize++;
@ -1238,8 +1257,10 @@ flush_buf (ffree_zone *zone)
{
size_t nextsize = chunkSize(nextchunk);
NSAssert(chunkIsPrevInUse(nextchunk), NSInternalInconsistencyException);
NSAssert((nextsize % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(nextchunk),
NSInternalInconsistencyException);
NSAssert((nextsize % MINCHUNK) == 0,
NSInternalInconsistencyException);
size += nextsize;
take_chunk(zone, nextchunk);
nextchunk = chunkNext(nextchunk);
@ -1249,7 +1270,8 @@ flush_buf (ffree_zone *zone)
chunkClrPrevInUse(nextchunk);
NSAssert(chunkNext(chunk) == nextchunk, NSInternalInconsistencyException);
NSAssert(chunkPrev(nextchunk) == chunk, NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0, NSInternalInconsistencyException);
NSAssert((chunkSize(chunk) % MINCHUNK) == 0,
NSInternalInconsistencyException);
NSAssert(!chunkIsInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsPrevInUse(chunk), NSInternalInconsistencyException);
NSAssert(chunkIsInUse(nextchunk), NSInternalInconsistencyException);
@ -1291,7 +1313,7 @@ nmalloc (NSZone *zone, size_t size)
/* First, get the block list in decreasing free size order. */
preblock = NULL;
while ((block->next != NULL)
&& (freesize < block->next->size-block->next->top))
&& (freesize < block->next->size-block->next->top))
{
preblock = block;
block = block->next;
@ -1313,11 +1335,11 @@ nmalloc (NSZone *zone, size_t size)
objc_mutex_unlock(zptr->lock);
if (zone->name != nil)
[NSException raise: NSMallocException
format: @"Zone %s has run out of memory",
format: @"Zone %s has run out of memory",
[zone->name cString]];
else
[NSException raise: NSMallocException
format: @"Out of memory"];
format: @"Out of memory"];
}
block->next = zptr->blocks;
block->size = blocksize;
@ -1476,19 +1498,21 @@ ncheck (NSZone *zone)
static BOOL
nlookup (NSZone *zone, void *ptr)
{
nfree_zone *zptr = (nfree_zone*)zone;
nf_block *block;
BOOL found = NO;
objc_mutex_lock(zptr->lock);
for (block = zptr->blocks; block != NULL; block = block->next) {
if (ptr >= (void*)block && ptr < ((void*)block)+block->size) {
found = YES;
break;
nfree_zone *zptr = (nfree_zone*)zone;
nf_block *block;
BOOL found = NO;
objc_mutex_lock(zptr->lock);
for (block = zptr->blocks; block != NULL; block = block->next)
{
if (ptr >= (void*)block && ptr < ((void*)block)+block->size)
{
found = YES;
break;
}
}
objc_mutex_unlock(zptr->lock);
return found;
objc_mutex_unlock(zptr->lock);
return found;
}
/* Return statistics for a nonfreeable zone. Doesn't have to

View file

@ -1224,7 +1224,8 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
struct sockaddr_in sin;
int size = sizeof(sin);
h = [[UnixFileHandle alloc] initWithFileDescriptor: desc];
h = [[UnixFileHandle alloc] initWithFileDescriptor: desc
closeOnDealloc: YES];
getpeername(desc, (struct sockaddr*)&sin, &size);
[h setAddr: &sin];
[readInfo setObject: h

View file

@ -291,7 +291,6 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
info->align = __alignof__(unsigned long);
break;
#ifdef _C_LNG_LNG
case _C_LNG_LNG:
info->size = sizeof(long long);
info->align = __alignof__(long long);
@ -302,7 +301,6 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
info->align = __alignof__(unsigned long long);
break;
#endif
case _C_FLT:
info->size = sizeof(float);
info->align = __alignof__(float);
@ -1653,7 +1651,6 @@ mframe_decode_return (const char *type, void* buffer, void* retframe)
break;
}
#ifdef _C_LNG_LNG
case _C_LNG_LNG:
case _C_ULNG_LNG:
{
@ -1664,7 +1661,6 @@ mframe_decode_return (const char *type, void* buffer, void* retframe)
*(unsigned long long*)buffer = retframe_longlong(retframe);
break;
}
#endif
case _C_FLT:
{