groff
[Top][All Lists]
Advanced

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

Re: [Groff] still exploring the last version: what is gremlin ?


From: Ralph Corderoy
Subject: Re: [Groff] still exploring the last version: what is gremlin ?
Date: Fri, 06 Oct 2000 21:23:02 +0100

Hi,

> > I just discovered that a change made in main.c for xgremlin-2.0
> > in line 592:
> > 
> >   readmask = ConnectionNumber(display);/*1 << display->fd;*/ 
> > 
> > slows down the program VERY much, so I went back to the old line,
> > that is:
> > 
> >               readmask = 1 << display->fd;
> 
> ...according to the various man pages, using ConnectionNumber() seems
> the right thing to do to be portable.  Can someone comment this
> please?

ConnectionNumber() is the way to get the display's file descriptor.  It
is traditionally just a macro in Xlib.h that gives `display->fd' but
the macro is meant to be used instead.  There's also a function
equivalent, XConnectionNumber().

    % g ConnectionNumber /usr/include/X11/Xlib.h
    #define ConnectionNumber(dpy)   (((_XPrivDisplay)dpy)->fd)
    extern int XConnectionNumber(
    extern Status XInternalConnectionNumbers(

The problem here is ConnectionNumber() and display->fd give a file
descriptor.  readmask presumably needs a mask, hence `1 <<
display->fd'.  If ConnectionNumber() is used then the bitwise shift is
still required to create a mask.

    readmask = 1 << ConnectionNumber(display);

Since display->fd is probably something with a few bits set the
checking of what bits select(2) or something else has left set is
probably taking the extra time.


Ralph.


reply via email to

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