Changeset d1193c7 in rtems


Ignore:
Timestamp:
Sep 18, 1996, 8:47:31 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
2069773
Parents:
a4d97d94
Message:

corrected white space problems

added CPU_STRUCTURE_ALIGNMENT to default context structures

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/cpu/unix/cpu.c

    ra4d97d94 rd1193c7  
    3030#define __EXTENSIONS__
    3131#endif
    32  
     32
    3333#if defined(linux)
    3434#define MALLOC_0_RETURNS_NULL
    3535#endif
    36  
     36
    3737#include <sys/types.h>
    3838#include <sys/times.h>
     
    6464
    6565static sigset_t         _CPU_Signal_mask;
    66 static Context_Control_overlay  _CPU_Context_Default_with_ISRs_enabled;
    67 static Context_Control_overlay  _CPU_Context_Default_with_ISRs_disabled;
     66static Context_Control_overlay
     67          CPU_STRUCTURE_ALIGNMENT _CPU_Context_Default_with_ISRs_enabled;
     68static Context_Control_overlay
     69          CPU_STRUCTURE_ALIGNMENT _CPU_Context_Default_with_ISRs_disabled;
    6870
    6971/*
     
    124126  struct sigaction  act;
    125127  sigset_t          mask;
    126  
     128
    127129  /* mark them all active except for TraceTrap  and Abort */
    128  
     130
    129131  mask = _CPU_Signal_mask;
    130132  sigprocmask(SIG_UNBLOCK, &mask, 0);
    131  
     133
    132134  act.sa_handler = _CPU_ISR_Handler;
    133135  act.sa_mask = mask;
    134136  act.sa_flags = SA_RESTART;
    135  
     137
    136138  sigaction(SIGHUP, &act, 0);
    137139  sigaction(SIGINT, &act, 0);
     
    194196   */
    195197
    196  
     198
    197199  (void) memset(
    198200    &_CPU_Context_Default_with_ISRs_enabled,
     
    211213    (Context_Control *) &_CPU_Context_Default_with_ISRs_enabled
    212214  );
    213  
     215
    214216  _CPU_ISR_Set_level( 1 );
    215217  _CPU_Context_switch(
     
    227229{
    228230  sigset_t old_mask;
    229  
     231
    230232  sigprocmask(SIG_BLOCK, 0, &old_mask);
    231  
     233
    232234  if (memcmp((void *)&posix_empty_mask, (void *)&old_mask, sizeof(sigset_t)))
    233235      return 1;
    234  
     236
    235237  return 0;
    236238}
     
    347349 *  _CPU_Thread_Idle_body
    348350 *
    349  *  Stop until we get a signal which is the logically the same thing 
     351 *  Stop until we get a signal which is the logically the same thing
    350352 *  entering low-power or sleep mode on a real processor and waiting for
    351353 *  an interrupt.  This significantly reduces the consumption of host
     
    367369
    368370/*PAGE
    369  * 
     371 *
    370372 *  _CPU_Context_Initialize
    371373 */
     
    390392  /*
    391393   *  On CPUs with stacks which grow down, we build the stack
    392    *  based on the _stack_high address.  On CPUs with stacks which 
    393    *  grow up, we build the stack based on the _stack_low address. 
     394   *  based on the _stack_high address.  On CPUs with stacks which
     395   *  grow up, we build the stack based on the _stack_low address.
    394396   */
    395397
     
    415417      *_the_context = *(Context_Control *)
    416418                         &_CPU_Context_Default_with_ISRs_disabled;
    417      
     419
    418420  addr = (unsigned32 *)_the_context;
    419421
     
    447449
    448450#elif defined(i386)
    449  
     451
    450452    /*
    451453     *  This information was gathered by disassembling setjmp().
     
    463465      *(addr + ESP_OFF) = stack_ptr;
    464466      *(addr + RET_OFF) = jmp_addr;
    465  
     467
    466468      addr = (unsigned32 *) stack_ptr;
    467  
     469
    468470      addr[ 0 ] = jmp_addr;
    469471      addr[ 1 ] = (unsigned32) stack_ptr;
     
    512514  int status;
    513515#endif
    514  
     516
    515517  currentp->isr_level = _CPU_ISR_Disable_support();
    516  
     518
    517519  do_jump( currentp, nextp );
    518520
     
    527529  }
    528530#endif
    529  
     531
    530532#ifdef RTEMS_DEBUG
    531533    if (_CPU_ISR_Get_level() == 0)
    532534       abort();
    533535#endif
    534  
     536
    535537  _CPU_ISR_Enable(currentp->isr_level);
    536538}
    537  
    538 static void do_jump( 
     539
     540static void do_jump(
    539541  Context_Control_overlay *currentp,
    540   Context_Control_overlay *nextp 
     542  Context_Control_overlay *nextp
    541543)
    542544{
     
    672674{
    673675  char buffer[ 4 ];
    674  
     676
    675677  /*
    676678   * print "stray" msg about ones which that might mean something
     
    678680   * The following is generally safe.
    679681   */
    680  
     682
    681683  switch (sig_num)
    682684  {
    683685      case SIGCLD:
    684686          break;
    685  
     687
    686688      default:
    687689      {
     
    690692         *  The following is generally safe
    691693         */
    692  
     694
    693695        int digit;
    694696        int number = sig_num;
     
    705707        digit = number;
    706708        buffer[len++] = '0' + digit;
    707  
     709
    708710        buffer[ len++ ] = '\n';
    709  
     711
    710712        write( 2, "Stray signal ", 13 );
    711713        write( 2, buffer, len );
     
    713715      }
    714716  }
    715  
     717
    716718  /*
    717719   * If it was a "fatal" signal, then exit here
     
    719721   * we won't call _CPU_Stray_signal, so this is ok.
    720722   */
    721  
     723
    722724  switch (sig_num) {
    723725      case SIGINT:
     
    766768}
    767769
    768 void _CPU_Start_clock( 
     770void _CPU_Start_clock(
    769771  int microseconds
    770772)
     
    784786  struct itimerval  new;
    785787  struct sigaction  act;
    786  
     788
    787789  /*
    788790   * Set the SIGALRM signal to ignore any last
     
    791793   * vector.
    792794   */
    793  
     795
    794796  (void) memset(&act, 0, sizeof(act));
    795797  act.sa_handler = SIG_IGN;
    796  
     798
    797799  sigaction(SIGALRM, &act, 0);
    798  
     800
    799801  (void) memset(&new, 0, sizeof(new));
    800802  setitimer(ITIMER_REAL, &new, 0);
     
    804806extern       void fix_syscall_errno( void );
    805807
    806 void _CPU_SHM_Init( 
     808void _CPU_SHM_Init(
    807809  unsigned32   maximum_nodes,
    808810  boolean      is_master_node,
     
    818820  int          status;
    819821  int          shm_size;
    820  
     822
    821823  if (getenv("RTEMS_SHM_KEY"))
    822824    shm_key = strtol(getenv("RTEMS_SHM_KEY"), 0, 0);
     
    827829    shm_key = 0xa000;
    828830#endif
    829  
     831
    830832    if (getenv("RTEMS_SHM_SIZE"))
    831833      shm_size = strtol(getenv("RTEMS_SHM_SIZE"), 0, 0);
     
    836838      shm_size = 64 * 1024;
    837839#endif
    838  
     840
    839841    if (getenv("RTEMS_SHM_SEMAPHORE_KEY"))
    840842      sem_key = strtol(getenv("RTEMS_SHM_SEMAPHORE_KEY"), 0, 0);
     
    845847      sem_key = 0xa001;
    846848#endif
    847  
     849
    848850    shmid = shmget(shm_key, shm_size, IPC_CREAT | 0660);
    849851    if ( shmid == -1 ) {
     
    852854      _CPU_Fatal_halt( 0xdead0001 );
    853855    }
    854  
     856
    855857    shm_addr = shmat(shmid, (char *)0, SHM_RND);
    856858    if ( shm_addr == (void *)-1 ) {
     
    859861      _CPU_Fatal_halt( 0xdead0002 );
    860862    }
    861  
     863
    862864    _CPU_SHM_Semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
    863865    if ( _CPU_SHM_Semid == -1 ) {
     
    866868      _CPU_Fatal_halt( 0xdead0003 );
    867869    }
    868  
     870
    869871    if ( is_master_node ) {
    870872      for ( i=0 ; i <= maximum_nodes ; i++ ) {
     
    875877          ushort *array;
    876878        } help;
    877  
     879
    878880        help.val = 1;
    879881        status = semctl( _CPU_SHM_Semid, i, SETVAL, help );
     
    882884        status = semctl( _CPU_SHM_Semid, i, SETVAL, 1 );
    883885#endif
    884  
     886
    885887        fix_syscall_errno(); /* in case of newlib */
    886888        if ( status == -1 ) {
     
    889891      }
    890892    }
    891  
     893
    892894  *shm_address = shm_addr;
    893895  *shm_length = shm_size;
     
    915917 *          Maybe systems that use /proc don't have this problem...
    916918 */
    917  
    918  
     919
     920
    919921int _CPU_SHM_Get_vector( void )
    920922{
     
    934936}
    935937
    936 void _CPU_SHM_Lock( 
     938void _CPU_SHM_Lock(
    937939  int semaphore
    938940)
     
    940942  struct sembuf      sb;
    941943  int                status;
    942  
     944
    943945  sb.sem_num = semaphore;
    944946  sb.sem_op  = -1;
    945947  sb.sem_flg = 0;
    946  
     948
    947949  while (1) {
    948950    status = semop(_CPU_SHM_Semid, &sb, 1);
     
    966968  struct sembuf  sb;
    967969  int            status;
    968  
     970
    969971  sb.sem_num = semaphore;
    970972  sb.sem_op  = 1;
    971973  sb.sem_flg = 0;
    972  
     974
    973975  while (1) {
    974976    status = semop(_CPU_SHM_Semid, &sb, 1);
    975977    if ( status >= 0 )
    976978      break;
    977  
     979
    978980    if ( status == -1 ) {
    979981      fix_syscall_errno();    /* in case of newlib */
  • cpukit/score/cpu/unix/cpu.c

    ra4d97d94 rd1193c7  
    3030#define __EXTENSIONS__
    3131#endif
    32  
     32
    3333#if defined(linux)
    3434#define MALLOC_0_RETURNS_NULL
    3535#endif
    36  
     36
    3737#include <sys/types.h>
    3838#include <sys/times.h>
     
    6464
    6565static sigset_t         _CPU_Signal_mask;
    66 static Context_Control_overlay  _CPU_Context_Default_with_ISRs_enabled;
    67 static Context_Control_overlay  _CPU_Context_Default_with_ISRs_disabled;
     66static Context_Control_overlay
     67          CPU_STRUCTURE_ALIGNMENT _CPU_Context_Default_with_ISRs_enabled;
     68static Context_Control_overlay
     69          CPU_STRUCTURE_ALIGNMENT _CPU_Context_Default_with_ISRs_disabled;
    6870
    6971/*
     
    124126  struct sigaction  act;
    125127  sigset_t          mask;
    126  
     128
    127129  /* mark them all active except for TraceTrap  and Abort */
    128  
     130
    129131  mask = _CPU_Signal_mask;
    130132  sigprocmask(SIG_UNBLOCK, &mask, 0);
    131  
     133
    132134  act.sa_handler = _CPU_ISR_Handler;
    133135  act.sa_mask = mask;
    134136  act.sa_flags = SA_RESTART;
    135  
     137
    136138  sigaction(SIGHUP, &act, 0);
    137139  sigaction(SIGINT, &act, 0);
     
    194196   */
    195197
    196  
     198
    197199  (void) memset(
    198200    &_CPU_Context_Default_with_ISRs_enabled,
     
    211213    (Context_Control *) &_CPU_Context_Default_with_ISRs_enabled
    212214  );
    213  
     215
    214216  _CPU_ISR_Set_level( 1 );
    215217  _CPU_Context_switch(
     
    227229{
    228230  sigset_t old_mask;
    229  
     231
    230232  sigprocmask(SIG_BLOCK, 0, &old_mask);
    231  
     233
    232234  if (memcmp((void *)&posix_empty_mask, (void *)&old_mask, sizeof(sigset_t)))
    233235      return 1;
    234  
     236
    235237  return 0;
    236238}
     
    347349 *  _CPU_Thread_Idle_body
    348350 *
    349  *  Stop until we get a signal which is the logically the same thing 
     351 *  Stop until we get a signal which is the logically the same thing
    350352 *  entering low-power or sleep mode on a real processor and waiting for
    351353 *  an interrupt.  This significantly reduces the consumption of host
     
    367369
    368370/*PAGE
    369  * 
     371 *
    370372 *  _CPU_Context_Initialize
    371373 */
     
    390392  /*
    391393   *  On CPUs with stacks which grow down, we build the stack
    392    *  based on the _stack_high address.  On CPUs with stacks which 
    393    *  grow up, we build the stack based on the _stack_low address. 
     394   *  based on the _stack_high address.  On CPUs with stacks which
     395   *  grow up, we build the stack based on the _stack_low address.
    394396   */
    395397
     
    415417      *_the_context = *(Context_Control *)
    416418                         &_CPU_Context_Default_with_ISRs_disabled;
    417      
     419
    418420  addr = (unsigned32 *)_the_context;
    419421
     
    447449
    448450#elif defined(i386)
    449  
     451
    450452    /*
    451453     *  This information was gathered by disassembling setjmp().
     
    463465      *(addr + ESP_OFF) = stack_ptr;
    464466      *(addr + RET_OFF) = jmp_addr;
    465  
     467
    466468      addr = (unsigned32 *) stack_ptr;
    467  
     469
    468470      addr[ 0 ] = jmp_addr;
    469471      addr[ 1 ] = (unsigned32) stack_ptr;
     
    512514  int status;
    513515#endif
    514  
     516
    515517  currentp->isr_level = _CPU_ISR_Disable_support();
    516  
     518
    517519  do_jump( currentp, nextp );
    518520
     
    527529  }
    528530#endif
    529  
     531
    530532#ifdef RTEMS_DEBUG
    531533    if (_CPU_ISR_Get_level() == 0)
    532534       abort();
    533535#endif
    534  
     536
    535537  _CPU_ISR_Enable(currentp->isr_level);
    536538}
    537  
    538 static void do_jump( 
     539
     540static void do_jump(
    539541  Context_Control_overlay *currentp,
    540   Context_Control_overlay *nextp 
     542  Context_Control_overlay *nextp
    541543)
    542544{
     
    672674{
    673675  char buffer[ 4 ];
    674  
     676
    675677  /*
    676678   * print "stray" msg about ones which that might mean something
     
    678680   * The following is generally safe.
    679681   */
    680  
     682
    681683  switch (sig_num)
    682684  {
    683685      case SIGCLD:
    684686          break;
    685  
     687
    686688      default:
    687689      {
     
    690692         *  The following is generally safe
    691693         */
    692  
     694
    693695        int digit;
    694696        int number = sig_num;
     
    705707        digit = number;
    706708        buffer[len++] = '0' + digit;
    707  
     709
    708710        buffer[ len++ ] = '\n';
    709  
     711
    710712        write( 2, "Stray signal ", 13 );
    711713        write( 2, buffer, len );
     
    713715      }
    714716  }
    715  
     717
    716718  /*
    717719   * If it was a "fatal" signal, then exit here
     
    719721   * we won't call _CPU_Stray_signal, so this is ok.
    720722   */
    721  
     723
    722724  switch (sig_num) {
    723725      case SIGINT:
     
    766768}
    767769
    768 void _CPU_Start_clock( 
     770void _CPU_Start_clock(
    769771  int microseconds
    770772)
     
    784786  struct itimerval  new;
    785787  struct sigaction  act;
    786  
     788
    787789  /*
    788790   * Set the SIGALRM signal to ignore any last
     
    791793   * vector.
    792794   */
    793  
     795
    794796  (void) memset(&act, 0, sizeof(act));
    795797  act.sa_handler = SIG_IGN;
    796  
     798
    797799  sigaction(SIGALRM, &act, 0);
    798  
     800
    799801  (void) memset(&new, 0, sizeof(new));
    800802  setitimer(ITIMER_REAL, &new, 0);
     
    804806extern       void fix_syscall_errno( void );
    805807
    806 void _CPU_SHM_Init( 
     808void _CPU_SHM_Init(
    807809  unsigned32   maximum_nodes,
    808810  boolean      is_master_node,
     
    818820  int          status;
    819821  int          shm_size;
    820  
     822
    821823  if (getenv("RTEMS_SHM_KEY"))
    822824    shm_key = strtol(getenv("RTEMS_SHM_KEY"), 0, 0);
     
    827829    shm_key = 0xa000;
    828830#endif
    829  
     831
    830832    if (getenv("RTEMS_SHM_SIZE"))
    831833      shm_size = strtol(getenv("RTEMS_SHM_SIZE"), 0, 0);
     
    836838      shm_size = 64 * 1024;
    837839#endif
    838  
     840
    839841    if (getenv("RTEMS_SHM_SEMAPHORE_KEY"))
    840842      sem_key = strtol(getenv("RTEMS_SHM_SEMAPHORE_KEY"), 0, 0);
     
    845847      sem_key = 0xa001;
    846848#endif
    847  
     849
    848850    shmid = shmget(shm_key, shm_size, IPC_CREAT | 0660);
    849851    if ( shmid == -1 ) {
     
    852854      _CPU_Fatal_halt( 0xdead0001 );
    853855    }
    854  
     856
    855857    shm_addr = shmat(shmid, (char *)0, SHM_RND);
    856858    if ( shm_addr == (void *)-1 ) {
     
    859861      _CPU_Fatal_halt( 0xdead0002 );
    860862    }
    861  
     863
    862864    _CPU_SHM_Semid = semget(sem_key, maximum_nodes + 1, IPC_CREAT | 0660);
    863865    if ( _CPU_SHM_Semid == -1 ) {
     
    866868      _CPU_Fatal_halt( 0xdead0003 );
    867869    }
    868  
     870
    869871    if ( is_master_node ) {
    870872      for ( i=0 ; i <= maximum_nodes ; i++ ) {
     
    875877          ushort *array;
    876878        } help;
    877  
     879
    878880        help.val = 1;
    879881        status = semctl( _CPU_SHM_Semid, i, SETVAL, help );
     
    882884        status = semctl( _CPU_SHM_Semid, i, SETVAL, 1 );
    883885#endif
    884  
     886
    885887        fix_syscall_errno(); /* in case of newlib */
    886888        if ( status == -1 ) {
     
    889891      }
    890892    }
    891  
     893
    892894  *shm_address = shm_addr;
    893895  *shm_length = shm_size;
     
    915917 *          Maybe systems that use /proc don't have this problem...
    916918 */
    917  
    918  
     919
     920
    919921int _CPU_SHM_Get_vector( void )
    920922{
     
    934936}
    935937
    936 void _CPU_SHM_Lock( 
     938void _CPU_SHM_Lock(
    937939  int semaphore
    938940)
     
    940942  struct sembuf      sb;
    941943  int                status;
    942  
     944
    943945  sb.sem_num = semaphore;
    944946  sb.sem_op  = -1;
    945947  sb.sem_flg = 0;
    946  
     948
    947949  while (1) {
    948950    status = semop(_CPU_SHM_Semid, &sb, 1);
     
    966968  struct sembuf  sb;
    967969  int            status;
    968  
     970
    969971  sb.sem_num = semaphore;
    970972  sb.sem_op  = 1;
    971973  sb.sem_flg = 0;
    972  
     974
    973975  while (1) {
    974976    status = semop(_CPU_SHM_Semid, &sb, 1);
    975977    if ( status >= 0 )
    976978      break;
    977  
     979
    978980    if ( status == -1 ) {
    979981      fix_syscall_errno();    /* in case of newlib */
Note: See TracChangeset for help on using the changeset viewer.