scsh-users
[Top] [All Lists]

Re: start-threads and db/dbm package for 0.4

To: scsh@martigny.ai.mit.edu
Subject: Re: start-threads and db/dbm package for 0.4
From: shivers@ai.mit.edu (Olin Shivers)
Date: 10 Jan 1996 21:20:01 -0500
Organization: Artificial Intelligence Lab, MIT
Reply-to: shivers@ai.mit.edu
Wow!

   This generates gcc-unfriendly braindamage in the .c file,
   so that has to be changed:

   scheme_value df_dbm_close(long nargs, scheme_value *args)
   {
       extern void dbm_close(DBM* );
       scheme_value ret1;
       long r1;

       cig_check_nargs(2, nargs, "dbm_close");
       dbm_close((DBM* )AlienVal(args[1]));
       r1=0;
       ret1 = VECTOR_REF(*args,0);
       AlienVal(ret1) = (long) r1;
       return ret1;
       }

   the changes here involved changing "void r1;" and 
   getting rid of "r1=" from in front of the call to
   dbm_close function, and adding in "r1=0" afterwards.

Actually, you would be better to just completely punt r1:

   scheme_value df_dbm_close(long nargs, scheme_value *args)
   {
       extern void dbm_close(DBM* );
       scheme_value ret1;

       cig_check_nargs(2, nargs, "dbm_close");
       dbm_close((DBM* )AlienVal(args[1]));
       ret1 = VECTOR_REF(*args,0);
       AlienVal(ret1) = 0;
       return ret1;
       }

The problem here is that I didn't design cig to generate foreign-function
calls that return no value at all. I should fix this.

   A check for errno or something to adjust the return
   value might be wise, but this was quicker.

Yes, that is the better fix.
        -Olin

<Prev in Thread] Current Thread [Next in Thread>