source: rtems/testsuites/psxtests/psxstack01/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
15#include <pmacros.h>
16#include <errno.h>
17#include <pthread.h>
18#include <sched.h>
19
20#include <rtems/posix/pthread.h> /* for PTHREAD_MINIMUM_STACK_SIZE */
21
22void *Stack_Low;
23void *Stack_High;
24
25void *Test_Thread(void *arg)
26{
27  #if defined(__GNUC__)
28    void *sp = __builtin_frame_address(0);
29
30    #if 0
31      printf( "Stack(%p - %p) and sp=%p\n", Stack_Low, Stack_High, sp );
32    #endif
33
34    if ( sp >= Stack_Low && sp <= Stack_High )
35      puts( "Test_Thread - running on user provided stack - OK" );
36    else {
37      puts( "Test_Thread - ERROR running on other stack" );
38      rtems_test_exit(0);
39    }
40  #else
41      puts( "Test_Thread - no way to get stack pointer and verify" );
42  #endif
43  puts( "Test_Thread - delete self" );
44  return NULL;
45}
46
47void *POSIX_Init(
48  void *argument
49)
50{
51  int                 sc;
52  pthread_t           id;
53  pthread_attr_t      attr;
54  struct timespec     delay_request;
55
56  puts( "\n\n*** POSIX STACK ATTRIBUTE TEST 01 ***" );
57
58  puts( "Init - Allocate stack from heap" );
59  Stack_Low = malloc(PTHREAD_MINIMUM_STACK_SIZE);
60  rtems_test_assert( Stack_Low );
61  Stack_High = Stack_Low + PTHREAD_MINIMUM_STACK_SIZE;
62
63  puts( "Init - Initialize thread attribute for user provided stack" );
64  sc = pthread_attr_init( &attr );
65  rtems_test_assert( !sc );
66
67  sc = pthread_attr_setstackaddr( &attr, Stack_Low );
68  rtems_test_assert( !sc );
69
70  sc = pthread_attr_setstacksize( &attr, PTHREAD_MINIMUM_STACK_SIZE );
71  rtems_test_assert( !sc );
72
73  /* create threads */
74  sc = pthread_create( &id, &attr, Test_Thread, NULL );
75  rtems_test_assert( !sc );
76
77  puts( "Init - let other thread run" );
78  delay_request.tv_sec = 0;
79  delay_request.tv_nsec = 5 * 100000000;
80  sc = nanosleep( &delay_request, NULL );
81  rtems_test_assert( !sc );
82
83  puts( "*** END OF POSIX STACK ATTRIBUTE TEST 01 ***" );
84  rtems_test_exit(0);
85
86  return NULL; /* just so the compiler thinks we returned something */
87}
88
89/* configuration information */
90
91#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
92#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
93
94#define CONFIGURE_MAXIMUM_POSIX_THREADS        2
95
96#define CONFIGURE_POSIX_INIT_THREAD_TABLE
97
98#define CONFIGURE_INIT
99#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.