Modified UNIX simulator port so all references to native unix

stuff is in the executive source proper in the file cpu.c.  This
should help avoid conflicts between RTEMS POSIX files and UNIX files.
This commit is contained in:
Joel Sherrill
1995-09-27 20:53:58 +00:00
parent c701f1974b
commit 37f4c2d99f
36 changed files with 966 additions and 342 deletions

View File

@@ -20,16 +20,39 @@
#include <rtems/score/isr.h>
#include <rtems/score/interr.h>
#if defined(solaris2)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 3
#undef __STRICT_ANSI__
#define __STRICT_ANSI__
#endif
#if defined(linux)
#define MALLOC_0_RETURNS_NULL
#endif
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#ifndef SA_RESTART
#define SA_RESTART 0
#endif
typedef struct {
jmp_buf regs;
sigset_t isr_level;
} Context_Control_overlay;
void _CPU_Signal_initialize(void);
void _CPU_Stray_signal(int);
void _CPU_ISR_Handler(int);
@@ -375,9 +398,9 @@ void _CPU_Context_Initialize(
*/
if ( _new_level == 0 )
source = _CPU_Context_Default_with_ISRs_enabled.regs;
source = &_CPU_Context_Default_with_ISRs_enabled;
else
source = _CPU_Context_Default_with_ISRs_disabled.regs;
source = &_CPU_Context_Default_with_ISRs_disabled;
memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
@@ -452,8 +475,10 @@ void _CPU_Context_restore(
Context_Control *next
)
{
sigprocmask( SIG_SETMASK, &next->isr_level, 0 );
longjmp( next->regs, 0 );
Context_Control_overlay *nextp = (Context_Control_overlay *)next;
sigprocmask( SIG_SETMASK, &nextp->isr_level, 0 );
longjmp( nextp->regs, 0 );
}
/*PAGE
@@ -466,13 +491,16 @@ void _CPU_Context_switch(
Context_Control *next
)
{
Context_Control_overlay *currentp = (Context_Control_overlay *)current;
Context_Control_overlay *nextp = (Context_Control_overlay *)next;
int status;
/*
* Switch levels in one operation
*/
status = sigprocmask( SIG_SETMASK, &next->isr_level, &current->isr_level );
status = sigprocmask( SIG_SETMASK, &nextp->isr_level, &currentp->isr_level );
if ( status )
_Internal_error_Occurred(
INTERNAL_ERROR_CORE,
@@ -480,8 +508,8 @@ void _CPU_Context_switch(
status
);
if (setjmp(current->regs) == 0) { /* Save the current context */
longjmp(next->regs, 0); /* Switch to the new context */
if (setjmp(currentp->regs) == 0) { /* Save the current context */
longjmp(nextp->regs, 0); /* Switch to the new context */
if ( status )
_Internal_error_Occurred(
INTERNAL_ERROR_CORE,
@@ -610,18 +638,19 @@ void _CPU_ISR_Handler(int vector)
void _CPU_Stray_signal(int sig_num)
{
char buffer[ 80 ];
char buffer[ 4 ];
/*
* We avoid using the stdio section of the library.
* The following is generally safe.
*/
write(
2,
buffer,
sprintf( buffer, "Stray signal %d\n", sig_num )
);
buffer[ 0 ] = (sig_num >> 4) + 0x30;
buffer[ 1 ] = (sig_num & 0xf) + 0x30;
buffer[ 2 ] = '\n';
write( 2, "Stray signal 0x", 12 );
write( 2, buffer, 3 );
/*
* If it was a "fatal" signal, then exit here
@@ -680,3 +709,252 @@ int _CPU_ffs(unsigned32 value)
return output;
}
/*
* Special Purpose Routines to hide the use of UNIX system calls.
*/
#if 0
/* XXX clock had this set of #define's */
/*
* In order to get the types and prototypes used in this file under
* Solaris 2.3, it is necessary to pull the following magic.
*/
#if defined(solaris)
#warning "Ignore the undefining __STDC__ warning"
#undef __STDC__
#define __STDC__ 0
#undef _POSIX_C_SOURCE
#endif
#endif
int _CPU_Get_clock_vector( void )
{
return SIGALRM;
}
void _CPU_Start_clock(
int microseconds
)
{
struct itimerval new;
new.it_value.tv_sec = 0;
new.it_value.tv_usec = microseconds;
new.it_interval.tv_sec = 0;
new.it_interval.tv_usec = microseconds;
setitimer(ITIMER_REAL, &new, 0);
}
void _CPU_Stop_clock( void )
{
struct itimerval new;
struct sigaction act;
/*
* Set the SIGALRM signal to ignore any last
* signals that might come in while we are
* disarming the timer and removing the interrupt
* vector.
*/
act.sa_handler = SIG_IGN;
sigaction(SIGALRM, &act, 0);
new.it_value.tv_sec = 0;
new.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &new, 0);
}
int _CPU_SHM_Semid;
extern void fix_syscall_errno( void );
void _CPU_SHM_Init(
unsigned32 maximum_nodes,
boolean is_master_node,
void **shm_address,
unsigned32 *shm_length
)
{
int i;
int shmid;
char *shm_addr;
key_t shm_key;
key_t sem_key;
int status;
int shm_size;
if (getenv("RTEMS_SHM_KEY"))
shm_key = strtol(getenv("RTEMS_SHM_KEY"), 0, 0);
else
#ifdef RTEMS_SHM_KEY
shm_key = RTEMS_SHM_KEY;
#else
shm_key = 0xa000;
#endif
if (getenv("RTEMS_SHM_SIZE"))
shm_size = strtol(getenv("RTEMS_SHM_SIZE"), 0, 0);
else
#ifdef RTEMS_SHM_SIZE
shm_size = RTEMS_SHM_SIZE;
#else
shm_size = 64 * 1024;
#endif
if (getenv("RTEMS_SHM_SEMAPHORE_KEY"))
sem_key = strtol(getenv("RTEMS_SHM_SEMAPHORE_KEY"), 0, 0);
else
#ifdef RTEMS_SHM_SEMAPHORE_KEY
sem_key = RTEMS_SHM_SEMAPHORE_KEY;
#else
sem_key = 0xa001;
#endif
shmid = shmget(shm_key, shm_size, IPC_CREAT | 0660);
if ( shmid == -1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "shmget" );
_CPU_Fatal_halt( 0xdead0001 );
}
shm_addr = shmat(shmid, (char *)0, SHM_RND);
if ( shm_addr == (void *)-1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "shmat" );
_CPU_Fatal_halt( 0xdead0002 );
}
_CPU_SHM_Semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
if ( _CPU_SHM_Semid == -1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "semget" );
_CPU_Fatal_halt( 0xdead0003 );
}
if ( is_master_node ) {
for ( i=0 ; i <= maximum_nodes ; i++ ) {
#if defined(solaris2)
union semun {
int val;
struct semid_ds *buf;
ushort *array;
} help;
help.val = 1;
status = semctl( _CPU_SHM_Semid, i, SETVAL, help );
#endif
#if defined(hpux)
status = semctl( _CPU_SHM_Semid, i, SETVAL, 1 );
#endif
fix_syscall_errno(); /* in case of newlib */
if ( status == -1 ) {
_CPU_Fatal_halt( 0xdead0004 );
}
}
}
*shm_address = shm_addr;
*shm_length = shm_size;
}
int _CPU_Get_pid( void )
{
return getpid();
}
/*
* Define this to use signals for MPCI shared memory driver.
* If undefined, the shared memory driver will poll from the
* clock interrupt.
* Ref: ../shmsupp/getcfg.c
*
* BEWARE:: many UN*X kernels and debuggers become severely confused when
* debugging programs which use signals. The problem is *much*
* worse when using multiple signals, since ptrace(2) tends to
* drop all signals except 1 in the case of multiples.
* On hpux9, this problem was so bad, we couldn't use interrupts
* with the shared memory driver if we ever hoped to debug
* RTEMS programs.
* Maybe systems that use /proc don't have this problem...
*/
int _CPU_SHM_Get_vector( void )
{
#ifdef CPU_USE_SHM_INTERRUPTS
return SIGUSR1;
#else
return 0;
#endif
}
void _CPU_SHM_Send_interrupt(
int pid,
int vector
)
{
kill((pid_t) pid, vector);
}
void _CPU_SHM_Lock(
int semaphore
)
{
struct sembuf sb;
int status;
sb.sem_num = semaphore;
sb.sem_op = -1;
sb.sem_flg = 0;
while (1) {
status = semop(_CPU_SHM_Semid, &sb, 1);
if ( status >= 0 )
break;
if ( status == -1 ) {
fix_syscall_errno(); /* in case of newlib */
if (errno == EINTR)
continue;
perror("shm lock");
_CPU_Fatal_halt( 0xdead0005 );
}
}
}
void _CPU_SHM_Unlock(
int semaphore
)
{
struct sembuf sb;
int status;
sb.sem_num = semaphore;
sb.sem_op = 1;
sb.sem_flg = 0;
while (1) {
status = semop(_CPU_SHM_Semid, &sb, 1);
if ( status >= 0 )
break;
if ( status == -1 ) {
fix_syscall_errno(); /* in case of newlib */
if (errno == EINTR)
continue;
perror("shm unlock");
_CPU_Fatal_halt( 0xdead0006 );
}
}
}

View File

@@ -31,6 +31,8 @@ extern "C" {
#include <rtems/score/unixtypes.h>
#endif
#include <rtems/score/unixsize.h>
#if defined(solaris2)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 3
@@ -42,10 +44,6 @@ extern "C" {
#define MALLOC_0_RETURNS_NULL
#endif
#include <unistd.h>
#include <setjmp.h>
#include <signal.h>
/* conditional compilation parameters */
/*
@@ -431,9 +429,17 @@ extern "C" {
* a debugger such as gdb. But that is another problem.
*/
/*
* This is really just the area for the following fields.
*
* jmp_buf regs;
* sigset_t isr_level;
*
* Doing it this way avoids conflicts between the native stuff and the
* RTEMS stuff.
*/
typedef struct {
jmp_buf regs;
sigset_t isr_level;
char Area[ CPU_CONTEXT_SIZE_IN_BYTES ];
} Context_Control;
typedef struct {
@@ -968,6 +974,42 @@ static inline unsigned int CPU_swap_u32(
return( swapped );
}
/*
* Special Purpose Routines to hide the use of UNIX system calls.
*/
int _CPU_Get_clock_vector( void );
void _CPU_Start_clock(
int microseconds
);
void _CPU_Stop_clock( void );
void _CPU_SHM_Init(
unsigned32 maximum_nodes,
boolean is_master_node,
void **shm_address,
unsigned32 *shm_length
);
int _CPU_Get_pid( void );
int _CPU_SHM_Get_vector( void );
void _CPU_SHM_Send_interrupt(
int pid,
int vector
);
void _CPU_SHM_Lock(
int semaphore
);
void _CPU_SHM_Unlock(
int semaphore
);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,116 @@
/*
* gensize.c
*
* This file generates the file unixsize.h
*
* NOTE: It only prints the minimal information required.
*
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
* On-Line Applications Research Corporation (OAR).
*
* This material may be reproduced by or for the U.S. Government pursuant
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
* $Id$
*
*/
/*
* This feels like a very crude way to determine if we are on a Solaris
* host but it does work.
*/
#if defined(__sun__) && defined(__sparc__) && \
defined(__unix__) && defined(__svr4__)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 3
#undef __STRICT_ANSI__
#endif
#include <stdio.h>
#include <unistd.h>
#include <setjmp.h>
#include <signal.h>
typedef struct {
jmp_buf regs;
sigset_t isr_level;
} Context_Control;
int main(
int argc,
char **argv
)
{
Context_Control *cc = 0;
/*
* Print the file header
*/
printf(
"/* unixsize.h\n"
" *\n"
" * This include file contans the size of the context control block\n"
" * C data structure. This structure must be defined in such a way\n"
" * that files NOT including the native header files can work.\n"
" *\n"
" * NOTE: THIS FILE IS AUTOMATICALLY GENERATED!!!!\n"
" * DO NOT EDIT THIS BY HAND!!!!\n"
" *\n"
" * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.\n"
" * On-Line Applications Research Corporation (OAR).\n"
" * All rights assigned to U.S. Government, 1994.\n"
" *\n"
" * This material may be reproduced by or for the U.S. Government pursuant\n"
" * to the copyright license under the clause at DFARS 252.227-7013. This\n"
" * notice must appear in all copies of this file and its derivatives.\n"
" */\n"
"\n"
"#ifndef __UNIXSIZE_h\n"
"#define __UNIXSIZE_h\n"
"\n"
);
#define PRINT_IT( STRING, NUMBER ) \
printf( "#define\t%s\t0x%x\t\t/* %d */\n", \
STRING, \
NUMBER, \
NUMBER );
#define PRINT_SIZE( STRING, NUMBER ) \
printf( "#define\t%s\t0x%x\t\t/* %d */\n", \
STRING, \
NUMBER, \
NUMBER );
#define PRINT_COMMENT( STRING ) \
printf( \
"\n" \
"/*\n" \
" * " STRING "\n" \
" */\n" \
"\n" \
);
PRINT_COMMENT("Context_Control information");
PRINT_SIZE("CPU_CONTEXT_SIZE_IN_BYTES", sizeof( Context_Control ) );
PRINT_SIZE("CPU_CONTEXT_REGISTERS_OFFSET_IN_BYTES", (int) &cc->regs );
PRINT_SIZE("CPU_CONTEXT_SIGNALS_OFFSET_IN_BYTES", (int) &cc->isr_level );
/*
* Print the end of file stuff
*/
printf(
"\n"
"#endif /* __UNIXSIZE_h */\n"
"\n"
"/* end of include file */\n"
);
return 0;
}

View File

@@ -236,6 +236,7 @@ rtems_mpci_entry Shm_Initialization( void )
}
MPCI_Shm_extensions.fatal = MPCI_Fatal;
(void) rtems_extension_create(
rtems_build_name( 'M', 'P', 'E', 'X' ),
&MPCI_Shm_extensions,

View File

@@ -14,33 +14,16 @@
* $Id$
*/
#include <rtems.h>
#include <rtems/libio.h>
#include <bsp.h>
/*
* In order to get the types and prototypes used in this file under
* Solaris 2.3, it is necessary to pull the following magic.
*/
#if defined(solaris)
#warning "Ignore the undefining __STDC__ warning"
#undef __STDC__
#define __STDC__ 0
#undef _POSIX_C_SOURCE
#endif
#include <rtems/libio.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
extern rtems_configuration_table Configuration;
void Clock_exit(void);
volatile rtems_unsigned32 Clock_driver_ticks;
rtems_unsigned32 Clock_driver_vector;
/*
* These are set by clock driver during its init
*/
@@ -51,18 +34,11 @@ rtems_device_minor_number rtems_clock_minor;
void
Install_clock(rtems_isr_entry clock_isr)
{
struct itimerval new;
Clock_driver_ticks = 0;
new.it_value.tv_sec = 0;
new.it_value.tv_usec = Configuration.microseconds_per_tick;
new.it_interval.tv_sec = 0;
new.it_interval.tv_usec = Configuration.microseconds_per_tick;
(void)set_vector(clock_isr, Clock_driver_vector, 1);
(void)set_vector(clock_isr, SIGALRM, 1);
setitimer(ITIMER_REAL, &new, 0);
_CPU_Start_clock( BSP_Configuration.microseconds_per_tick );
atexit(Clock_exit);
}
@@ -73,7 +49,7 @@ ReInstall_clock(rtems_isr_entry new_clock_isr)
rtems_unsigned32 isrlevel = 0;
rtems_interrupt_disable(isrlevel);
(void)set_vector(new_clock_isr, SIGALRM, 1);
(void)set_vector(new_clock_isr, Clock_driver_vector, 1);
rtems_interrupt_enable(isrlevel);
}
@@ -92,26 +68,9 @@ Clock_isr(int vector)
void
Clock_exit(void)
{
struct itimerval new;
struct sigaction act;
_CPU_Stop_clock();
/*
* Set the SIGALRM signal to ignore any last
* signals that might come in while we are
* disarming the timer and removing the interrupt
* vector.
*/
act.sa_handler = SIG_IGN;
sigaction(SIGALRM, &act, 0);
new.it_value.tv_sec = 0;
new.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &new, 0);
(void)set_vector(0, SIGALRM, 1);
(void)set_vector(0, Clock_driver_vector, 1);
}
rtems_device_driver
@@ -121,6 +80,8 @@ Clock_initialize(
void *pargp
)
{
Clock_driver_vector = _CPU_Get_clock_vector();
Install_clock((rtems_isr_entry) Clock_isr);
/*
@@ -150,7 +111,7 @@ rtems_device_driver Clock_control(
if (args->command == rtems_build_name('I', 'S', 'R', ' '))
{
Clock_isr(SIGALRM);
Clock_isr(Clock_driver_vector);
}
else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
{

View File

@@ -21,7 +21,6 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <unistd.h>

View File

@@ -25,7 +25,6 @@ extern "C" {
#include <console.h>
#include <iosupp.h>
#include <libcsupport.h>
#include <signal.h>
/*
* Define the time limits for RTEMS Test Suite test durations.
@@ -62,24 +61,6 @@ extern "C" {
extern rtems_configuration_table BSP_Configuration;
/*
* Define this to use signals for MPCI shared memory driver.
* If undefined, the shared memory driver will poll from the
* clock interrupt.
* Ref: ../shmsupp/getcfg.c
*
* BEWARE:: many UN*X kernels and debuggers become severely confused when
* debugging programs which use signals. The problem is *much*
* worse when using multiple signals, since ptrace(2) tends to
* drop all signals except 1 in the case of multiples.
* On hpux9, this problem was so bad, we couldn't use interrupts
* with the shared memory driver if we ever hoped to debug
* RTEMS programs.
* Maybe systems that use /proc don't have this problem...
*/
/* #define INTERRUPT_EXTERNAL_MPCI SIGUSR1 */
/*
* Device Driver Table Entries
*/

View File

@@ -19,8 +19,6 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <shm.h>

View File

@@ -25,19 +25,8 @@
* $Id$
*/
#include <rtems.h>
#include <shm.h>
#include <bsp.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <shm.h>
shm_config_table BSP_shm_cfgtbl;
@@ -47,102 +36,17 @@ void Shm_Cause_interrupt_unix(
rtems_unsigned32 node
);
void fix_semaphores( void )
{
rtems_unsigned32 maximum_nodes;
int i;
int shmid;
char *shm_addr;
key_t shm_key;
key_t sem_key;
int status;
int shm_size;
if (getenv("RTEMS_SHM_KEY"))
shm_key = strtol(getenv("RTEMS_SHM_KEY"), 0, 0);
else
#ifdef RTEMS_SHM_KEY
shm_key = RTEMS_SHM_KEY;
#else
shm_key = 0xa000;
#endif
if (getenv("RTEMS_SHM_SIZE"))
shm_size = strtol(getenv("RTEMS_SHM_SIZE"), 0, 0);
else
#ifdef RTEMS_SHM_SIZE
shm_size = RTEMS_SHM_SIZE;
#else
shm_size = 64 * KILOBYTE;
#endif
if (getenv("RTEMS_SHM_SEMAPHORE_KEY"))
sem_key = strtol(getenv("RTEMS_SHM_SEMAPHORE_KEY"), 0, 0);
else
#ifdef RTEMS_SHM_SEMAPHORE_KEY
sem_key = RTEMS_SHM_SEMAPHORE_KEY;
#else
sem_key = 0xa001;
#endif
shmid = shmget(shm_key, shm_size, IPC_CREAT | 0660);
if ( shmid == -1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "shmget" );
rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
}
shm_addr = shmat(shmid, (char *)0, SHM_RND);
if ( shm_addr == (void *)-1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "shmat" );
rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
}
maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
if ( semid == -1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "semget" );
rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
}
if ( Shm_Is_master_node() ) {
for ( i=0 ; i <= maximum_nodes ; i++ ) {
#if defined(solaris2)
union semun {
int val;
struct semid_ds *buf;
ushort *array;
} help;
help.val = 1;
semctl( semid, i, SETVAL, help );
#endif
#if defined(hpux)
semctl( semid, i, SETVAL, 1 );
#endif
fix_syscall_errno(); /* in case of newlib */
if ( status == -1 ) {
fprintf( stderr, "Sem init failed %d\n", errno ); fflush( stderr );
rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
}
}
}
BSP_shm_cfgtbl.base = (vol_u32 *)shm_addr;
BSP_shm_cfgtbl.length = shm_size;
}
void Shm_Get_configuration(
rtems_unsigned32 localnode,
shm_config_table **shmcfg
)
{
fix_semaphores();
_CPU_SHM_Init(
Shm_Maximum_nodes,
Shm_Is_master_node(),
(void **)&BSP_shm_cfgtbl.base,
(unsigned32 *)&BSP_shm_cfgtbl.length
);
BSP_shm_cfgtbl.format = SHM_BIG;
@@ -154,17 +58,17 @@ void Shm_Get_configuration(
BSP_shm_cfgtbl.convert = CPU_swap_u32;
#endif
#ifdef INTERRUPT_EXTERNAL_MPCI
if ( _CPU_SHM_Get_vector() ) {
BSP_shm_cfgtbl.poll_intr = INTR_MODE;
BSP_shm_cfgtbl.Intr.address = (vol_u32 *) getpid(); /* process id */
BSP_shm_cfgtbl.Intr.value = INTERRUPT_EXTERNAL_MPCI; /* signal to send */
BSP_shm_cfgtbl.Intr.address = (vol_u32 *) _CPU_Get_pid(); /* process id */
BSP_shm_cfgtbl.Intr.value = _CPU_SHM_Get_vector(); /* signal to send */
BSP_shm_cfgtbl.Intr.length = LONG;
#else
} else {
BSP_shm_cfgtbl.poll_intr = POLLED_MODE;
BSP_shm_cfgtbl.Intr.address = NO_INTERRUPT;
BSP_shm_cfgtbl.Intr.value = NO_INTERRUPT;
BSP_shm_cfgtbl.Intr.length = NO_INTERRUPT;
#endif
}
*shmcfg = &BSP_shm_cfgtbl;
}

View File

@@ -19,12 +19,9 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <shm.h>
#include <stdio.h>
#include <signal.h>
void Shm_Cause_interrupt_unix(
rtems_unsigned32 node
)
@@ -32,5 +29,5 @@ void Shm_Cause_interrupt_unix(
Shm_Interrupt_information *intr;
intr = &Shm_Interrupt_table[node];
kill((pid_t) intr->address, intr->value);
_CPU_SHM_Send_interrupt( (int) intr->address, (int) intr->value );
}

View File

@@ -17,18 +17,9 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <shm.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
extern int semid;
/*
@@ -56,29 +47,12 @@ void Shm_Lock(
)
{
rtems_unsigned32 isr_level;
struct sembuf sb;
int status;
sb.sem_num = lq_cb->lock;
sb.sem_op = -1;
sb.sem_flg = 0;
rtems_interrupt_disable( isr_level );
Shm_isrstat = isr_level;
while (1) {
status = semop(semid, &sb, 1);
if ( status >= 0 )
break;
if ( status == -1 ) {
fix_syscall_errno(); /* in case of newlib */
if (errno == EINTR)
continue;
perror("shm lock");
rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
}
}
_CPU_SHM_Lock( lq_cb->lock );
}
/*
@@ -92,26 +66,8 @@ void Shm_Unlock(
)
{
rtems_unsigned32 isr_level;
struct sembuf sb;
int status;
sb.sem_num = lq_cb->lock;
sb.sem_op = 1;
sb.sem_flg = 0;
while (1) {
status = semop(semid, &sb, 1);
if ( status >= 0 )
break;
if ( status == -1 ) {
fix_syscall_errno(); /* in case of newlib */
if (errno == EINTR)
continue;
perror("shm unlock");
rtems_fatal_error_occurred(RTEMS_UNSATISFIED);
}
}
_CPU_SHM_Unlock( lq_cb->lock );
isr_level = Shm_isrstat;
rtems_interrupt_enable( isr_level );

