コード例 #1
0
ファイル: os2msg.c プロジェクト: barak/mit-scheme
void
OS2_open_qid (qid_t qid, tqueue_t * tqueue)
{
  if ((QID_TQUEUE (qid)) != 0)
    OS2_logic_error ("Reopening already open QID.");
  if (tqueue == 0)
    OS2_logic_error ("Null tqueue passed to OS2_open_qid.");
  (QID_TQUEUE (qid)) = tqueue;
}
コード例 #2
0
ファイル: os2msg.c プロジェクト: barak/mit-scheme
static void
process_interrupt_messages (void)
{
  /* Reads all of the interrupts out of the interrupt queue, and sets
     the corresponding bits in the interrupt word.  */
  while (1)
    {
      msg_t * message = (read_subqueue (OS2_interrupt_qid_local));
      if (message == 0)
	break;
      switch (MSG_TYPE (message))
	{
	case mt_console_interrupt:
	  tty_set_next_interrupt_char (SM_CONSOLE_INTERRUPT_CODE (message));
	  break;
	case mt_timer_event:
	  request_timer_interrupt ();
	  break;
	default:
	  OS2_logic_error ("Illegal message type in interrupt queue.");
	  break;
	}
      OS2_destroy_message (message);
    }
}
コード例 #3
0
ファイル: os2msg.c プロジェクト: barak/mit-scheme
msg_t *
OS2_wait_for_message (qid_t qid, msg_type_t reply_type)
{
  msg_t * reply = (OS2_receive_message (qid, 1, 0));
  if (OS2_error_message_p (reply))
    OS2_handle_error_message (reply);
  if ((MSG_TYPE (reply)) != reply_type)
    OS2_logic_error ("Incorrect reply message type.");
  return (reply);
}
コード例 #4
0
ファイル: os2msg.c プロジェクト: barak/mit-scheme
msg_length_t
OS2_message_type_length (msg_type_t type)
{
  msg_length_t length;
  if (type > MSG_TYPE_MAX)
    {
      char buffer [64];
      sprintf (buffer, "Message type %d out of range.", type);
      OS2_logic_error (buffer);
    }
  length = (MESSAGE_LENGTH (type));
  if (length == 0)
    {
      char buffer [64];
      sprintf (buffer, "Message type %d has unknown length.", type);
      OS2_logic_error (buffer);
    }
  return (length);
}
コード例 #5
0
ファイル: os2.c プロジェクト: atupal/mit-scheme
static malloc_header_t *
guarantee_valid_malloc_pointer (void * ptr)
{
  malloc_header_t * header = (((malloc_header_t *) ptr) - 1);
  if ((((char *) header) < ((char *) malloc_object))
      || (((char *) header) > (((char *) malloc_object) + malloc_object_size))
      || ((((ULONG) header) & 7) != 0)
      || ((header -> check) != (((char *) header) - 47)))
    OS2_logic_error ("Bad pointer passed to OS_free.");
  return (header);
}
コード例 #6
0
ファイル: os2.c プロジェクト: atupal/mit-scheme
void
OS_free (void * ptr)
{
  malloc_header_t * header = (guarantee_valid_malloc_pointer (ptr));
  APIRET rc;
  (header -> check) = 0;
  rc = (DosSubFreeMem (malloc_object, header, (header -> size)));
  if (rc != NO_ERROR)
    {
      char buffer [1024];
      sprintf (buffer, "DosSubFreeMem error: %d.", rc);
      OS2_logic_error (buffer);
    }
}
コード例 #7
0
ファイル: os2msg.c プロジェクト: barak/mit-scheme
void
OS2_check_message_length_initializations (void)
{
  unsigned int type = 0;
  while (1)
    {
      if ((MESSAGE_LENGTH (type)) == 0)
	{
	  char buffer [64];
	  sprintf (buffer, "Message type %d not initialized.", type);
	  OS2_logic_error (buffer);
	}
      if (type == MSG_TYPE_MAX)
	break;
      type += 1;
    }
}
コード例 #8
0
ファイル: os2pipe.c プロジェクト: henrylim/henry-work
static void
input_pipe_operator (Tchannel channel, chop_t operation,
		     choparg_t arg1, choparg_t arg2, choparg_t arg3)
{
  switch (operation)
    {
    case chop_read:
      OS2_channel_thread_read_op (channel, arg1, arg2, arg3);
      break;
    case chop_close:
      OS2_channel_thread_close (channel);
      STD_API_CALL (dos_close, (CHANNEL_HANDLE (channel)));
      break;
    default:
      OS2_logic_error ("Unknown operation for input pipe.");
      break;
    }
}
コード例 #9
0
ファイル: os2msg.c プロジェクト: barak/mit-scheme
msg_t *
OS2_create_message_1 (msg_type_t type, msg_length_t extra)
{
  /* Do allocation carefully to prevent infinite loop when signalling
     "out of memory" condition.  */
  msg_t * message =
    (OS2_malloc_noerror (((unsigned long) (OS2_message_type_length (type)))
			 + extra));
  if (message == 0)
    if ((type == mt_syscall_error)
	&& ((SM_SYSCALL_ERROR_CODE (message)) == ERROR_NOT_ENOUGH_MEMORY)
	&& ((SM_SYSCALL_ERROR_NAME (message)) == syscall_malloc))
      OS2_logic_error ("Unable to allocate memory for error message.");
    else
      OS2_error_system_call (ERROR_NOT_ENOUGH_MEMORY, syscall_malloc);
  (MSG_TYPE (message)) = type;
  return (message);
}
コード例 #10
0
ファイル: os2.c プロジェクト: atupal/mit-scheme
void *
OS2_malloc_noerror (unsigned long size)
{
  PVOID result;
  APIRET rc
    = (DosSubAllocMem (malloc_object,
		       (&result),
		       (size + (sizeof (malloc_header_t)))));
  if (rc == ERROR_DOSSUB_NOMEM)
    return (0);
  if (rc != NO_ERROR)
    {
      char buffer [1024];
      sprintf (buffer, "DosSubAllocMem error: %d.", rc);
      OS2_logic_error (buffer);
    }
  (((malloc_header_t *) result) -> check) = (((char *) result) - 47);
  (((malloc_header_t *) result) -> size) = size;
  return (((malloc_header_t *) result) + 1);
}
コード例 #11
0
ファイル: os2msg.c プロジェクト: barak/mit-scheme
static qid_t
allocate_qid (void)
{
  unsigned int qid = 0;
  OS2_request_mutex_semaphore (qid_lock);
  while (1)
    {
      if ((QID_ALLOCATEDP (qid)) == 0)
	break;
      if (qid == QID_MAX)
	OS2_logic_error ("No more QIDs available.");
      qid += 1;
    }
  (QID_ALLOCATEDP (qid)) = 1;
  (QID_TWIN (qid)) = QID_NONE;
  OS2_release_mutex_semaphore (qid_lock);
  (QID_FILTER (qid)) = 0;
  (QID_TQUEUE (qid)) = 0;
  (QID_SUBQUEUE (qid)) = (OS2_create_msg_fifo ());
  if ((QID_LOCK (qid)) == NULLHANDLE)
    (QID_LOCK (qid)) = (OS2_create_mutex_semaphore (0, 0));
  return (qid);
}