source: tests/concurrent/pthread/pthread_attr_test.cfa @ 5c473c9

ADTast-experimental
Last change on this file since 5c473c9 was 428adbc, checked in by z277zhu <z277zhu@…>, 2 years ago

fix pthread_sig* interpose problems; add test doc

Signed-off-by: z277zhu <z277zhu@…>

  • Property mode set to 100644
File size: 685 bytes
Line 
1/* test attr init; set stack; get stack */
2
3#include <fstream.hfa>
4#include <thread.hfa>
5
6void* foo(void* _attr){
7    size_t size;
8    pthread_attr_t* attr = (pthread_attr_t*)_attr;
9    int status = pthread_attr_getstacksize(attr, &size);
10    if (status != 0){
11        sout | "error return code";
12        exit(1);
13    }
14    sout | "stack size is " | size;
15    return NULL;
16}
17
18int main(int argc, char const *argv[])
19{
20    pthread_attr_t attr;
21    pthread_attr_init(&attr);
22    pthread_attr_setstacksize(&attr, 123456789);
23    pthread_t thr;
24    void* res;
25    pthread_create(&thr, &attr, foo, (void*)&attr);
26    pthread_join(thr, &res);
27    pthread_attr_destroy(&attr);
28    return 0;
29}
Note: See TracBrowser for help on using the repository browser.