diff --git a/HACKING b/HACKING index 92a27890..9a35180a 100644 --- a/HACKING +++ b/HACKING @@ -136,6 +136,10 @@ enough to work on compiling tinycc's tcc.c albeit a somewhat modified version. * Bugs +** mes: gcc-x86 compiled, tests/srfi-13.test number->string INT-MIN fails: +test: number->string INT-MIN: fail +expected: -2147483648 +actual: -./,),(-*,( ** tcc: tcc-built lib/libc+tcc.c segfaults with mes, with tcc. ** mes: remove pmatch-car/pmatch-cdr hack. ** mescc: softcode stack frame size, now hardcoded and very large diff --git a/module/mes/mes-0.scm b/module/mes/mes-0.scm index 773c0a17..7e92d664 100644 --- a/module/mes/mes-0.scm +++ b/module/mes/mes-0.scm @@ -35,6 +35,8 @@ guile? guile-1.8? guile-2? + %arch + %compiler )) (define-macro (mes-use-module . rest) #t) @@ -45,3 +47,5 @@ (define guile-2? (equal? (major-version) "2")) (define EOF (if #f #f)) (define append2 append) +(define %arch (car (string-split %host-type #\-))) +(define %compiler "gcc") diff --git a/scaffold/mini-mes.c b/scaffold/mini-mes.c index 59508bdb..3ade758f 100644 --- a/scaffold/mini-mes.c +++ b/scaffold/mini-mes.c @@ -195,8 +195,8 @@ struct scm scm_type_variable = {TSYMBOL, "",0}; struct scm scm_type_vector = {TSYMBOL, "",0}; struct scm scm_type_broken_heart = {TSYMBOL, "",0}; -struct scm scm_symbol_gnuc = {TSYMBOL, "%gnuc",0}; -struct scm scm_symbol_mesc = {TSYMBOL, "%mesc",0}; +struct scm scm_symbol_compiler = {TSYMBOL, "%compiler",0}; +struct scm scm_symbol_arch = {TSYMBOL, "%arch",0}; struct scm scm_test = {TSYMBOL, "test",0}; @@ -838,13 +838,19 @@ mes_symbols () ///((internal)) a = acons (cell_symbol_call_with_current_continuation, cell_call_with_current_continuation, a); a = acons (cell_symbol_sc_expand, cell_f, a); -#if __GNUC__ - a = acons (cell_symbol_gnuc, cell_t, a); - a = acons (cell_symbol_mesc, cell_f, a); -#else - a = acons (cell_symbol_gnuc, cell_f, a); - a = acons (cell_symbol_mesc, cell_t, a); + char *compiler = "gcc"; +#if __MESC__ + compiler = "mescc"; +#elif __TINYC__ + compiler = "tcc"; #endif + a = acons (cell_symbol_compiler, MAKE_STRING (cstring_to_list (compiler)), a); + + char *arch = "x86"; +#if __x86_64__ + arch = "x86_64"; +#endif + a = acons (cell_symbol_arch, MAKE_STRING (cstring_to_list (arch)), a); a = acons (cell_closure, a, a); @@ -918,13 +924,19 @@ bload_env (SCM a) ///((internal)) g_stdin = STDIN; r0 = mes_builtins (r0); -#if __GNUC__ - set_env_x (cell_symbol_gnuc, cell_t, r0); - set_env_x (cell_symbol_mesc, cell_f, r0); -#else - set_env_x (cell_symbol_gnuc, cell_f, r0); - set_env_x (cell_symbol_mesc, cell_t, r0); + char *compiler = "gcc"; +#if __MESC__ + compiler = "mescc"; +#elif __TINYC__ + compiler = "tcc"; #endif + set_env_x (cell_symbol_compiler, MAKE_STRING (cstring_to_list (compiler)), r0); + + char *arch = "x86"; +#if __x86_64__ + arch = "x86_64"; +#endif + set_env_x (cell_symbol_arch, MAKE_STRING (cstring_to_list (arch)), r0); if (g_debug) { diff --git a/src/mes.c b/src/mes.c index fe5280a4..0eef233a 100644 --- a/src/mes.c +++ b/src/mes.c @@ -235,10 +235,10 @@ struct scm scm_type_variable = {TSYMBOL, "",0}; struct scm scm_type_vector = {TSYMBOL, "",0}; struct scm scm_type_broken_heart = {TSYMBOL, "",0}; -struct scm scm_symbol_gnuc = {TSYMBOL, "%gnuc",0}; -struct scm scm_symbol_mesc = {TSYMBOL, "%mesc",0}; +struct scm scm_symbol_compiler = {TSYMBOL, "%compiler",0}; +struct scm scm_symbol_arch = {TSYMBOL, "%arch",0}; -struct scm scm_test = {TSYMBOL, "test",0}; +struct scm scm_test = {TSYMBOL, "%%test",0}; #if !_POSIX_SOURCE #include "mes.mes.symbols.h" @@ -1830,10 +1830,10 @@ g_free++; g_cells[cell_vm_return] = scm_vm_return; g_free++; -g_cells[cell_symbol_gnuc] = scm_symbol_gnuc; +g_cells[cell_symbol_compiler] = scm_symbol_compiler; g_free++; -g_cells[cell_symbol_mesc] = scm_symbol_mesc; +g_cells[cell_symbol_arch] = scm_symbol_arch; g_free++; g_cells[cell_test] = scm_test; @@ -1948,8 +1948,8 @@ g_cells[cell_vm_call_with_values2].car = g_cells[cell_vm_evlis].car; g_cells[cell_vm_call_with_current_continuation2].car = g_cells[cell_vm_evlis].car; g_cells[cell_vm_return].car = g_cells[cell_vm_evlis].car; -g_cells[cell_symbol_gnuc].car = cstring_to_list (scm_symbol_gnuc.name); -g_cells[cell_symbol_mesc].car = cstring_to_list (scm_symbol_mesc.name); +g_cells[cell_symbol_compiler].car = cstring_to_list (scm_symbol_compiler.name); +g_cells[cell_symbol_arch].car = cstring_to_list (scm_symbol_arch.name); g_cells[cell_test].car = cstring_to_list (scm_test.name); ////////////////// gc @@ -1967,13 +1967,20 @@ g_cells[cell_test].car = cstring_to_list (scm_test.name); a = acons (cell_symbol_mes_version, MAKE_STRING (cstring_to_list (VERSION)), a); a = acons (cell_symbol_mes_prefix, MAKE_STRING (cstring_to_list (PREFIX)), a); -#if __GNUC__ - a = acons (cell_symbol_gnuc, cell_t, a); - a = acons (cell_symbol_mesc, cell_f, a); -#else - a = acons (cell_symbol_gnuc, cell_f, a); - + char *compiler = "gcc"; +#if __MESC__ + compiler = "mescc"; +#elif __TINYC__ + compiler = "tcc"; #endif + a = acons (cell_symbol_compiler, MAKE_STRING (cstring_to_list (compiler)), a); + + char *arch = "x86"; +#if __x86_64__ + arch = "x86_64"; +#endif + a = acons (cell_symbol_arch, MAKE_STRING (cstring_to_list (arch)), a); + #endif // !MES_MINI a = acons (cell_type_char, MAKE_NUMBER (TCHAR), a); @@ -2329,13 +2336,19 @@ bload_env (SCM a) ///((internal)) g_stdin = STDIN; r0 = mes_builtins (r0); -#if __GNUC__ - set_env_x (cell_symbol_gnuc, cell_t, r0); - set_env_x (cell_symbol_mesc, cell_f, r0); -#else - set_env_x (cell_symbol_gnuc, cell_f, r0); - set_env_x (cell_symbol_mesc, cell_t, r0); + char *compiler = "gcc"; +#if __MESC__ + compiler = "mescc"; +#elif __TINYC__ + compiler = "tcc"; #endif + a = acons (cell_symbol_compiler, MAKE_STRING (cstring_to_list (compiler)), a); + + char *arch = "x86"; +#if __x86_64__ + arch = "x86_64"; +#endif + a = acons (cell_symbol_arch, MAKE_STRING (cstring_to_list (arch)), a); if (g_debug > 3) { diff --git a/tests/srfi-13.test b/tests/srfi-13.test index 527c0e17..1a446c70 100755 --- a/tests/srfi-13.test +++ b/tests/srfi-13.test @@ -108,4 +108,4 @@ exec ${MES-src/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests (pass-if-equal "string-replace" "fubar" (string-replace "foobar" "u" 1 3)) -(result 'report) +(result 'report (if (and (equal? %compiler "gcc") (equal? %arch "x86")) 1 0))