[Chicken-users] Re: endian-port

2010-02-22 Thread Shawn Rutledge
On Mon, Feb 22, 2010 at 7:34 PM, Shawn Rutledge
 wrote:
> Functions like endian_lowio_read_int8 return by value, but
> endian_lowio_read_ieee_float32 set a value into a passed pointer, so
> wonder why that is... anyway seems to be where the problem is.  Maybe
> it's done that way because of NaN?  But usually NaN is a valid value,
> and can be tested for with isnan().

And indeed it seems to work OK if I make those functions return
double, just as the integer ones return ints/longs.  I can still store
a +nan.0 into a file, and read it back successfully.  I regenerated
the swig interface too.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] endian-port

2010-02-22 Thread Shawn Rutledge
On Mon, Feb 22, 2010 at 8:52 PM, Ivan Raikov  wrote:
>   Actually, the endian-blob egg in Chicken 4 is meant to take over the
> functionality of endian-port.

I saw that, but wrapping a port is pretty useful actually, since
endian conversions are usually relevant for I/O.  It's mostly a matter
of keeping some existing code that I wrote a couple years ago working,
but I didn't use floats back then, and have since found a need for
them...

> Your port of endian-port would probably
> have to rely on the wrappers generated by swig, which are not especially
> readable or maintainable. Unfortunately, I don't have Chicken 3
> installed anymore, so I cannot help with this particular problem, but
> take a look at endian-blob and let me know if it would be suitable for
> your needs.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] endian-port

2010-02-22 Thread Ivan Raikov

Hello,


   Actually, the endian-blob egg in Chicken 4 is meant to take over the
functionality of endian-port. Your port of endian-port would probably
have to rely on the wrappers generated by swig, which are not especially
readable or maintainable. Unfortunately, I don't have Chicken 3
installed anymore, so I cannot help with this particular problem, but
take a look at endian-blob and let me know if it would be suitable for
your needs. 


   -Ivan


Shawn Rutledge  writes:

> I'm having trouble reading back a float from a file that I just wrote:
>
> (use endian-port)
>
> (let ([outp (port->endian-port (open-output-file "eptest"))])
>   (endian-port-write-ieee-float32 outp 5.25)
>   (close-endian-port outp))
>
> (let ([inp (port->endian-port (open-input-file "eptest"))])
>   (print (endian-port-read-ieee-float32 inp))
>   (close-endian-port inp))
>
> it returns #f.
>
> This was with chicken 3, but I managed to compile that egg for chicken
> 4 as well, and it acts the same:
>
> /usr/bin/csc -feature compiling-extension -setup-mode   -O2 -d0 -s -o
> endian-port.so endian-port.scm endian_lowio_wrap.c endian_lowio_lib.c
> floatformat.c endian_lowio.scm -lchicken -ldl -lm
>
> #;1> (load "endian-port.so")
> ; loading endian-port.so ...
> ; loading /usr/lib64/chicken/4/iset.so ...
>
> so apparently porting that egg is going to be fairly trivial.  Maybe
> I'll give it a shot if someone will create the directory under
> release/4?
>
>
> Functions like endian_lowio_read_int8 return by value, but
> endian_lowio_read_ieee_float32 set a value into a passed pointer, so
> wonder why that is... anyway seems to be where the problem is.  Maybe
> it's done that way because of NaN?  But usually NaN is a valid value,
> and can be tested for with isnan().


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] endian-port

2010-02-22 Thread Shawn Rutledge
I'm having trouble reading back a float from a file that I just wrote:

(use endian-port)

(let ([outp (port->endian-port (open-output-file "eptest"))])
(endian-port-write-ieee-float32 outp 5.25)
(close-endian-port outp))

(let ([inp (port->endian-port (open-input-file "eptest"))])
(print (endian-port-read-ieee-float32 inp))
(close-endian-port inp))

it returns #f.

This was with chicken 3, but I managed to compile that egg for chicken
4 as well, and it acts the same:

/usr/bin/csc -feature compiling-extension -setup-mode   -O2 -d0 -s -o
endian-port.so endian-port.scm endian_lowio_wrap.c endian_lowio_lib.c
floatformat.c endian_lowio.scm -lchicken -ldl -lm

#;1> (load "endian-port.so")
; loading endian-port.so ...
; loading /usr/lib64/chicken/4/iset.so ...

so apparently porting that egg is going to be fairly trivial.  Maybe
I'll give it a shot if someone will create the directory under
release/4?


Functions like endian_lowio_read_int8 return by value, but
endian_lowio_read_ieee_float32 set a value into a passed pointer, so
wonder why that is... anyway seems to be where the problem is.  Maybe
it's done that way because of NaN?  But usually NaN is a valid value,
and can be tested for with isnan().


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users