__assert.c 734 B

12345678910111213141516171819202122232425262728293031323334
  1. /* Copyright (C) 1996 Robert de Bath <rdebath@cix.compulink.co.uk>
  2. * This file is part of the Linux-8086 C library and is distributed
  3. * under the GNU Library General Public License.
  4. */
  5. #include <unistd.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. extern char *itoa(int);
  9. static void errput(str)
  10. const char *str;
  11. {
  12. write(2, str, strlen(str));
  13. }
  14. void __assert(assertion, filename, linenumber, function)
  15. const char *assertion;
  16. const char *filename;
  17. int linenumber;
  18. const char *function;
  19. {
  20. errput(filename);
  21. errput(":");
  22. errput(itoa(linenumber));
  23. errput(function ? ": " : "");
  24. errput(function ? function : "");
  25. errput(function ? "() " : "");
  26. errput(": Assertion \"");
  27. errput(assertion);
  28. errput("\" failed.\n");
  29. abort();
  30. }