Пример #1
0
void
OS2_request_mutex_semaphore (HMTX s)
{
  while (1)
    {
      APIRET rc = (dos_request_mutex_sem (s, SEM_INDEFINITE_WAIT));
      if (rc == NO_ERROR)
	break;
      /* This return code has been regularly occurring on my machine.
	 On one occurrence, I proceeded past the error in the
	 debugger, and the program continued working without errors.
	 However, more recently proceeding past this error has caused
	 a subsequent error when unlocking the semaphore because the
	 lock didn't succeed.  IBM tech support is mystified because
	 this code appears nowhere in their sources.  */
      if (rc == 3000)
	{
	  PID pid;
	  TID tid;
	  ULONG count;
	  DosQueryMutexSem (s, (&pid), (&tid), (&count));
	  if ((count > 0) && (tid == (OS2_current_tid ())))
	    break;
	}
      else if (rc != ERROR_INTERRUPT)
	OS2_error_system_call (rc, syscall_dos_request_mutex_sem);
    }
}
Пример #2
0
void *
OS_realloc (void * ptr, size_t size)
{
  void * result = (OS2_realloc_noerror (ptr, size));
  if (result == 0)
    OS2_error_system_call (ERROR_NOT_ENOUGH_MEMORY, syscall_realloc);
  return (result);
}
Пример #3
0
static ULONG
set_file_pointer (Tchannel channel, ULONG type, LONG distance)
{
  ULONG fp;
  if ((CHANNEL_TYPE (channel)) != channel_type_file)
    OS2_error_system_call (ERROR_INVALID_HANDLE, syscall_dos_set_file_ptr);
  STD_API_CALL
    (dos_set_file_ptr, ((CHANNEL_HANDLE (channel)), distance, type, (&fp)));
  return (fp);
}
Пример #4
0
off_t
OS_file_length (Tchannel channel)
{
  FILESTATUS3 buffer;
  if ((CHANNEL_TYPE (channel)) != channel_type_file)
    OS2_error_system_call (ERROR_INVALID_HANDLE, syscall_dos_query_file_info);
  STD_API_CALL
    (dos_query_file_info,
     ((CHANNEL_HANDLE (channel)), FIL_STANDARD,
      (&buffer), (sizeof (buffer))));
  return (buffer.cbFile);
}
Пример #5
0
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);
}