util.c 1.1 KB

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