/*---------------------------------------------------------------------------*
  Project:  NitroSDK - FS - libraries
  File:     mw_dtor.h

  Copyright 2003-2004 Nintendo.  All rights reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law.  They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Log: mw_dtor.h,v $
  Revision 1.1  2004/07/08 13:40:41  yosizaki
  (none)

  $NoKeywords: $
 *---------------------------------------------------------------------------*/


#if	!defined(NITRO_FS_MW_DTOR_H_)
#define NITRO_FS_MW_DTOR_H_

#include <nitro/misc.h>
#include <nitro/types.h>


/* CodeWarrior compiler global destructor chained operation */


#ifdef __cplusplus
extern "C" {
#endif

/********************************************************************/

/*
 * Destructor callback.
 * The first argument is an object pointer equivalent to "this".
 */
typedef	void	(*MWI_DESTRUCTOR_FUNC)(void*);

/*
 * Destructor chain.
 * One available for each global object.
 */
typedef	struct	MWiDestructorChain
{
	struct	MWiDestructorChain	*next;	/* next chain */
	MWI_DESTRUCTOR_FUNC	dtor;	/* destructor */
	void	*obj;	/* this */
} MWiDestructorChain;

/*
 * Global destructor chain.
 * Added at the top, so that they will be called in the reverse order of ctor.
 */
extern	MWiDestructorChain	*__global_destructor_chain;


/* Insert a chain at the top the global destructor chain.  */
extern	void	__register_global_object(void *obj,
	MWI_DESTRUCTOR_FUNC dtor, MWiDestructorChain *chain);
/*
{
	chain->next = __global_destructor_chain;
	chain->dtor = dtor;
	chain->obj = obj;
	__global_destructor_chain = chain;
}
*/


/********************************************************************/


#ifdef __cplusplus
} /* extern "C" */
#endif


#endif	/* NITRO_FS_UTIL_H_ */
