mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Various fixes, Frith-MacDonald, others.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2805 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1996a609cc
commit
88cbc598e5
26 changed files with 536 additions and 154 deletions
|
@ -65,7 +65,7 @@ NSStringEncoding GetDefEncoding()
|
|||
if (encoding)
|
||||
{
|
||||
count = 0;
|
||||
while ((count < str_encoding_table_size) &
|
||||
while ((count < str_encoding_table_size) &&
|
||||
strcmp(str_encoding_table[count].ename,encoding))
|
||||
{
|
||||
count++;
|
||||
|
@ -125,7 +125,7 @@ GetEncodingName(NSStringEncoding encoding)
|
|||
{
|
||||
char* ret;
|
||||
unsigned int count=0;
|
||||
while ((count < str_encoding_table_size) &
|
||||
while ((count < str_encoding_table_size) &&
|
||||
!(str_encoding_table[count].enc == encoding))
|
||||
{
|
||||
count++;
|
||||
|
|
|
@ -125,6 +125,7 @@ static BOOL debug_memory_stream = NO;
|
|||
}
|
||||
|
||||
/* xxx This method will disappear. */
|
||||
#if 0
|
||||
- initWithSize: (unsigned)s
|
||||
prefix: (unsigned)p
|
||||
position: (unsigned)i
|
||||
|
@ -136,18 +137,27 @@ static BOOL debug_memory_stream = NO;
|
|||
prefix: p
|
||||
position: i];
|
||||
}
|
||||
#endif
|
||||
|
||||
- initWithCapacity: (unsigned)capacity
|
||||
prefix: (unsigned)p
|
||||
{
|
||||
return [self initWithSize: capacity
|
||||
return [self _initOnMallocBuffer: 0
|
||||
freeWhenDone: YES
|
||||
size: capacity
|
||||
eofPosition: 0
|
||||
prefix: p
|
||||
position: 0];
|
||||
position: i];
|
||||
}
|
||||
|
||||
- initWithCapacity: (unsigned)capacity
|
||||
{
|
||||
return [self initWithSize:capacity prefix:0 position:0];
|
||||
return [self _initOnMallocBuffer: 0
|
||||
freeWhenDone: YES
|
||||
size: capacity
|
||||
eofPosition: 0
|
||||
prefix: 0
|
||||
position: i];
|
||||
}
|
||||
|
||||
- initWithData: (id)anObject
|
||||
|
@ -173,10 +183,12 @@ static BOOL debug_memory_stream = NO;
|
|||
return self;
|
||||
}
|
||||
|
||||
#if 0
|
||||
- initWithSize: (unsigned)s
|
||||
{
|
||||
return [self initWithCapacity:s];
|
||||
}
|
||||
#endif
|
||||
|
||||
- init
|
||||
{
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <gnustep/base/preface.h>
|
||||
|
||||
/* Deal with memchr: */
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
#include <string.h>
|
||||
|
@ -37,8 +40,6 @@
|
|||
/* memory.h and strings.h conflict on some systems. */
|
||||
#endif /* not STDC_HEADERS and not HAVE_STRING_H */
|
||||
|
||||
#include <config.h>
|
||||
#include <gnustep/base/preface.h>
|
||||
#include <Foundation/NSMethodSignature.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
#define getpagesize() sysconf(_SC_PAGESIZE)
|
||||
#endif
|
||||
|
||||
#ifdef __svr4__
|
||||
#define getpagesize() sysconf(_SC_PAGESIZE)
|
||||
#endif
|
||||
|
||||
#if __mach__
|
||||
#define getpagesize vm_page_size
|
||||
#endif
|
||||
|
|
|
@ -325,8 +325,13 @@ int main(int argc, char *argv[], char *env[])
|
|||
+ (NSProcessInfo *)processInfo
|
||||
{
|
||||
// Check if the main() function was successfully called
|
||||
NSAssert(_gnu_processName && _gnu_arguments && _gnu_environment,
|
||||
_GNU_MISSING_MAIN_FUNCTION_CALL);
|
||||
// We can't use NSAssert, which calls NSLog, which calls NSProcessInfo...
|
||||
if (!(_gnu_processName && _gnu_arguments && _gnu_environment))
|
||||
{
|
||||
_NSLog_printf_handler(_GNU_MISSING_MAIN_FUNCTION_CALL);
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: _GNU_MISSING_MAIN_FUNCTION_CALL];
|
||||
}
|
||||
|
||||
if (!_gnu_sharedProcessInfoObject)
|
||||
_gnu_sharedProcessInfoObject = [[_NSConcreteProcessInfo alloc] init];
|
||||
|
|
|
@ -335,7 +335,11 @@ NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
|
|||
}
|
||||
|
||||
hasTerminated = YES;
|
||||
#ifdef HAVE_KILLPG
|
||||
killpg(taskId, SIGTERM);
|
||||
#else
|
||||
kill(-taskId, SIGTERM);
|
||||
#endif
|
||||
|
||||
if (hasNotified == NO) {
|
||||
[self _sendNotification];
|
||||
|
|
|
@ -45,6 +45,20 @@ static o_map_t thread_id_2_nsthread;
|
|||
/* Flag indicating whether the objc runtime ever went multi-threaded. */
|
||||
static BOOL entered_multi_threaded_state;
|
||||
|
||||
void gnustep_base_thread_callback()
|
||||
{
|
||||
/* Post a notification if this is the first new thread to be created.
|
||||
Won't work properly if threads are not all created by this class.
|
||||
*/
|
||||
if (!entered_multi_threaded_state)
|
||||
{
|
||||
entered_multi_threaded_state = YES;
|
||||
[NotificationDispatcher
|
||||
postNotificationName: NSBecomingMultiThreaded
|
||||
object: nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@implementation NSThread
|
||||
|
||||
|
@ -59,6 +73,7 @@ static BOOL entered_multi_threaded_state;
|
|||
autorelease];
|
||||
#endif
|
||||
entered_multi_threaded_state = NO;
|
||||
objc_set_thread_callback(gnustep_base_thread_callback());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,20 +138,12 @@ static BOOL entered_multi_threaded_state;
|
|||
toTarget:(id)aTarget
|
||||
withObject:(id)anArgument
|
||||
{
|
||||
/* Post a notification if this is the first new thread to be created.
|
||||
Won't work properly if threads are not all created by this class.
|
||||
xxx Should the notification be done before the new thread starts,
|
||||
or after? */
|
||||
if (!entered_multi_threaded_state)
|
||||
{
|
||||
entered_multi_threaded_state = YES;
|
||||
[NotificationDispatcher
|
||||
postNotificationName: NSBecomingMultiThreaded
|
||||
object: nil];
|
||||
}
|
||||
|
||||
// Have the runtime detach the thread
|
||||
objc_thread_detach (aSelector, aTarget, anArgument);
|
||||
if (objc_thread_detach (aSelector, aTarget, anArgument) == NULL)
|
||||
{
|
||||
/* This should probably be an exception */
|
||||
NSLog(@"Unable to detach thread (unknown error)");
|
||||
}
|
||||
|
||||
/* NOTE we can't create the new NSThread object for this thread here
|
||||
because there would be a race condition. The newly created
|
||||
|
@ -177,14 +184,22 @@ static BOOL entered_multi_threaded_state;
|
|||
while (delay > 30.0*60.0)
|
||||
{
|
||||
// sleep 30 minutes
|
||||
#ifdef HAVE_USLEEP
|
||||
usleep (30*60*1000000);
|
||||
#else
|
||||
sleep (30*60);
|
||||
#endif
|
||||
delay = [date timeIntervalSinceNow];
|
||||
}
|
||||
|
||||
// usleep may return early because of signals
|
||||
while (delay > 0)
|
||||
{
|
||||
usleep (delay*1000000.0);
|
||||
#ifdef HAVE_USLEEP
|
||||
usleep (delay*1000000);
|
||||
#else
|
||||
sleep (delay);
|
||||
#endif
|
||||
delay = [date timeIntervalSinceNow];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,8 +346,9 @@ ostream_close_memory (ostream *s, int option)
|
|||
{
|
||||
if (s->flags & OSTREAM_ISBUFFER)
|
||||
{
|
||||
/* Dumb way to save buffer, but what else? */
|
||||
if (option == OSTREAM_SAVEBUFFER)
|
||||
[(MemoryStream*)s->stream_obj setFreeWhenDone: NO];
|
||||
[(MemoryStream*)s->stream_obj retain];
|
||||
}
|
||||
ostream_close(s);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue