Branch: Tag:

1998-04-13

1998-04-13 14:28:24 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Somewhat improved threads_disabled handling.

Rev: src/program.c:1.77

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: program.c,v 1.76 1998/04/10 22:24:21 hubbe Exp $"); + RCSID("$Id: program.c,v 1.77 1998/04/13 14:28:24 grubba Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
393:   }      /* +  * Error handler. +  * +  * This function should not normally be called, +  * but is here for safety reasons. +  */ + void restore_threads_disabled(void *arg) + { +  fprintf(stderr, "restore_threads_disabled(): threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); + #ifdef DEBUG +  fatal("restore_threads_disabled() called\n"); + #endif /* DEBUG */ +  +  if (threads_disabled) +  threads_disabled--; +  co_signal(&threads_disabled_change); + } +  + /*    * Start building a new program    */   void low_start_new_program(struct program *p,
404:    threads_disabled++;    compilation_depth++;    +  /* fprintf(stderr, "low_start_new_program(): compilation_depth:%d\n", compilation_depth); */ +     if(!p)    {    p=ALLOC_STRUCT(program);
510:      void start_new_program(void)   { +  /* fprintf(stderr, "start_new_program(): threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); */    low_start_new_program(0,0,0);   }   
837:    compilation_depth--;    threads_disabled--;    co_signal(&threads_disabled_change); +  +  /* fprintf(stderr, "end_first_pass(): compilation_depth:%d\n", compilation_depth); */ +     free_all_nodes();    return prog;   }
2004:    struct lex save_lex;    int save_depth=compilation_depth;    void yyparse(void); +  ONERROR just_in_case;       save_lex=lex;   
2012:    lex.current_file=make_shared_string("-");    lex.pragmas=0;    +  threads_disabled++; +  SET_ONERROR(just_in_case, restore_threads_disabled, NULL); +  +  /* fprintf(stderr, "compile() Enter: threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); */ +     start_new_program();    compilation_depth=0;   
2034:    p=end_program();    }    +  threads_disabled--; +  fprintf(stderr, "compile() Leave: threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); +  co_signal(&threads_disabled_change);    -  +  UNSET_ONERROR(just_in_case); +     free_string(lex.current_file);    lex=save_lex;