PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Simple Libraries
Utility
libstacktest
cogstartStackTest.c
1
/*
2
* @file cogstartStackTest.c
3
*
4
* @author Andy Lindsay
5
*
6
* @copyright
7
* Copyright (C) Parallax, Inc. 2014. All Rights MIT Licensed.
8
*
9
* @brief Source code for cog_end function.
10
*
11
* @version 0.50
12
*/
13
14
#include "stacktest.h"
15
#include "simpletools.h"
16
17
int
cogstart_stackTest(
void
(*func)(
void
*),
void
*par,
void
*stack,
size_t
stacksize)
18
{
19
int
*addr = (
int
*) stack;
20
21
int
cogRunTestOverhead = 2 *
sizeof
(int);
22
//print("cogRunTestOverhead = %d bytes, %d ints\n", cogRunTestOverhead, cogRunTestOverhead/sizeof(int));
23
int
stackOverhead =
sizeof
(_thread_state_t) + (3 *
sizeof
(
unsigned
int
));
24
//print("stackOverhead = %d bytes, %d ints\n", stackOverhead, stackOverhead/sizeof(int));
25
int
stackOther = (stacksize/
sizeof
(int)) - (stackOverhead/
sizeof
(int)) - (cogRunTestOverhead/
sizeof
(int));
26
//print("stackOther = %d ints\n\n", stackOther);
27
srand(stackOther);
28
29
int
n = 0;
30
for
(
int
*i = addr+2; i < ((
int
*)addr + (stacksize/
sizeof
(
int
))); i++)
31
{
32
// *i = n;
33
*i = rand();
34
n++;
35
}
36
37
*addr = cogstart(func, par, (
int
*) stack + cogRunTestOverhead/
sizeof
(
int
), stacksize - cogRunTestOverhead);
38
39
//print("\n\n---[ cogstart_stackTest ]--- \n\n");
40
//print("Cog Address = %d, Cog Value = %d\n", (int) addr, *addr);
41
*(addr + 1) = stacksize/
sizeof
(
int
);
42
//print("Stack Count Address = %d, Stack Count = %d\n\n", (int)(addr+1), *(addr+1));
43
// // print("(int)(addr+2) = %d\n", (int)(addr+2));
44
return
*addr;
45
}
46
47
Generated on Sat Aug 27 2016 00:58:09 for PropWare by
1.8.12