utils.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. *
  4. * Authors: David Frese, Mike Sperber
  5. */
  6. #ifndef __S48_BIBOP_UTILS_H
  7. #define __S48_BIBOP_UTILS_H
  8. #include <stdio.h>
  9. #include <signal.h>
  10. #include <stdlib.h>
  11. #ifndef _WIN32
  12. #include "sysdep.h"
  13. #else
  14. #include "scheme48arch.h"
  15. #endif
  16. /* inline isn't in ANSI C */
  17. #ifdef _WIN32
  18. #define inline _inline
  19. #elif !defined(HAVE_INLINE)
  20. #define inline
  21. #endif
  22. extern void s48_gc_error(const char* message, ...);
  23. #if (DISPLAY_MEASURE_GC)
  24. extern void newline();
  25. extern void space();
  26. extern void display_string(char* message);
  27. extern void dis_string(char* message);
  28. extern void display_number(int digits, long n);
  29. extern void dis_number(int digits, long n);
  30. extern void display_double(int digits, double n);
  31. extern void dis_double(int digits, double n);
  32. extern void write_vm_options(FILE* f);
  33. extern void display_vm_options();
  34. extern void display_string_x(char* message, int times);
  35. extern void display_comparison(long new, long old);
  36. extern void write_line(FILE* f, long num);
  37. #endif
  38. #if (BIBOP_LOG)
  39. extern void s48_bibop_log(const char* message, ...);
  40. #endif
  41. /* These functions are too dangerous to have around. The BIBOP GC
  42. should not need to do much arithmetic on ints, as all sizes must be
  43. stored in longs. */
  44. /*
  45. inline static int int_min(int a, int b) {
  46. return (a < b) ? a : b;
  47. }
  48. inline static int int_max(int a, int b) {
  49. return (a > b) ? a : b;
  50. }
  51. */
  52. inline static unsigned long ulong_min(unsigned long a, unsigned long b) {
  53. return (a < b) ? a : b;
  54. }
  55. inline static unsigned long ulong_max(unsigned long a, unsigned long b) {
  56. return (a > b) ? a : b;
  57. }
  58. #ifndef FALSE
  59. #define FALSE (0 == 1)
  60. #endif
  61. #ifndef TRUE
  62. #define TRUE (0 == 0)
  63. #endif
  64. #endif