try.c
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*---------------------------------------------------------------------*
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;
}
/* 解説 */