try.c 1.47 KB

/*---------------------------------------------------------------------*
        Copyright (C) 1998 Nintendo.
        
        $RCSfile: try.c,v $
        $Revision: 1.1.1.1 $
        $Date: 2002/05/02 03:27:33 $
 *---------------------------------------------------------------------*/

/*
   try.c   - 例外処理クラス
 */

/* pre-process */
#include <stdarg.h>   /* SGIのものを借用 */ 
#include "hglobals.h"
#include "htry.h"
#include "hdd.h"

/* declarerations */

OSMesgQueue     tryMsgQ;
OSMesg          tryMsgBuf[TRY_MSGQ_SIZE];

static OSThread tryThread;
static u64      tryThreadStack[STACKSIZE/sizeof(u64)];
static void     objectOftry(void *);

/* implmentations */

void
try_create(void)
{
  osCreateMesgQueue(&tryMsgQ, tryMsgBuf,TRY_MSGQ_SIZE);

  osCreateThread(&tryThread, ++g_thread_id,(void *)objectOftry, 0
                                 ,tryThreadStack + STACKSIZE/sizeof(u64), TRY_THREAD_PRIORITY);
  osStartThread(&tryThread);
}

static void
objectOftry(void * arg)
{
  TException *e=NULL;
  arg=arg; /* no use */

  while(1)
	{
	  osRecvMesg(&tryMsgQ, (OSMesg *)e, OS_MESG_BLOCK);

	  switch(e->id)
		{

		}
	} 
}

void
try_assert(u8 * str , s32 i)
{
#ifdef DEBUG
  if(!i) 
	{
	  osSyncPrintf("catch exception %s \n",str );
	  osStopThread(0);
	  while(1);
	}
#else
  str = str;
  i = i;
#endif
  return;
}

s32
try_warning(u8 * str , s32 i)
{
#ifdef DEBUG
  if(!i) 
	{
	  osSyncPrintf("warning ! catch exception %s \n",str );
	}
#else
  str = str;
#endif
  return !i;
}

/* 解説 */