FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inter-library interface

 
Post new topic   Reply to topic     Forum Index -> Ares
View previous topic :: View next topic  
Author Message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Thu Feb 23, 2006 3:23 am    Post subject: Inter-library interface Reply with quote

I haven't gotten around to writing an official doc, but here's a quick summary of how Ares works internally.

The Ares distribution is made up of three logically separate libraries: the compiler runtime (dmdrt), the garbage collector (dmdgc), and the standard library (ares). Each of these libraries are required to expose a set of functions for use by the other libraries or by user code. These functions are as follows:

The runtime is currently not required to expose any functionality. This will likely change before too terribly long.

The garbage collector must expose these functions:
Code:
    extern (C) void gc_init();
    extern (C) void gc_term();

    extern (C) void gc_setFinalizer( void *p );

    extern (C) void gc_enable();
    extern (C) void gc_disable();
    extern (C) void gc_collect();

    extern (C) void* gc_malloc( size_t sz, bool df = false );
    extern (C) void* gc_calloc( size_t sz, bool df = false );
    extern (C) void* gc_realloc( void* p, size_t sz, bool df = false );
    extern (C) void gc_free( void* p );

    extern (C) size_t gc_sizeOf( void* p );
    extern (C) size_t gc_capacityOf( void* p );

    extern (C) void gc_addRoot( void* p );
    extern (C) void gc_addRange( void* pbeg, void* pend );

    extern (C) void gc_removeRoot( void* p );
    extern (C) void gc_removeRange( void* pbeg, void* pend );

    extern (C) void gc_pin( void* p );
    extern (C) void gc_unpin( void* p );

The standard library must expose these functions:
Code:
    extern (C) bool onCollectResource( Object obj );
    extern (C) void onArrayBoundsError( char[] file, size_t line );
    extern (C) void onAssertError( char[] file, uint line );
    extern (C) void onAssertErrorMsg( char[] file, uint line, char[] msg );
    extern (C) void onFinalizeError( ClassInfo info, Exception ex );
    extern (C) void onOutOfMemoryError();
    extern (C) void onSwitchError( char[] file, size_t line );
    extern (C) void onUnicodeError( char[] msg, size_t idx );

    extern (C) void thread_init();
    extern (C) bit  thread_needLock();
    extern (C) void thread_suspendAll();
    extern (C) void thread_resumeAll();
    extern (C) void thread_scanAll( void delegate( void*, void* ) fn, void* curStackTop = null );

And the compiler runtime must expose these functions:
Code:
    extern (C) void cr_finalize( void* p, bool det = true );

To replace any of the three libraries, it should only be necessary to define the appropriate functions as listed above.


Last edited by sean on Mon Jun 05, 2006 5:44 pm; edited 3 times in total
Back to top
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Fri Mar 03, 2006 2:55 pm    Post subject: Reply with quote

As of next release, "onInvalidUtfError" will be renamed to "onUnicodeError," and "InvalidUtfException" will be renamed to "UnicodeException."
Back to top
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Wed Mar 08, 2006 1:23 am    Post subject: Reply with quote

The new release is out and includes changes to functionality exposed by std.thread. The function list above has been edited to include these updates.
Back to top
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Wed Apr 12, 2006 4:49 pm    Post subject: Reply with quote

The declarations for the following functions have changed in 0.19:

gc_malloc
gc_calloc
gc_realloc

And a new function has been added:

cr_finalize
Back to top
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Mon Jun 05, 2006 5:46 pm    Post subject: Reply with quote

Added new standard library calls. These changes go back a few releases--I'd forgotten about this thread.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Ares All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group