scsh-users
[Top] [All Lists]

external interface in scsh 0.5.1 in Solaris 2.5.1

To: scsh-news@martigny.ai.mit.edu
Subject: external interface in scsh 0.5.1 in Solaris 2.5.1
From: Kumar Balachandran <kumar*xspam*@*xspam*rtp.ericsson.se>
Date: 09 Jun 1998 11:46:43 -0400
Organization: Ericsson Inc., RTP, NC
Resent-to: scsh-list@martigny.ai.mit.edu
--Multipart_Tue_Jun__9_11:46:43_1998-1
Content-Type: text/plain; charset=US-ASCII


I tried executing the external call example in external.txt with
scsh0.5.1. It took rebuilding scsh because configure creates a
sysdep.h in the source root with HAVE_DLOPEN defined, but undefines it 
in src/scsh/machine/sysdep.h.  To cut a long story short, the example
works as defined 
        > (external-call test "yow" 3)
        "yow"
        3
        #t
        > 
I then modified the file interface.c as follows:

--Multipart_Tue_Jun__9_11:46:43_1998-1
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="interface.c"
Content-Transfer-Encoding: 7bit

#include "/apps/public/src/scheme/scsh-0.5.1/scheme48.h"
#include <stdio.h>

scheme_value interface (long argc, scheme_value *argv)
{
    int i; 
    for (i = argc-1; i >= 0; i--) {
        scheme_value arg = argv[i];
        if (STRINGP(arg)) {
            printf ("string: ");
            fwrite(&STRING_REF(arg, 0), 1, STRING_LENGTH(arg), stdout);
            printf ("\n");
        }
        else if (FIXNUMP(arg)) {
            printf("fixnum: %d\n", EXTRACT_FIXNUM(arg));
        }
        else if (VECTORP(arg)) {
            int count;
            printf("STOB_TAG: %ld\n", ((long)(VECTOR_REF(arg,0)) & 3L));
            printf("STOB_TYPE: %ld\n", STOB_TYPE(VECTOR_REF(arg,0)));
            
            printf("vector: #( ");
            for (count = 0; count < VECTOR_LENGTH(arg); ++count)
                printf("%5.3f  ", ((ADDRESS_AFTER_HEADER(arg, float))[count]));
            printf (")\n");
        }
        else{
            printf("STOB_TYPE: %ld\n", STOB_TYPE(arg));
            printf("?\n");
        }
    }
    return SCHTRUE;
}


--Multipart_Tue_Jun__9_11:46:43_1998-1
Content-Type: text/plain; charset=US-ASCII


        The above file was then run within scsh using
Scsh 0.5
> (define dynamic-load (get-external "s48_dynamic_load"))
> (external-call dynamic-load (null-terminate "./interface.so"))
#t
> (define test (get-external "interface"))
> (external-call test "yow" 3 3.0e0 '#(1.0 2.0))
 string: yow
fixnum: 3
STOB_TYPE: 9
?
STOB_TAG: 3
STOB_TYPE: 9
vector: #( 0.000  0.000  )
#t
>

I was trying to retrieve the elements of a floating point
vector. Since there is no FLOAT_TYPE defined in scheme48.h, and DOUBLE 
does not seem to be  used, the vector elements produced seem to be of
type EXTENDED_NUMBER. How do I map the data to a float? 

-- Kumar

--Multipart_Tue_Jun__9_11:46:43_1998-1--

<Prev in Thread] Current Thread [Next in Thread>
  • external interface in scsh 0.5.1 in Solaris 2.5.1, Kumar Balachandran <=