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