Example #1
0
static SLCONST char *intrin_errno_string (void)
{
    int e;
    if (SLang_Num_Function_Args == 0)
        return SLerrno_strerror (_pSLerrno_errno);
    if (-1 == SLang_pop_int (&e))
        return NULL;
    return SLerrno_strerror (e);
}
Example #2
0
static void pipe_intrin (void)
{
   int fds[2];
   SLFile_FD_Type *f0;
   SLFile_FD_Type *f1;

   while (-1 == pipe (fds))
     {
	if (errno == EINTR)
	  {
	     if (-1 != SLang_handle_interrupt ())
	       continue;
	  }
	SLerrno_set_errno (errno);
	SLang_verror (SL_OS_Error, "pipe failed: %s", SLerrno_strerror(errno));
	return;
     }
   
   f0 = SLfile_create_fd ("*pipe*", fds[0]);
   f1 = SLfile_create_fd ("*pipe*", fds[1]);
   if ((NULL != f0) && (NULL != f1))
     {
	/* Ignore errors and allow the free_fd routines to clean up */
	(void) SLfile_push_fd (f0);
	(void) SLfile_push_fd (f1);
     }
   SLfile_free_fd (f1);
   SLfile_free_fd (f0);
}
Example #3
0
static void getitimer_intrinsic (int *wp)
{
   struct itimerval it;

   if (-1 == getitimer (*wp, &it))
     {
	SLerrno_set_errno (errno);
	SLang_verror (SL_OS_Error, "getitimer failed: %s", SLerrno_strerror (errno));
	return;
     }
   (void) SLang_push_double (timeval_to_double (&it.it_value));
   (void) SLang_push_double (timeval_to_double (&it.it_interval));
}
Example #4
0
static void setitimer_intrinsic (void)
{
   SLang_Ref_Type *interval_ref = NULL, *value_ref = NULL;
   int w;
   struct itimerval new_value, old_value;
   double interval = 0.0, value;
   int argc = SLang_Num_Function_Args;

   if (SLang_peek_at_stack () == SLANG_REF_TYPE)
     {
	if (-1 == SLang_pop_ref (&value_ref))
	  return;
	argc--;
	if (SLang_peek_at_stack() == SLANG_REF_TYPE)
	  {
	     interval_ref = value_ref;
	     if (-1 == SLang_pop_ref (&value_ref))
	       goto free_and_return;
	     argc--;
	  }
     }

   switch (argc)
     {
      case 3:
	if (-1 == SLang_pop_double (&interval))
	  goto free_and_return;
	/* drop */
      case 2:
      default:
	if ((-1 == SLang_pop_double (&value))
	    || (-1 == SLang_pop_int (&w)))
	  goto free_and_return;
     }

   double_to_timeval (interval, &new_value.it_interval);
   double_to_timeval (value, &new_value.it_value);

   if (-1 == setitimer (w, &new_value, &old_value))
     {
	SLerrno_set_errno (errno);
	SLang_verror (SL_OS_Error, "setitimer failed: %s", SLerrno_strerror (errno));
	goto free_and_return;
     }

   if (value_ref != NULL)
     {
	value = timeval_to_double (&old_value.it_value);
	if (-1 == SLang_assign_to_ref (value_ref, SLANG_DOUBLE_TYPE, &value))
	  goto free_and_return;
     }
   if (interval_ref != NULL)
     {
	interval = timeval_to_double (&old_value.it_interval);
	if (-1 == SLang_assign_to_ref (interval_ref, SLANG_DOUBLE_TYPE, &interval))
	  goto free_and_return;
     }

free_and_return:
   if (value_ref != NULL)
     SLang_free_ref (value_ref);
   if (interval_ref != NULL)
     SLang_free_ref (interval_ref);
}
Example #5
0
static void throw_errno_error (SLFUTURE_CONST char *what, int e)
{
   SLerrno_set_errno (e);
   SLang_verror (SocketError, "%s: %s", what, SLerrno_strerror (e));
}