Re: Verrazano/CFFI R.I.P.?



In article <7cktf.23536$GW1.21401@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
Kenny Tilton <NOktiltonSPAM@xxxxxxxxxx> wrote:
> My subject was indeed in jest. I just want to get the bulk of 23kloc of
> C reasonably "re-typed" as CL, so foo(x,y,z); becomes (foo x y z)
> without pushing my carpal tunnel syndrome over the edge.

If this is what you want the parser I'm working on already produces
mostly lispish-looking code for function bodies - where it really falls
down on right now is declarations, as they are so screwy in C.

For example (declarations replaced with ... for brevity):

long sys_times(struct tms * tbuf)
{
if (tbuf) {
struct tms tmp;
struct task_struct *tsk = current;
struct task_struct *t;
int utime, stime, cutime, cstime;

read_lock(&tasklist_lock);
utime = tsk->signal->utime;
stime = tsk->signal->stime;
t = tsk;
do {
utime = cputime_add(utime, t->utime);
stime = cputime_add(stime, t->stime);
t = next_thread(t);
} while (t != tsk);

spin_lock_irq(&tsk->sighand->siglock);
cutime = tsk->signal->cutime;
cstime = tsk->signal->cstime;
spin_unlock_irq(&tsk->sighand->siglock);
read_unlock(&tasklist_lock);

tmp.tms_utime = cputime_to_clock_t(utime);
tmp.tms_stime = cputime_to_clock_t(stime);
tmp.tms_cutime = cputime_to_clock_t(cutime);
tmp.tms_cstime = cputime_to_clock_t(cstime);
if (copy_to_user(tbuf, &tmp, sizeof(struct tms)))
return -EFAULT;
}
return (long) jiffies_64_to_clock_t(get_jiffies_64());
}

((DEFUN (...)
(PROGN
(IF tbuf
(LET (...)
(read_lock (REF tasklist_lock))
(SETF utime (ELT-> (ELT-> tsk signal) utime))
(SETF stime (ELT-> (ELT-> tsk signal) stime))
(SETF t tsk)
(DO-WHILE
(PROGN
(SETF utime (cputime_add utime (ELT-> t utime)))
(SETF stime (cputime_add stime (ELT-> t stime)))
(SETF t (next_thread t)))
(!= t tsk))
(spin_lock_irq
(REF (ELT-> (ELT-> tsk sighand) siglock)))
(SETF cutime (ELT-> (ELT-> tsk signal) cutime))
(SETF cstime (ELT-> (ELT-> tsk signal) cstime))
(spin_unlock_irq
(REF (ELT-> (ELT-> tsk sighand) siglock)))
(read_unlock (REF tasklist_lock))
(SETF (ELT. tmp tms_utime) (cputime_to_clock_t utime))
(SETF (ELT. tmp tms_stime) (cputime_to_clock_t stime))
(SETF (ELT. tmp tms_cutime) (cputime_to_clock_t cutime))
(SETF (ELT. tmp tms_cstime) (cputime_to_clock_t cstime))
(IF (copy_to_user
tbuf
(REF tmp)
(SIZEOF-TYPE ((STRUCT tms))))
(RETURN (- EFAULT)))))
(RETURN (CAST
(jiffies_64_to_clock_t (get_jiffies_64))
(long))))))

Still a lot of work to do to understand declarations usefully...

-bcd
--
*** Brian Downing <bdowning at lavos dot net>
.