lua-users home
lua-l archive

Re: Pooling of strings is good

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


On Wed, Aug 27, 2014 at 05:58:36PM -0400, Sean Conner wrote:
> It was thus said that the Great Coroutines once stated:
> > On Sat, Aug 23, 2014 at 12:47 AM, Coroutines <coroutines@gmail.com> wrote:
> > 
> > > My bad, I thought I read static :\ Stack overflows are fun... :p I
> > > was just thinking offhandedly that you could create a mmap, expose it
> > > to Lua as a file to read and write from -- and pass it to the
> > > networking lib as the buffer to recv into. Hmm. And it could be
> > > shared depending on the threading setup -- but that's an afterthought.
> > 
> > Hmm. This is another tangent -- mostly talking to Sean here. 
> 
> I'm stil here.
> 
> > I was off-base when I said mmap() -- I haven't used mmap() often and for
> > some reason I thought I could take a [page-sized] block of memory and get
> > an fd from it. WRONG. I was really thinking of shm_open().
> 
> shm_open() doesn't do what you think it does. 
> 
> 	int shm_open(const char *name, int oflag, mode_t mode);
> 
> That "name" there is the name of a file; if the name doesn't exist, a file
> is created with that name (and I'm checking the man pages of three different
> systems here). 
> 
> No, what you want is open_memstream(). It's a POSIX function, so it'll
> exist on Linux and Mac. I don't know what you would do under Windows, but I
> would double check the documentation for CreateFileMapping() to make sure it
> does what you think it does.
OS X doesn't have open_memstream. fmemopen and open_memstream were added to
POSIX.1-2008, but OS X is only nominally compliant to POSIX.1-2001**, and
supports very few newer interfaces.
See my other post elsethread regarding fopencookie and funopen.
** I say nominally because OS X doesn't actually implement some interfaces,
such as pselect (POSIX.1-2001), according to the specification. The Open
Group's conformance testing is broken.

AltStyle によって変換されたページ (->オリジナル) /