guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposed getitimer and setitimer functions


From: Rob Browning
Subject: Re: proposed getitimer and setitimer functions
Date: 29 Jul 2001 16:34:30 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

(Message that postdrop dropped on 09 Jul 2001 11:52:55 -0500.
 Re-sending now.  This msg is mostly irrelevant now...)

Rob Browning <address@hidden> writes:

> Is the following implementation of/interface for setitimer OK?  I
> need to add real docs, but in summary, you call it like this:

OK, the new code uses the POSIX convention (so it throws system-error
on error), and so now there's just one return value for setitimer and
getitimer which is a list of two cons pairs representing the itimerval
result.

I also think I might have fixed the argument checking, though I'm not
using the bignums yet -- until I see what Marius has to say.

Here's setitimer (getitimer's roughly the same):

SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0,
           (SCM which_timer,
            SCM interval_seconds, SCM interval_microseconds,
            SCM value_seconds, SCM value_microseconds),
            "Undocumented yet.")
#define FUNC_NAME s_scm_setitimer
{
  int rv;
  int c_which_timer;
  struct itimerval new_timer;
  struct itimerval old_timer;

  c_which_timer = SCM_NUM2INT(1, which_timer);
  new_timer.it_interval.tv_sec = SCM_NUM2LONG(2, interval_seconds);
  new_timer.it_interval.tv_usec = SCM_NUM2LONG(3, interval_microseconds);
  new_timer.it_value.tv_sec = SCM_NUM2LONG(4, value_seconds);
  new_timer.it_value.tv_usec = SCM_NUM2LONG(5, value_microseconds);

  SCM_SYSCALL(rv = setitimer(c_which_timer, &new_timer, &old_timer));
  
  if(rv != 0)
    SCM_SYSERROR;

  return scm_list_2(scm_cons(scm_long2num(old_timer.it_interval.tv_sec),
                             scm_long2num(old_timer.it_interval.tv_usec)),
                    scm_cons(scm_long2num(old_timer.it_value.tv_sec),
                             scm_long2num(old_timer.it_value.tv_usec)));
}
#undef FUNC_NAME

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD



reply via email to

[Prev in Thread] Current Thread [Next in Thread]