gcl-devel
[Top][All Lists]
Advanced

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

Re: [Gcl-devel] Re: Server sockets with GCL?


From: Jeff Dalton
Subject: Re: [Gcl-devel] Re: Server sockets with GCL?
Date: Thu, 06 May 2004 00:21:55 +0100 (BST)
User-agent: IMP/PHP IMAP webmail program 2.2.8

Quoting Chris Hall <address@hidden>:

> I found an 'accept-socket-connection' in the GCL Tk support code, for
> use with the GCL Tk server, apparently.  Camm has mentioned though,
> that TK-oriented socket C code seems to expecting magic numbers in the
> packet headers - whatever that mean, I haven't gotten that far with
> C sockets yet.

I asked the local socket expert, and it means nothing to him

He thinks the magic numbers must be something specific to
whatever GCL is doing when communicating with Tk.

Anyway, it's sounding like the socket code that's already in GCL
isn't sufficient for the server side.

> > BTW, is there any documentation for the GCL C interface.
> > My copy of the KCL manual was destroyed in a fire, and I
> > couldn't find anything on-line.
> 
> As for 'official' docs, in gcl-si.info (gcl-si.info-4, to be precise),
> I found:

Where is that?  

I'm looking at

   http://savannah.gnu.org/cgi-bin/viewcvs/gcl/gcl/

and there's an "info" dir.  File "info/internal.texi" contains
some information, but not enough.

>   * DEFENTRY - appears to be the GCL eqivalent of the FFI?  A way to
>     call C routines from Lisp.  Minimal example, I haven't tried it
>     (yet!), but it looks sufficient from here.

Yes, it defines a Lisp function that calls a C one.

>   * DEFCFUN - the reverse of DEFENTRY, apparently.  Allows calling GCL
>     Lisp functions from C.  Minimal example, haven't tried.

It lets you mix Lisp and C.

>   * CLINES - embed line(s) of C in an GCL function.  Inline C?  The
>     hacker in me immediately thinks "And if the C compiler on your
>     system supports inline assembler . . ." :-D
> 
> This may be enough to get me started, at least.

There used to be examples somewhere that used the following macro:

(eval-when (eval compile)
  (set-macro-character #\% 
    #'(lambda (s c) (declare (ignore c)) (values (read-line s)))))

I then used it in my code that used the C interface.

For example, the following sometimes very useful fn:

;;; (WAITPID-NO-HANG pid) returns (pid . status) or (0 . ?) if the
;;; status is not yet available.  Errors of various sorts, including
;;; signals to the calling process, result in (-1 . errno).  To deal
;;; with the signal case, we should check whether errno = EINTR.

(Clines

%#      include <sys/wait.h>

%       static object zwaitpid_no_hang(zpid)
%       object zpid;
%       {
%           int status = -1, pid;
%           object result;
%           extern int errno;
%
%           check_arg(1);

%           pid = waitpid(fix(zpid), &status, WNOHANG);

%           result = make_cons(Cnil, Cnil);
%           vs_push(result);
%           result->c.c_car = make_fixnum(pid);
%           result->c.c_cdr = make_fixnum(pid != -1 ? status : errno);
%           return(vs_pop);
%       }

)

(defentry waitpid-no-hang (object) (object zwaitpid_no_hang))

For some reason, I put "z" in front of names to avoid
conflicts.  Any convention would do.

Anyway, the documentation needs to cover such things as
vs_push (if it still exists).

-- Jeff




reply via email to

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