migrate substitution keywords to SVN
[reactos.git] / reactos / lib / rosrtl / thread / linearstack.c
1 /* $Id$
2 */
3 /*
4 */
5
6 #define NTOS_MODE_USER
7 #include <ntos.h>
8
9 #include <rosrtl/thread.h>
10
11 NTSTATUS NTAPI RtlpRosValidateLinearUserStack
12 (
13 IN PVOID StackBase,
14 IN PVOID StackLimit,
15 IN BOOLEAN Direction
16 )
17 {
18 /* the stack has a null or negative (relatively to its direction) length */
19 /*
20 Direction: TRUE for down-top, FALSE for top-down
21
22 Direction == TRUE and positive stack size: OK
23 Direction == TRUE and negative stack size: error
24 Direction == FALSE and positive stack size: error
25 Direction == FALSE and negative stack size: OK
26 */
27 if
28 (
29 StackBase == StackLimit ||
30 (Direction ^ ((PCHAR)StackBase < (PCHAR)StackLimit))
31 )
32 return STATUS_BAD_INITIAL_STACK;
33
34 /* valid stack */
35 return STATUS_SUCCESS;
36 }
37
38 /* EOF */