|
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 |
|
2
|
28 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
29 // ------------------------------------------- |
|
|
30 // |
|
|
31 //####COPYRIGHTEND#### |
|
|
32 //========================================================================== |
|
|
33 //#####DESCRIPTIONBEGIN#### |
|
|
34 // |
|
|
35 // Author(s): dsm |
|
2
|
36 // Contributors: dsm |
|
0
|
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 |
|
2
|
46 |
|
|
47 static inline void *operator new(size_t size, void *ptr) { return ptr; }; |
|
|
48 |
|
|
49 |
|
0
|
50 #ifdef NTHREADS |
|
|
51 |
|
2
|
52 #ifndef STACKSIZE |
|
|
53 #define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL |
|
|
54 #endif |
|
0
|
55 |
|
|
56 static Cyg_Thread *thread[NTHREADS]; |
|
|
57 |
|
2
|
58 typedef CYG_WORD64 CYG_ALIGNMENT_TYPE; |
|
0
|
59 |
|
2
|
60 static CYG_ALIGNMENT_TYPE thread_obj[NTHREADS] [ |
|
|
61 (sizeof(Cyg_Thread)+sizeof(CYG_ALIGNMENT_TYPE)-1) |
|
|
62 / sizeof(CYG_ALIGNMENT_TYPE) ]; |
|
|
63 |
|
|
64 static CYG_ALIGNMENT_TYPE stack[NTHREADS] [ |
|
|
65 (STACKSIZE+sizeof(CYG_ALIGNMENT_TYPE)-1) |
|
|
66 / sizeof(CYG_ALIGNMENT_TYPE) ]; |
|
0
|
67 |
|
|
68 static int nthreads = 0; |
|
|
69 |
|
|
70 static Cyg_Thread *new_thread(cyg_thread_entry *entry, CYG_ADDRWORD data) { |
|
|
71 |
|
|
72 CYG_ASSERT(nthreads < NTHREADS, |
|
|
73 "Attempt to create more than NTHREADS threads"); |
|
|
74 |
|
|
75 thread[nthreads] = new( (void *)&thread_obj[nthreads] ) |
|
2
|
76 Cyg_Thread(CYG_SCHED_DEFAULT_INFO, |
|
|
77 entry, data, |
|
|
78 NULL, // no name |
|
|
79 (CYG_ADDRESS)stack[nthreads], STACKSIZE ); |
|
0
|
80 |
|
|
81 thread[nthreads]->resume(); |
|
|
82 |
|
|
83 return thread[nthreads++]; |
|
|
84 } |
|
|
85 #endif // defined(NTHREADS) |
|
|
86 |
|
|
87 #define CHECK(b) CYG_TEST_CHECK(b,#b) |
|
|
88 |
|
|
89 #endif // ifndef CYGONCE_KERNEL_TESTS_TESTAUX_HXX |
|
|
90 |
|
|
91 // End of testaux.hxx |