mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fixed size type support plus a few bugfixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3523 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
64135f2cdd
commit
44d6899a6e
9 changed files with 1123 additions and 641 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Tue Jan 5 16:20:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* configure.in: New stuff for making byte-order and type-size
|
||||
information available in GSConfig.h
|
||||
* src/NSTask.h: Set process group for child process and preliminary
|
||||
code for keeping track of active child tasks.
|
||||
* src/include/Foundation.h: include GSConfig.h
|
||||
* src/include/NSObject.h: include GSConfig.h
|
||||
* src/include/NSByteOrder.h: Use GS_WORDS_BIGENDIAN from GSConfig.h
|
||||
* src/include/GSConfig.h.in: Add typedefs for types with known size.
|
||||
* src/include/config.h.in: Added HAVE_SETPGID and HAVE_SETPGRP
|
||||
|
||||
Tue Jan 5 9:45:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* src/NSTask.m: Workaround for bug in linux waitpid(), general
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#ifndef __Foundation_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __Foundation_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <GSConfig.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSObject.h>
|
||||
|
||||
|
|
|
@ -6,9 +6,26 @@
|
|||
* Machine/OS specific information required by GNUstep headers.
|
||||
*/
|
||||
|
||||
/* Define if your processor stores words with the most significant
|
||||
byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#undef WORDS_BIGENDIAN
|
||||
/*
|
||||
* Definition to specify if your processor stores words with the most
|
||||
* significant byte first (like Motorola and SPARC, unlike Intel and VAX).
|
||||
*/
|
||||
#define GS_WORDS_BIGENDIAN @GS_WORDS_BIGENDIAN@
|
||||
|
||||
/*
|
||||
* Type definitions for types with known sizes.
|
||||
*/
|
||||
|
||||
typedef @GS_SINT8@ gss8;
|
||||
typedef @GS_UINT8@ gsu8;
|
||||
typedef @GS_SINT16@ gss16;
|
||||
typedef @GS_UINT16@ gsu16;
|
||||
typedef @GS_SINT32@ gss32;
|
||||
typedef @GS_UINT32@ gsu32;
|
||||
typedef @GS_SINT64@ gss64;
|
||||
typedef @GS_UINT64@ gsu64;
|
||||
typedef @GS_FLT32@ gsf32;
|
||||
typedef @GS_FLT64@ gsf64;
|
||||
|
||||
#endif /* included_GSConfig_h */
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ typedef unsigned long NSSwappedFloat;
|
|||
typedef unsigned long long NSSwappedDouble;
|
||||
|
||||
typedef enum {
|
||||
NSLittleEndian,
|
||||
NSBigEndian
|
||||
NSLittleEndian,
|
||||
NSBigEndian
|
||||
} NSByteOrder;
|
||||
|
||||
/*
|
||||
|
@ -173,123 +173,123 @@ NSSwapHostShortToLittle(unsigned short num) __attribute__((unused));
|
|||
static inline NSSwappedDouble
|
||||
NSConvertHostDoubleToSwapped(double num)
|
||||
{
|
||||
union dconv {
|
||||
double number;
|
||||
NSSwappedDouble sd;
|
||||
};
|
||||
return ((union dconv *)&num)->sd;
|
||||
union dconv {
|
||||
double number;
|
||||
NSSwappedDouble sd;
|
||||
};
|
||||
return ((union dconv *)&num)->sd;
|
||||
}
|
||||
|
||||
static inline NSSwappedFloat
|
||||
NSConvertHostFloatToSwapped(float num)
|
||||
{
|
||||
union fconv {
|
||||
float number;
|
||||
NSSwappedFloat sf;
|
||||
};
|
||||
return ((union fconv *)&num)->sf;
|
||||
union fconv {
|
||||
float number;
|
||||
NSSwappedFloat sf;
|
||||
};
|
||||
return ((union fconv *)&num)->sf;
|
||||
}
|
||||
|
||||
static inline double
|
||||
NSConvertSwappedDoubleToHost(NSSwappedDouble num)
|
||||
{
|
||||
union dconv {
|
||||
double number;
|
||||
NSSwappedDouble sd;
|
||||
};
|
||||
return ((union dconv *)&num)->number;
|
||||
union dconv {
|
||||
double number;
|
||||
NSSwappedDouble sd;
|
||||
};
|
||||
return ((union dconv *)&num)->number;
|
||||
}
|
||||
|
||||
static inline float
|
||||
NSConvertSwappedFloatToHost(NSSwappedFloat num)
|
||||
{
|
||||
union fconv {
|
||||
float number;
|
||||
NSSwappedFloat sf;
|
||||
};
|
||||
return ((union fconv *)&num)->number;
|
||||
union fconv {
|
||||
float number;
|
||||
NSSwappedFloat sf;
|
||||
};
|
||||
return ((union fconv *)&num)->number;
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapInt(unsigned int in)
|
||||
{
|
||||
union swap {
|
||||
unsigned int num;
|
||||
unsigned char byt[4];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[3];
|
||||
dst.byt[1] = src->byt[2];
|
||||
dst.byt[2] = src->byt[1];
|
||||
dst.byt[3] = src->byt[0];
|
||||
return dst.num;
|
||||
union swap {
|
||||
unsigned int num;
|
||||
unsigned char byt[4];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[3];
|
||||
dst.byt[1] = src->byt[2];
|
||||
dst.byt[2] = src->byt[1];
|
||||
dst.byt[3] = src->byt[0];
|
||||
return dst.num;
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapLongLong(unsigned long long in)
|
||||
{
|
||||
union swap {
|
||||
unsigned long long num;
|
||||
unsigned char byt[8];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[7];
|
||||
dst.byt[1] = src->byt[6];
|
||||
dst.byt[2] = src->byt[5];
|
||||
dst.byt[3] = src->byt[4];
|
||||
dst.byt[4] = src->byt[3];
|
||||
dst.byt[5] = src->byt[2];
|
||||
dst.byt[6] = src->byt[1];
|
||||
dst.byt[7] = src->byt[0];
|
||||
return dst.num;
|
||||
union swap {
|
||||
unsigned long long num;
|
||||
unsigned char byt[8];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[7];
|
||||
dst.byt[1] = src->byt[6];
|
||||
dst.byt[2] = src->byt[5];
|
||||
dst.byt[3] = src->byt[4];
|
||||
dst.byt[4] = src->byt[3];
|
||||
dst.byt[5] = src->byt[2];
|
||||
dst.byt[6] = src->byt[1];
|
||||
dst.byt[7] = src->byt[0];
|
||||
return dst.num;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapLong(unsigned long in)
|
||||
{
|
||||
union swap {
|
||||
unsigned long num;
|
||||
unsigned char byt[4];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[3];
|
||||
dst.byt[1] = src->byt[2];
|
||||
dst.byt[2] = src->byt[1];
|
||||
dst.byt[3] = src->byt[0];
|
||||
return dst.num;
|
||||
union swap {
|
||||
unsigned long num;
|
||||
unsigned char byt[4];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[3];
|
||||
dst.byt[1] = src->byt[2];
|
||||
dst.byt[2] = src->byt[1];
|
||||
dst.byt[3] = src->byt[0];
|
||||
return dst.num;
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapShort(unsigned short in)
|
||||
{
|
||||
union swap {
|
||||
unsigned short num;
|
||||
unsigned char byt[2];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[1];
|
||||
dst.byt[1] = src->byt[0];
|
||||
return dst.num;
|
||||
union swap {
|
||||
unsigned short num;
|
||||
unsigned char byt[2];
|
||||
} dst;
|
||||
union swap *src = (union swap*)∈
|
||||
dst.byt[0] = src->byt[1];
|
||||
dst.byt[1] = src->byt[0];
|
||||
return dst.num;
|
||||
}
|
||||
|
||||
static inline NSSwappedDouble
|
||||
NSSwapDouble(NSSwappedDouble num)
|
||||
{
|
||||
return NSSwapLongLong(num);
|
||||
return NSSwapLongLong(num);
|
||||
}
|
||||
|
||||
static inline NSSwappedFloat
|
||||
NSSwapFloat(NSSwappedFloat num)
|
||||
{
|
||||
return NSSwapLong(num);
|
||||
return NSSwapLong(num);
|
||||
}
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#if GS_WORDS_BIGENDIAN
|
||||
|
||||
static inline NSByteOrder
|
||||
NSHostByteOrder(void)
|
||||
{
|
||||
return NSBigEndian;
|
||||
return NSBigEndian;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -298,37 +298,37 @@ NSHostByteOrder(void)
|
|||
static inline double
|
||||
NSSwapBigDoubleToHost(NSSwappedDouble num)
|
||||
{
|
||||
return NSConvertSwappedDoubleToHost(num);
|
||||
return NSConvertSwappedDoubleToHost(num);
|
||||
}
|
||||
|
||||
static inline float
|
||||
NSSwapBigFloatToHost(NSSwappedFloat num)
|
||||
{
|
||||
return NSConvertSwappedFloatToHost(num);
|
||||
return NSConvertSwappedFloatToHost(num);
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapBigIntToHost(unsigned int num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapBigLongLongToHost(unsigned long long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapBigLongToHost(unsigned long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapBigShortToHost(unsigned short num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -337,37 +337,37 @@ NSSwapBigShortToHost(unsigned short num)
|
|||
static inline NSSwappedDouble
|
||||
NSSwapHostDoubleToBig(double num)
|
||||
{
|
||||
return NSConvertHostDoubleToSwapped(num);
|
||||
return NSConvertHostDoubleToSwapped(num);
|
||||
}
|
||||
|
||||
static inline NSSwappedFloat
|
||||
NSSwapHostFloatToBig(float num)
|
||||
{
|
||||
return NSConvertHostFloatToSwapped(num);
|
||||
return NSConvertHostFloatToSwapped(num);
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapHostIntToBig(unsigned int num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapHostLongLongToBig(unsigned long long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapHostLongToBig(unsigned long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapHostShortToBig(unsigned short num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -376,37 +376,37 @@ NSSwapHostShortToBig(unsigned short num)
|
|||
static inline double
|
||||
NSSwapLittleDoubleToHost(NSSwappedDouble num)
|
||||
{
|
||||
return NSConvertSwappedDoubleToHost(NSSwapDouble(num));
|
||||
return NSConvertSwappedDoubleToHost(NSSwapDouble(num));
|
||||
}
|
||||
|
||||
static inline float
|
||||
NSSwapLittleFloatToHost(NSSwappedFloat num)
|
||||
{
|
||||
return NSConvertSwappedFloatToHost(NSSwapFloat(num));
|
||||
return NSConvertSwappedFloatToHost(NSSwapFloat(num));
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapLittleIntToHost(unsigned int num)
|
||||
{
|
||||
return NSSwapInt(num);
|
||||
return NSSwapInt(num);
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapLittleLongLongToHost(unsigned long long num)
|
||||
{
|
||||
return NSSwapLongLong(num);
|
||||
return NSSwapLongLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapLittleLongToHost(unsigned long num)
|
||||
{
|
||||
return NSSwapLong(num);
|
||||
return NSSwapLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapLittleShortToHost(unsigned short num)
|
||||
{
|
||||
return NSSwapShort(num);
|
||||
return NSSwapShort(num);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -415,37 +415,37 @@ NSSwapLittleShortToHost(unsigned short num)
|
|||
static inline NSSwappedDouble
|
||||
NSSwapHostDoubleToLittle(double num)
|
||||
{
|
||||
return NSSwapDouble(NSConvertHostDoubleToSwapped(num));
|
||||
return NSSwapDouble(NSConvertHostDoubleToSwapped(num));
|
||||
}
|
||||
|
||||
static inline NSSwappedFloat
|
||||
NSSwapHostFloatToLittle(float num)
|
||||
{
|
||||
return NSSwapFloat(NSConvertHostFloatToSwapped(num));
|
||||
return NSSwapFloat(NSConvertHostFloatToSwapped(num));
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapHostIntToLittle(unsigned int num)
|
||||
{
|
||||
return NSSwapInt(num);
|
||||
return NSSwapInt(num);
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapHostLongLongToLittle(unsigned long long num)
|
||||
{
|
||||
return NSSwapLongLong(num);
|
||||
return NSSwapLongLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapHostLongToLittle(unsigned long num)
|
||||
{
|
||||
return NSSwapLong(num);
|
||||
return NSSwapLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapHostShortToLittle(unsigned short num)
|
||||
{
|
||||
return NSSwapShort(num);
|
||||
return NSSwapShort(num);
|
||||
}
|
||||
|
||||
|
||||
|
@ -454,7 +454,7 @@ NSSwapHostShortToLittle(unsigned short num)
|
|||
static inline NSByteOrder
|
||||
NSHostByteOrder(void)
|
||||
{
|
||||
return NSLittleEndian;
|
||||
return NSLittleEndian;
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,37 +464,37 @@ NSHostByteOrder(void)
|
|||
static inline double
|
||||
NSSwapBigDoubleToHost(NSSwappedDouble num)
|
||||
{
|
||||
return NSConvertSwappedDoubleToHost(NSSwapDouble(num));
|
||||
return NSConvertSwappedDoubleToHost(NSSwapDouble(num));
|
||||
}
|
||||
|
||||
static inline float
|
||||
NSSwapBigFloatToHost(NSSwappedFloat num)
|
||||
{
|
||||
return NSConvertSwappedFloatToHost(NSSwapFloat(num));
|
||||
return NSConvertSwappedFloatToHost(NSSwapFloat(num));
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapBigIntToHost(unsigned int num)
|
||||
{
|
||||
return NSSwapInt(num);
|
||||
return NSSwapInt(num);
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapBigLongLongToHost(unsigned long long num)
|
||||
{
|
||||
return NSSwapLongLong(num);
|
||||
return NSSwapLongLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapBigLongToHost(unsigned long num)
|
||||
{
|
||||
return NSSwapLong(num);
|
||||
return NSSwapLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapBigShortToHost(unsigned short num)
|
||||
{
|
||||
return NSSwapShort(num);
|
||||
return NSSwapShort(num);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -503,37 +503,37 @@ NSSwapBigShortToHost(unsigned short num)
|
|||
static inline NSSwappedDouble
|
||||
NSSwapHostDoubleToBig(double num)
|
||||
{
|
||||
return NSSwapDouble(NSConvertHostDoubleToSwapped(num));
|
||||
return NSSwapDouble(NSConvertHostDoubleToSwapped(num));
|
||||
}
|
||||
|
||||
static inline NSSwappedFloat
|
||||
NSSwapHostFloatToBig(float num)
|
||||
{
|
||||
return NSSwapFloat(NSConvertHostFloatToSwapped(num));
|
||||
return NSSwapFloat(NSConvertHostFloatToSwapped(num));
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapHostIntToBig(unsigned int num)
|
||||
{
|
||||
return NSSwapInt(num);
|
||||
return NSSwapInt(num);
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapHostLongLongToBig(unsigned long long num)
|
||||
{
|
||||
return NSSwapLongLong(num);
|
||||
return NSSwapLongLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapHostLongToBig(unsigned long num)
|
||||
{
|
||||
return NSSwapLong(num);
|
||||
return NSSwapLong(num);
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapHostShortToBig(unsigned short num)
|
||||
{
|
||||
return NSSwapShort(num);
|
||||
return NSSwapShort(num);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -542,37 +542,37 @@ NSSwapHostShortToBig(unsigned short num)
|
|||
static inline double
|
||||
NSSwapLittleDoubleToHost(NSSwappedDouble num)
|
||||
{
|
||||
return NSConvertSwappedDoubleToHost(num);
|
||||
return NSConvertSwappedDoubleToHost(num);
|
||||
}
|
||||
|
||||
static inline float
|
||||
NSSwapLittleFloatToHost(NSSwappedFloat num)
|
||||
{
|
||||
return NSConvertSwappedFloatToHost(num);
|
||||
return NSConvertSwappedFloatToHost(num);
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapLittleIntToHost(unsigned int num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapLittleLongLongToHost(unsigned long long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapLittleLongToHost(unsigned long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapLittleShortToHost(unsigned short num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -581,37 +581,37 @@ NSSwapLittleShortToHost(unsigned short num)
|
|||
static inline NSSwappedDouble
|
||||
NSSwapHostDoubleToLittle(double num)
|
||||
{
|
||||
return NSConvertHostDoubleToSwapped(num);
|
||||
return NSConvertHostDoubleToSwapped(num);
|
||||
}
|
||||
|
||||
static inline NSSwappedFloat
|
||||
NSSwapHostFloatToLittle(float num)
|
||||
{
|
||||
return NSConvertHostFloatToSwapped(num);
|
||||
return NSConvertHostFloatToSwapped(num);
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
NSSwapHostIntToLittle(unsigned int num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long long
|
||||
NSSwapHostLongLongToLittle(unsigned long long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
NSSwapHostLongToLittle(unsigned long num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
NSSwapHostShortToLittle(unsigned short num)
|
||||
{
|
||||
return num;
|
||||
return num;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#undef NO_GNUSTEP
|
||||
#endif
|
||||
|
||||
#include <GSConfig.h>
|
||||
#include <objc/objc.h>
|
||||
#include <objc/Protocol.h>
|
||||
#include <Foundation/NSZone.h>
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
/* Define if you have the killpg function. */
|
||||
#undef HAVE_KILLPG
|
||||
|
||||
/* Define if you have the setpgrp function. */
|
||||
#undef HAVE_SETPGRP
|
||||
|
||||
/* Define if you have the setpgid function. */
|
||||
#undef HAVE_SETPGID
|
||||
|
||||
/* Define if you have the mmap function. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
|
|
101
Source/NSTask.m
101
Source/NSTask.m
|
@ -30,6 +30,7 @@
|
|||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSFileHandle.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
@ -42,17 +43,56 @@
|
|||
|
||||
NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
|
||||
|
||||
static NSRecursiveLock *tasksLock = nil;
|
||||
static NSMapTable *activeTasks = 0;
|
||||
|
||||
@interface NSTask (Private)
|
||||
- (void) _collectChild;
|
||||
- (void) _sendNotification;
|
||||
- (void) _terminatedChild: (int)status;
|
||||
@end
|
||||
|
||||
@implementation NSTask
|
||||
|
||||
static void handleSignal(int sig)
|
||||
{
|
||||
int result;
|
||||
int status;
|
||||
|
||||
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)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (result > 0);
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSTask class])
|
||||
{
|
||||
[gnustep_global_lock lock];
|
||||
if (tasksLock == nil)
|
||||
{
|
||||
tasksLock = [NSRecursiveLock new];
|
||||
activeTasks = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 0);
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +110,9 @@ NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[tasksLock lock];
|
||||
NSMapRemove(activeTasks, (void*)taskId);
|
||||
[tasksLock unlock];
|
||||
[arguments release];
|
||||
[environment release];
|
||||
[launchPath release];
|
||||
|
@ -387,6 +430,14 @@ NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
|
|||
}
|
||||
if (pid == 0)
|
||||
{
|
||||
#if HAVE_SETPGRP
|
||||
setpgrp();
|
||||
#else
|
||||
#if HAVE_SETPGID
|
||||
pid = getpid();
|
||||
setpgid(pid, pid);
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* Set up stdin, stdout and stderr by duplicating descriptors as
|
||||
* necessary and closing the originals (to ensure we won't have a
|
||||
|
@ -421,6 +472,11 @@ NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
|
|||
{
|
||||
taskId = pid;
|
||||
hasLaunched = YES;
|
||||
|
||||
[tasksLock lock];
|
||||
NSMapInsert(activeTasks, (void*)taskId, (void*)self);
|
||||
[tasksLock unlock];
|
||||
|
||||
/*
|
||||
* Close the ends of any pipes used by the child.
|
||||
*/
|
||||
|
@ -487,26 +543,32 @@ NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
|
|||
|
||||
errno = 0;
|
||||
result = waitpid(taskId, &terminationStatus, WNOHANG);
|
||||
if (result == taskId || (result == 0 && errno == 0))
|
||||
if (result < 0)
|
||||
{
|
||||
NSLog(@"waitpid %d, result %d, error %s",
|
||||
taskId, result, strerror(errno));
|
||||
[self _terminatedChild: -1];
|
||||
}
|
||||
else if (result == taskId || (result == 0 && errno == 0))
|
||||
{
|
||||
if (WIFEXITED(terminationStatus))
|
||||
{
|
||||
terminationStatus = WEXITSTATUS(terminationStatus);
|
||||
hasCollected = YES;
|
||||
hasTerminated = YES;
|
||||
if (hasNotified == NO)
|
||||
{
|
||||
[self _sendNotification];
|
||||
}
|
||||
#ifdef WAITDEBUG
|
||||
NSLog(@"waitpid %d, termination status = %d",
|
||||
taskId, terminationStatus);
|
||||
#endif
|
||||
[self _terminatedChild: WEXITSTATUS(terminationStatus)];
|
||||
}
|
||||
#ifdef DEBUG
|
||||
#ifdef WAITDEBUG
|
||||
else
|
||||
NSLog(@"Termination status = %d", terminationStatus);
|
||||
NSLog(@"waitpid %d, event status = %d",
|
||||
taskId, terminationStatus);
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
#ifdef WAITDEBUG
|
||||
else
|
||||
NSLog(@"waitpid result %d, error %s", result, strerror(errno));
|
||||
NSLog(@"waitpid %d, result %d, error %s",
|
||||
taskId, result, strerror(errno));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -528,5 +590,20 @@ NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
|
|||
forModes: nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _terminatedChild: (int)status
|
||||
{
|
||||
[tasksLock lock];
|
||||
NSMapRemove(activeTasks, (void*)taskId);
|
||||
[tasksLock unlock];
|
||||
terminationStatus = status;
|
||||
hasCollected = YES;
|
||||
hasTerminated = YES;
|
||||
if (hasNotified == NO)
|
||||
{
|
||||
[self _sendNotification];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
103
configure.in
103
configure.in
|
@ -27,7 +27,7 @@ AC_INIT(src/Collection.m)
|
|||
#--------------------------------------------------------------------
|
||||
# Use a .h file with #define's, instead of -D command-line switches
|
||||
#--------------------------------------------------------------------
|
||||
AC_CONFIG_HEADER(src/include/config.h src/include/GSConfig.h)
|
||||
AC_CONFIG_HEADER(src/include/config.h)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Determine the host, build, and target systems
|
||||
|
@ -180,6 +180,95 @@ AC_DEFINE_UNQUOTED(NeXT_runtime, $NeXT_runtime)
|
|||
AC_DEFINE_UNQUOTED(NeXT_cc, $NeXT_cc)
|
||||
AC_SUBST(NEXT_INCLUDES)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Byte order and type size information needed for foundation headers.
|
||||
#--------------------------------------------------------------------
|
||||
AC_C_BIGENDIAN
|
||||
if test $ac_cv_c_bigendian = yes; then
|
||||
GS_WORDS_BIGENDIAN=1
|
||||
else
|
||||
GS_WORDS_BIGENDIAN=0
|
||||
fi
|
||||
AC_SUBST(GS_WORDS_BIGENDIAN)
|
||||
|
||||
GS_SINT8="signed char"
|
||||
GS_UINT8="unsigned char"
|
||||
AC_SUBST(GS_SINT8)
|
||||
AC_SUBST(GS_UINT8)
|
||||
|
||||
AC_CHECK_SIZEOF(short)
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(long long)
|
||||
AC_CHECK_SIZEOF(float)
|
||||
AC_CHECK_SIZEOF(double)
|
||||
|
||||
if test $ac_cv_sizeof_short = 2; then
|
||||
GS_SINT16="signed short"
|
||||
GS_UINT16="unsigned short"
|
||||
else
|
||||
if test $ac_cv_sizeof_int = 2; then
|
||||
GS_SINT16="signed int"
|
||||
GS_UINT16="unsigned int"
|
||||
else
|
||||
echo "Unable to determine type for 16-bit integer - abort configuration"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(GS_SINT16)
|
||||
AC_SUBST(GS_UINT16)
|
||||
|
||||
if test $ac_cv_sizeof_int = 4; then
|
||||
GS_SINT32="signed int"
|
||||
GS_UINT32="unsigned int"
|
||||
else
|
||||
if test $ac_cv_sizeof_long = 4; then
|
||||
GS_SINT32="signed long"
|
||||
GS_UINT32="unsigned long"
|
||||
else
|
||||
if test $ac_cv_sizeof_short = 4; then
|
||||
GS_SINT32="signed short"
|
||||
GS_UINT32="unsigned short"
|
||||
else
|
||||
echo "Unable to determine type for 32-bit integer - abort configuration"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(GS_SINT32)
|
||||
AC_SUBST(GS_UINT32)
|
||||
|
||||
if test $ac_cv_sizeof_long_long = 8; then
|
||||
GS_SINT64="signed long long"
|
||||
GS_UINT64="unsigned long long"
|
||||
else
|
||||
if test $ac_cv_sizeof_long = 8; then
|
||||
GS_SINT64="signed long"
|
||||
GS_UINT64="unsigned long"
|
||||
else
|
||||
echo "Unable to determine type for 64-bit integer - abort configuration"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(GS_SINT64)
|
||||
AC_SUBST(GS_UINT64)
|
||||
|
||||
if test $ac_cv_sizeof_float = 4; then
|
||||
GS_FLT32="float"
|
||||
else
|
||||
echo "Unable to determine type for 32-bit float - abort configuration"
|
||||
exit
|
||||
fi
|
||||
AC_SUBST(GS_FLT32)
|
||||
|
||||
if test $ac_cv_sizeof_double = 8; then
|
||||
GS_FLT64="double"
|
||||
else
|
||||
echo "Unable to determine type for 64-bit float - abort configuration"
|
||||
exit
|
||||
fi
|
||||
AC_SUBST(GS_FLT64)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Setup dynamic linking
|
||||
#--------------------------------------------------------------------
|
||||
|
@ -191,12 +280,6 @@ OBJC_SYS_DYNAMIC_LINKER()
|
|||
AC_TYPE_SIZE_T
|
||||
AC_C_INLINE
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Following needed by NSTimeZone.m
|
||||
#--------------------------------------------------------------------
|
||||
AC_C_BIGENDIAN
|
||||
AC_CHECK_SIZEOF(int)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Following header checks needed for bzero in Storage.m and other places
|
||||
#--------------------------------------------------------------------
|
||||
|
@ -282,9 +365,9 @@ AC_CHECK_FUNCS(mmap)
|
|||
AC_CHECK_FUNCS(inet_aton)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This function needed by NSTask.m
|
||||
# These functions needed by NSTask.m
|
||||
#--------------------------------------------------------------------
|
||||
AC_CHECK_FUNCS(killpg)
|
||||
AC_CHECK_FUNCS(killpg, setpgrp, setpgid)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This function needed by NSThread.m
|
||||
|
@ -355,7 +438,7 @@ AC_CONFIG_SUBDIRS(src/mframe)
|
|||
#--------------------------------------------------------------------
|
||||
# Write the Makefiles
|
||||
#--------------------------------------------------------------------
|
||||
AC_OUTPUT(config.mak)
|
||||
AC_OUTPUT(config.mak src/include/GSConfig.h)
|
||||
|
||||
#echo "Running 'configure' in src/mframe"
|
||||
#(cd src/mframe; ./configure)
|
||||
|
|
Loading…
Reference in a new issue