Lines 58-74
Link Here
|
58 |
* |
58 |
* |
59 |
* |
59 |
* |
60 |
************************************************************************/ |
60 |
************************************************************************/ |
61 |
#include <stdio.h> |
|
|
62 |
|
61 |
|
63 |
#ifdef UNX |
62 |
/* POSIX defines that a program is undefined after a SIG_SEGV. The |
|
|
63 |
* code stopped working on Linux Kernel 2.6 so I have moved this back to |
64 |
* use FORK. |
65 |
* If at a later time the signals work correctly with the Linux Kernel 2.6 |
66 |
* then this change may be reverted although not strictly posix safe. */ |
67 |
#define USE_FORK_TO_CHECK 1 |
68 |
|
69 |
#include <stdio.h> |
70 |
#include <stdlib.h> |
71 |
#include <errno.h> |
72 |
#include <string.h> |
64 |
|
73 |
|
65 |
#include <unistd.h> |
74 |
#include <unistd.h> |
66 |
#include <sys/types.h> |
75 |
#include <sys/types.h> |
67 |
|
76 |
|
68 |
#ifdef HPUX |
|
|
69 |
#include <stdlib.h> |
70 |
#endif |
71 |
|
72 |
#define I_STDARG |
77 |
#define I_STDARG |
73 |
#ifdef I_STDARG |
78 |
#ifdef I_STDARG |
74 |
#include <stdarg.h> |
79 |
#include <stdarg.h> |
Lines 84-92
Link Here
|
84 |
#include <setjmp.h> |
89 |
#include <setjmp.h> |
85 |
#endif |
90 |
#endif |
86 |
|
91 |
|
87 |
#else |
|
|
88 |
#endif |
89 |
|
90 |
#define printTypeSize(Type,Name) printf( "sizeof(%s)\t= %d\n", Name, sizeof (Type) ) |
92 |
#define printTypeSize(Type,Name) printf( "sizeof(%s)\t= %d\n", Name, sizeof (Type) ) |
91 |
|
93 |
|
92 |
#define isSignedType(Type) (((Type)-1) < 0) |
94 |
#define isSignedType(Type) (((Type)-1) < 0) |
Lines 133-139
Link Here
|
133 |
|
135 |
|
134 |
/************************************************************************* |
136 |
/************************************************************************* |
135 |
|* |
137 |
|* |
136 |
|* IsStackGrowingDown() |
138 |
|* GetStackAlignment() |
137 |
|* |
139 |
|* |
138 |
|* Beschreibung Alignment von char Parametern, die (hoffentlich) |
140 |
|* Beschreibung Alignment von char Parametern, die (hoffentlich) |
139 |
|* ueber den Stack uebergeben werden |
141 |
|* ueber den Stack uebergeben werden |
Lines 176-183
Link Here
|
176 |
typedef int (*TestFunc)( Type, void* ); |
178 |
typedef int (*TestFunc)( Type, void* ); |
177 |
|
179 |
|
178 |
|
180 |
|
179 |
#ifdef UNX |
|
|
180 |
|
181 |
/************************************************************************* |
181 |
/************************************************************************* |
182 |
|* |
182 |
|* |
183 |
|* PrintArgs() |
183 |
|* PrintArgs() |
Lines 230-240
Link Here
|
230 |
void SignalHdl( int sig ) |
230 |
void SignalHdl( int sig ) |
231 |
{ |
231 |
{ |
232 |
bSignal = 1; |
232 |
bSignal = 1; |
233 |
/* |
233 |
|
234 |
fprintf( stderr, "Signal %d caught\n", sig ); |
234 |
fprintf( stderr, "Signal %d caught\n", sig ); |
235 |
signal( sig, SignalHdl ); |
235 |
signal( SIGSEGV, SIG_DFL ); |
236 |
/**/ |
236 |
signal( SIGBUS, SIG_DFL ); |
237 |
longjmp( check_env, sig ); |
237 |
siglongjmp( check_env, sig ); |
238 |
} |
238 |
} |
239 |
#endif |
239 |
#endif |
240 |
|
240 |
|
Lines 270-276
Link Here
|
270 |
|
270 |
|
271 |
bSignal = 0; |
271 |
bSignal = 0; |
272 |
|
272 |
|
273 |
if ( !setjmp( check_env ) ) |
273 |
if ( !sigsetjmp( check_env, 0 ) ) |
274 |
{ |
274 |
{ |
275 |
signal( SIGSEGV, SignalHdl ); |
275 |
signal( SIGSEGV, SignalHdl ); |
276 |
signal( SIGBUS, SignalHdl ); |
276 |
signal( SIGBUS, SignalHdl ); |
Lines 286-294
Link Here
|
286 |
#endif |
286 |
#endif |
287 |
} |
287 |
} |
288 |
|
288 |
|
289 |
#endif |
|
|
290 |
|
291 |
|
292 |
/************************************************************************* |
289 |
/************************************************************************* |
293 |
|* |
290 |
|* |
294 |
|* GetAtAddress() |
291 |
|* GetAtAddress() |
Lines 373-378
Link Here
|
373 |
int CheckSetAccess( Type eT, void* p ) |
370 |
int CheckSetAccess( Type eT, void* p ) |
374 |
{ |
371 |
{ |
375 |
int b; |
372 |
int b; |
|
|
373 |
|
376 |
b = -1 != check( (TestFunc)SetAtAddress, eT, p ); |
374 |
b = -1 != check( (TestFunc)SetAtAddress, eT, p ); |
377 |
#if OSL_DEBUG_LEVEL > 1 |
375 |
#if OSL_DEBUG_LEVEL > 1 |
378 |
fprintf( stderr, |
376 |
fprintf( stderr, |
Lines 437-443
Link Here
|
437 |
|* Letzte Aenderung |
435 |
|* Letzte Aenderung |
438 |
|* |
436 |
|* |
439 |
*************************************************************************/ |
437 |
*************************************************************************/ |
440 |
Description_Ctor( struct Description* pThis ) |
438 |
void Description_Ctor( struct Description* pThis ) |
441 |
{ |
439 |
{ |
442 |
pThis->bBigEndian = IsBigEndian(); |
440 |
pThis->bBigEndian = IsBigEndian(); |
443 |
pThis->bStackGrowsDown = IsStackGrowingDown(); |
441 |
pThis->bStackGrowsDown = IsStackGrowingDown(); |
Lines 468-483
Link Here
|
468 |
|* Letzte Aenderung |
466 |
|* Letzte Aenderung |
469 |
|* |
467 |
|* |
470 |
*************************************************************************/ |
468 |
*************************************************************************/ |
471 |
Description_Print( struct Description* pThis, char* name ) |
469 |
void Description_Print( struct Description* pThis, char* name ) |
472 |
{ |
470 |
{ |
473 |
int i; |
471 |
int i; |
474 |
FILE* f = fopen( name, "w" ); |
472 |
FILE* f = fopen( name, "w" ); |
|
|
473 |
if( ! f ) { |
474 |
fprintf( stderr, "Unable to open file %s: %s\n", name, strerror( errno ) ); |
475 |
exit( 99 ); |
476 |
} |
475 |
fprintf( f, "#define __%s\n", |
477 |
fprintf( f, "#define __%s\n", |
476 |
pThis->bBigEndian ? "BIGENDIAN" : "LITTLEENDIAN" ); |
478 |
pThis->bBigEndian ? "BIGENDIAN" : "LITTLEENDIAN" ); |
477 |
for ( i = 0; i < 3; i++ ) |
479 |
for ( i = 0; i < 3; i++ ) |
478 |
fprintf( f, "#define __ALIGNMENT%d\t%d\n", |
480 |
fprintf( f, "#define __ALIGNMENT%d\t%d\n", |
479 |
1 << i+1, pThis->nAlignment[i] ); |
481 |
1 << (i+1), pThis->nAlignment[i] ); |
480 |
fprintf( f, "#define __STACKALIGNMENT wird nicht benutzt\t%d\n", pThis->nStackAlignment ); |
482 |
fprintf( f, "/* Stack alignment is not used... */\n" ); |
|
|
483 |
fprintf( f, "#define __STACKALIGNMENT\t%d\n", pThis->nStackAlignment ); |
481 |
fprintf( f, "#define __STACKDIRECTION\t%d\n", |
484 |
fprintf( f, "#define __STACKDIRECTION\t%d\n", |
482 |
pThis->bStackGrowsDown ? -1 : 1 ); |
485 |
pThis->bStackGrowsDown ? -1 : 1 ); |
483 |
fprintf( f, "#define __SIZEOFCHAR\t%d\n", sizeof( char ) ); |
486 |
fprintf( f, "#define __SIZEOFCHAR\t%d\n", sizeof( char ) ); |
Lines 538-545
Link Here
|
538 |
printf( ( CheckGetAccess( eT, (long*)&a[i] ) ? "OK\n" : "ERROR\n" ) ); |
541 |
printf( ( CheckGetAccess( eT, (long*)&a[i] ) ? "OK\n" : "ERROR\n" ) ); |
539 |
} |
542 |
} |
540 |
} |
543 |
} |
541 |
|
544 |
/************************************************************************ |
542 |
main( int argc, char* argv[] ) |
545 |
* |
|
|
546 |
* Use C code to determine the characteristics of the building platform. |
547 |
* |
548 |
************************************************************************/ |
549 |
int main( int argc, char* argv[] ) |
543 |
{ |
550 |
{ |
544 |
printTypeSign( char, "char" ); |
551 |
printTypeSign( char, "char" ); |
545 |
printTypeSign( short, "short" ); |
552 |
printTypeSign( short, "short" ); |
Lines 574-580
Link Here
|
574 |
Description_Ctor( &description ); |
581 |
Description_Ctor( &description ); |
575 |
Description_Print( &description, argv[1] ); |
582 |
Description_Print( &description, argv[1] ); |
576 |
} |
583 |
} |
577 |
|
|
|
578 |
{ |
584 |
{ |
579 |
char* p = NULL; |
585 |
char* p = NULL; |
580 |
InfoMemoryAccess( p ); |
586 |
InfoMemoryAccess( p ); |