util.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef NORCSID
  2. static char rcsid[] = "$Id$";
  3. #endif
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include "param.h"
  7. #include "types.h"
  8. #include "tes.h"
  9. #include "assert.h"
  10. #include "lookup.h"
  11. #include "proinf.h"
  12. #include "optim.h"
  13. #include "ext.h"
  14. /*
  15. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  16. * See the copyright notice in the ACK home directory, in the file "Copyright".
  17. *
  18. * Author: Hans van Staveren
  19. */
  20. /* VARARGS1 */
  21. void error(char *s, char *a)
  22. {
  23. fprintf(stderr,"%s: error on line %u",progname,linecount);
  24. if (prodepth != 0)
  25. fprintf(stderr,"(%.*s)",IDL,curpro.symbol->s_name);
  26. fprintf(stderr,": ");
  27. fprintf(stderr,s,a);
  28. fprintf(stderr,"\n");
  29. #ifndef NDEBUG
  30. abort();
  31. #endif
  32. exit(-1);
  33. }
  34. #ifndef NDEBUG
  35. void badassertion(char *file, unsigned int line)
  36. {
  37. fprintf(stderr,"assertion failed file %s, line %u\n",file,line);
  38. error("assertion", NULL);
  39. }
  40. #endif
  41. #ifdef DIAGOPT
  42. void optim(int n)
  43. {
  44. fprintf(stderr,"Made optimization %d",n);
  45. if (prodepth)
  46. fprintf(stderr," (%.*s)",IDL,curpro.symbol->s_name);
  47. fprintf(stderr,"\n");
  48. }
  49. #endif