ADT
      
      
        
          | Last change
 on this file since f11010e was             428adbc, checked in by z277zhu <z277zhu@…>, 3 years ago | 
        
          | 
fix pthread_sig* interpose problems; add test doc
 
Signed-off-by: z277zhu <z277zhu@…>
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            685 bytes | 
      
      
| Rev | Line |  | 
|---|
| [20be782] | 1 | /* test attr init; set stack; get stack */ | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #include <fstream.hfa> | 
|---|
|  | 4 | #include <thread.hfa> | 
|---|
|  | 5 |  | 
|---|
| [428adbc] | 6 | void* 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; | 
|---|
| [20be782] | 15 | return NULL; | 
|---|
|  | 16 | } | 
|---|
|  | 17 |  | 
|---|
|  | 18 | int 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; | 
|---|
| [428adbc] | 25 | pthread_create(&thr, &attr, foo, (void*)&attr); | 
|---|
| [20be782] | 26 | pthread_join(thr, &res); | 
|---|
| [428adbc] | 27 | pthread_attr_destroy(&attr); | 
|---|
| [20be782] | 28 | return 0; | 
|---|
|  | 29 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.