summaryrefslogtreecommitdiffstats
path: root/private/os2/client/os2xcpt.c
blob: 1c266ec7bfd95f6e70584472d8b618103ee916ec (plain) (blame)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*++

Copyright (c) 1989  Microsoft Corporation

Module Name:

    os2xcpt.c

Abstract:

    This is a test OS/2 application to test the exception/signal component
    of OS/2

Author:

    Therese Stowell (thereses) 17-July-1990

Environment:

    User Mode Only.

    This test must be run under the session manager or cmd.exe so that
    the user's process has an exception port set up.

Revision History:

--*/

#define OS2_API32
#define INCL_OS2V20_ERRORS
#define INCL_OS2V20_MEMORY
#define INCL_OS2V20_TASKING
#define INCL_OS2V20_EXCEPTIONS
#include <os2.h>

PCHAR NullApiArguments[] = {
    "String Number One",
    "String Number Two",
    "String Number Three",
    NULL
};

VOID
ExceedStackTest( VOID );

VOID
TestExit( VOID );

int
main(
    int argc,
    char *argv[],
    char *envp[]
    )
{
    int i;

    DbgPrint( "*** Entering OS/2 Test Application\n" );

    //TestExit();
    ExceedStackTest();

    DbgPrint( "*** Exiting OS/2 Test Application\n" );
    return( 0 );
}

VOID
ExitRoutine1(
    ULONG ExitReason
    )
{
    DbgPrint( "*** ExitRoutine1( %lX ) called\n", ExitReason );
    DosExitList( EXLST_EXIT, NULL );
}

VOID
ExitRoutine2(
    ULONG ExitReason
    )
{
    DbgPrint( "*** ExitRoutine2( %lX ) called\n", ExitReason );
    DosExitList( EXLST_EXIT, NULL );
}

VOID
ExitRoutine3(
    ULONG ExitReason
    )
{
    DbgPrint( "*** ExitRoutine3( %lX ) called\n", ExitReason );
    DosExitList( EXLST_EXIT, NULL );
}

VOID
TestThread0(
    IN UCHAR ThreadChar
    )
{
    CHAR ThreadName[2];

    ThreadName[0] = ThreadChar;
    ThreadName[1] = '\0';

    DbgPrint( "*** Entering OS/2 Thread%s\n", (PCH)ThreadName );
    while (TRUE)
        ;

    DbgPrint( "*** Exiting  OS/2 Thread%s\n", (PCH)ThreadName );
}


VOID
ExceedStack(
    ULONG Depth
    )
{
    UCHAR BigArray[3000];

    if (Depth < 1000) {
        DbgPrint("Depth is %ld\n",Depth);
        ExceedStack(Depth+1);
    }
}


VOID
ExceedStackTest( VOID )

//
//  This tests the handling of a guard page fault on the stack.  this and
//  the can't grow stack are the only non-fatal exceptions.
//

{
    ExceedStack(0);
}

VOID
TestExit( VOID )

//
//  This tests synchronization of exiting between threads.
//

{
    TID ThreadAId;
    APIRET rc;

    rc = DosExitList( EXLST_ADD | 0x3000, ExitRoutine1 );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosExitList(EXLST_ADD) failed  - rc == %ld\n",
                  rc
                );
        }
    rc = DosExitList( EXLST_ADD | 0x3000, ExitRoutine2 );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosExitList(EXLST_ADD) failed  - rc == %ld\n",
                  rc
                );
        }
    rc = DosExitList( EXLST_ADD | 0xFF00, ExitRoutine3 );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosExitList(EXLST_ADD) failed  - rc == %ld\n",
                  rc
                );
        }
    rc = DosCreateThread( &ThreadAId,
                          (PFNTHREAD)TestThread0,
                          (ULONG)'a',
                          DCT_SUSPENDED,
                          0x10000
                        );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosCreateThread( ThreadA ) failed  - rc == %ld\n",
                  rc
                );
        }

    rc = DosResumeThread( ThreadAId );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosResumeThread( ThreadA ) failed  - rc == %ld\n",
                  rc
                );
        }

    DbgPrint("Exiting thread 1\n");
    DosExit( EXIT_PROCESS, 0xA5A5 );
}