mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Added the clib2 shared library initialization/cleanup code.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15006 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lib_user.c,v 1.3 2005-07-04 11:06:21 obarthel Exp $
|
||||
* $Id: lib_user.c,v 1.4 2005-07-04 11:21:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -35,6 +35,10 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#include <dos.h>
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following function is called as part of the library initialization,
|
||||
right after the library is loaded. This function should perform only
|
||||
initialization operations which can be accomplished quickly and without
|
||||
@ -94,13 +98,34 @@ UserLibInit(
|
||||
BOOL
|
||||
UserLibOpen(struct UserData * ud)
|
||||
{
|
||||
BOOL result;
|
||||
BOOL result = FALSE;
|
||||
|
||||
/* For the AmigaOS4 build, invoke the clib2 shared library
|
||||
initialization code. Note that this is not strictly
|
||||
necessary. In fact, you should not need this functionality
|
||||
if you stick to use Amiga operating system routines only
|
||||
and stay away from using 'C' runtime library functions
|
||||
that are not reentrant, such as malloc() or fprintf().
|
||||
Use this feature only if you are porting code to the Amiga
|
||||
which cannot be easily converted to follow the AmigaOS
|
||||
API definitions only. */
|
||||
#if defined(__amigaos4__) && defined(__THREAD_SAFE)
|
||||
{
|
||||
/* Note that the clib2 library initialization is
|
||||
called exactly once, when the first client
|
||||
opens this library. */
|
||||
if(ud->ud_UseCount == 0 && !__lib_init(SysBase))
|
||||
goto out;
|
||||
}
|
||||
#endif /* __amigaos4__ && __THREAD_SAFE */
|
||||
|
||||
/* Remember that one more customer is using this data structure. */
|
||||
ud->ud_UseCount++;
|
||||
|
||||
result = TRUE;
|
||||
|
||||
out:
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
@ -114,6 +139,25 @@ UserLibClose(struct UserData * ud)
|
||||
{
|
||||
/* Remember that one less customer is using this data structure. */
|
||||
ud->ud_UseCount--;
|
||||
|
||||
/* For the AmigaOS4 build, invoke the clib2 shared library
|
||||
cleanup code. Note that this is not strictly
|
||||
necessary. In fact, you should not need this functionality
|
||||
if you stick to use Amiga operating system routines only
|
||||
and stay away from using 'C' runtime library functions
|
||||
that are not reentrant, such as malloc() or fprintf().
|
||||
Use this feature only if you are porting code to the Amiga
|
||||
which cannot be easily converted to follow the AmigaOS
|
||||
API definitions only. */
|
||||
#if defined(__amigaos4__) && defined(__THREAD_SAFE)
|
||||
{
|
||||
/* Note that the clib2 library cleanup code is
|
||||
called exactly once, when the first client
|
||||
opens this library. */
|
||||
if(ud->ud_UseCount == 0)
|
||||
__lib_exit();
|
||||
}
|
||||
#endif /* __amigaos4__ && __THREAD_SAFE */
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user