--- tools/source/solar/solar.c 15 Apr 2003 17:55:43 -0000 1.2 +++ tools/source/solar/solar.c 22 Oct 2003 13:08:21 -0000 @@ -58,17 +58,22 @@ * * ************************************************************************/ -#include -#ifdef UNX +/* POSIX defines that a program is undefined after a SIG_SEGV. The + * code stopped working on Linux Kernel 2.6 so I have moved this back to + * use FORK. + * If at a later time the signals work correctly with the Linux Kernel 2.6 + * then this change may be reverted although not strictly posix safe. */ +#define USE_FORK_TO_CHECK 1 + +#include +#include +#include +#include #include #include -#ifdef HPUX -#include -#endif - #define I_STDARG #ifdef I_STDARG #include @@ -84,9 +89,6 @@ #include #endif -#else -#endif - #define printTypeSize(Type,Name) printf( "sizeof(%s)\t= %d\n", Name, sizeof (Type) ) #define isSignedType(Type) (((Type)-1) < 0) @@ -133,7 +135,7 @@ /************************************************************************* |* -|* IsStackGrowingDown() +|* GetStackAlignment() |* |* Beschreibung Alignment von char Parametern, die (hoffentlich) |* ueber den Stack uebergeben werden @@ -176,8 +178,6 @@ typedef int (*TestFunc)( Type, void* ); -#ifdef UNX - /************************************************************************* |* |* PrintArgs() @@ -230,11 +230,11 @@ void SignalHdl( int sig ) { bSignal = 1; - /* + fprintf( stderr, "Signal %d caught\n", sig ); - signal( sig, SignalHdl ); - /**/ - longjmp( check_env, sig ); + signal( SIGSEGV, SIG_DFL ); + signal( SIGBUS, SIG_DFL ); + siglongjmp( check_env, sig ); } #endif @@ -270,7 +270,7 @@ bSignal = 0; - if ( !setjmp( check_env ) ) + if ( !sigsetjmp( check_env, 0 ) ) { signal( SIGSEGV, SignalHdl ); signal( SIGBUS, SignalHdl ); @@ -286,9 +286,6 @@ #endif } -#endif - - /************************************************************************* |* |* GetAtAddress() @@ -373,6 +370,7 @@ int CheckSetAccess( Type eT, void* p ) { int b; + b = -1 != check( (TestFunc)SetAtAddress, eT, p ); #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, @@ -437,7 +435,7 @@ |* Letzte Aenderung |* *************************************************************************/ -Description_Ctor( struct Description* pThis ) +void Description_Ctor( struct Description* pThis ) { pThis->bBigEndian = IsBigEndian(); pThis->bStackGrowsDown = IsStackGrowingDown(); @@ -468,16 +466,21 @@ |* Letzte Aenderung |* *************************************************************************/ -Description_Print( struct Description* pThis, char* name ) +void Description_Print( struct Description* pThis, char* name ) { int i; FILE* f = fopen( name, "w" ); + if( ! f ) { + fprintf( stderr, "Unable to open file %s: %s\n", name, strerror( errno ) ); + exit( 99 ); + } fprintf( f, "#define __%s\n", pThis->bBigEndian ? "BIGENDIAN" : "LITTLEENDIAN" ); for ( i = 0; i < 3; i++ ) fprintf( f, "#define __ALIGNMENT%d\t%d\n", - 1 << i+1, pThis->nAlignment[i] ); - fprintf( f, "#define __STACKALIGNMENT wird nicht benutzt\t%d\n", pThis->nStackAlignment ); + 1 << (i+1), pThis->nAlignment[i] ); + fprintf( f, "/* Stack alignment is not used... */\n" ); + fprintf( f, "#define __STACKALIGNMENT\t%d\n", pThis->nStackAlignment ); fprintf( f, "#define __STACKDIRECTION\t%d\n", pThis->bStackGrowsDown ? -1 : 1 ); fprintf( f, "#define __SIZEOFCHAR\t%d\n", sizeof( char ) ); @@ -538,8 +541,12 @@ printf( ( CheckGetAccess( eT, (long*)&a[i] ) ? "OK\n" : "ERROR\n" ) ); } } - -main( int argc, char* argv[] ) +/************************************************************************ + * + * Use C code to determine the characteristics of the building platform. + * + ************************************************************************/ +int main( int argc, char* argv[] ) { printTypeSign( char, "char" ); printTypeSign( short, "short" ); @@ -574,7 +581,6 @@ Description_Ctor( &description ); Description_Print( &description, argv[1] ); } - { char* p = NULL; InfoMemoryAccess( p );