[Top][All Lists]

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

Re: [Chicken-users] Memory mapped I/O and CHICKEN ports

From: felix winkelmann
Subject: Re: [Chicken-users] Memory mapped I/O and CHICKEN ports
Date: Mon, 6 Dec 2004 11:47:54 +0100

On Mon, 06 Dec 2004 11:08:59 +0100, Thomas Chust <address@hidden> wrote:
> felix winkelmann wrote:
> > [...]
> > Effectively, just put a 4-byte (on 32-bit platforms) header at the start
> > of the mmapped region and set it to (C_STRING_TYPE | <length>).
> > [...]
> Hello,
> thank you for the tip -- it works fine in a controlled environment. But
> I have one more problem: I cannot map the file to a totally arbitrary
> position in memory (it must be exactly on a page boundary), so how can I
> get the header bytes directly in front of the mapped file?!?

In that case I'd do everything by hand:

___declare(rename, "write;fd_write")
int write(int fd, void *buf, int count);

(use posix)

(define fdin (file-open "input" open/read))
(define size (file-size fdin))
(define mmap (map-file-to-memory #f size prot/read map/private fdin))
(define fdout (file-open "output" (+ open/creat open/write)))
(print (fd_write fdout (memory-mapped-file-pointer mmap) size))
(file-close fdout)

If you want to write out the file with standard display/write/whatever,
then we probably would have to hack the internal printer stuff.


reply via email to

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