Repository navigation
Expand file tree
/
Copy pathstkext.c
More file actions
85 lines (73 loc) · 2.08 KB
/
Copy pathstkext.c
File metadata and controls
85 lines (73 loc) · 2.08 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
/*
* @(#) $Header$
*
* BGUI library
* stkext.c
* Generic stack extension routines.
*
* Copyright © 2011, The AROS Development Team.
* (C) Janne Jalkanen 1998
* (C) Copyright 1998 Manuel Lemos.
* (C) Copyright 1996-1997 Ian J. Einman.
* (C) Copyright 1993-1996 Jaba Development.
* (C) Copyright 1993-1996 Jan van den Baard.
* All Rights Reserved.
*
* Converted by hand from stkext.asm
*
*/
#include <proto/intuition.h>
#include <proto/exec.h>
#define STKMARGIN 2048 // When should we start worrying about the stack?
#define STKSIZE 16384 // Allocate this much stack space
#define CTLBLOCK sizeof(StackSwapStruct)
extern struct Task *InputDevice;
extern APTR InputStack;
/*****************************************************************************
*
* EnsureStack allocates a handle, which must be returned back to RevertStack
*
* Registers preserved: all, except d0 and sp
*/
APTR EnsureStack(VOID)
{
struct Task *task;
struct EasyStruct easy = {
.es_StructSize = sizeof(struct EasyStruct),
.es_Flags = 0,
.es_Title = "BGUI Stack Overflow",
.es_TextFormat = "The \"%s\" process is out of stack space.",
.es_GadgetFormat = "Suspend",
};
// Figure out our address
task = FindTask(NULL);
// Calculate current stack left and check if it is within
// allowed limits
if ((IPTR)&task >= ((IPTR)task->tc_SPLower + STKMARGIN))
return NULL;
// It's not safe to do on-the-fly stack extensions
// under AROS.
for (;;)
EasyRequest(NULL, &easy, NULL, task->tc_Node.ln_Name);
}
/*****************************************************************************
*
* This function returns the stack back to free memory pool.
* Safe to call with NULL args
*
* Registers destroyed: d0/a0/a1/a7
*/
VOID RevertStack(APTR stack)
{
}
/*******************************************************************************
*
* This function allocates memory for the input.device stack extension,
* which is allocated only during library initialization.
*/
VOID InitInputStack(VOID)
{
}
VOID FreeInputStack(VOID)
{
}