Exemplo n.º 1
0
static void test_case_unblock_op(
  Thread_Control *executing,
  Scheduler_SMP_Node *executing_node,
  Thread_Control *other,
  Scheduler_SMP_Node_state new_state
)
{
  Thread_Control *needs_help;

  switch (new_state) {
    case SCHEDULER_SMP_NODE_SCHEDULED:
      _Thread_Change_priority(executing, 2, false);
      rtems_test_assert(executing_node->state == SCHEDULER_SMP_NODE_SCHEDULED);
      break;
    case SCHEDULER_SMP_NODE_READY:
      _Thread_Change_priority(executing, 4, false);
      rtems_test_assert(executing_node->state == SCHEDULER_SMP_NODE_READY);
      break;
    default:
      rtems_test_assert(0);
      break;
  }

  block_op(executing);
  rtems_test_assert(executing_node->state == SCHEDULER_SMP_NODE_BLOCKED);

  needs_help = unblock_op(executing);
  rtems_test_assert(executing_node->state == new_state);

  switch (new_state) {
    case SCHEDULER_SMP_NODE_SCHEDULED:
      rtems_test_assert(needs_help == other);
      break;
    case SCHEDULER_SMP_NODE_READY:
      rtems_test_assert(needs_help == executing);
      break;
    default:
      rtems_test_assert(0);
      break;
  }
}
Exemplo n.º 2
0
int extraction_stub(char *block, int block_len, int action)
{
 char c;
 char *block_ptr;
 int cn;

 #if SFX_LEVEL>=ARJ
  if(!debug_enabled||strchr(debug_opt, 'c')==NULL)
   crc_for_block(block, block_len);
 #else
  crc32_for_block(block, block_len);
 #endif
 if(!file_packing)                      /* Not applicable for memory data */
 {
  if(encmem_limit<block_len)            /* Check for overrun */
   error(M_BAD_HEADER);
  encmem_limit-=block_len;
  far_memmove(encblock_ptr, (char FAR *)block, block_len);
  encblock_ptr+=block_len;
  encmem_remain+=block_len;
  return(0);
 }
 /* Postprocessing */
 #if SFX_LEVEL>=ARJ
  if(action==BOP_LIST||action==BOP_SEARCH||action==BOP_COMPARE||action==BOP_DISPLAY)
   return(block_op(action, block, block_len));
 #endif
 if(atstream==NULL)
  return(0);
 /* Strip high bit from files created by different OS */
 if(file_type==ARJT_TEXT&&host_os!=OS
 #if SFX_LEVEL>=ARJ
  &&type_override!=FT_BINARY
 #endif
 )
 {
  block_ptr=block;
  while(block_len-->0)
  {
   c=*(block_ptr++);
   c&=0x7F;
   if(fputc((int)c, atstream)==EOF)
    error(M_DISK_FULL);
  }
 }
 else
 {
  /* HACK for IBM LIBC implementations under 32-bit OS/2 */
  #if SFX_LEVEL>=ARJSFXV&&TARGET==OS2&&(COMPILER==ICC||defined(LIBC))
   int fn=fileno(atstream);

   if(fn<6)
   {
    _setmode(fn, file_type?0x4000:0x8000); /* O_TEXT:O_BINARY */
    cn=write(fn, block, block_len);
   }
   else
    cn=fwrite(block, 1, block_len, atstream);
  #else
   cn=fwrite(block, 1, block_len, atstream);
  #endif
  #if SFX_LEVEL>=ARJSFXV
   if(is_tty(atstream))
    cn=block_len;
  #endif
  if(cn!=block_len)
   error(M_DISK_FULL);
 }
 return(0);
}