Re: [Chicken-users] using mmap files as strings?

2010-10-23 Thread Alan Post
I've summarized this information and created an mmap example on the
wiki:

  http://wiki.call-cc.org/manual/Unit%20posix#memory-mapped-io-example

I'm afraid to ask, for being told to do it myself, but the ability to
edit single docment sections rather than whole documents would be very
nice.

-Alan

On Sat, Oct 23, 2010 at 08:11:20PM -0500, Jim Ursetto wrote:
> On Sat, Oct 23, 2010 at 05:04, Peter Bex  wrote:
> > On Fri, Oct 22, 2010 at 05:58:02PM -0600, Alan Post wrote:
> >> This is excellent, I've learned a lot more about how all of this
> >> works together now.
> >>
> >> What method would I use to convert a pointer and a length to a
> >> string?  Even though I'm copying the memory, how do I do it at
> >> all?
> >
> > Something like this:
> >
> > {
> >  C_word *scheme_string;
> >
> >  scheme_string = C_alloc(C_SIZEOF_STRING(the_length));
> >  C_string(&scheme_string, the_length, the_pointer);
> >  C_kontinue(the_continuation, scheme_string);
> > }
> 
> I think this might be better:
> 
> (let ((to (make-string len))
>  (move-memory! from to len))
> 
> Using your original example,
> 
> (use posix lolevel)
> 
> (let* ((fd (file-open "mmap.scm" (+ open/rdonly open/nonblock)))
>(size (file-size fd))
>(mmap (map-file-to-memory #f size prot/read (+ map/file map/shared) 
> fd))
>(buf  (memory-mapped-file-pointer mmap)))
>   (let* ((len 10)
>   (str (make-string len)))
> (move-memory! buf str len)
> (print str)))
> 
> $ csi -script mmap.scm
> (use posix
> 
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/chicken-users

-- 
.i ko djuno fi le do sevzi

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


Re: [Chicken-users] using mmap files as strings?

2010-10-23 Thread Jim Ursetto
On Sat, Oct 23, 2010 at 05:04, Peter Bex  wrote:
> On Fri, Oct 22, 2010 at 05:58:02PM -0600, Alan Post wrote:
>> This is excellent, I've learned a lot more about how all of this
>> works together now.
>>
>> What method would I use to convert a pointer and a length to a
>> string?  Even though I'm copying the memory, how do I do it at
>> all?
>
> Something like this:
>
> {
>  C_word *scheme_string;
>
>  scheme_string = C_alloc(C_SIZEOF_STRING(the_length));
>  C_string(&scheme_string, the_length, the_pointer);
>  C_kontinue(the_continuation, scheme_string);
> }

I think this might be better:

(let ((to (make-string len))
 (move-memory! from to len))

Using your original example,

(use posix lolevel)

(let* ((fd (file-open "mmap.scm" (+ open/rdonly open/nonblock)))
   (size (file-size fd))
   (mmap (map-file-to-memory #f size prot/read (+ map/file map/shared) fd))
   (buf  (memory-mapped-file-pointer mmap)))
  (let* ((len 10)
  (str (make-string len)))
(move-memory! buf str len)
(print str)))

$ csi -script mmap.scm
(use posix

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


Re: [Chicken-users] Installing data files for eggs

2010-10-23 Thread Felix
From: John Cowan 
Subject: Re: [Chicken-users] Installing data files for eggs
Date: Sat, 23 Oct 2010 14:23:36 -0400

> Felix scripsit:
> 
>> Thanks. This was the information I was looking for.
> 
> You can find all this stuff in the Filesystem Hierarchy Standard version
> 2.3 at .  It applies for
> the most part to both Linux and the BSDs.
> 

Thanks for the link, but I try to avoid reading
standards documents.


cheers,
felix

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


Re: [Chicken-users] Installing data files for eggs

2010-10-23 Thread Alan Post
On Sat, Oct 23, 2010 at 02:23:36PM -0400, John Cowan wrote:
> Felix scripsit:
> 
> > Thanks. This was the information I was looking for.
> 
> You can find all this stuff in the Filesystem Hierarchy Standard version
> 2.3 at .  It applies for
> the most part to both Linux and the BSDs.
> 

The hier(7) man page in (Open|*)BSD is also a good source of
information, for when the fhs doesn't match *BSD practice:

  
http://www.openbsd.org/cgi-bin/man.cgi?query=hier&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html

-Alan
-- 
.i ko djuno fi le do sevzi

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


Re: [Chicken-users] Installing data files for eggs

2010-10-23 Thread John Cowan
Felix scripsit:

> Thanks for the link, but I try to avoid reading
> standards documents.

As standards documents go, the FHS is fairly pain-free; it was
written by geeks, not by standardizers, much like R5RS.

-- 
John Cowanhttp://www.ccil.org/~cowan co...@ccil.org
Uneasy lies the head that wears the Editor's hat! --Eddie Foirbeis Climo

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


Re: [Chicken-users] Installing data files for eggs

2010-10-23 Thread John Cowan
Felix scripsit:

> Thanks. This was the information I was looking for.

You can find all this stuff in the Filesystem Hierarchy Standard version
2.3 at .  It applies for
the most part to both Linux and the BSDs.


-- 
Long-short-short, long-short-short / Dactyls in dimeter, John Cowan
Verse form with choriambs / (Masculine rhyme):   co...@ccil.org
One sentence (two stanzas) / Hexasyllabically
Challenges poets who / Don't have the time. --robison who's at texas dot net

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


Re: [Chicken-users] Installing data files for eggs

2010-10-23 Thread Felix
From: John Cowan 
Subject: Re: [Chicken-users] Installing data files for eggs
Date: Fri, 22 Oct 2010 09:22:30 -0400

> On Fri, Oct 22, 2010 at 6:24 AM, Felix
>  wrote:
> 
>> Well, the question is whether it is allowed on systems that use a
>> strict policy on what directories can be written to on installation
>> (my terminology may be wrong). So on debian systems the egg repository
>> ends up somewhere in /var. What I'd like to know whether the same
>> policy applies to $PREFIX/share, or more precisely: should the data be
>> installed there or in /var ? Installing in the normal repository path
>> ($PREFIX/lib/chicken/$BINVERSION or $PREFIX/var/) is
>> no big deal, and any extension can already install subdirectories
>> by simple putting the directory name in the files-list in
>> `install-extension'.
> 
> The constraint on share directories (or at least on /usr/share and
> /usr/local/share) is that files placed there must be read-only (in
> normal operation, obviously not during installation) and
> architecture-independent.
> 
> For example, /usr/share/dict/words is the current system dictionary,
> which meets both requirements.  Man pages also meet both requirements
> and go in /usr(/local)/share/man (for historical reasons there is a
> symlink at /usr/local/man to /usr/local/share/man).  Preformatted man
> pages in plain text or HTML, being writable, are supposed to go in
> /var/cache/man, but not every distro does this.
> 
> Stuff in /var is intended to be mutated in normal operation, like
> /var/log (syslogs) or /var/mail.  In principle, if /usr and /var are
> different partitions, you can mount /usr read-only except when
> installing software (it can even be shared between homogeneous
> computers using NFS), whereas /var must be mounted read-write and is
> specific to a particular computer.
> 

Thanks. This was the information I was looking for.


cheers,
felix

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


Re: [Chicken-users] using mmap files as strings?

2010-10-23 Thread Peter Bex
On Fri, Oct 22, 2010 at 05:58:02PM -0600, Alan Post wrote:
> This is excellent, I've learned a lot more about how all of this
> works together now.
> 
> What method would I use to convert a pointer and a length to a
> string?  Even though I'm copying the memory, how do I do it at
> all?

Something like this:

{
  C_word *scheme_string;

  scheme_string = C_alloc(C_SIZEOF_STRING(the_length));
  C_string(&scheme_string, the_length, the_pointer);
  C_kontinue(the_continuation, scheme_string);
}

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
-- Donald Knuth

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