Subject: Re: Problem with libc.so.12.2
To: J.T. Conklin <jconklin@netcom.com>
From: Bernd Ernesti <netbsd@arresum.inka.de>
List: current-users
Date: 04/01/1995 01:04:09
Hi,

> > after I updated my libc from 12.1 to 12.2 I got a problem that it is no more
> > possible to start my Xserver (the screen swiched to X, but it stops before I
> > get the grayscaled background) for my Picasso (Amiga), a friend has the same
> > problem with the new generic Xserver, but when I use the old libc I can work
> > again with that Xserver.
> 
> Hmm.  The changes between 12.1 and 12.2 were simply the addition of
> qabs and qdiv; a change of the type fgets()'s second argument from
> size_t to int; and posibly a change to vfprintf to handle
> %ll[d,i,o,u,x] for long long integers.
> 
> I don't know how any these changes could cause the problems you are 
> encountering.

I think the same, BUT you forget one change:

mycroft
Tue Mar 21 08:50:33 EST 1995
Update of /a/cvsroot/src/lib/libc/gen
In directory pain.lcs.mit.edu:/b/tmp/cvs-serv21590

Modified Files:
        usleep.c 
Log Message:
Clone from sleep(), with the logic for returning a value removed.


And I am 99% sure that this is the problem. I made a ktrace of the Xserver
(the last one was only from xinit :() and now I get this:

[..]
   489 Xcl      CALL  gettimeofday(0xdfffbc4,0)
   489 Xcl      RET   gettimeofday 0
   489 Xcl      CALL  gettimeofday(0xdfffba8,0)
   489 Xcl      RET   gettimeofday 0
   489 Xcl      CALL  sigaction(0x17,0xdfffbb4,0xdfffba8)
   489 Xcl      RET   sigaction 0
   489 Xcl      CALL  fcntl(0,0x4,0x44)
   489 Xcl      RET   fcntl 0
   489 Xcl      CALL  getpid
   489 Xcl      RET   getpid 489/0x1e9
   489 Xcl      CALL  fcntl(0,0x6,0x1e9)
   489 Xcl      RET   fcntl 0
   489 Xcl      CALL  fcntl(0x1,0x4,0x44)
   489 Xcl      RET   fcntl 0
   489 Xcl      CALL  getpid
   489 Xcl      RET   getpid 489/0x1e9
   489 Xcl      CALL  fcntl(0x1,0x6,0x1e9)
   489 Xcl      RET   fcntl 0
   489 Xcl      CALL  break(0x1c7ffc)
   489 Xcl      RET   break 0
   489 Xcl      CALL  sigprocmask(0x1,0xffffffff)
   489 Xcl      RET   sigprocmask 0
   489 Xcl      CALL  gettimeofday(0xdffdb68,0)
   489 Xcl      RET   gettimeofday 0
   489 Xcl      CALL  sigprocmask(0x1,0x2000)
   489 Xcl      RET   sigprocmask -65793/0xfffefeff
   489 Xcl      CALL  sigaction(0xe,0xdffdb18,0xdffdb0c)
   489 Xcl      RET   sigaction 0
   489 Xcl      CALL  setitimer(0,0xdffdb34,0xdffdb24)
   489 Xcl      RET   setitimer 0
   489 Xcl      CALL  sigsuspend(0xfffefeff)

And this is the corresponding source part:

#define X_GETTIMEOFDAY(tv) (gettimeofday((tv),0))
#define TVTOMILLI(tv)   (((tv).tv_usec/1000)+((tv).tv_sec*1000)
#define tvminus(tv, tv1, tv2)   /* tv = tv1 - tv2 */ \
                if ((tv1).tv_usec < (tv2).tv_usec) { \
                    (tv1).tv_usec += 1000000; \
                    (tv1).tv_sec -= 1; \
                } \
                (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
                (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;

void amigaKbdWait() 
{
    static struct timeval lastChngKbdTransTv;
    struct timeval tv;
    struct timeval lastChngKbdDeltaTv;
    unsigned int lastChngKbdDelta;

    X_GETTIMEOFDAY(&tv);
    if (!lastChngKbdTransTv.tv_sec)
        lastChngKbdTransTv = tv;
    tvminus(lastChngKbdDeltaTv, tv, lastChngKbdTransTv);
    lastChngKbdDelta = TVTOMILLI(lastChngKbdDeltaTv);
    if (lastChngKbdDelta < 750) {
        unsigned wait;
        /*
         * We need to guarantee at least 750 milliseconds between
         * calls to KIOCTRANS. YUCK!
         */
        wait = (750L - lastChngKbdDelta) * 1000L; 
        usleep (wait); 
        X_GETTIMEOFDAY(&tv);
    } 
    lastChngKbdTransTv = tv;
}


Thats the same as it is in xc/programs/Xserver/sun/sunKbd.c only sunKbdWait is
changed to amigaKbdWait.

Bernd