View File

@@ -18,14 +18,15 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <shm.h>
void Shm_setvec( void )
{
#ifdef INTERRUPT_EXTERNAL_MPCI
set_vector( Shm_isr, INTERRUPT_EXTERNAL_MPCI, 1 );
#endif
int vector;
vector = _CPU_SHM_Get_vector();
if ( vector )
set_vector( Shm_isr, vector, 1 );
}

View File

@@ -19,7 +19,6 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <stdio.h>
@@ -35,8 +34,8 @@ void bsp_cleanup( void )
* By definition, rtems_fatal_error_occurred does not return.
*/
fflush(stdout);
fflush(stderr);
fflush(stdout);
fflush(stderr);
rtems_fatal_error_occurred(0);
}

View File

@@ -27,8 +27,6 @@
* $Id$
*/
#include <rtems.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

View File

@@ -14,7 +14,6 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <clockdrv.h>

View File

@@ -24,7 +24,6 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
/*

View File

@@ -16,8 +16,8 @@
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <time.h>
#include <sys/time.h>

View File

@@ -236,6 +236,7 @@ rtems_mpci_entry Shm_Initialization( void )
}
MPCI_Shm_extensions.fatal = MPCI_Fatal;
(void) rtems_extension_create(
rtems_build_name( 'M', 'P', 'E', 'X' ),
&MPCI_Shm_extensions,

View File

@@ -35,7 +35,7 @@ PRI5 - rtems_semaphore_release - nested
PRI5 - rtems_semaphore_release - restore priority
PRI5 - priority of PRI5 is 68
<pause>
TA1 - rtems_semaphore_ident - smid => 10010002
TA1 - rtems_semaphore_ident - smid => 14010002
TA1 - rtems_semaphore_obtain - wait forever on SM2
TA1 - got SM2
TA1 - rtems_semaphore_obtain - wait forever on SM3

View File

@@ -1,5 +1,5 @@
*** TEST 13 ***
TA1 - rtems_message_queue_ident - qid => 14010001
TA1 - rtems_message_queue_ident - qid => 18010001
TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1
TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1
TA1 - rtems_task_wake_after - sleep 5 seconds

View File

@@ -1,8 +1,8 @@
*** TEST 15 ***
INIT - rtems_partition_create - partition 1
INIT - rtems_partition_create - partition 2
TA1 - rtems_partition_ident - partition 1 id = 18010001
TA1 - rtems_partition_ident - partition 2 id = 18010002
TA1 - rtems_partition_ident - partition 1 id = 1c010001
TA1 - rtems_partition_ident - partition 2 id = 1c010002
TA1 - rtems_partition_get_buffer - buffer 1 from partition 1 - 0x00000000
TA1 - rtems_partition_get_buffer - buffer 2 from partition 1 - 0x00000200
TA1 - rtems_partition_get_buffer - buffer 1 from partition 2 - 0x00000000

View File

@@ -1,5 +1,5 @@
*** TEST 16 ***
TA1 - rtems_region_ident - rnid => 1c010002
TA1 - rtems_region_ident - rnid => 20010002
TA1 - rtems_region_get_segment - wait on 100 byte segment from region 2
TA1 - got segment from region 2 - 0x00000f78
TA1 - rtems_region_get_segment - wait on 3K segment from region 3

View File

@@ -1,19 +1,19 @@
*** TEST 20 ***
TA1 - rtems_rate_monotonic_create id = 0x24010001
TA1 - rtems_rate_monotonic_ident id = 0x24010001
TA1 - (0x24010001) period 2
TA2 - rtems_rate_monotonic_create id = 0x24010002
TA2 - rtems_rate_monotonic_ident id = 0x24010002
TA2 - (0x24010002) period 2
TA3 - rtems_rate_monotonic_create id = 0x24010003
TA3 - rtems_rate_monotonic_ident id = 0x24010003
TA3 - (0x24010003) period 2
TA4 - rtems_rate_monotonic_create id = 0x24010004
TA4 - rtems_rate_monotonic_ident id = 0x24010004
TA4 - (0x24010004) period 2
TA5 - rtems_rate_monotonic_create id = 0x24010005
TA5 - rtems_rate_monotonic_ident id = 0x24010005
TA5 - (0x24010005) period 100
TA1 - rtems_rate_monotonic_create id = 0x28010001
TA1 - rtems_rate_monotonic_ident id = 0x28010001
TA1 - (0x28010001) period 2
TA2 - rtems_rate_monotonic_create id = 0x28010002
TA2 - rtems_rate_monotonic_ident id = 0x28010002
TA2 - (0x28010002) period 2
TA3 - rtems_rate_monotonic_create id = 0x28010003
TA3 - rtems_rate_monotonic_ident id = 0x28010003
TA3 - (0x28010003) period 2
TA4 - rtems_rate_monotonic_create id = 0x28010004
TA4 - rtems_rate_monotonic_ident id = 0x28010004
TA4 - (0x28010004) period 2
TA5 - rtems_rate_monotonic_create id = 0x28010005
TA5 - rtems_rate_monotonic_ident id = 0x28010005
TA5 - (0x28010005) period 100
TA5 - PERIODS CHECK OK (1)
TA5 - PERIODS CHECK OK (2)
TA5 - PERIODS CHECK OK (3)

View File

@@ -1,8 +1,8 @@
*** TEST 22 ***
INIT - rtems_timer_create - creating timer 1
INIT - timer 1 has id (0xc010001)
INIT - timer 1 has id (0x10010001)
TA1 - rtems_timer_ident - identing timer 1
TA1 - timer 1 has id (0xc010001)
TA1 - timer 1 has id (0x10010001)
TA1 - rtems_clock_get - 09:00:00 12/31/1988
TA1 - rtems_timer_fire_after - timer 1 in 3 seconds
TA1 - rtems_task_suspend( RTEMS_SELF )

View File

@@ -1,6 +1,6 @@
*** TEST 23 ***
INIT - rtems_port_create - DP1 - int = 0x00001000 ext = 0x00002000
TA1 - rtems_port_ident - 0x20010001
TA1 - rtems_port_ident - 0x24010001
TA1 - rtems_port_external_to_internal - 0x0000200e => 0x0000100e
TA1 - rtems_port_internal_to_external - 0x0000100e => 0x0000200e
TA1 - rtems_port_external_to_internal - 0x0000300e => 0x0000300e

View File

@@ -1,5 +1,5 @@
*** TEST 25 ***
TA1 - rtems_region_ident - 0x1c010002
TA1 - rtems_region_ident - 0x20010002
TA1 - rtems_region_get_segment - wait on 64 byte segment from region 1
TA1 - got segment from region 1 - 0x0000f9b8
TA1 - rtems_region_get_segment - wait on 128 byte segment from region 1

View File

@@ -20,16 +20,39 @@
#include <rtems/score/isr.h>
#include <rtems/score/interr.h>
#if defined(solaris2)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 3
#undef __STRICT_ANSI__
#define __STRICT_ANSI__
#endif
#if defined(linux)
#define MALLOC_0_RETURNS_NULL
#endif
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#ifndef SA_RESTART
#define SA_RESTART 0
#endif
typedef struct {
jmp_buf regs;
sigset_t isr_level;
} Context_Control_overlay;
void _CPU_Signal_initialize(void);
void _CPU_Stray_signal(int);
void _CPU_ISR_Handler(int);
@@ -375,9 +398,9 @@ void _CPU_Context_Initialize(
*/
if ( _new_level == 0 )
source = _CPU_Context_Default_with_ISRs_enabled.regs;
source = &_CPU_Context_Default_with_ISRs_enabled;
else
source = _CPU_Context_Default_with_ISRs_disabled.regs;
source = &_CPU_Context_Default_with_ISRs_disabled;
memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
@@ -452,8 +475,10 @@ void _CPU_Context_restore(
Context_Control *next
)
{
sigprocmask( SIG_SETMASK, &next->isr_level, 0 );
longjmp( next->regs, 0 );
Context_Control_overlay *nextp = (Context_Control_overlay *)next;
sigprocmask( SIG_SETMASK, &nextp->isr_level, 0 );
longjmp( nextp->regs, 0 );
}
/*PAGE
@@ -466,13 +491,16 @@ void _CPU_Context_switch(
Context_Control *next
)
{
Context_Control_overlay *currentp = (Context_Control_overlay *)current;
Context_Control_overlay *nextp = (Context_Control_overlay *)next;
int status;
/*
* Switch levels in one operation
*/
status = sigprocmask( SIG_SETMASK, &next->isr_level, &current->isr_level );
status = sigprocmask( SIG_SETMASK, &nextp->isr_level, &currentp->isr_level );
if ( status )
_Internal_error_Occurred(
INTERNAL_ERROR_CORE,
@@ -480,8 +508,8 @@ void _CPU_Context_switch(
status
);
if (setjmp(current->regs) == 0) { /* Save the current context */
longjmp(next->regs, 0); /* Switch to the new context */
if (setjmp(currentp->regs) == 0) { /* Save the current context */
longjmp(nextp->regs, 0); /* Switch to the new context */
if ( status )
_Internal_error_Occurred(
INTERNAL_ERROR_CORE,
@@ -610,18 +638,19 @@ void _CPU_ISR_Handler(int vector)
void _CPU_Stray_signal(int sig_num)
{
char buffer[ 80 ];
char buffer[ 4 ];
/*
* We avoid using the stdio section of the library.
* The following is generally safe.
*/
write(
2,
buffer,
sprintf( buffer, "Stray signal %d\n", sig_num )
);
buffer[ 0 ] = (sig_num >> 4) + 0x30;
buffer[ 1 ] = (sig_num & 0xf) + 0x30;
buffer[ 2 ] = '\n';
write( 2, "Stray signal 0x", 12 );
write( 2, buffer, 3 );
/*
* If it was a "fatal" signal, then exit here
@@ -680,3 +709,252 @@ int _CPU_ffs(unsigned32 value)
return output;
}
/*
* Special Purpose Routines to hide the use of UNIX system calls.
*/
#if 0
/* XXX clock had this set of #define's */
/*
* In order to get the types and prototypes used in this file under
* Solaris 2.3, it is necessary to pull the following magic.
*/
#if defined(solaris)
#warning "Ignore the undefining __STDC__ warning"
#undef __STDC__
#define __STDC__ 0
#undef _POSIX_C_SOURCE
#endif
#endif
int _CPU_Get_clock_vector( void )
{
return SIGALRM;
}
void _CPU_Start_clock(
int microseconds
)
{
struct itimerval new;
new.it_value.tv_sec = 0;
new.it_value.tv_usec = microseconds;
new.it_interval.tv_sec = 0;
new.it_interval.tv_usec = microseconds;
setitimer(ITIMER_REAL, &new, 0);
}
void _CPU_Stop_clock( void )
{
struct itimerval new;
struct sigaction act;
/*
* Set the SIGALRM signal to ignore any last
* signals that might come in while we are
* disarming the timer and removing the interrupt
* vector.
*/
act.sa_handler = SIG_IGN;
sigaction(SIGALRM, &act, 0);
new.it_value.tv_sec = 0;
new.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &new, 0);
}
int _CPU_SHM_Semid;
extern void fix_syscall_errno( void );
void _CPU_SHM_Init(
unsigned32 maximum_nodes,
boolean is_master_node,
void **shm_address,
unsigned32 *shm_length
)
{
int i;
int shmid;
char *shm_addr;
key_t shm_key;
key_t sem_key;
int status;
int shm_size;
if (getenv("RTEMS_SHM_KEY"))
shm_key = strtol(getenv("RTEMS_SHM_KEY"), 0, 0);
else
#ifdef RTEMS_SHM_KEY
shm_key = RTEMS_SHM_KEY;
#else
shm_key = 0xa000;
#endif
if (getenv("RTEMS_SHM_SIZE"))
shm_size = strtol(getenv("RTEMS_SHM_SIZE"), 0, 0);
else
#ifdef RTEMS_SHM_SIZE
shm_size = RTEMS_SHM_SIZE;
#else
shm_size = 64 * 1024;
#endif
if (getenv("RTEMS_SHM_SEMAPHORE_KEY"))
sem_key = strtol(getenv("RTEMS_SHM_SEMAPHORE_KEY"), 0, 0);
else
#ifdef RTEMS_SHM_SEMAPHORE_KEY
sem_key = RTEMS_SHM_SEMAPHORE_KEY;
#else
sem_key = 0xa001;
#endif
shmid = shmget(shm_key, shm_size, IPC_CREAT | 0660);
if ( shmid == -1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "shmget" );
_CPU_Fatal_halt( 0xdead0001 );
}
shm_addr = shmat(shmid, (char *)0, SHM_RND);
if ( shm_addr == (void *)-1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "shmat" );
_CPU_Fatal_halt( 0xdead0002 );
}
_CPU_SHM_Semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
if ( _CPU_SHM_Semid == -1 ) {
fix_syscall_errno(); /* in case of newlib */
perror( "semget" );
_CPU_Fatal_halt( 0xdead0003 );
}
if ( is_master_node ) {
for ( i=0 ; i <= maximum_nodes ; i++ ) {
#if defined(solaris2)
union semun {
int val;
struct semid_ds *buf;
ushort *array;
} help;
help.val = 1;
status = semctl( _CPU_SHM_Semid, i, SETVAL, help );
#endif
#if defined(hpux)
status = semctl( _CPU_SHM_Semid, i, SETVAL, 1 );
#endif
fix_syscall_errno(); /* in case of newlib */
if ( status == -1 ) {
_CPU_Fatal_halt( 0xdead0004 );
}
}
}
*shm_address = shm_addr;
*shm_length = shm_size;
}
int _CPU_Get_pid( void )
{
return getpid();
}
/*
* Define this to use signals for MPCI shared memory driver.
* If undefined, the shared memory driver will poll from the
* clock interrupt.
* Ref: ../shmsupp/getcfg.c
*
* BEWARE:: many UN*X kernels and debuggers become severely confused when
* debugging programs which use signals. The problem is *much*
* worse when using multiple signals, since ptrace(2) tends to
* drop all signals except 1 in the case of multiples.
* On hpux9, this problem was so bad, we couldn't use interrupts
* with the shared memory driver if we ever hoped to debug
* RTEMS programs.
* Maybe systems that use /proc don't have this problem...
*/
int _CPU_SHM_Get_vector( void )
{
#ifdef CPU_USE_SHM_INTERRUPTS
return SIGUSR1;
#else
return 0;
#endif
}
void _CPU_SHM_Send_interrupt(
int pid,
int vector
)
{
kill((pid_t) pid, vector);
}
void _CPU_SHM_Lock(
int semaphore
)
{
struct sembuf sb;
int status;
sb.sem_num = semaphore;
sb.sem_op = -1;
sb.sem_flg = 0;
while (1) {
status = semop(_CPU_SHM_Semid, &sb, 1);
if ( status >= 0 )
break;
if ( status == -1 ) {
fix_syscall_errno(); /* in case of newlib */
if (errno == EINTR)
continue;
perror("shm lock");
_CPU_Fatal_halt( 0xdead0005 );
}
}
}
void _CPU_SHM_Unlock(
int semaphore
)
{
struct sembuf sb;
int status;
sb.sem_num = semaphore;
sb.sem_op = 1;
sb.sem_flg = 0;
while (1) {
status = semop(_CPU_SHM_Semid, &sb, 1);
if ( status >= 0 )
break;
if ( status == -1 ) {
fix_syscall_errno(); /* in case of newlib */
if (errno == EINTR)
continue;
perror("shm unlock");
_CPU_Fatal_halt( 0xdead0006 );
}
}
}

View File

@@ -35,7 +35,7 @@ PRI5 - rtems_semaphore_release - nested
PRI5 - rtems_semaphore_release - restore priority
PRI5 - priority of PRI5 is 68
<pause>
TA1 - rtems_semaphore_ident - smid => 10010002
TA1 - rtems_semaphore_ident - smid => 14010002
TA1 - rtems_semaphore_obtain - wait forever on SM2
TA1 - got SM2
TA1 - rtems_semaphore_obtain - wait forever on SM3

View File

@@ -1,5 +1,5 @@
*** TEST 13 ***
TA1 - rtems_message_queue_ident - qid => 14010001
TA1 - rtems_message_queue_ident - qid => 18010001
TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1
TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1
TA1 - rtems_task_wake_after - sleep 5 seconds

View File

@@ -1,8 +1,8 @@
*** TEST 15 ***
INIT - rtems_partition_create - partition 1
INIT - rtems_partition_create - partition 2
TA1 - rtems_partition_ident - partition 1 id = 18010001
TA1 - rtems_partition_ident - partition 2 id = 18010002
TA1 - rtems_partition_ident - partition 1 id = 1c010001
TA1 - rtems_partition_ident - partition 2 id = 1c010002
TA1 - rtems_partition_get_buffer - buffer 1 from partition 1 - 0x00000000
TA1 - rtems_partition_get_buffer - buffer 2 from partition 1 - 0x00000200
TA1 - rtems_partition_get_buffer - buffer 1 from partition 2 - 0x00000000

View File

@@ -1,5 +1,5 @@
*** TEST 16 ***
TA1 - rtems_region_ident - rnid => 1c010002
TA1 - rtems_region_ident - rnid => 20010002
TA1 - rtems_region_get_segment - wait on 100 byte segment from region 2
TA1 - got segment from region 2 - 0x00000f78
TA1 - rtems_region_get_segment - wait on 3K segment from region 3

View File

@@ -1,19 +1,19 @@
*** TEST 20 ***
TA1 - rtems_rate_monotonic_create id = 0x24010001
TA1 - rtems_rate_monotonic_ident id = 0x24010001
TA1 - (0x24010001) period 2
TA2 - rtems_rate_monotonic_create id = 0x24010002
TA2 - rtems_rate_monotonic_ident id = 0x24010002
TA2 - (0x24010002) period 2
TA3 - rtems_rate_monotonic_create id = 0x24010003
TA3 - rtems_rate_monotonic_ident id = 0x24010003
TA3 - (0x24010003) period 2
TA4 - rtems_rate_monotonic_create id = 0x24010004
TA4 - rtems_rate_monotonic_ident id = 0x24010004
TA4 - (0x24010004) period 2
TA5 - rtems_rate_monotonic_create id = 0x24010005
TA5 - rtems_rate_monotonic_ident id = 0x24010005
TA5 - (0x24010005) period 100
TA1 - rtems_rate_monotonic_create id = 0x28010001
TA1 - rtems_rate_monotonic_ident id = 0x28010001
TA1 - (0x28010001) period 2
TA2 - rtems_rate_monotonic_create id = 0x28010002
TA2 - rtems_rate_monotonic_ident id = 0x28010002
TA2 - (0x28010002) period 2
TA3 - rtems_rate_monotonic_create id = 0x28010003
TA3 - rtems_rate_monotonic_ident id = 0x28010003
TA3 - (0x28010003) period 2
TA4 - rtems_rate_monotonic_create id = 0x28010004
TA4 - rtems_rate_monotonic_ident id = 0x28010004
TA4 - (0x28010004) period 2
TA5 - rtems_rate_monotonic_create id = 0x28010005
TA5 - rtems_rate_monotonic_ident id = 0x28010005
TA5 - (0x28010005) period 100
TA5 - PERIODS CHECK OK (1)
TA5 - PERIODS CHECK OK (2)
TA5 - PERIODS CHECK OK (3)

View File

@@ -1,8 +1,8 @@
*** TEST 22 ***
INIT - rtems_timer_create - creating timer 1
INIT - timer 1 has id (0xc010001)
INIT - timer 1 has id (0x10010001)
TA1 - rtems_timer_ident - identing timer 1
TA1 - timer 1 has id (0xc010001)
TA1 - timer 1 has id (0x10010001)
TA1 - rtems_clock_get - 09:00:00 12/31/1988
TA1 - rtems_timer_fire_after - timer 1 in 3 seconds
TA1 - rtems_task_suspend( RTEMS_SELF )

View File

@@ -1,6 +1,6 @@
*** TEST 23 ***
INIT - rtems_port_create - DP1 - int = 0x00001000 ext = 0x00002000
TA1 - rtems_port_ident - 0x20010001
TA1 - rtems_port_ident - 0x24010001
TA1 - rtems_port_external_to_internal - 0x0000200e => 0x0000100e
TA1 - rtems_port_internal_to_external - 0x0000100e => 0x0000200e
TA1 - rtems_port_external_to_internal - 0x0000300e => 0x0000300e

View File

@@ -1,5 +1,5 @@
*** TEST 25 ***
TA1 - rtems_region_ident - 0x1c010002
TA1 - rtems_region_ident - 0x20010002
TA1 - rtems_region_get_segment - wait on 64 byte segment from region 1
TA1 - got segment from region 1 - 0x0000f9b8
TA1 - rtems_region_get_segment - wait on 128 byte segment from region 1

116
tools/cpu/unix/gensize.c Normal file
View File

@@ -0,0 +1,116 @@
/*
* gensize.c
*
* This file generates the file unixsize.h
*
* NOTE: It only prints the minimal information required.
*
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
* On-Line Applications Research Corporation (OAR).
*
* This material may be reproduced by or for the U.S. Government pursuant
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
* $Id$
*
*/
/*
* This feels like a very crude way to determine if we are on a Solaris
* host but it does work.
*/
#if defined(__sun__) && defined(__sparc__) && \
defined(__unix__) && defined(__svr4__)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 3
#undef __STRICT_ANSI__
#endif
#include <stdio.h>
#include <unistd.h>
#include <setjmp.h>
#include <signal.h>
typedef struct {
jmp_buf regs;
sigset_t isr_level;
} Context_Control;
int main(
int argc,
char **argv
)
{
Context_Control *cc = 0;
/*
* Print the file header
*/
printf(
"/* unixsize.h\n"
" *\n"
" * This include file contans the size of the context control block\n"
" * C data structure. This structure must be defined in such a way\n"
" * that files NOT including the native header files can work.\n"
" *\n"
" * NOTE: THIS FILE IS AUTOMATICALLY GENERATED!!!!\n"
" * DO NOT EDIT THIS BY HAND!!!!\n"
" *\n"
" * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.\n"
" * On-Line Applications Research Corporation (OAR).\n"
" * All rights assigned to U.S. Government, 1994.\n"
" *\n"
" * This material may be reproduced by or for the U.S. Government pursuant\n"
" * to the copyright license under the clause at DFARS 252.227-7013. This\n"
" * notice must appear in all copies of this file and its derivatives.\n"
" */\n"
"\n"
"#ifndef __UNIXSIZE_h\n"
"#define __UNIXSIZE_h\n"
"\n"
);
#define PRINT_IT( STRING, NUMBER ) \
printf( "#define\t%s\t0x%x\t\t/* %d */\n", \
STRING, \
NUMBER, \
NUMBER );
#define PRINT_SIZE( STRING, NUMBER ) \
printf( "#define\t%s\t0x%x\t\t/* %d */\n", \
STRING, \
NUMBER, \
NUMBER );
#define PRINT_COMMENT( STRING ) \
printf( \
"\n" \
"/*\n" \
" * " STRING "\n" \
" */\n" \
"\n" \
);
PRINT_COMMENT("Context_Control information");
PRINT_SIZE("CPU_CONTEXT_SIZE_IN_BYTES", sizeof( Context_Control ) );
PRINT_SIZE("CPU_CONTEXT_REGISTERS_OFFSET_IN_BYTES", (int) &cc->regs );
PRINT_SIZE("CPU_CONTEXT_SIGNALS_OFFSET_IN_BYTES", (int) &cc->isr_level );
/*
* Print the end of file stuff
*/
printf(
"\n"
"#endif /* __UNIXSIZE_h */\n"
"\n"
"/* end of include file */\n"
);
return 0;
}