- File:
-
- 1 edited
-
doc/working/exception/impl/test-main.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/working/exception/impl/test-main.c
re1055441 r35ba584c 6 6 #include <stdbool.h> 7 7 8 // Helps with manual translation. It may or may not get folded into the 9 // header, that depends on how it interacts with concurancy. 8 // Translation Helpers: 9 #define CLEANUP(function) \ 10 struct __cleanup_hook __hidden_hook __attribute__((cleanup(function))) 11 12 #define SET_UP_RESUME_NODE(handler_function) \ 13 struct __try_resume_node node \ 14 __attribute__((cleanup(__try_resume_node_delete))); \ 15 __try_resume_node_new(&node, handler_function) 16 10 17 void __try_resume_node_new(struct __try_resume_node * node, 11 18 _Bool (*handler)(exception except)) { … … 13 20 shared_stack.top_resume = node; 14 21 node->try_to_handle = handler; 22 } 23 24 void __try_resume_node_delete(struct __try_resume_node * node) { 25 shared_stack.top_resume = node->next; 15 26 } 16 27 … … 111 122 } 112 123 struct __try_resume_node node 113 __attribute__((cleanup(__try_resume_ cleanup)));124 __attribute__((cleanup(__try_resume_node_delete))); 114 125 __try_resume_node_new(&node, beta_handle1); 115 126 { … … 133 144 } 134 145 struct __try_resume_node node 135 __attribute__((cleanup(__try_resume_ cleanup)));146 __attribute__((cleanup(__try_resume_node_delete))); 136 147 __try_resume_node_new(&node, alpha_handle1); 137 148 { … … 142 153 143 154 // Finally Test: 144 void farewell( bool jump) {155 void farewell() { 145 156 { 146 157 void farewell_finally1() { … … 150 161 __attribute__((cleanup(farewell_finally1))); 151 162 { 152 if (jump) { 153 printf("jump out of farewell\n"); 154 goto endoffunction; 155 } else { 156 printf("walk out of farewell\n"); 157 } 158 } 159 } 160 endoffunction: 161 printf("leaving farewell\n"); 163 printf("walk out of farewell\n"); 164 } 165 } 162 166 } 163 167 … … 256 260 } 257 261 struct __try_resume_node node 258 __attribute__((cleanup(__try_resume_ cleanup)));262 __attribute__((cleanup(__try_resume_node_delete))); 259 263 __try_resume_node_new(&node, fn_handle1); 260 264 { … … 275 279 } 276 280 struct __try_resume_node node 277 __attribute__((cleanup(__try_resume_ cleanup)));281 __attribute__((cleanup(__try_resume_node_delete))); 278 282 __try_resume_node_new(&node, fn_handle1); 279 283 { … … 345 349 } 346 350 struct __try_resume_node node 347 __attribute__((cleanup(__try_resume_ cleanup)));351 __attribute__((cleanup(__try_resume_node_delete))); 348 352 __try_resume_node_new(&node, reresume_handle1); 349 353 { … … 357 361 } 358 362 struct __try_resume_node node 359 __attribute__((cleanup(__try_resume_ cleanup)));363 __attribute__((cleanup(__try_resume_node_delete))); 360 364 __try_resume_node_new(&node, reresume_handle2); 361 365 { … … 405 409 } 406 410 struct __try_resume_node node 407 __attribute__((cleanup(__try_resume_ cleanup)));411 __attribute__((cleanup(__try_resume_node_delete))); 408 412 __try_resume_node_new(&node, foe_handle1); 409 413 { … … 452 456 } 453 457 struct __try_resume_node node 454 __attribute__((cleanup(__try_resume_ cleanup)));458 __attribute__((cleanup(__try_resume_node_delete))); 455 459 __try_resume_node_new(&node, fee_handle1); 456 460 { … … 467 471 foo(); printf("\n"); 468 472 alpha(); printf("\n"); 469 farewell(false); printf("\n"); 470 farewell(true); printf("\n"); 473 farewell(); printf("\n"); 471 474 fallback(); printf("\n"); 472 475 terminate_swapped(); printf("\n");
Note:
See TracChangeset
for help on using the changeset viewer.