Hi all,

This ##sys#fudge stuff has bothered me for a long time.  It's an obscure
name and it uses magic numbers, which means almost every use includes a
comment that says what it's doing.  Historically, some fudges have
disappeared, leaving gaps in the switch() statement, and there are
several values in there that are accessible in other ways.

I think it's a good idea to remove it.  This will also reduce runtime.c
in size a little bit.  It's 100% safe to remove; there are no hidden
dependencies in build bootstrapping or anything.  I think the main reason
it was kept all this time is because some eggs might use it.  We're
allowed to break compat now, so it's a good moment to do this.

Attached are a LOT of patches (9 in total).  Don't let that scare you,
I tried to keep them all relatively small and self-contained, so it's
hopefully easier to review them individually instead of doing it one
huge patch.

I took the most straightforward approach (I think) in most cases.  Some
of these patches can probably be improved on.  We can do this beforehand,
or after these changes are applied.

I noticed that the srfi-18 egg is using (##sys#fudge 12).  This can be
replaced with (##core#inline "C_i_tty_forcedp()") instead, now.

Cheers,
Peter
From 2c1ae6230d8e98d40199ea042848903bb29ddc74 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Tue, 11 Oct 2016 21:42:30 +0200
Subject: [PATCH 1/9] Replace uses of (##sys#fudge 7) by C_wordstobytes.

---
 lolevel.scm              |  4 ++--
 runtime.c                |  2 +-
 support.scm              | 13 +++----------
 tests/compiler-tests.scm |  6 ++++--
 4 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/lolevel.scm b/lolevel.scm
index bac44f9..cd98f52 100644
--- a/lolevel.scm
+++ b/lolevel.scm
@@ -341,8 +341,8 @@ EOF
   (let ((unset (list 'unset)))
     (lambda (n #!optional (init unset))
       (##sys#check-exact n 'make-pointer-vector)
-      (let* ((mul (##sys#fudge 7))	; wordsize
-	     (size (fx* n mul))
+      (let* ((words->bytes (foreign-lambda int "C_wordstobytes" int))
+	     (size (words->bytes n))
 	     (buf (##sys#make-blob size)))
 	(unless (eq? init unset)
 	  (when init
diff --git a/runtime.c b/runtime.c
index 8af8cdd..6eb2352 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4862,7 +4862,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 6) [current CPU milliseconds] not implemented"));
 
   case C_fix(7):		/* wordsize */
-    return C_fix(sizeof(C_word));
+    panic(C_text("(##sys#fudge 7) [wordsize] is obsolete"));
 
   case C_fix(8):		/* words needed for double */
     return C_fix(C_wordsperdouble(1));
diff --git a/support.scm b/support.scm
index 1bce489..5f9bf7b 100644
--- a/support.scm
+++ b/support.scm
@@ -253,16 +253,9 @@
 		(any (lambda (c) (or (char-alphabetic? c) (char-numeric? c) (char=? #\_ c)))
 		     (cdr str) ) ) ) ) ) )
 
-(eval-when (load)
-  (define bytes->words (foreign-lambda int "C_bytestowords" int)) 
-  (define words->bytes (foreign-lambda int "C_wordstobytes" int)) )
-
-(eval-when (eval)
-  (define (bytes->words n)
-    (let ([wordsize (##sys#fudge 7)])
-      (+ (quotient n wordsize) (if (zero? (modulo n wordsize)) 0 1)) ) )
-  (define (words->bytes n)
-    (* n (##sys#fudge 7)) ) )
+;; TODO: Move these to (chicken memory)?
+(define bytes->words (foreign-lambda int "C_bytestowords" int))
+(define words->bytes (foreign-lambda int "C_wordstobytes" int))
 
 ;; Used only in batch-driver; move it there?
 (define (check-and-open-input-file fname . line)
diff --git a/tests/compiler-tests.scm b/tests/compiler-tests.scm
index 2d149d9..459fbaf 100644
--- a/tests/compiler-tests.scm
+++ b/tests/compiler-tests.scm
@@ -1,7 +1,8 @@
 ;;;; compiler-tests.scm
 
 
-(import bitwise flonum foreign srfi-4)
+(import (chicken bitwise) (chicken flonum) (chicken foreign)
+	srfi-4)
 (import-for-syntax data-structures expand)
 
 ;; test dropping of previous toplevel assignments
@@ -14,7 +15,8 @@
 (assert (eq? 'ok (foo)))
 
 (assert (= 1 (foreign-type-size "char")))
-(let ((bytes-in-a-word (##sys#fudge 7)))
+(let* ((words->bytes (foreign-lambda int "C_wordstobytes" int))
+       (bytes-in-a-word (words->bytes 1)))
   (assert (= bytes-in-a-word (foreign-type-size "C_word"))))
 
 ;; test hiding of unexported toplevel variables
-- 
2.1.4

From 84e286f309d3c737a6a87fcb5492ed3a81ed7c96 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Tue, 11 Oct 2016 21:54:27 +0200
Subject: [PATCH 2/9] Replace (##sys#fudge 3) by #:64bit feature checks.

We could alternatively use cond-expand.

When _defining_ the feature, we resort to checking the C_WORD_SIZE
foreign value, which is more or less equivalent to what the fudge did.
---
 csi.scm                   | 2 +-
 library.scm               | 9 +++++----
 runtime.c                 | 6 +-----
 support.scm               | 2 +-
 tests/arithmetic-test.scm | 4 ++--
 tests/fixnum-tests.scm    | 6 +++---
 tests/lolevel-tests.scm   | 2 +-
 tests/numbers-test.scm    | 2 +-
 8 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/csi.scm b/csi.scm
index b0ed7cf..6ba4d48 100644
--- a/csi.scm
+++ b/csi.scm
@@ -483,7 +483,7 @@ EOF
                      nursery size is ~S bytes, stack grows ~A~%~
                    Command line:    \t~S~%"
 		    (machine-type)
-		    (if (##sys#fudge 3) "(64-bit)" "")
+		    (if (feature? #:64bit) "(64-bit)" "")
 		    (software-type)
 		    (software-version)
 		    (build-platform)
diff --git a/library.scm b/library.scm
index f591b91..7580b56 100644
--- a/library.scm
+++ b/library.scm
@@ -4394,12 +4394,12 @@ EOF
       (string-append (str sv) (str st) (str bp) (##sys#symbol->string mt)) ) )
   (if full
       (let ((spec (string-append
-		   (if (##sys#fudge 3)	" 64bit" "")
+		   (if (feature? #:64bit) " 64bit" "")
 		   (if (##sys#fudge 15) " symbolgc" "")
 		   (if (##sys#fudge 40) " manyargs" "")
-		   (if (##sys#fudge 24) " dload" "") 
+		   (if (##sys#fudge 24) " dload" "")
 		   (if (##sys#fudge 28) " ptables" "")
-		   (if (##sys#fudge 32) " gchooks" "") 
+		   (if (##sys#fudge 32) " gchooks" "")
 		   (if (##sys#fudge 39) " cross" "") ) ) )
 	(string-append
 	 "Version " ##sys#build-version
@@ -4451,7 +4451,8 @@ EOF
 (when (##sys#fudge 24) (set! ##sys#features (cons #:dload ##sys#features)))
 (when (##sys#fudge 28) (set! ##sys#features (cons #:ptables ##sys#features)))
 (when (##sys#fudge 39) (set! ##sys#features (cons #:cross-chicken ##sys#features)))
-(when (##sys#fudge 3) (set! ##sys#features (cons #:64bit ##sys#features)))
+(when (fx= (foreign-value "C_WORD_SIZE" int) 64)
+  (set! ##sys#features (cons #:64bit ##sys#features)))
 
 (set! ##sys#features
   (let ((major (##sys#string-append "chicken-" (##sys#number->string (##sys#fudge 41)))))
diff --git a/runtime.c b/runtime.c
index 6eb2352..c20c6d8 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4838,11 +4838,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 2) [get time] not implemented"));
 
   case C_fix(3):		/* 64-bit system? */
-#ifdef C_SIXTY_FOUR
-    return C_SCHEME_TRUE;
-#else
-    return C_SCHEME_FALSE;
-#endif
+    panic(C_text("(##sys#fudge 3) [64bit] is obsolete"));
 
   case C_fix(4):		/* is this a console application? */
     return C_mk_bool(!C_gui_mode);
diff --git a/support.scm b/support.scm
index 5f9bf7b..020f335 100644
--- a/support.scm
+++ b/support.scm
@@ -1586,7 +1586,7 @@
 
 (define (big-fixnum? x)	;; XXX: This should probably be in c-platform
   (and (fixnum? x)
-       (##sys#fudge 3)			; 64 bit?
+       (feature? #:64bit)
        (or (fx> x 1073741823)
 	   (fx< x -1073741824) ) ) )
 
diff --git a/tests/arithmetic-test.scm b/tests/arithmetic-test.scm
index d03dd1a..9584c69 100644
--- a/tests/arithmetic-test.scm
+++ b/tests/arithmetic-test.scm
@@ -121,7 +121,7 @@
  (cond-expand
    (check-numbers "arithmetic-test.numbers.expected")
    (else
-    (if (##sys#fudge 3)
+    (if (feature? #:64bit)
 	"arithmetic-test.64.expected"
 	"arithmetic-test.32.expected")))
  (lambda (x)
@@ -138,4 +138,4 @@
       (set! result (cdr result)))
     x)))
 
-(exit (if errors? 1 0))
\ No newline at end of file
+(exit (if errors? 1 0))
diff --git a/tests/fixnum-tests.scm b/tests/fixnum-tests.scm
index 9c5b95c..3b4fb27 100644
--- a/tests/fixnum-tests.scm
+++ b/tests/fixnum-tests.scm
@@ -5,17 +5,17 @@
 (assert (= -26 (fxo+ 74 -100)))
 (assert (= 1073741823 (fxo+ #x3ffffffe 1)))
 (assert
- (if (##sys#fudge 3)                   ; 64-bit?
+ (if (feature? #:64bit)
      (not (fxo+ #x3fffffffffffffff 1))
      (not (fxo+ #x3fffffff 1))))
 (assert (= 4 (fxo- 6 2)))
 (assert (= -4 (fxo- 1000 1004)))
 (assert (= 2004 (fxo- 1000 -1004)))
 (assert
- (if (##sys#fudge 3)                   ; 64-bit?
+ (if (feature? #:64bit)
      (= -4611686018427387904 (fxo- (- #x3fffffffffffffff) 1))
      (= -1073741824 (fxo- (- #x3fffffff) 1))))
 (assert
- (if (##sys#fudge 3)                   ; 64-bit?
+ (if (feature? #:64bit)
      (not (fxo- (- #x3fffffffffffffff) 2))
      (not (fxo- (- #x3fffffff) 2))))
diff --git a/tests/lolevel-tests.scm b/tests/lolevel-tests.scm
index 243d2d7..7ec0554 100644
--- a/tests/lolevel-tests.scm
+++ b/tests/lolevel-tests.scm
@@ -246,7 +246,7 @@
 
 (assert (= 4 (number-of-bytes "abcd")))
 
-(assert (= (if (##sys#fudge 3) 8 4) (number-of-bytes '#(1))))
+(assert (= (if (feature? #:64bit) 8 4) (number-of-bytes '#(1))))
 
 ; make-record-instance
 
diff --git a/tests/numbers-test.scm b/tests/numbers-test.scm
index 81231b8..af415ab 100644
--- a/tests/numbers-test.scm
+++ b/tests/numbers-test.scm
@@ -28,7 +28,7 @@
 ;; The minimal bignum in the sense that any smaller makes it a fixnum
 (define min-big (+ most-positive-fixnum 1))
 
-(define 64-bits? (##sys#fudge 3))
+(define 64-bits? (feature? #:64bit))
 
 (define (show x) 
   (print (and x (number->string x)))
-- 
2.1.4

From 06cd33b50f96cb86e5abd88c3c38d095e41b6053 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Tue, 11 Oct 2016 22:03:30 +0200
Subject: [PATCH 3/9] Remove a few obsolete fudge factors.

- eof-object wasn't used anywhere via fudge-factor anymore.
- symbolgc can no longer be disabled.
- manyargs and apply-hook are no longer relevant.
- Reading any other obsolete fudge factor will now cause a panic.

After this change, #:manyargs is simply always defined.
---
 csi.scm     |  1 -
 library.scm |  6 ++----
 runtime.c   | 19 ++++++++++---------
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/csi.scm b/csi.scm
index 6ba4d48..e329136 100644
--- a/csi.scm
+++ b/csi.scm
@@ -502,7 +502,6 @@ EOF
 		    (argv))
 	    (##sys#write-char-0 #\newline ##sys#standard-output)
 	    (when (##sys#fudge 14) (display "interrupts are enabled\n"))
-	    (when (##sys#fudge 15) (display "symbol gc is enabled\n")) 
 	    (##core#undefined) ) ) ) ) ) )
 
 
diff --git a/library.scm b/library.scm
index 7580b56..c3e1dce 100644
--- a/library.scm
+++ b/library.scm
@@ -4395,8 +4395,6 @@ EOF
   (if full
       (let ((spec (string-append
 		   (if (feature? #:64bit) " 64bit" "")
-		   (if (##sys#fudge 15) " symbolgc" "")
-		   (if (##sys#fudge 40) " manyargs" "")
 		   (if (##sys#fudge 24) " dload" "")
 		   (if (##sys#fudge 28) " ptables" "")
 		   (if (##sys#fudge 32) " gchooks" "")
@@ -4434,7 +4432,8 @@ EOF
 (define ##sys#features
   '(#:chicken
     #:srfi-6 #:srfi-12 #:srfi-17 #:srfi-23 #:srfi-30 #:srfi-39 #:srfi-62
-    #:irregex-is-core-unit #:full-numeric-tower))
+    ;; TODO: consider removing at least irregex-is-core-unit
+    #:irregex-is-core-unit #:full-numeric-tower #:manyargs))
 
 ;; Add system features:
 
@@ -4447,7 +4446,6 @@ EOF
   (check (machine-type))
   (check (machine-byte-order)) )
 
-(when (##sys#fudge 40) (set! ##sys#features (cons #:manyargs ##sys#features)))
 (when (##sys#fudge 24) (set! ##sys#features (cons #:dload ##sys#features)))
 (when (##sys#fudge 28) (set! ##sys#features (cons #:ptables ##sys#features)))
 (when (##sys#fudge 39) (set! ##sys#features (cons #:cross-chicken ##sys#features)))
diff --git a/runtime.c b/runtime.c
index c20c6d8..cc7ba6f 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4833,7 +4833,8 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
   double tgc;
 
   switch(fudge_factor) {
-  case C_fix(1): return C_SCHEME_END_OF_FILE; /* eof object */
+  case C_fix(1):                              /* eof object */
+    panic(C_text("(##sys#fudge 1) [eof object] is obsolete"));
   case C_fix(2):			      /* get time */
     panic(C_text("(##sys#fudge 2) [get time] not implemented"));
 
@@ -4886,7 +4887,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_mk_bool(C_interrupts_enabled);
 
   case C_fix(15):		/* symbol-gc enabled? */
-    return C_SCHEME_TRUE;
+    panic(C_text("(##sys#fudge 15) [symbolgc] is obsolete"));
 
   case C_fix(16):		/* milliseconds (wall clock) */
     panic(C_text("(##sys#fudge 16) [current wall clock milliseconds] not implemented"));
@@ -4903,7 +4904,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(j);
 
   case C_fix(20):		/* unused */
-    return C_SCHEME_FALSE;
+    panic(C_text("(##sys#fudge 20) [?] is obsolete"));
 
   case C_fix(21):		/* largest fixnum */
     return C_fix(C_MOST_POSITIVE_FIXNUM);
@@ -4941,7 +4942,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(C_trace_buffer_size);
 
   case C_fix(30):		/* unused */
-    return C_SCHEME_FALSE;
+    panic(C_text("(##sys#fudge 30) [?] is obsolete"));
 
   case C_fix(31):		/* GC time since last invocation */
     tgc = timer_accumulated_gc_ms;
@@ -4962,8 +4963,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(stack_size / 2); /* An educated guess :) */
 
   case C_fix(35):		/* unused */
-    /* used to be apply-hook indicator */
-    return C_SCHEME_FALSE;
+    panic(C_text("(##sys#fudge 35) [old apply-hack] is obsolete"));
     
   case C_fix(36):		/* toggle debug mode */
     debug_mode = !debug_mode;
@@ -4973,7 +4973,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_mk_bool(dump_heap_on_exit);
 
   case C_fix(38):		/* unused */
-    return C_SCHEME_FALSE;      /* used to be SVN revision */
+    panic(C_text("(##sys#fudge 38) [old svn rev.] is obsolete"));
 
   case C_fix(39):		/* is this a cross-chicken? */
 #if defined(C_CROSS_CHICKEN) && C_CROSS_CHICKEN
@@ -4983,7 +4983,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
 #endif
 
   case C_fix(40):		/* many arguments supported? */
-    return C_SCHEME_TRUE;
+    panic(C_text("(##sys#fudge 40) [manyargs] is obsolete"));
 
   case C_fix(41):		/* major CHICKEN version */
     return C_fix(C_MAJOR_VERSION);
@@ -5004,7 +5004,8 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
   case C_fix(45):  /* Whether we're currently profiling */
     return C_mk_bool(profiling);
 
-  default: return C_SCHEME_UNDEFINED;
+  default:
+    panic(C_text("Unknown fudge factor"));
   }
 }
 
-- 
2.1.4

From 0e2e403666b922b4dd609d7e5969437e03c5ba94 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Tue, 11 Oct 2016 22:30:11 +0200
Subject: [PATCH 4/9] Use C_gui_mode directly; remove OS-specific fudges

Only fudge 4 was used by core at all.  These are all quite weird; in
fact, fudge factor 5 even has a comment indicating its silliness.
---
 library.scm   |  2 +-
 runtime.c     | 18 +++---------------
 setup-api.scm |  8 ++++----
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/library.scm b/library.scm
index c3e1dce..decde2a 100644
--- a/library.scm
+++ b/library.scm
@@ -4579,7 +4579,7 @@ EOF
    (let ([string-append string-append])
      (lambda (msg . args)
        (##sys#error-handler (lambda args (##core#inline "C_halt" "error in error")))
-       (cond ((##sys#fudge 4)
+       (cond ((not (foreign-value "C_gui_mode" bool))
 	      (##sys#print "\nError" #f ##sys#standard-error)
 	      (when msg
 		(##sys#print ": " #f ##sys#standard-error)
diff --git a/runtime.c b/runtime.c
index cc7ba6f..36f3819 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4842,18 +4842,10 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 3) [64bit] is obsolete"));
 
   case C_fix(4):		/* is this a console application? */
-    return C_mk_bool(!C_gui_mode);
+    panic(C_text("(##sys#fudge 4) [console application] is obsolete"));
 
   case C_fix(5):		/* is this a GUI/console or Windows-GUI application? (silly) */
-    if(C_gui_mode) {
-#ifdef _WIN32
-      return C_fix(1);
-#else
-      return C_SCHEME_FALSE;
-#endif
-    }
-
-    return C_fix(0);
+    panic(C_text("(##sys#fudge 5) [Windows GUI application] is obsolete"));
 
   case C_fix(6): 		/* milliseconds CPU */
     panic(C_text("(##sys#fudge 6) [current CPU milliseconds] not implemented"));
@@ -4871,11 +4863,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(CLOCKS_PER_SEC);
 
   case C_fix(11):		/* not a unix system? */
-#if defined(C_NONUNIX) || defined(__CYGWIN__)
-    return C_SCHEME_FALSE;
-#else
-    return C_SCHEME_TRUE;
-#endif
+    panic(C_text("(##sys#fudge 11) [UNIX system] is obsolete"));
 
   case C_fix(12):		/* tty forced? */
     return C_mk_bool(fake_tty_flag);
diff --git a/setup-api.scm b/setup-api.scm
index 0eed0a5..5d009eb 100644
--- a/setup-api.scm
+++ b/setup-api.scm
@@ -704,12 +704,12 @@ C_confirmation_dialog(char *msg, char *caption, int def, int abort) { return -1;
 ;;       unless that requires linking any libraries. This would also
 ;;       be useful for runtime error messages.
 
-(define-foreign-variable C_HAS_MESSAGE_BOX bool)
-
 (define yes-or-no?
-  (let ((dialog (foreign-lambda int "C_confirmation_dialog" c-string c-string int bool)))
+  (let ((dialog (foreign-lambda int "C_confirmation_dialog" c-string c-string int bool))
+	(C_HAS_MESSAGE_BOX (foreign-value "C_HAS_MESSAGE_BOX" bool))
+	(C_gui_mode (foreign-value "C_gui_mode" bool)))
     (lambda (str #!key default title (abort reset))
-      (let ((gui (and C_HAS_MESSAGE_BOX (not (##sys#fudge 4))))) ; C_gui_mode
+      (let ((gui (and C_HAS_MESSAGE_BOX C_gui_mode)))
 	(define (get-input)
 	  (if gui
 	      (let ((r (dialog
-- 
2.1.4

From 22e93e0611cee22842a57febf8286741584c94de Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Tue, 11 Oct 2016 22:40:49 +0200
Subject: [PATCH 5/9] Remove a few more semi-unused fudge factors.

Fudges 8 (words per double), 9 (latency), 10 (clocks per sec),
23 (startup time), 29 (trace buffer size) were used nowhere.

Remove ##sys#apply-limit, as it is used nowhere and doesn't make much
sense (its value is just a crude guess anyway).  This was the only use
of fudge 34.

Fudge 36 (toggle debug mode) doesn't make much sense either.  If we want
to set it it is more logical to just set it to the desired value.  The
one test that used it seemed to use it for no apparent reason (??)
---
 library.scm         |  1 -
 runtime.c           | 15 +++++++--------
 tests/embedded2.scm |  1 -
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/library.scm b/library.scm
index decde2a..7c6f828 100644
--- a/library.scm
+++ b/library.scm
@@ -287,7 +287,6 @@ EOF
 (define (##sys#block-ref x i) (##core#inline "C_i_block_ref" x i))
 (define ##sys#apply-values (##core#primitive "C_apply_values"))
 (define ##sys#copy-closure (##core#primitive "C_copy_closure"))
-(define ##sys#apply-argument-limit (##sys#fudge 34))
 
 (define (##sys#block-set! x i y)
   (when (or (not (##core#inline "C_blockp" x)) 
diff --git a/runtime.c b/runtime.c
index 36f3819..99be687 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4854,13 +4854,13 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 7) [wordsize] is obsolete"));
 
   case C_fix(8):		/* words needed for double */
-    return C_fix(C_wordsperdouble(1));
+    panic(C_text("(##sys#fudge 8) [wordsperdouble] is obsolete"));
 
   case C_fix(9):		/* latency */
-    return C_fix(last_interrupt_latency);
+    panic(C_text("(##sys#fudge 9) [latency] is obsolete"));
 
   case C_fix(10):		/* clocks per sec */
-    return C_fix(CLOCKS_PER_SEC);
+    panic(C_text("(##sys#fudge 10) [clockspersec] is obsolete"));
 
   case C_fix(11):		/* not a unix system? */
     panic(C_text("(##sys#fudge 11) [UNIX system] is obsolete"));
@@ -4901,7 +4901,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_mk_bool(private_repository != NULL);
 
   case C_fix(23):		/* seconds since process startup */
-    return C_fix(C_startup_time_seconds);
+    panic(C_text("(##sys#fudge 23) [startuptime] is obsolete"));
 
   case C_fix(24):		/* dynamic loading available? */
 #ifdef NO_DLOAD2
@@ -4927,7 +4927,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
 #endif
 
   case C_fix(29):		/* size of ring-buffer used to hold trace entries */
-    return C_fix(C_trace_buffer_size);
+    panic(C_text("(##sys#fudge 29) [trace buffer size] is obsolete"));
 
   case C_fix(30):		/* unused */
     panic(C_text("(##sys#fudge 30) [?] is obsolete"));
@@ -4948,14 +4948,13 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(C_getpid());
 
   case C_fix(34):		/* effective maximum for procedure arguments */
-    return C_fix(stack_size / 2); /* An educated guess :) */
+    panic(C_text("(##sys#fudge 34) [apply-argument-limit] is obsolete"));
 
   case C_fix(35):		/* unused */
     panic(C_text("(##sys#fudge 35) [old apply-hack] is obsolete"));
     
   case C_fix(36):		/* toggle debug mode */
-    debug_mode = !debug_mode;
-    return C_mk_bool(debug_mode);
+    panic(C_text("(##sys#fudge 36) [toggle debug-mode] is obsolete"));
 
   case C_fix(37):		/* heap-dump enabled? */
     return C_mk_bool(dump_heap_on_exit);
diff --git a/tests/embedded2.scm b/tests/embedded2.scm
index 3e44cdc..b05428d 100644
--- a/tests/embedded2.scm
+++ b/tests/embedded2.scm
@@ -18,7 +18,6 @@ int main()
 <#
 
 
-(##sys#fudge 36)
 (gc)
 (print "starting...")
 
-- 
2.1.4

From 3b40a1acde316eb3ebc639df71f10f3b7ffaaa18 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Wed, 12 Oct 2016 22:07:23 +0200
Subject: [PATCH 6/9] Replace fudges with readily available variables.

C_BINARY_VERSION was defined in chicken-{install,uninstall,status}
already.

C_enable_repl wasn't static, so added it to chicken.h, after which
we can use that directly in ##sys#break-on-error definition.

dload, ptables, gchooks and cross-chicken features can be determined
through their corresponding #defined values.  Everywhere else, we can
just check if the feature is defined.

This adds a new #:gchooks feature for consistency with other "spec"
printing aspects.

C_getpid() is now directly used from a foreign-lambda.

repository-path simply checks C_private_repository_path() result, which
is defined to return c-string.  This may be NULL, which maps to #f
already, making fudge 22 completely unnecessary.
---
 chicken-install.scm         |  2 +-
 chicken-status.scm          |  2 +-
 chicken-uninstall.scm       |  2 +-
 chicken.h                   |  1 +
 csc.scm                     |  2 +-
 csi.scm                     | 13 ++++++++-----
 eval.scm                    | 27 +++++++++++++-------------
 files.scm                   |  6 ++++--
 library.scm                 | 45 ++++++++++++++++++++++++++++++++++++--------
 posix-common.scm            |  2 +-
 posixunix.scm               |  3 ++-
 runtime.c                   | 46 +++++++++++++--------------------------------
 scripts/mini-salmonella.scm |  2 +-
 setup-api.scm               |  3 ++-
 tcp.scm                     |  3 ++-
 15 files changed, 88 insertions(+), 71 deletions(-)

diff --git a/chicken-install.scm b/chicken-install.scm
index 853827b..4813226 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -140,7 +140,7 @@
 	    (if *prefix*
 		(make-pathname
 		 *prefix*
-		 (sprintf "lib/chicken/~a" (##sys#fudge 42)))
+		 (sprintf "lib/chicken/~a" C_BINARY_VERSION))
 		(repository-path)))))
 
   (define (get-prefix #!optional runtime)
diff --git a/chicken-status.scm b/chicken-status.scm
index c2a9615..0216261 100644
--- a/chicken-status.scm
+++ b/chicken-status.scm
@@ -56,7 +56,7 @@
 	    (if *prefix*
 		(make-pathname
 		 *prefix*
-		 (sprintf "lib/chicken/~a" (##sys#fudge 42)))
+		 (sprintf "lib/chicken/~a" C_BINARY_VERSION))
 		(repository-path)))))
 
   (define (grep rx lst)
diff --git a/chicken-uninstall.scm b/chicken-uninstall.scm
index 7de0a74..13cd11a 100644
--- a/chicken-uninstall.scm
+++ b/chicken-uninstall.scm
@@ -54,7 +54,7 @@
 	    (if *prefix*
 		(make-pathname
 		 *prefix*
-		 (sprintf "lib/chicken/~a" (##sys#fudge 42)))
+		 (sprintf "lib/chicken/~a" C_BINARY_VERSION))
 		(repository-path)))))
 
   (define *force* #f)
diff --git a/chicken.h b/chicken.h
index 2740d91..bdb0522 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1758,6 +1758,7 @@ C_varextern C_TLS jmp_buf C_restart;
 C_varextern C_TLS void *C_restart_address;
 C_varextern C_TLS int C_entry_point_status;
 C_varextern C_TLS int C_gui_mode;
+C_varextern C_TLS int C_enable_repl;
 
 C_varextern C_TLS void *C_restart_trampoline;
 C_varextern C_TLS void (*C_pre_gc_hook)(int mode);
diff --git a/csc.scm b/csc.scm
index 822947d..c9d626d 100644
--- a/csc.scm
+++ b/csc.scm
@@ -88,7 +88,7 @@
 (define chicken-prefix (get-environment-variable "CHICKEN_PREFIX"))
 (define arguments (command-line-arguments))
 (define host-mode (member "-host" arguments))
-(define cross-chicken (##sys#fudge 39))
+(define cross-chicken (feature? #:cross-chicken))
 
 (define (prefix str dir default)
   (if chicken-prefix
diff --git a/csi.scm b/csi.scm
index e329136..bda4803 100644
--- a/csi.scm
+++ b/csi.scm
@@ -446,8 +446,11 @@ EOF
       (with-output-to-port (if (pair? port) (car port) (current-output-port))
 	(lambda ()
 	  (gc)
-	  (let ([sinfo (##sys#symbol-table-info)]
-		[minfo (memory-statistics)] )
+	  (let ((sinfo (##sys#symbol-table-info))
+		(minfo (memory-statistics))
+		(interrupts (foreign-value "C_interrupts_enabled" bool))
+		(fixed-heap (foreign-value "C_heap_size_is_fixed" bool))
+		(downward-stack (foreign-value "C_STACK_GROWS_DOWNWARD" bool)))
 	    (define (shorten n) (/ (truncate (* n 100)) 100))
 	    (printf "Features:~%~%")
 	    (let ((fs (sort (map keyword->string ##sys#features) string<?))
@@ -495,13 +498,13 @@ EOF
 		    (shorten (vector-ref sinfo 1))
 		    (vector-ref sinfo 2)
 		    (vector-ref minfo 0)
-		    (if (##sys#fudge 17) " (fixed)" "")
+		    (if fixed-heap " (fixed)" "")
 		    (vector-ref minfo 1)
 		    (vector-ref minfo 2)
-		    (if (= 1 (##sys#fudge 18)) "downward" "upward")
+		    (if downward-stack "downward" "upward")
 		    (argv))
 	    (##sys#write-char-0 #\newline ##sys#standard-output)
-	    (when (##sys#fudge 14) (display "interrupts are enabled\n"))
+	    (when interrupts (display "interrupts are enabled\n"))
 	    (##core#undefined) ) ) ) ) ) )
 
 
diff --git a/eval.scm b/eval.scm
index 86d8c21..1b72164 100644
--- a/eval.scm
+++ b/eval.scm
@@ -1002,7 +1002,7 @@
 
       (define dload?
 	(and (not ##sys#dload-disabled)
-	     (##sys#fudge 24)))
+	     (feature? #:dload)))
 
       (define fname
 	(cond ((port? input) #f)
@@ -1179,14 +1179,13 @@
 
 (define repository-path
   (make-parameter
-   (if (##sys#fudge 22) ; private repository?
-       (foreign-value "C_private_repository_path()" c-string)
-       (or (get-environment-variable repository-environment-variable)
-	   (chicken-prefix
-	    (##sys#string-append
-	     "lib/chicken/"
-	     (##sys#number->string (##sys#fudge 42))))
-	   install-egg-home))))
+   (or (foreign-value "C_private_repository_path()" c-string)
+       (get-environment-variable repository-environment-variable)
+       (chicken-prefix
+	(##sys#string-append
+	 "lib/chicken/"
+	 (##sys#number->string binary-version)))
+       install-egg-home)))
 
 (define ##sys#repository-path repository-path)
 
@@ -1202,7 +1201,7 @@
 	  (let ((p0 (string-append path "/" p)))
 	    (or (and rp
 		     (not ##sys#dload-disabled)
-		     (##sys#fudge 24) ; dload?
+		     (feature? #:dload)
 		     (file-exists? (##sys#string-append p0 ##sys#load-dynamic-extension)))
 		(file-exists? (##sys#string-append p0 source-file-extension)))))
 	(let loop ((paths (##sys#append
@@ -1407,12 +1406,12 @@
       (define (test fname)
 	(test-extensions
 	 fname
-	 (cond ((pair? exts) exts)     ; specific list of extensions
-	       ((not (##sys#fudge 24)) ; no dload -> source only
+	 (cond ((pair? exts) exts)       ; specific list of extensions
+	       ((not (feature? #:dload)) ; no dload -> source only
 		(list source-file-extension))
-	       ((not exts)             ; prefer compiled
+	       ((not exts)               ; prefer compiled
 		(list ##sys#load-dynamic-extension source-file-extension))
-	       (else                   ; prefer source
+	       (else                     ; prefer source
 		(list source-file-extension ##sys#load-dynamic-extension)))))
       (or (test (make-relative-pathname source fname))
 	  (let loop ((paths (if repo
diff --git a/files.scm b/files.scm
index 4a086f0..2a97df2 100644
--- a/files.scm
+++ b/files.scm
@@ -161,13 +161,14 @@ EOF
       (##sys#check-string ext 'create-temporary-file)
       (let loop ()
 	(let* ((n (##core#inline "C_random_fixnum" #x10000))
+	       (getpid (foreign-lambda int "C_getpid"))
 	       (pn (make-pathname 
 		    (tempdir)
 		    (string-append 
 		     temp-prefix
 		     (number->string n 16)
 		     "."
-		     (##sys#number->string (##sys#fudge 33))) ; PID
+		     (##sys#number->string (getpid)))
 		    ext)) )
 	  (if (file-exists? pn)
 	      (loop)
@@ -176,13 +177,14 @@ EOF
     (lambda ()
       (let loop ()
 	(let* ((n (##core#inline "C_random_fixnum" #x10000))
+	       (getpid (foreign-lambda int "C_getpid"))
 	       (pn (make-pathname 
 		    (tempdir)
 		    (string-append
 		     temp-prefix
 		     (number->string n 16)
 		     "."
-		     (##sys#number->string (##sys#fudge 33)))))) ; PID
+		     (##sys#number->string (getpid))))))
 	  (if (file-exists? pn)
 	      (loop)
 	      (let ((r (##core#inline "C_mkdir" (##sys#make-c-string pn 'create-temporary-directory))))
diff --git a/library.scm b/library.scm
index 7c6f828..90cbf15 100644
--- a/library.scm
+++ b/library.scm
@@ -150,6 +150,30 @@ signal_debug_event(C_word mode, C_word msg, C_word args)
   C_debugger(&cell, 3, av);
   return C_SCHEME_UNDEFINED;
 }
+
+#ifdef NO_DLOAD2
+# define HAVE_DLOAD 0
+#else
+# define HAVE_DLOAD 1
+#endif
+
+#ifdef C_ENABLE_PTABLES
+# define HAVE_PTABLES 1
+#else
+# define HAVE_PTABLES 0
+#endif
+
+#ifdef C_GC_HOOKS
+# define HAVE_GCHOOKS 1
+#else
+# define HAVE_GCHOOKS 0
+#endif
+
+#if defined(C_CROSS_CHICKEN) && C_CROSS_CHICKEN
+# define IS_CROSS_CHICKEN 1
+#else
+# define IS_CROSS_CHICKEN 0
+#endif
 EOF
 ) )
 
@@ -4394,10 +4418,10 @@ EOF
   (if full
       (let ((spec (string-append
 		   (if (feature? #:64bit) " 64bit" "")
-		   (if (##sys#fudge 24) " dload" "")
-		   (if (##sys#fudge 28) " ptables" "")
-		   (if (##sys#fudge 32) " gchooks" "")
-		   (if (##sys#fudge 39) " cross" "") ) ) )
+		   (if (feature? #:dload) " dload" "")
+		   (if (feature? #:ptables) " ptables" "")
+		   (if (feature? #:gchooks) " gchooks" "")
+		   (if (feature? #:cross-chicken) " cross" "") ) ) )
 	(string-append
 	 "Version " ##sys#build-version
 	 (if ##sys#build-branch (string-append " (" ##sys#build-branch ")") "")
@@ -4445,9 +4469,14 @@ EOF
   (check (machine-type))
   (check (machine-byte-order)) )
 
-(when (##sys#fudge 24) (set! ##sys#features (cons #:dload ##sys#features)))
-(when (##sys#fudge 28) (set! ##sys#features (cons #:ptables ##sys#features)))
-(when (##sys#fudge 39) (set! ##sys#features (cons #:cross-chicken ##sys#features)))
+(when (foreign-value "HAVE_DLOAD" bool)
+  (set! ##sys#features (cons #:dload ##sys#features)))
+(when (foreign-value "HAVE_PTABLES" bool)
+  (set! ##sys#features (cons #:ptables ##sys#features)))
+(when (foreign-value "HAVE_GCHOOKS" bool)
+  (set! ##sys#features (cons #:gchooks ##sys#features)))
+(when (foreign-value "IS_CROSS_CHICKEN" bool)
+  (set! ##sys#features (cons #:cross-chicken ##sys#features)))
 (when (fx= (foreign-value "C_WORD_SIZE" int) 64)
   (set! ##sys#features (cons #:64bit ##sys#features)))
 
@@ -4569,7 +4598,7 @@ EOF
 
 ;;; Default handlers
 
-(define ##sys#break-on-error (##sys#fudge 25))
+(define ##sys#break-on-error (foreign-value "C_enable_repl" bool))
 
 (define-foreign-variable _ex_software int "EX_SOFTWARE")
 
diff --git a/posix-common.scm b/posix-common.scm
index 0c85f00..4044959 100644
--- a/posix-common.scm
+++ b/posix-common.scm
@@ -684,7 +684,7 @@ EOF
 
 ;;; Processes
 
-(define (current-process-id) (##sys#fudge 33))
+(define current-process-id (foreign-lambda int "C_getpid"))
 
 (define (process-sleep n)
   (##sys#check-fixnum n 'process-sleep)
diff --git a/posixunix.scm b/posixunix.scm
index b73df20..96f30e5 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -1119,7 +1119,8 @@ EOF
 		       (fetch))
 		     (if (fx>= bufpos buflen)
 			 #!eof
-			 (let ((limit (or limit (fx- (##sys#fudge 21) bufpos))))
+			 (let ((limit (or limit (fx- most-positive-fixnum
+						     bufpos))))
 			   (receive (next line full-line?)
 			       (##sys#scan-buffer-line
 				buf
diff --git a/runtime.c b/runtime.c
index 99be687..3f8859e 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4872,7 +4872,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_mk_bool(debug_mode);
 
   case C_fix(14):		/* interrupts enabled? */
-    return C_mk_bool(C_interrupts_enabled);
+    panic(C_text("(##sys#fudge 14) [interrupts enabled] is obsolete"));
 
   case C_fix(15):		/* symbol-gc enabled? */
     panic(C_text("(##sys#fudge 15) [symbolgc] is obsolete"));
@@ -4881,10 +4881,10 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 16) [current wall clock milliseconds] not implemented"));
 
   case C_fix(17):		/* fixed heap? */
-    return(C_mk_bool(C_heap_size_is_fixed));
+    panic(C_text("(##sys#fudge 17) [fixed heap] is obsolete"));
 
   case C_fix(18):		/* stack direction */
-    return(C_fix(C_STACK_GROWS_DOWNWARD));
+    panic(C_text("(##sys#fudge 18) [stack direction] is obsolete"));
 
   case C_fix(19):		/* number of locatives */
     for(i = j = 0; i < locative_table_count; ++i)
@@ -4895,23 +4895,19 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 20) [?] is obsolete"));
 
   case C_fix(21):		/* largest fixnum */
-    return C_fix(C_MOST_POSITIVE_FIXNUM);
+    panic(C_text("(##sys#fudge 21) [largest fixnum] is obsolete"));
 
   case C_fix(22):		/* does this process use a private egg-repository? */
-    return C_mk_bool(private_repository != NULL);
+    panic(C_text("(##sys#fudge 22) [private repo?] is obsolete"));
 
   case C_fix(23):		/* seconds since process startup */
     panic(C_text("(##sys#fudge 23) [startuptime] is obsolete"));
 
   case C_fix(24):		/* dynamic loading available? */
-#ifdef NO_DLOAD2
-    return C_SCHEME_FALSE;
-#else
-    return C_SCHEME_TRUE;
-#endif
+    panic(C_text("(##sys#fudge 24) [dload] is obsolete"));
 
   case C_fix(25):		/* REPL on error? XXX Is this used anywhere? */
-    return C_mk_bool(C_enable_repl);
+    panic(C_text("(##sys#fudge 25) [enable repl on error] is obsolete"));
 
   case C_fix(26):		/* number of untriggered finalizers */
     return C_fix(live_finalizer_count);
@@ -4920,11 +4916,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(allocated_finalizer_count);
 
   case C_fix(28):		/* are procedure-tabled enabled? */
-#ifdef C_ENABLE_PTABLES
-    return C_SCHEME_TRUE;
-#else
-    return C_SCHEME_FALSE;
-#endif
+    panic(C_text("(##sys#fudge 28) [ptables] is obsolete"));
 
   case C_fix(29):		/* size of ring-buffer used to hold trace entries */
     panic(C_text("(##sys#fudge 29) [trace buffer size] is obsolete"));
@@ -4938,14 +4930,10 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(tgc);
 
   case C_fix(32):		/* are GC-hooks enabled? */
-#ifdef C_GC_HOOKS
-    return C_SCHEME_TRUE;
-#else
-    return C_SCHEME_FALSE;
-#endif
+    panic(C_text("(##sys#fudge 32) [gchooks] is obsolete"));
 
   case C_fix(33):		/* return process-ID */
-    return C_fix(C_getpid());
+    panic(C_text("(##sys#fudge 33) [getpid] is obsolete"));
 
   case C_fix(34):		/* effective maximum for procedure arguments */
     panic(C_text("(##sys#fudge 34) [apply-argument-limit] is obsolete"));
@@ -4963,11 +4951,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 38) [old svn rev.] is obsolete"));
 
   case C_fix(39):		/* is this a cross-chicken? */
-#if defined(C_CROSS_CHICKEN) && C_CROSS_CHICKEN
-    return C_SCHEME_TRUE;
-#else
-    return C_SCHEME_FALSE;
-#endif
+    panic(C_text("(##sys#fudge 39) [cross-chicken] is obsolete"));
 
   case C_fix(40):		/* many arguments supported? */
     panic(C_text("(##sys#fudge 40) [manyargs] is obsolete"));
@@ -4976,17 +4960,13 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     return C_fix(C_MAJOR_VERSION);
 
   case C_fix(42):		/* binary version number */
-#ifdef C_BINARY_VERSION
-    return C_fix(C_BINARY_VERSION);
-#else
-    return C_fix(0);
-#endif
+    panic(C_text("(##sys#fudge 42) [binary version] is obsolete"));
 
   case C_fix(43):		/* minor CHICKEN version */
     return C_fix(C_MINOR_VERSION);
 
   case C_fix(44):  /* whether debugger is active */
-    return C_mk_bool(C_debugging);
+    panic(C_text("(##sys#fudge 44) [debugging] is obsolete"));
 
   case C_fix(45):  /* Whether we're currently profiling */
     return C_mk_bool(profiling);
diff --git a/scripts/mini-salmonella.scm b/scripts/mini-salmonella.scm
index 4bd62a5..7761789 100644
--- a/scripts/mini-salmonella.scm
+++ b/scripts/mini-salmonella.scm
@@ -33,7 +33,7 @@
 
 (unless *eggdir* (usage 1))
 
-(define *binary-version* (##sys#fudge 42))
+(define-foreign-variable *binary-version* int "C_BINARY_VERSION")
 (define *repository* (make-pathname *prefix* (conc "lib/chicken/" *binary-version*)))
 (define *snapshot* (directory *repository*))
 
diff --git a/setup-api.scm b/setup-api.scm
index 5d009eb..8dc73f8 100644
--- a/setup-api.scm
+++ b/setup-api.scm
@@ -88,6 +88,7 @@
 (define *target-lib-home* (foreign-value "C_TARGET_LIB_HOME" c-string))
 (define *sudo* #f)
 (define *windows-shell* (foreign-value "C_WINDOWS_SHELL" bool))
+(define *binary-version* (foreign-value "C_BINARY_VERSION" int))
 (define *registered-programs* '())
 
 (define *windows*
@@ -517,7 +518,7 @@
 		     (if p		; installation-prefix changed: use it
 			 (make-pathname 
 			  p
-			  (sprintf "lib/chicken/~a" (##sys#fudge 42)))
+			  (sprintf "lib/chicken/~a" *binary-version*))
 			 (repository-path)))) ; otherwise use repo-path
 	       (repository-path))) )
     (ensure-directory p #t)
diff --git a/tcp.scm b/tcp.scm
index 81b1088..7748e67 100644
--- a/tcp.scm
+++ b/tcp.scm
@@ -446,7 +446,8 @@ EOF
 		   (read-input))
 		 (if (fx>= bufindex buflen)
 		     #!eof
-		     (let ((limit (or limit (fx- (##sys#fudge 21) bufindex))))
+		     (let ((limit (or limit (fx- most-positive-fixnum
+						 bufindex))))
 		       (receive (next line full-line?)
 			   (##sys#scan-buffer-line
 			    buf
-- 
2.1.4

From 21d22fa63507501582e4eb95fe57bc3e31e166bb Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Fri, 14 Oct 2016 21:11:56 +0200
Subject: [PATCH 7/9] Replace CHICKEN version fudges with foreign-values

This requires the version test to be compiled.  The test is still
useful, as it compares the version in build-version.scm with the baked
in constant definitions of C_{MAJOR,MINOR}_VERSION.
---
 library.scm             | 11 +++++------
 runtime.c               |  4 ++--
 setup-download.scm      |  3 ++-
 tests/runtests.bat      |  4 +++-
 tests/runtests.sh       |  3 ++-
 tests/version-tests.scm | 17 ++++++++++++++---
 6 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/library.scm b/library.scm
index 90cbf15..7b1bc7e 100644
--- a/library.scm
+++ b/library.scm
@@ -4481,12 +4481,11 @@ EOF
   (set! ##sys#features (cons #:64bit ##sys#features)))
 
 (set! ##sys#features
-  (let ((major (##sys#string-append "chicken-" (##sys#number->string (##sys#fudge 41)))))
-    (cons (##sys#->feature-id major)
-	  (cons (##sys#->feature-id 
-		 (string-append
-		  major "."
-		  (##sys#number->string (##sys#fudge 43))))
+  (let ((major (##sys#number->string (foreign-value "C_MAJOR_VERSION" int)))
+	(minor (##sys#number->string (foreign-value "C_MINOR_VERSION" int))))
+    (cons (##sys#->feature-id (string-append "chicken-" major))
+	  (cons (##sys#->feature-id
+		 (string-append "chicken-" major "." minor))
 		##sys#features))))
 
 (define (register-feature! . fs)
diff --git a/runtime.c b/runtime.c
index 3f8859e..bf7e633 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4957,13 +4957,13 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 40) [manyargs] is obsolete"));
 
   case C_fix(41):		/* major CHICKEN version */
-    return C_fix(C_MAJOR_VERSION);
+    panic(C_text("(##sys#fudge 41) [major version] is obsolete"));
 
   case C_fix(42):		/* binary version number */
     panic(C_text("(##sys#fudge 42) [binary version] is obsolete"));
 
   case C_fix(43):		/* minor CHICKEN version */
-    return C_fix(C_MINOR_VERSION);
+    panic(C_text("(##sys#fudge 43) [minor version] is obsolete"));
 
   case C_fix(44):  /* whether debugger is active */
     panic(C_text("(##sys#fudge 44) [debugging] is obsolete"));
diff --git a/setup-download.scm b/setup-download.scm
index f4f257d..9eaa8f0 100644
--- a/setup-download.scm
+++ b/setup-download.scm
@@ -60,6 +60,7 @@
   (define *trunk* #f)
   (define *mode* 'default)
   (define *windows-shell* (foreign-value "C_WINDOWS_SHELL" bool))
+  (define *chicken-release* (foreign-value "C_MAJOR_VERSION" int))
 
   (define (d fstr . args)
     (let ([port (if *quiet* (current-error-port) (current-output-port))])
@@ -186,7 +187,7 @@
       (let* ((locn (string-append
 		    locn
 		    "?name=" egg
-		    "&release=" (->string (##sys#fudge 41))
+		    "&release=" (->string *chicken-release*)
 		    (if version (string-append "&version=" version) "")
 		    "&mode=" (->string *mode*)
 		    (if tests "&tests=yes" "")))
diff --git a/tests/runtests.bat b/tests/runtests.bat
index 248a152..888c71a 100644
--- a/tests/runtests.bat
+++ b/tests/runtests.bat
@@ -27,7 +27,9 @@ mkdir test-repository
 copy %TYPESDB% test-repository
 
 echo ======================================== version tests ...
-%interpret% -s version-tests.scm
+%compile% version-tests.scm
+if errorlevel 1 exit /b 1
+a.out
 if errorlevel 1 exit /b 1
 
 echo ======================================== compiler tests ...
diff --git a/tests/runtests.sh b/tests/runtests.sh
index e10482e..745ad1c 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -95,7 +95,8 @@ interpret="../csi -n -include-path ${TEST_DIR}/.."
 rm -f *.exe *.so *.o *.import.* a.out ../foo.import.*
 
 echo "======================================== version tests ..."
-$interpret -s version-tests.scm
+$compile version-tests.scm
+./a.out
 
 echo "======================================== compiler tests ..."
 $compile compiler-tests.scm
diff --git a/tests/version-tests.scm b/tests/version-tests.scm
index 851850c..f26d3d1 100644
--- a/tests/version-tests.scm
+++ b/tests/version-tests.scm
@@ -5,9 +5,8 @@
        (minor (string->number (cadr version-tokens))))
 
   (display "Checking major and minor version numbers against chicken-version... ")
-  ;; Those fudges are mapped to C_MAJOR_VERSION and C_MINOR_VERSION
-  (assert (= (##sys#fudge 41) major))
-  (assert (= (##sys#fudge 43) minor))
+  (assert (= (foreign-value "C_MAJOR_VERSION" int) major))
+  (assert (= (foreign-value "C_MINOR_VERSION" int) minor))
   (print "ok")
 
   (display "Checking the registered feature chicken-<major>.<minor>... ")
@@ -24,4 +23,16 @@
                                   (irregex-match-substring match 2))
                                  minor))))
                 (else (loop (cdr features)))))))
+
+  (display "Checking the registered feature chicken-<major>... ")
+  (let loop ((features (features)))
+    (if (null? features)
+        (error "Could not find feature chicken-<major>")
+        (let ((feature (symbol->string (car features))))
+          (cond ((irregex-match "chicken-(\\d+)" feature)
+                 => (lambda (match)
+                      (assert (= (string->number
+                                  (irregex-match-substring match 1))
+                                 major))))
+                (else (loop (cdr features)))))))
   (print "ok"))
-- 
2.1.4

From 0773092062085c650aa7e5b162891c7f9cc087d3 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Fri, 14 Oct 2016 21:46:13 +0200
Subject: [PATCH 8/9] Add helper functions for remaining fudge factors.

These are all used directly inline in the one place they were used.

For fudge factor 13 (debug mode), a ##sys#debug-mode? is added, to make
it more readable.  A types.db entry is provided to ensure debug mode
checks don't cause a performance regression (there was a built-in
rewrite for ##sys#fudge).

Alternatively, some of the internal variables could be exposed to the
outside world (like fake_tty, finalizer_count etc), but this would also
make them settable, which is something we might not want.  And by not
having them be static, performance could also be adversely affected in
case of the variables used in the GC.
---
 chicken.h               |  7 ++++++
 common-declarations.scm |  2 +-
 core.scm                |  2 +-
 csc.scm                 |  2 +-
 csi.scm                 |  3 ++-
 eval.scm                |  2 +-
 lfa2.scm                |  2 +-
 library.scm             | 34 +++++++++++++++++-----------
 profiler.scm            |  2 +-
 runtime.c               | 60 ++++++++++++++++++++++++++++++++++++-------------
 scrutinizer.scm         |  2 +-
 tests/gobble.scm        |  2 +-
 types.db                |  2 ++
 13 files changed, 85 insertions(+), 37 deletions(-)

diff --git a/chicken.h b/chicken.h
index bdb0522..0fd3754 100644
--- a/chicken.h
+++ b/chicken.h
@@ -2148,6 +2148,13 @@ C_fctexport C_word C_fcall C_i_get_keyword(C_word key, C_word args, C_word def)
 C_fctexport C_u64 C_fcall C_milliseconds(void) C_regparm;
 C_fctexport C_u64 C_fcall C_cpu_milliseconds(void) C_regparm;
 C_fctexport double C_fcall C_bignum_to_double(C_word bignum) C_regparm;
+C_fctexport C_word C_fcall C_i_debug_modep(void) C_regparm;
+C_fctexport C_word C_fcall C_i_dump_heap_on_exitp(void) C_regparm;
+C_fctexport C_word C_fcall C_i_accumulated_gc_time(void) C_regparm;
+C_fctexport C_word C_fcall C_i_allocated_finalizer_count(void) C_regparm;
+C_fctexport C_word C_fcall C_i_live_finalizer_count(void) C_regparm;
+C_fctexport C_word C_fcall C_i_profilingp(void) C_regparm;
+C_fctexport C_word C_fcall C_i_tty_forcedp(void) C_regparm;
 
 
 C_fctexport C_word C_fcall C_a_i_cpu_time(C_word **a, int c, C_word buf) C_regparm;
diff --git a/common-declarations.scm b/common-declarations.scm
index 27ce297..36960ed 100644
--- a/common-declarations.scm
+++ b/common-declarations.scm
@@ -42,7 +42,7 @@
   (define-syntax d
     (syntax-rules ()
       ((_ arg ...)
-       (when (##sys#fudge 13) ; debug-mode
+       (when (##sys#debug-mode?)
 	 (print arg ...))))))
  (else
   (begin
diff --git a/core.scm b/core.scm
index 574c8fc..db6337d 100644
--- a/core.scm
+++ b/core.scm
@@ -332,7 +332,7 @@
 	chicken.pretty-print)
 
 (define (d arg1 . more)
-  (when (##sys#fudge 13)		; debug mode?
+  (when (##sys#debug-mode?)
     (if (null? more)
 	(pp arg1)
 	(apply print arg1 more))))
diff --git a/csc.scm b/csc.scm
index c9d626d..54b57dd 100644
--- a/csc.scm
+++ b/csc.scm
@@ -879,7 +879,7 @@ EOF
 		 (if to-stdout 
 		     '("-to-stdout")
 		     `("-output-file" ,(quotewrap fc)) )
-		 (if (##sys#fudge 13)
+		 (if (##sys#debug-mode?)
 		     '("-:d")
 		     '())
 		 (map quote-option
diff --git a/csi.scm b/csi.scm
index bda4803..881b6aa 100644
--- a/csi.scm
+++ b/csi.scm
@@ -244,7 +244,8 @@ EOF
        history-count))))
 
 (define (tty-input?)
-  (or (##sys#fudge 12) (##sys#tty-port? ##sys#standard-input)) )
+  (or (##core#inline "C_i_tty_forcedp")
+      (##sys#tty-port? ##sys#standard-input)) )
 
 (set! ##sys#break-on-error #f)
 
diff --git a/eval.scm b/eval.scm
index 1b72164..c43e444 100644
--- a/eval.scm
+++ b/eval.scm
@@ -942,7 +942,7 @@
 
 ;;; Loading source/object files:
 
-(define load-verbose (make-parameter (##sys#fudge 13)))
+(define load-verbose (make-parameter (##sys#debug-mode?)))
 
 (define ##sys#current-load-filename #f)
 (define ##sys#dload-disabled #f)
diff --git a/lfa2.scm b/lfa2.scm
index 70b5e0b..ad9a4a2 100644
--- a/lfa2.scm
+++ b/lfa2.scm
@@ -50,7 +50,7 @@
 (define lfa2-debug #t)
 
 (define (d fstr . args)
-  (when (and lfa2-debug (##sys#fudge 13))
+  (when (and lfa2-debug (##sys#debug-mode?))
     (printf "[debug|~a] ~a~?~%" d-depth (make-string d-depth #\space) fstr args)) )
 
 (define dd d)
diff --git a/library.scm b/library.scm
index 7b1bc7e..1368032 100644
--- a/library.scm
+++ b/library.scm
@@ -240,6 +240,7 @@ EOF
 (define (reset) ((##sys#reset-handler)))
 (define (##sys#quit-hook result) ((##sys#exit-handler) 0))
 (define (quit #!optional result) (##sys#quit-hook result))
+(define (##sys#debug-mode?) (##core#inline "C_i_debug_modep"))
 
 (define (error . args)
   (if (pair? args)
@@ -247,7 +248,7 @@ EOF
       (##sys#signal-hook #:error #f)))
 
 (define ##sys#warnings-enabled #t)
-(define ##sys#notices-enabled (##sys#fudge 13))
+(define ##sys#notices-enabled (##sys#debug-mode?))
 
 (define (warning msg . args)
   (when ##sys#warnings-enabled
@@ -4669,10 +4670,10 @@ EOF
 
 (define (##sys#cleanup-before-exit)
   (set! exit-in-progress #t)
-  (when (##sys#fudge 37)		; -:H given?
+  (when (##core#inline "C_i_dump_heap_on_exitp")
     (##sys#print "\n" #f ##sys#standard-error)
     (##sys#dump-heap-state))
-  (when (##sys#fudge 45)		; -:p or -:P given?
+  (when (##core#inline "C_i_profilingp")
     (##core#inline "C_i_dump_statistical_profile"))
   (let loop ()
     (let ((tasks ##sys#cleanup-tasks))
@@ -4680,7 +4681,7 @@ EOF
       (unless (null? tasks)
 	(for-each (lambda (t) (t)) tasks)
 	(loop))))    
-  (when (##sys#fudge 13)		; debug mode
+  (when (##sys#debug-mode?)
     (##sys#print "[debug] forcing finalizers...\n" #f ##sys#standard-error) )
   (when (force-finalizers) (##sys#force-finalizers)) )
 
@@ -5418,7 +5419,8 @@ EOF
 
 ;;; GC info:
 
-(define (current-gc-milliseconds) (##sys#fudge 31))
+(define (current-gc-milliseconds)
+  (##core#inline "C_i_accumulated_gc_time"))
 
 (define (set-gc-report! flag)
   (##core#inline "C_set_gc_report" flag))
@@ -5445,27 +5447,29 @@ EOF
 (define set-finalizer! 
   (let ((string-append string-append))
     (lambda (x y)
-      (when (fx>= (##sys#fudge 26) _max_pending_finalizers)
+      (when (fx>= (##core#inline "C_i_live_finalizer_count")
+		  _max_pending_finalizers)
 	(cond ((##core#inline "C_resize_pending_finalizers" (fx* 2 _max_pending_finalizers))
 	       (set! ##sys#pending-finalizers
 		 (##sys#vector-resize ##sys#pending-finalizers
 				      (fx+ (fx* 2 _max_pending_finalizers) 1)
 				      (##core#undefined)))
-	       (when (##sys#fudge 13)
+	       (when (##sys#debug-mode?)
 		 (##sys#print 
 		  (string-append
 		   "[debug] too many finalizers (" 
-		   (##sys#number->string (##sys#fudge 26))
+		   (##sys#number->string
+		    (##core#inline "C_i_live_finalizer_count"))
 		   "), resized max finalizers to "
 		   (##sys#number->string _max_pending_finalizers)
 		   "\n")
 		  #f ##sys#standard-error)))
 	      (else
-	       (when (##sys#fudge 13)
+	       (when (##sys#debug-mode?)
 		 (##sys#print 
 		  (string-append
 		   "[debug] too many finalizers ("
-		   (##sys#fudge 26)
+		   (##core#inline "C_i_live_finalizer_count")
 		   "), forcing ...\n")
 		  #f ##sys#standard-error))
 	       (##sys#force-finalizers) ) ) )
@@ -5479,11 +5483,15 @@ EOF
       (unless working
 	(set! working #t)
 	(let* ((c (##sys#slot ##sys#pending-finalizers 0)) )
-	  (when (##sys#fudge 13)
+	  (when (##sys#debug-mode?)
 	    (##sys#print 
 	     (string-append "[debug] running " (##sys#number->string c)
-			    " finalizer(s) (" (##sys#number->string (##sys#fudge 26))
-			    " live, " (##sys#number->string (##sys#fudge 27))
+			    " finalizer(s) ("
+			    (##sys#number->string
+			     (##core#inline "C_i_live_finalizer_count"))
+			    " live, "
+			    (##sys#number->string
+			     (##core#inline "C_i_allocated_finalizer_count"))
 			    " allocated) ...\n")
 	     #f ##sys#standard-error))
 	  (do ([i 0 (fx+ i 1)])
diff --git a/profiler.scm b/profiler.scm
index 01c791c..a473634 100644
--- a/profiler.scm
+++ b/profiler.scm
@@ -124,7 +124,7 @@
 	[write-char write-char]
 	[write write] )
     (lambda ()
-      (when (##sys#fudge 13)
+      (when (##sys#debug-mode?)
 	(##sys#print "[debug] writing profile...\n" #f ##sys#standard-error) )
       (apply
        with-output-to-file ##sys#profile-name
diff --git a/runtime.c b/runtime.c
index bf7e633..e2a744d 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4665,6 +4665,14 @@ C_regparm C_word C_fcall C_set_gc_report(C_word flag)
   return C_SCHEME_UNDEFINED;
 }
 
+C_regparm C_word C_fcall C_i_accumulated_gc_time(void)
+{
+  double tgc;
+
+  tgc = timer_accumulated_gc_ms;
+  timer_accumulated_gc_ms = 0;
+  return C_fix(tgc);
+}
 
 C_regparm C_word C_fcall C_start_timer(void)
 {
@@ -4826,12 +4834,38 @@ C_regparm C_word C_fcall C_char_ready_p(C_word port)
 #endif
 }
 
+C_regparm C_word C_fcall C_i_tty_forcedp(void)
+{
+  return C_mk_bool(fake_tty_flag);
+}
+
+C_regparm C_word C_fcall C_i_debug_modep(void)
+{
+  return C_mk_bool(debug_mode);
+}
 
-C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
+C_regparm C_word C_fcall C_i_dump_heap_on_exitp(void)
 {
-  int i, j;
-  double tgc;
+  return C_mk_bool(dump_heap_on_exit);
+}
+
+C_regparm C_word C_fcall C_i_profilingp(void)
+{
+  return C_mk_bool(profiling);
+}
+
+C_regparm C_word C_fcall C_i_live_finalizer_count(void)
+{
+  return C_fix(live_finalizer_count);
+}
+
+C_regparm C_word C_fcall C_i_allocated_finalizer_count(void)
+{
+  return C_fix(allocated_finalizer_count);
+}
 
+C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
+{
   switch(fudge_factor) {
   case C_fix(1):                              /* eof object */
     panic(C_text("(##sys#fudge 1) [eof object] is obsolete"));
@@ -4866,10 +4900,10 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 11) [UNIX system] is obsolete"));
 
   case C_fix(12):		/* tty forced? */
-    return C_mk_bool(fake_tty_flag);
+    panic(C_text("(##sys#fudge 12) [tty forced] is obsolete"));
 
   case C_fix(13):		/* debug mode */
-    return C_mk_bool(debug_mode);
+    panic(C_text("(##sys#fudge 13) [debug mode] is obsolete"));
 
   case C_fix(14):		/* interrupts enabled? */
     panic(C_text("(##sys#fudge 14) [interrupts enabled] is obsolete"));
@@ -4887,9 +4921,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 18) [stack direction] is obsolete"));
 
   case C_fix(19):		/* number of locatives */
-    for(i = j = 0; i < locative_table_count; ++i)
-      if(locative_table[ i ] != C_SCHEME_UNDEFINED) ++j;
-    return C_fix(j);
+    panic(C_text("(##sys#fudge 19) [nr. of locatives] is obsolete"));
 
   case C_fix(20):		/* unused */
     panic(C_text("(##sys#fudge 20) [?] is obsolete"));
@@ -4910,10 +4942,10 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 25) [enable repl on error] is obsolete"));
 
   case C_fix(26):		/* number of untriggered finalizers */
-    return C_fix(live_finalizer_count);
+    panic(C_text("(##sys#fudge 26) [live finalizers] is obsolete"));
 
   case C_fix(27):		/* total number of finalizers used and unused */
-    return C_fix(allocated_finalizer_count);
+    panic(C_text("(##sys#fudge 27) [total finalizers] is obsolete"));
 
   case C_fix(28):		/* are procedure-tabled enabled? */
     panic(C_text("(##sys#fudge 28) [ptables] is obsolete"));
@@ -4925,9 +4957,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 30) [?] is obsolete"));
 
   case C_fix(31):		/* GC time since last invocation */
-    tgc = timer_accumulated_gc_ms;
-    timer_accumulated_gc_ms = 0;
-    return C_fix(tgc);
+    panic(C_text("(##sys#fudge 31) [accumulated gc time] is obsolete"));
 
   case C_fix(32):		/* are GC-hooks enabled? */
     panic(C_text("(##sys#fudge 32) [gchooks] is obsolete"));
@@ -4945,7 +4975,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 36) [toggle debug-mode] is obsolete"));
 
   case C_fix(37):		/* heap-dump enabled? */
-    return C_mk_bool(dump_heap_on_exit);
+    panic(C_text("(##sys#fudge 37) [dump heap on exit] is obsolete"));
 
   case C_fix(38):		/* unused */
     panic(C_text("(##sys#fudge 38) [old svn rev.] is obsolete"));
@@ -4969,7 +4999,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
     panic(C_text("(##sys#fudge 44) [debugging] is obsolete"));
 
   case C_fix(45):  /* Whether we're currently profiling */
-    return C_mk_bool(profiling);
+    panic(C_text("(##sys#fudge 45) [profiling] is obsolete"));
 
   default:
     panic(C_text("Unknown fudge factor"));
diff --git a/scrutinizer.scm b/scrutinizer.scm
index ea19bac..1075054 100644
--- a/scrutinizer.scm
+++ b/scrutinizer.scm
@@ -51,7 +51,7 @@
 (define scrutiny-debug #t)
 
 (define (d fstr . args)
-  (when (and scrutiny-debug (##sys#fudge 13))
+  (when (and scrutiny-debug (##sys#debug-mode?))
     (printf "[debug|~a] ~a~?~%" d-depth (make-string d-depth #\space) fstr args)) )
 
 (define dd d)
diff --git a/tests/gobble.scm b/tests/gobble.scm
index b587bb1..aac4651 100644
--- a/tests/gobble.scm
+++ b/tests/gobble.scm
@@ -8,7 +8,7 @@
   (let loop ((k 0))
     (when (< k n)
       (let ((x (make-string 1000)))
-	(when (and (zero? (modulo k 100000)) (##sys#fudge 13))
+	(when (and (zero? (modulo k 100000)) (##sys#debug-mode?))
 	  (print* "."))
 	(loop (+ k 1000))))))
 
diff --git a/types.db b/types.db
index 4ac0c07..17250e9 100644
--- a/types.db
+++ b/types.db
@@ -1035,6 +1035,8 @@
 (error (procedure error (* #!rest) noreturn))
 (##sys#error (procedure ##sys#error (* #!rest) noreturn))
 (##sys#signal-hook (procedure ##sys#signal-hook (* #!rest) noreturn))
+(##sys#debug-mode? (procedure ##sys#debug-mode? () boolean)
+		   (() (##core#inline "C_i_debug_modep")))
 (executable-pathname (#(procedure #:pure) executable-pathname () (or string false)))
 (exit (procedure exit (#!optional fixnum) noreturn))
 (exit-handler (#(procedure #:clean #:enforce) exit-handler (#!optional (procedure (fixnum) . *)) procedure))
-- 
2.1.4

From e67b106863af4ed53efa4ffdc3e9e6d96914463c Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Fri, 14 Oct 2016 21:51:56 +0200
Subject: [PATCH 9/9] Finally, remove all traces of ##sys#fudge/C_fudge

---
 c-platform.scm |   5 +-
 chicken.h      |   1 -
 library.scm    |   1 -
 runtime.c      | 143 ---------------------------------------------------------
 4 files changed, 2 insertions(+), 148 deletions(-)

diff --git a/c-platform.scm b/c-platform.scm
index 25098e4..aba4916 100644
--- a/c-platform.scm
+++ b/c-platform.scm
@@ -229,7 +229,7 @@
     ##sys#check-open-port
     ##sys#check-char ##sys#check-vector ##sys#check-byte-vector ##sys#list ##sys#cons
     ##sys#call-with-values ##sys#flonum-in-fixnum-range? 
-    ##sys#fudge ##sys#immediate? ##sys#context-switch
+    ##sys#immediate? ##sys#context-switch
     ##sys#make-structure ##sys#apply ##sys#apply-values
     chicken.continuation#continuation-graft
     ##sys#bytevector? ##sys#make-vector ##sys#setter ##sys#car ##sys#cdr ##sys#pair?
@@ -245,7 +245,7 @@
 (for-each
  (cut mark-variable <> '##compiler#pure '#t)
  '(##sys#slot ##sys#block-ref ##sys#size ##sys#byte
-    ##sys#pointer? ##sys#generic-structure? ##sys#fudge ##sys#immediate?
+    ##sys#pointer? ##sys#generic-structure? ##sys#immediate?
     ##sys#bytevector? ##sys#pair? ##sys#eq? ##sys#list? ##sys#vector? ##sys#eqv? 
     ##sys#get-keyword			; ok it isn't, but this is only used for ext. llists
     ##sys#void ##sys#permanent?))
@@ -842,7 +842,6 @@
 (rewrite '##sys#poke-double 17 3 "C_poke_double")
 (rewrite 'string=? 17 2 "C_i_string_equal_p" "C_u_i_string_equal_p")
 (rewrite 'string-ci=? 17 2 "C_i_string_ci_equal_p")
-(rewrite '##sys#fudge 17 1 "C_fudge")
 (rewrite '##sys#permanent? 17 1 "C_permanentp")
 (rewrite '##sys#null-pointer? 17 1 "C_null_pointerp" "C_null_pointerp")
 (rewrite '##sys#immediate? 17 1 "C_immp")
diff --git a/chicken.h b/chicken.h
index 0fd3754..0f619aa 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1902,7 +1902,6 @@ C_fctexport C_word C_fcall C_peek_char(C_word port) C_regparm;
 C_fctexport C_word C_fcall C_execute_shell_command(C_word string) C_regparm;
 C_fctexport int C_fcall C_check_fd_ready(int fd) C_regparm;
 C_fctexport C_word C_fcall C_char_ready_p(C_word port) C_regparm;
-C_fctexport C_word C_fcall C_fudge(C_word fudge_factor) C_regparm;
 C_fctexport void C_fcall C_raise_interrupt(int reason) C_regparm;
 C_fctexport C_word C_fcall C_establish_signal_handler(C_word signum, C_word reason) C_regparm;
 C_fctexport C_word C_fcall C_copy_block(C_word from, C_word to) C_regparm;
diff --git a/library.scm b/library.scm
index 1368032..ff612f1 100644
--- a/library.scm
+++ b/library.scm
@@ -280,7 +280,6 @@ EOF
 (define (argc+argv) (##sys#values main_argc main_argv))
 (define ##sys#make-structure (##core#primitive "C_make_structure"))
 (define ##sys#ensure-heap-reserve (##core#primitive "C_ensure_heap_reserve"))
-(define (##sys#fudge index) (##core#inline "C_fudge" index))
 (define return-to-host (##core#primitive "C_return_to_host"))
 (define ##sys#symbol-table-info (##core#primitive "C_get_symbol_table_info"))
 (define ##sys#memory-info (##core#primitive "C_get_memory_info"))
diff --git a/runtime.c b/runtime.c
index e2a744d..146da1b 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4864,149 +4864,6 @@ C_regparm C_word C_fcall C_i_allocated_finalizer_count(void)
   return C_fix(allocated_finalizer_count);
 }
 
-C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
-{
-  switch(fudge_factor) {
-  case C_fix(1):                              /* eof object */
-    panic(C_text("(##sys#fudge 1) [eof object] is obsolete"));
-  case C_fix(2):			      /* get time */
-    panic(C_text("(##sys#fudge 2) [get time] not implemented"));
-
-  case C_fix(3):		/* 64-bit system? */
-    panic(C_text("(##sys#fudge 3) [64bit] is obsolete"));
-
-  case C_fix(4):		/* is this a console application? */
-    panic(C_text("(##sys#fudge 4) [console application] is obsolete"));
-
-  case C_fix(5):		/* is this a GUI/console or Windows-GUI application? (silly) */
-    panic(C_text("(##sys#fudge 5) [Windows GUI application] is obsolete"));
-
-  case C_fix(6): 		/* milliseconds CPU */
-    panic(C_text("(##sys#fudge 6) [current CPU milliseconds] not implemented"));
-
-  case C_fix(7):		/* wordsize */
-    panic(C_text("(##sys#fudge 7) [wordsize] is obsolete"));
-
-  case C_fix(8):		/* words needed for double */
-    panic(C_text("(##sys#fudge 8) [wordsperdouble] is obsolete"));
-
-  case C_fix(9):		/* latency */
-    panic(C_text("(##sys#fudge 9) [latency] is obsolete"));
-
-  case C_fix(10):		/* clocks per sec */
-    panic(C_text("(##sys#fudge 10) [clockspersec] is obsolete"));
-
-  case C_fix(11):		/* not a unix system? */
-    panic(C_text("(##sys#fudge 11) [UNIX system] is obsolete"));
-
-  case C_fix(12):		/* tty forced? */
-    panic(C_text("(##sys#fudge 12) [tty forced] is obsolete"));
-
-  case C_fix(13):		/* debug mode */
-    panic(C_text("(##sys#fudge 13) [debug mode] is obsolete"));
-
-  case C_fix(14):		/* interrupts enabled? */
-    panic(C_text("(##sys#fudge 14) [interrupts enabled] is obsolete"));
-
-  case C_fix(15):		/* symbol-gc enabled? */
-    panic(C_text("(##sys#fudge 15) [symbolgc] is obsolete"));
-
-  case C_fix(16):		/* milliseconds (wall clock) */
-    panic(C_text("(##sys#fudge 16) [current wall clock milliseconds] not implemented"));
-
-  case C_fix(17):		/* fixed heap? */
-    panic(C_text("(##sys#fudge 17) [fixed heap] is obsolete"));
-
-  case C_fix(18):		/* stack direction */
-    panic(C_text("(##sys#fudge 18) [stack direction] is obsolete"));
-
-  case C_fix(19):		/* number of locatives */
-    panic(C_text("(##sys#fudge 19) [nr. of locatives] is obsolete"));
-
-  case C_fix(20):		/* unused */
-    panic(C_text("(##sys#fudge 20) [?] is obsolete"));
-
-  case C_fix(21):		/* largest fixnum */
-    panic(C_text("(##sys#fudge 21) [largest fixnum] is obsolete"));
-
-  case C_fix(22):		/* does this process use a private egg-repository? */
-    panic(C_text("(##sys#fudge 22) [private repo?] is obsolete"));
-
-  case C_fix(23):		/* seconds since process startup */
-    panic(C_text("(##sys#fudge 23) [startuptime] is obsolete"));
-
-  case C_fix(24):		/* dynamic loading available? */
-    panic(C_text("(##sys#fudge 24) [dload] is obsolete"));
-
-  case C_fix(25):		/* REPL on error? XXX Is this used anywhere? */
-    panic(C_text("(##sys#fudge 25) [enable repl on error] is obsolete"));
-
-  case C_fix(26):		/* number of untriggered finalizers */
-    panic(C_text("(##sys#fudge 26) [live finalizers] is obsolete"));
-
-  case C_fix(27):		/* total number of finalizers used and unused */
-    panic(C_text("(##sys#fudge 27) [total finalizers] is obsolete"));
-
-  case C_fix(28):		/* are procedure-tabled enabled? */
-    panic(C_text("(##sys#fudge 28) [ptables] is obsolete"));
-
-  case C_fix(29):		/* size of ring-buffer used to hold trace entries */
-    panic(C_text("(##sys#fudge 29) [trace buffer size] is obsolete"));
-
-  case C_fix(30):		/* unused */
-    panic(C_text("(##sys#fudge 30) [?] is obsolete"));
-
-  case C_fix(31):		/* GC time since last invocation */
-    panic(C_text("(##sys#fudge 31) [accumulated gc time] is obsolete"));
-
-  case C_fix(32):		/* are GC-hooks enabled? */
-    panic(C_text("(##sys#fudge 32) [gchooks] is obsolete"));
-
-  case C_fix(33):		/* return process-ID */
-    panic(C_text("(##sys#fudge 33) [getpid] is obsolete"));
-
-  case C_fix(34):		/* effective maximum for procedure arguments */
-    panic(C_text("(##sys#fudge 34) [apply-argument-limit] is obsolete"));
-
-  case C_fix(35):		/* unused */
-    panic(C_text("(##sys#fudge 35) [old apply-hack] is obsolete"));
-    
-  case C_fix(36):		/* toggle debug mode */
-    panic(C_text("(##sys#fudge 36) [toggle debug-mode] is obsolete"));
-
-  case C_fix(37):		/* heap-dump enabled? */
-    panic(C_text("(##sys#fudge 37) [dump heap on exit] is obsolete"));
-
-  case C_fix(38):		/* unused */
-    panic(C_text("(##sys#fudge 38) [old svn rev.] is obsolete"));
-
-  case C_fix(39):		/* is this a cross-chicken? */
-    panic(C_text("(##sys#fudge 39) [cross-chicken] is obsolete"));
-
-  case C_fix(40):		/* many arguments supported? */
-    panic(C_text("(##sys#fudge 40) [manyargs] is obsolete"));
-
-  case C_fix(41):		/* major CHICKEN version */
-    panic(C_text("(##sys#fudge 41) [major version] is obsolete"));
-
-  case C_fix(42):		/* binary version number */
-    panic(C_text("(##sys#fudge 42) [binary version] is obsolete"));
-
-  case C_fix(43):		/* minor CHICKEN version */
-    panic(C_text("(##sys#fudge 43) [minor version] is obsolete"));
-
-  case C_fix(44):  /* whether debugger is active */
-    panic(C_text("(##sys#fudge 44) [debugging] is obsolete"));
-
-  case C_fix(45):  /* Whether we're currently profiling */
-    panic(C_text("(##sys#fudge 45) [profiling] is obsolete"));
-
-  default:
-    panic(C_text("Unknown fudge factor"));
-  }
-}
-
-
 C_regparm void C_fcall C_paranoid_check_for_interrupt(void)
 {
   if(--C_timer_interrupt_counter <= 0)
-- 
2.1.4

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to