1/*
2 * Copyright (c) 2002, Intel Corporation. All rights reserved.
3 * Created by:  rolla.n.selbak REMOVE-THIS AT intel DOT com
4 * This file is licensed under the GPL license.  For the full content
5 * of this license, see the COPYING file at the top level of this
6 * source tree.
7
8 * Test pthread_create()
9 * The thread is created executing 'start_routine' with 'arg' as its only
10 * argument.
11 *
12 * Steps:
13 * 1.  Create 5 separete threads using pthread_create() passing to it a single int 'arg'.
14 * 2.  Use that passed int argument in the thread function start routine  and make sure no
15 *     errors occur.
16 */
17
18#include <stdint.h>
19#include <pthread.h>
20#include <stdio.h>
21#include "posixtest.h"
22
23#define NUM_THREADS 5
24
25/* The thread start routine. */
26void *a_thread_func(void* num)
27{
28	intptr_t i = (intptr_t) num;
29	printf("Passed argument for thread: %d\n", (int)i);
30
31	pthread_exit(0);
32	return NULL;
33}
34
35int main()
36{
37	pthread_t new_th;
38	long i;
39
40	for(i=1;i<NUM_THREADS+1;i++)
41	{
42		if(pthread_create(&new_th, NULL, a_thread_func, (void*)i) != 0)
43		{
44			printf("Error creating thread\n");
45			return PTS_FAIL;
46		}
47
48		/* Wait for thread to end execution */
49		pthread_join(new_th, NULL);
50	}
51
52	printf("Test PASSED\n");
53	return PTS_PASS;
54}
55
56
57