|
0
|
1 #ifndef CYGONCE_KERNEL_TESTS_TESTAUX_HXX |
|
|
2 #define CYGONCE_KERNEL_TESTS_TESTAUX_HXX |
|
|
3 |
|
|
4 //========================================================================== |
|
|
5 // |
|
|
6 // testaux.hxx |
|
|
7 // |
|
|
8 // Auxiliary test header file |
|
|
9 // |
|
|
10 //========================================================================== |
|
|
11 //####COPYRIGHTBEGIN#### |
|
|
12 // |
|
|
13 // ------------------------------------------- |
|
|
14 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
15 // Version 1.0 (the "License"); you may not use this file except in |
|
|
16 // compliance with the License. You may obtain a copy of the License at |
|
|
17 // http://sourceware.cygnus.com/ecos |
|
|
18 // |
|
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
21 // License for the specific language governing rights and limitations under |
|
|
22 // the License. |
|
|
23 // |
|
|
24 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
25 // September 30, 1998. |
|
|
26 // |
|
|
27 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
28 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
29 // ------------------------------------------- |
|
|
30 // |
|
|
31 //####COPYRIGHTEND#### |
|
|
32 //========================================================================== |
|
|
33 //#####DESCRIPTIONBEGIN#### |
|
|
34 // |
|
|
35 // Author(s): dsm |
|
|
36 // Contributors: dsm |
|
|
37 // Date: 1998-03-09 |
|
|
38 // Description: |
|
|
39 // Defines some convenience functions to get us going. In |
|
|
40 // particular this file reserves space for NTHREADS threads, |
|
|
41 // which can be created by calls to aux_new_thread() |
|
|
42 // It also defines a CHECK function. |
|
|
43 // |
|
|
44 //####DESCRIPTIONEND#### |
|
|
45 |
|
|
46 #ifdef NTHREADS |
|
|
47 |
|
|
48 #define STACKSIZE 4096 |
|
|
49 |
|
|
50 static Cyg_Thread *thread[NTHREADS]; |
|
|
51 |
|
|
52 static char thread_obj[NTHREADS][sizeof(Cyg_Thread)]; |
|
|
53 static char stack[NTHREADS][STACKSIZE]; |
|
|
54 |
|
|
55 static inline void *operator new(size_t size, void *ptr) { return ptr; }; |
|
|
56 |
|
|
57 static int nthreads = 0; |
|
|
58 |
|
|
59 static Cyg_Thread *new_thread(cyg_thread_entry *entry, CYG_ADDRWORD data) { |
|
|
60 |
|
|
61 CYG_ASSERT(nthreads < NTHREADS, |
|
|
62 "Attempt to create more than NTHREADS threads"); |
|
|
63 |
|
|
64 thread[nthreads] = new( (void *)&thread_obj[nthreads] ) |
|
|
65 Cyg_Thread(entry, data, STACKSIZE, (CYG_ADDRESS)stack[nthreads] ); |
|
|
66 |
|
|
67 thread[nthreads]->resume(); |
|
|
68 |
|
|
69 return thread[nthreads++]; |
|
|
70 } |
|
|
71 #endif // defined(NTHREADS) |
|
|
72 |
|
|
73 #define CHECK(b) CYG_TEST_CHECK(b,#b) |
|
|
74 |
|
|
75 #endif // ifndef CYGONCE_KERNEL_TESTS_TESTAUX_HXX |
|
|
76 |
|
|
77 // End of testaux.hxx |