std library hooks

Manu turkeyman at gmail.com
Fri Apr 13 03:47:19 PDT 2012


No comment...

I'm also finding that I really need an assert hook. The default assert
implementation is not useful to me, and just crashes my programs
(exceptions when interacting with C is problematic).
I'd like to route runtime asserts through my own system. A simple backend
hook would sort me out here too..

Does anyone know any existing way to do the stuff I'm talking about here?
If not, what do people think about the possibility of putting hook register
functions into druntime?

On 9 April 2012 03:59, Manu <turkeyman at gmail.com> wrote:

> So one thing that almost every major middleware provides, is an interface
> to hook your own allocation and filesystem callbacks under the hood, to
> allow integration with your potentially complex technology.
>
> In my industry, memory and filesystem hooks are non-negotiable. We can't
> use any middleware that does not provide them.
> Traditionally, we have a problem with the C library, and many core C libs
> which depend heavily on the CRT. Almost all games engines have to
> wastefully rewrite large portions of the CRT, just to implement the
> appropriate memory and filesystem interface, and some super handy common
> libs are lost to us due to lack of this foresight.
>
> So this in mind, many of the goodies in phobos are currently unusable to
> us (although fortunately source is available).
> Has it ever been considered to allow hooks into the backends of those
> systems which could be registered at runtime?
> It would be simple to provide an API where you could register the
> filesystem primitives, which all standard libraries would then magically
> route through (huzzah!).
> A primitive malloc/free hook would be nice to have too, that way we can
> direct memory to the appropriate locations, and keep mem stats along with
> the the rest of the system.
> It's not uncommon to malloc the entire heap on boot, and implement our own
> heap management through our own API's. Obviously system functions would
> fail to allocate memory in this environment...
>
> Having these hooks in phobos would also lift this burden off of library
> developers (usually only added on request with a few months turn around
> time, which is no good for project scheduling), and it would never prevent
> us access to those libraries where the developers never considered our use
> case.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120413/0e39ddd4/attachment-0001.html>


More information about the Digitalmars-d mailing list