source: tests/concurrency/pthread/pthread_attr_test.cfa @ 0766399

Last change on this file since 0766399 was c26bea2a, checked in by Peter A. Buhr <pabuhr@…>, 18 months ago

first attempt at renaming directory tests/concurrent to tests/concurrency to harmonize with other concurrency directory names

  • 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.