mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
Merge branch 'master' of https://github.com/ashinn/chibi-scheme
This commit is contained in:
commit
231c4bc04b
12 changed files with 119 additions and 50 deletions
18
Makefile
18
Makefile
|
@ -24,10 +24,11 @@ TEMPFILE := $(shell mktemp -t chibi.XXXXXX)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
CHIBI_COMPILED_LIBS = lib/chibi/filesystem$(SO) lib/chibi/process$(SO) \
|
CHIBI_COMPILED_LIBS = lib/chibi/filesystem$(SO) lib/chibi/weak$(SO) \
|
||||||
lib/chibi/time$(SO) lib/chibi/system$(SO) lib/chibi/stty$(SO) \
|
lib/chibi/heap-stats$(SO) lib/chibi/disasm$(SO) lib/chibi/ast$(SO) \
|
||||||
lib/chibi/weak$(SO) lib/chibi/heap-stats$(SO) lib/chibi/disasm$(SO) \
|
lib/chibi/emscripten$(SO)
|
||||||
lib/chibi/net$(SO) lib/chibi/ast$(SO) lib/chibi/emscripten$(SO)
|
CHIBI_POSIX_COMPILED_LIBS = lib/chibi/process$(SO) lib/chibi/time$(SO) \
|
||||||
|
lib/chibi/system$(SO) lib/chibi/stty$(SO) lib/chibi/net$(SO)
|
||||||
CHIBI_CRYPTO_COMPILED_LIBS = lib/chibi/crypto/crypto$(SO)
|
CHIBI_CRYPTO_COMPILED_LIBS = lib/chibi/crypto/crypto$(SO)
|
||||||
CHIBI_IO_COMPILED_LIBS = lib/chibi/io/io$(SO)
|
CHIBI_IO_COMPILED_LIBS = lib/chibi/io/io$(SO)
|
||||||
CHIBI_OPT_COMPILED_LIBS = lib/chibi/optimize/rest$(SO) \
|
CHIBI_OPT_COMPILED_LIBS = lib/chibi/optimize/rest$(SO) \
|
||||||
|
@ -36,10 +37,14 @@ EXTRA_COMPILED_LIBS ?=
|
||||||
COMPILED_LIBS = $(CHIBI_COMPILED_LIBS) $(CHIBI_IO_COMPILED_LIBS) \
|
COMPILED_LIBS = $(CHIBI_COMPILED_LIBS) $(CHIBI_IO_COMPILED_LIBS) \
|
||||||
$(CHIBI_OPT_COMPILED_LIBS) $(CHIBI_CRYPTO_COMPILED_LIBS) \
|
$(CHIBI_OPT_COMPILED_LIBS) $(CHIBI_CRYPTO_COMPILED_LIBS) \
|
||||||
$(EXTRA_COMPILED_LIBS) \
|
$(EXTRA_COMPILED_LIBS) \
|
||||||
lib/srfi/18/threads$(SO) lib/srfi/27/rand$(SO) lib/srfi/151/bit$(SO) \
|
lib/srfi/27/rand$(SO) lib/srfi/151/bit$(SO) \
|
||||||
lib/srfi/39/param$(SO) lib/srfi/69/hash$(SO) lib/srfi/95/qsort$(SO) \
|
lib/srfi/39/param$(SO) lib/srfi/69/hash$(SO) lib/srfi/95/qsort$(SO) \
|
||||||
lib/srfi/98/env$(SO) lib/srfi/144/math$(SO) lib/scheme/time$(SO)
|
lib/srfi/98/env$(SO) lib/srfi/144/math$(SO) lib/scheme/time$(SO)
|
||||||
|
|
||||||
|
ifndef EXCLUDE_POSIX_LIBS
|
||||||
|
COMPILED_LIBS += $(CHIBI_POSIX_COMPILED_LIBS) lib/srfi/18/threads$(SO)
|
||||||
|
endif
|
||||||
|
|
||||||
BASE_INCLUDES = include/chibi/sexp.h include/chibi/features.h include/chibi/install.h include/chibi/bignum.h
|
BASE_INCLUDES = include/chibi/sexp.h include/chibi/features.h include/chibi/install.h include/chibi/bignum.h
|
||||||
INCLUDES = $(BASE_INCLUDES) include/chibi/eval.h include/chibi/gc_heap.h
|
INCLUDES = $(BASE_INCLUDES) include/chibi/eval.h include/chibi/gc_heap.h
|
||||||
|
|
||||||
|
@ -287,7 +292,7 @@ install-base: all
|
||||||
$(MKDIR) $(DESTDIR)$(MODDIR)/chibi/char-set $(DESTDIR)$(MODDIR)/chibi/crypto $(DESTDIR)$(MODDIR)/chibi/io $(DESTDIR)$(MODDIR)/chibi/iset $(DESTDIR)$(MODDIR)/chibi/loop $(DESTDIR)$(MODDIR)/chibi/match $(DESTDIR)$(MODDIR)/chibi/math $(DESTDIR)$(MODDIR)/chibi/monad $(DESTDIR)$(MODDIR)/chibi/net $(DESTDIR)$(MODDIR)/chibi/optimize $(DESTDIR)$(MODDIR)/chibi/parse $(DESTDIR)$(MODDIR)/chibi/regexp $(DESTDIR)$(MODDIR)/chibi/show $(DESTDIR)$(MODDIR)/chibi/snow $(DESTDIR)$(MODDIR)/chibi/term
|
$(MKDIR) $(DESTDIR)$(MODDIR)/chibi/char-set $(DESTDIR)$(MODDIR)/chibi/crypto $(DESTDIR)$(MODDIR)/chibi/io $(DESTDIR)$(MODDIR)/chibi/iset $(DESTDIR)$(MODDIR)/chibi/loop $(DESTDIR)$(MODDIR)/chibi/match $(DESTDIR)$(MODDIR)/chibi/math $(DESTDIR)$(MODDIR)/chibi/monad $(DESTDIR)$(MODDIR)/chibi/net $(DESTDIR)$(MODDIR)/chibi/optimize $(DESTDIR)$(MODDIR)/chibi/parse $(DESTDIR)$(MODDIR)/chibi/regexp $(DESTDIR)$(MODDIR)/chibi/show $(DESTDIR)$(MODDIR)/chibi/snow $(DESTDIR)$(MODDIR)/chibi/term
|
||||||
$(MKDIR) $(DESTDIR)$(MODDIR)/scheme/char
|
$(MKDIR) $(DESTDIR)$(MODDIR)/scheme/char
|
||||||
$(MKDIR) $(DESTDIR)$(MODDIR)/scheme/time
|
$(MKDIR) $(DESTDIR)$(MODDIR)/scheme/time
|
||||||
$(MKDIR) $(DESTDIR)$(MODDIR)/srfi/1 $(DESTDIR)$(MODDIR)/srfi/18 $(DESTDIR)$(MODDIR)/srfi/27 $(DESTDIR)$(MODDIR)/srfi/151 $(DESTDIR)$(MODDIR)/srfi/39 $(DESTDIR)$(MODDIR)/srfi/69 $(DESTDIR)$(MODDIR)/srfi/95 $(DESTDIR)$(MODDIR)/srfi/99 $(DESTDIR)$(MODDIR)/srfi/99/records $(DESTDIR)$(MODDIR)/srfi/121 $(DESTDIR)$(MODDIR)/srfi/125 $(DESTDIR)$(MODDIR)/srfi/128 $(DESTDIR)$(MODDIR)/srfi/129 $(DESTDIR)$(MODDIR)/srfi/132 $(DESTDIR)$(MODDIR)/srfi/133 $(DESTDIR)$(MODDIR)/srfi/143 $(DESTDIR)$(MODDIR)/srfi/144
|
$(MKDIR) $(DESTDIR)$(MODDIR)/srfi/1 $(DESTDIR)$(MODDIR)/srfi/18 $(DESTDIR)$(MODDIR)/srfi/27 $(DESTDIR)$(MODDIR)/srfi/151 $(DESTDIR)$(MODDIR)/srfi/39 $(DESTDIR)$(MODDIR)/srfi/69 $(DESTDIR)$(MODDIR)/srfi/95 $(DESTDIR)$(MODDIR)/srfi/99 $(DESTDIR)$(MODDIR)/srfi/99/records $(DESTDIR)$(MODDIR)/srfi/117 $(DESTDIR)$(MODDIR)/srfi/121 $(DESTDIR)$(MODDIR)/srfi/125 $(DESTDIR)$(MODDIR)/srfi/128 $(DESTDIR)$(MODDIR)/srfi/129 $(DESTDIR)$(MODDIR)/srfi/132 $(DESTDIR)$(MODDIR)/srfi/133 $(DESTDIR)$(MODDIR)/srfi/143 $(DESTDIR)$(MODDIR)/srfi/144
|
||||||
$(INSTALL) -m0644 $(META_FILES) $(DESTDIR)$(MODDIR)/
|
$(INSTALL) -m0644 $(META_FILES) $(DESTDIR)$(MODDIR)/
|
||||||
$(INSTALL) -m0644 lib/*.scm $(DESTDIR)$(MODDIR)/
|
$(INSTALL) -m0644 lib/*.scm $(DESTDIR)$(MODDIR)/
|
||||||
$(INSTALL) -m0644 lib/chibi/*.sld lib/chibi/*.scm $(DESTDIR)$(MODDIR)/chibi/
|
$(INSTALL) -m0644 lib/chibi/*.sld lib/chibi/*.scm $(DESTDIR)$(MODDIR)/chibi/
|
||||||
|
@ -319,6 +324,7 @@ install-base: all
|
||||||
$(INSTALL) -m0644 lib/srfi/95/*.scm $(DESTDIR)$(MODDIR)/srfi/95/
|
$(INSTALL) -m0644 lib/srfi/95/*.scm $(DESTDIR)$(MODDIR)/srfi/95/
|
||||||
$(INSTALL) -m0644 lib/srfi/99/*.sld $(DESTDIR)$(MODDIR)/srfi/99/
|
$(INSTALL) -m0644 lib/srfi/99/*.sld $(DESTDIR)$(MODDIR)/srfi/99/
|
||||||
$(INSTALL) -m0644 lib/srfi/99/records/*.sld lib/srfi/99/records/*.scm $(DESTDIR)$(MODDIR)/srfi/99/records/
|
$(INSTALL) -m0644 lib/srfi/99/records/*.sld lib/srfi/99/records/*.scm $(DESTDIR)$(MODDIR)/srfi/99/records/
|
||||||
|
$(INSTALL) -m0644 lib/srfi/117/*.scm $(DESTDIR)$(MODDIR)/srfi/117/
|
||||||
$(INSTALL) -m0644 lib/srfi/121/*.scm $(DESTDIR)$(MODDIR)/srfi/121/
|
$(INSTALL) -m0644 lib/srfi/121/*.scm $(DESTDIR)$(MODDIR)/srfi/121/
|
||||||
$(INSTALL) -m0644 lib/srfi/125/*.scm $(DESTDIR)$(MODDIR)/srfi/125/
|
$(INSTALL) -m0644 lib/srfi/125/*.scm $(DESTDIR)$(MODDIR)/srfi/125/
|
||||||
$(INSTALL) -m0644 lib/srfi/128/*.scm $(DESTDIR)$(MODDIR)/srfi/128/
|
$(INSTALL) -m0644 lib/srfi/128/*.scm $(DESTDIR)$(MODDIR)/srfi/128/
|
||||||
|
|
|
@ -45,6 +45,7 @@ endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Set default variables for the platform.
|
# Set default variables for the platform.
|
||||||
|
@ -73,24 +74,22 @@ else
|
||||||
ifeq ($(PLATFORM),windows)
|
ifeq ($(PLATFORM),windows)
|
||||||
SO = .dll
|
SO = .dll
|
||||||
EXE = .exe
|
EXE = .exe
|
||||||
CC = gcc
|
CC ?= gcc
|
||||||
CLIBFLAGS =
|
CLIBFLAGS =
|
||||||
CLINKFLAGS = -shared
|
CLINKFLAGS = -shared
|
||||||
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0 -DSEXP_USE_GREEN_THREADS=0 -DSEXP_USE_GC_FILE_DESCRIPTORS=0 -DBUILDING_DLL
|
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0 -DSEXP_USE_GREEN_THREADS=0 -DSEXP_USE_GC_FILE_DESCRIPTORS=0 -DBUILDING_DLL
|
||||||
LIBCHIBI_FLAGS = -Wl,--out-implib,libchibi-scheme$(SO).a
|
LIBCHIBI_FLAGS = -Wl,--out-implib,libchibi-scheme$(SO).a
|
||||||
STATICFLAGS = -DSEXP_USE_DL=0
|
STATICFLAGS =
|
||||||
LIBDL = -lws2_32
|
LIBDL = -lws2_32
|
||||||
else
|
else
|
||||||
ifeq ($(PLATFORM),mingw)
|
ifeq ($(PLATFORM),msys)
|
||||||
SO = .dll
|
SO = .dll
|
||||||
EXE = .exe
|
EXE = .exe
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CLIBFLAGS =
|
CLIBFLAGS =
|
||||||
CLINKFLAGS = -shared
|
CLINKFLAGS = -shared
|
||||||
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0 -DSEXP_USE_GREEN_THREADS=0 -DBUILDING_DLL
|
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0
|
||||||
LIBCHIBI_FLAGS = -Wl,--out-implib,libchibi-scheme$(SO).a
|
LIBCHIBI_FLAGS = -Wl,--out-implib,libchibi-scheme$(SO).a
|
||||||
STATICFLAGS = -DSEXP_USE_DL=0
|
|
||||||
LIBDL = -lws2_32
|
|
||||||
else
|
else
|
||||||
ifeq ($(PLATFORM),cygwin)
|
ifeq ($(PLATFORM),cygwin)
|
||||||
SO = .dll
|
SO = .dll
|
||||||
|
@ -116,7 +115,6 @@ endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM),unix)
|
ifeq ($(PLATFORM),unix)
|
||||||
#RLDFLAGS=-rpath $(LIBDIR)
|
#RLDFLAGS=-rpath $(LIBDIR)
|
||||||
|
|
19
appveyor.yml
Normal file
19
appveyor.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- ARCH: x64
|
||||||
|
- ARCH: x86
|
||||||
|
- ARCH: msys
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- if %ARCH%.==x64. set PATH=c:\msys64\usr\bin;c:\msys64\mingw64\bin;%PATH%
|
||||||
|
- if %ARCH%.==x86. set PATH=c:\msys64\usr\bin;c:\msys64\mingw32\bin;%PATH%
|
||||||
|
- if %ARCH%.==msys. set PATH=c:\msys64\usr\bin;%PATH%
|
||||||
|
- if %ARCH%.==x64. set CC=c:/msys64/mingw64/bin/gcc
|
||||||
|
- if %ARCH%.==x86. set CC=c:/msys64/mingw32/bin/gcc
|
||||||
|
- if %ARCH%.==msys. set CC=gcc
|
||||||
|
- if %ARCH%.==x64. set EXARG=EXCLUDE_POSIX_LIBS=1
|
||||||
|
- if %ARCH%.==x86. set EXARG=EXCLUDE_POSIX_LIBS=1
|
||||||
|
- if %ARCH%.==msys. set EXARG=PLATFORM=msys
|
||||||
|
- make CC=%CC% %EXARG%
|
||||||
|
- make CC=%CC% %EXARG% test
|
||||||
|
|
8
bignum.c
8
bignum.c
|
@ -531,8 +531,8 @@ sexp sexp_bignum_quot_rem (sexp ctx, sexp *rem, sexp a, sexp b) {
|
||||||
<< (sizeof(sexp_uint_t)*8))
|
<< (sizeof(sexp_uint_t)*8))
|
||||||
+ sexp_bignum_data(b1)[blen-2]);
|
+ sexp_bignum_data(b1)[blen-2]);
|
||||||
if (alen > 2 && blen > 2 &&
|
if (alen > 2 && blen > 2 &&
|
||||||
sexp_bignum_data(a1)[alen-1] < (1uL<<(sizeof(sexp_uint_t)*4)) &&
|
sexp_bignum_data(a1)[alen-1] < ((sexp_luint_t)1<<(sizeof(sexp_uint_t)*4)) &&
|
||||||
sexp_bignum_data(b1)[blen-1] < (1uL<<(sizeof(sexp_uint_t)*4))) {
|
sexp_bignum_data(b1)[blen-1] < ((sexp_luint_t)1<<(sizeof(sexp_uint_t)*4))) {
|
||||||
dn = (dn << (sizeof(sexp_uint_t)*4))
|
dn = (dn << (sizeof(sexp_uint_t)*4))
|
||||||
+ (sexp_bignum_data(a1)[alen-3] >> (sizeof(sexp_uint_t)*4));
|
+ (sexp_bignum_data(a1)[alen-3] >> (sizeof(sexp_uint_t)*4));
|
||||||
dd = (dd << (sizeof(sexp_uint_t)*4))
|
dd = (dd << (sizeof(sexp_uint_t)*4))
|
||||||
|
@ -544,8 +544,8 @@ sexp sexp_bignum_quot_rem (sexp ctx, sexp *rem, sexp a, sexp b) {
|
||||||
<< (sizeof(sexp_uint_t)*8))
|
<< (sizeof(sexp_uint_t)*8))
|
||||||
+ sexp_bignum_data(a1)[alen-2]);
|
+ sexp_bignum_data(a1)[alen-2]);
|
||||||
dd = sexp_bignum_data(b1)[blen-1];
|
dd = sexp_bignum_data(b1)[blen-1];
|
||||||
if (sexp_bignum_data(a1)[alen-1] < (1uL<<(sizeof(sexp_uint_t)*4)) &&
|
if (sexp_bignum_data(a1)[alen-1] < ((sexp_luint_t)1<<(sizeof(sexp_uint_t)*4)) &&
|
||||||
sexp_bignum_data(b1)[blen-1] < (1uL<<(sizeof(sexp_uint_t)*4))) {
|
sexp_bignum_data(b1)[blen-1] < ((sexp_luint_t)1<<(sizeof(sexp_uint_t)*4))) {
|
||||||
dn = (dn << (sizeof(sexp_uint_t)*4))
|
dn = (dn << (sizeof(sexp_uint_t)*4))
|
||||||
+ (sexp_bignum_data(a1)[alen-3] >> (sizeof(sexp_uint_t)*4));
|
+ (sexp_bignum_data(a1)[alen-3] >> (sizeof(sexp_uint_t)*4));
|
||||||
dd = (dd << (sizeof(sexp_uint_t)*4))
|
dd = (dd << (sizeof(sexp_uint_t)*4))
|
||||||
|
|
2
eval.c
2
eval.c
|
@ -1324,7 +1324,7 @@ static struct sexp_library_entry_t *sexp_find_static_library(const char *file)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SEXP_USE_DL
|
#if SEXP_USE_DL
|
||||||
#ifdef __MINGW32__
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
||||||
sexp res;
|
sexp res;
|
||||||
|
|
2
gc.c
2
gc.c
|
@ -90,7 +90,7 @@ void sexp_release_object(sexp ctx, sexp x) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sexp_uint_t sexp_allocated_bytes (sexp ctx, sexp x) {
|
SEXP_API sexp_uint_t sexp_allocated_bytes (sexp ctx, sexp x) {
|
||||||
sexp_uint_t res;
|
sexp_uint_t res;
|
||||||
sexp t;
|
sexp t;
|
||||||
if (!sexp_pointerp(x) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx)))
|
if (!sexp_pointerp(x) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx)))
|
||||||
|
|
|
@ -480,6 +480,13 @@ done:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static void* load_image_fn(sexp ctx, sexp dl, sexp name) {
|
||||||
|
snprintf(gc_heap_err_str, ERR_STR_SIZE,
|
||||||
|
"load_image_fn: Needed to be ported to Win32");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static void* load_image_fn(sexp ctx, sexp dl, sexp name) {
|
static void* load_image_fn(sexp ctx, sexp dl, sexp name) {
|
||||||
sexp ls;
|
sexp ls;
|
||||||
void *fn = NULL;
|
void *fn = NULL;
|
||||||
|
@ -525,6 +532,7 @@ static void* load_image_fn(sexp ctx, sexp dl, sexp name) {
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static sexp load_image_callback_p2 (sexp ctx, sexp dstp, void *user) {
|
static sexp load_image_callback_p2 (sexp ctx, sexp dstp, void *user) {
|
||||||
sexp res = NULL;
|
sexp res = NULL;
|
||||||
|
|
|
@ -342,7 +342,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SEXP_USE_DL
|
#ifndef SEXP_USE_DL
|
||||||
#if defined(PLAN9) || defined(_WIN32)
|
#if defined(PLAN9)
|
||||||
#define SEXP_USE_DL 0
|
#define SEXP_USE_DL 0
|
||||||
#else
|
#else
|
||||||
#define SEXP_USE_DL ! SEXP_USE_NO_FEATURES
|
#define SEXP_USE_DL ! SEXP_USE_NO_FEATURES
|
||||||
|
@ -770,18 +770,21 @@
|
||||||
#define isinf(x) (isInf(x,1) || isInf(x,-1))
|
#define isinf(x) (isInf(x,1) || isInf(x,-1))
|
||||||
#define isnan(x) isNaN(x)
|
#define isnan(x) isNaN(x)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#define _CRT_SECURE_NO_WARNINGS 1
|
#define SHUT_RD 0 /* SD_RECEIVE */
|
||||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
#define SHUT_WR 1 /* SD_SEND */
|
||||||
#pragma warning(disable:4146) /* unary minus operator to unsigned type */
|
#define SHUT_RDWR 2 /* SD_BOTH */
|
||||||
#ifdef __MINGW32__
|
#if !defined(__MINGW32__) && !defined(__MINGW64__)
|
||||||
#include <shlwapi.h>
|
|
||||||
#define strcasecmp lstrcmpi
|
#define strcasecmp lstrcmpi
|
||||||
#define strncasecmp(s1, s2, n) lstrcmpi(s1, s2)
|
#define strncasecmp(s1, s2, n) lstrcmpi(s1, s2)
|
||||||
|
#endif
|
||||||
|
#include <shlwapi.h>
|
||||||
#define strcasestr StrStrI
|
#define strcasestr StrStrI
|
||||||
#define SHUT_RD 0
|
#ifdef _MSC_VER
|
||||||
#define SHUT_WR 1
|
#define _CRT_SECURE_NO_WARNINGS 1
|
||||||
#define SHUT_RDWR 2
|
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||||
#else
|
#define _USE_MATH_DEFINES /* For M_LN10 */
|
||||||
|
#pragma warning(disable:4146) /* unary minus operator to unsigned type */
|
||||||
|
#if _MSC_VER < 1900
|
||||||
#define snprintf(buf, len, fmt, val) sprintf(buf, fmt, val)
|
#define snprintf(buf, len, fmt, val) sprintf(buf, fmt, val)
|
||||||
#define strcasecmp lstrcmpi
|
#define strcasecmp lstrcmpi
|
||||||
#define strncasecmp(s1, s2, n) lstrcmpi(s1, s2)
|
#define strncasecmp(s1, s2, n) lstrcmpi(s1, s2)
|
||||||
|
@ -790,6 +793,9 @@
|
||||||
#define isnan(x) (x!=x)
|
#define isnan(x) (x!=x)
|
||||||
#define isinf(x) (x > DBL_MAX || x < -DBL_MAX)
|
#define isinf(x) (x > DBL_MAX || x < -DBL_MAX)
|
||||||
#endif
|
#endif
|
||||||
|
#elif !defined(__MINGW32__)
|
||||||
|
#error Unknown Win32 compiler!
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -806,7 +812,7 @@
|
||||||
#define sexp_nan (0.0/0.0)
|
#define sexp_nan (0.0/0.0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef _WIN32
|
||||||
#ifdef BUILDING_DLL
|
#ifdef BUILDING_DLL
|
||||||
#define SEXP_API __declspec(dllexport)
|
#define SEXP_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -17,8 +17,9 @@ extern "C" {
|
||||||
#include "chibi/features.h"
|
#include "chibi/features.h"
|
||||||
#include "chibi/install.h"
|
#include "chibi/install.h"
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__MINGW32__)
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <errno.h>
|
||||||
#define sexp_isalpha(x) ((isalpha)((int)(x)))
|
#define sexp_isalpha(x) ((isalpha)((int)(x)))
|
||||||
#define sexp_isxdigit(x) ((isxdigit)((int)(x)))
|
#define sexp_isxdigit(x) ((isxdigit)((int)(x)))
|
||||||
#define sexp_isdigit(x) ((isdigit)((int)(x)))
|
#define sexp_isdigit(x) ((isdigit)((int)(x)))
|
||||||
|
@ -197,15 +198,20 @@ enum sexp_types {
|
||||||
#define SEXP_STRING_CURSOR SEXP_FIXNUM
|
#define SEXP_STRING_CURSOR SEXP_FIXNUM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* procedure flags */
|
|
||||||
#define SEXP_PROC_NONE 0uL
|
|
||||||
#define SEXP_PROC_VARIADIC 1uL
|
|
||||||
#define SEXP_PROC_UNUSED_REST 2uL
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#if defined(_MSC_VER) && SEXP_64_BIT
|
||||||
|
/* On SEXP_64_BIT, 128bits arithmetic is mandatory */
|
||||||
|
#error Unsupported configuration
|
||||||
|
#endif
|
||||||
|
#if SEXP_64_BIT
|
||||||
|
typedef unsigned int sexp_tag_t;
|
||||||
|
typedef unsigned long long sexp_uint_t;
|
||||||
|
typedef long long sexp_sint_t;
|
||||||
|
#else
|
||||||
typedef unsigned short sexp_tag_t;
|
typedef unsigned short sexp_tag_t;
|
||||||
typedef SIZE_T sexp_uint_t;
|
typedef unsigned int sexp_uint_t;
|
||||||
typedef SSIZE_T sexp_sint_t;
|
typedef int sexp_sint_t;
|
||||||
|
#endif
|
||||||
#define sexp_heap_align(n) sexp_align(n, 5)
|
#define sexp_heap_align(n) sexp_align(n, 5)
|
||||||
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>5)
|
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>5)
|
||||||
#elif SEXP_64_BIT
|
#elif SEXP_64_BIT
|
||||||
|
@ -228,6 +234,12 @@ typedef int sexp_sint_t;
|
||||||
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>4)
|
#define sexp_heap_chunks(n) (sexp_heap_align(n)>>4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* procedure flags */
|
||||||
|
#define SEXP_PROC_NONE ((sexp_uint_t)0)
|
||||||
|
#define SEXP_PROC_VARIADIC ((sexp_uint_t)1)
|
||||||
|
#define SEXP_PROC_UNUSED_REST ((sexp_uint_t)2)
|
||||||
|
|
||||||
|
|
||||||
#ifdef SEXP_USE_INTTYPES
|
#ifdef SEXP_USE_INTTYPES
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
# ifdef UINT8_MAX
|
# ifdef UINT8_MAX
|
||||||
|
@ -309,6 +321,7 @@ typedef sexp (*sexp_proc5) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp);
|
||||||
typedef sexp (*sexp_proc6) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp);
|
typedef sexp (*sexp_proc6) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp);
|
||||||
typedef sexp (*sexp_proc7) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp);
|
typedef sexp (*sexp_proc7) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp);
|
||||||
typedef sexp (*sexp_init_proc)(sexp, sexp, sexp_sint_t, sexp, const char*, const sexp_abi_identifier_t);
|
typedef sexp (*sexp_init_proc)(sexp, sexp, sexp_sint_t, sexp, const char*, const sexp_abi_identifier_t);
|
||||||
|
SEXP_API sexp sexp_init_library(sexp, sexp, sexp_sint_t, sexp, const char*, const sexp_abi_identifier_t);
|
||||||
|
|
||||||
typedef struct sexp_free_list_t *sexp_free_list;
|
typedef struct sexp_free_list_t *sexp_free_list;
|
||||||
struct sexp_free_list_t {
|
struct sexp_free_list_t {
|
||||||
|
@ -720,7 +733,7 @@ SEXP_API sexp sexp_make_flonum(sexp ctx, float f);
|
||||||
#define sexp_flonump(x) (sexp_check_tag(x, SEXP_FLONUM))
|
#define sexp_flonump(x) (sexp_check_tag(x, SEXP_FLONUM))
|
||||||
#define sexp_flonum_value(f) ((f)->value.flonum)
|
#define sexp_flonum_value(f) ((f)->value.flonum)
|
||||||
#define sexp_flonum_bits(f) ((f)->value.flonum_bits)
|
#define sexp_flonum_bits(f) ((f)->value.flonum_bits)
|
||||||
sexp sexp_make_flonum(sexp ctx, double f);
|
SEXP_API sexp sexp_make_flonum(sexp ctx, double f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define sexp_typep(x) (sexp_check_tag(x, SEXP_TYPE))
|
#define sexp_typep(x) (sexp_check_tag(x, SEXP_TYPE))
|
||||||
|
@ -806,8 +819,8 @@ SEXP_API int sexp_idp(sexp x);
|
||||||
#define sexp_make_fixnum(n) ((sexp) ((((sexp_sint_t)(n))<<SEXP_FIXNUM_BITS) + SEXP_FIXNUM_TAG))
|
#define sexp_make_fixnum(n) ((sexp) ((((sexp_sint_t)(n))<<SEXP_FIXNUM_BITS) + SEXP_FIXNUM_TAG))
|
||||||
#define sexp_unbox_fixnum(n) (((sexp_sint_t)(n))>>SEXP_FIXNUM_BITS)
|
#define sexp_unbox_fixnum(n) (((sexp_sint_t)(n))>>SEXP_FIXNUM_BITS)
|
||||||
#else
|
#else
|
||||||
#define sexp_make_fixnum(n) ((sexp) ((((sexp_sint_t)(n))*(sexp_sint_t)(1uL<<SEXP_FIXNUM_BITS)) | SEXP_FIXNUM_TAG))
|
#define sexp_make_fixnum(n) ((sexp) ((((sexp_sint_t)(n))*(sexp_sint_t)((sexp_sint_t)1<<SEXP_FIXNUM_BITS)) | SEXP_FIXNUM_TAG))
|
||||||
#define sexp_unbox_fixnum(n) (((sexp_sint_t)((sexp_uint_t)(n) & ~SEXP_FIXNUM_TAG))/(sexp_sint_t)(1uL<<SEXP_FIXNUM_BITS))
|
#define sexp_unbox_fixnum(n) (((sexp_sint_t)((sexp_uint_t)(n) & ~SEXP_FIXNUM_TAG))/(sexp_sint_t)((sexp_sint_t)1<<SEXP_FIXNUM_BITS))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SEXP_NEG_ONE sexp_make_fixnum(-1)
|
#define SEXP_NEG_ONE sexp_make_fixnum(-1)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <chibi/eval.h>
|
#include <chibi/eval.h>
|
||||||
|
|
||||||
#ifndef PLAN9
|
#ifndef PLAN9
|
||||||
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
13
main.c
13
main.c
|
@ -94,7 +94,7 @@ static void sexp_make_unblocking (sexp ctx, sexp port) {
|
||||||
sexp_port_flags(port) |= O_NONBLOCK;
|
sexp_port_flags(port) |= O_NONBLOCK;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define sexp_make_unblocking(ctx, port) 0
|
#define sexp_make_unblocking(ctx, port) (void)0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static sexp sexp_meta_env (sexp ctx) {
|
static sexp sexp_meta_env (sexp ctx) {
|
||||||
|
@ -307,6 +307,17 @@ sexp run_main (int argc, char **argv) {
|
||||||
args = SEXP_NULL;
|
args = SEXP_NULL;
|
||||||
env = NULL;
|
env = NULL;
|
||||||
|
|
||||||
|
/* SRFI 22: invoke `main` procedure by default if the interpreter is invoked */
|
||||||
|
/* as `scheme-r7rs`. */
|
||||||
|
if (strncmp(basename(argv[0]), "scheme-r7rs", strlen("scheme-r7rs")) == 0) {
|
||||||
|
main_symbol = "main";
|
||||||
|
/* skip option parsing since we can't pass `--` before the name of script */
|
||||||
|
/* to avoid misinterpret the name as options when the interpreter is */
|
||||||
|
/* executed via `#!/usr/env/bin scheme-r7rs` shebang. */
|
||||||
|
i = 1;
|
||||||
|
goto done_options;
|
||||||
|
}
|
||||||
|
|
||||||
/* parse options */
|
/* parse options */
|
||||||
for (i=1; i < argc && argv[i][0] == '-'; i++) {
|
for (i=1; i < argc && argv[i][0] == '-'; i++) {
|
||||||
switch ((c=argv[i][1])) {
|
switch ((c=argv[i][1])) {
|
||||||
|
|
23
sexp.c
23
sexp.c
|
@ -168,11 +168,18 @@ sexp sexp_finalize_port (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SEXP_USE_DL
|
#if SEXP_USE_DL
|
||||||
|
#ifdef _WIN32
|
||||||
|
sexp sexp_finalize_dl (sexp ctx, sexp self, sexp_sint_t n, sexp dl) {
|
||||||
|
FreeLibrary(sexp_dl_handle(dl));
|
||||||
|
return SEXP_VOID;
|
||||||
|
}
|
||||||
|
#else
|
||||||
sexp sexp_finalize_dl (sexp ctx, sexp self, sexp_sint_t n, sexp dl) {
|
sexp sexp_finalize_dl (sexp ctx, sexp self, sexp_sint_t n, sexp dl) {
|
||||||
dlclose(sexp_dl_handle(dl));
|
dlclose(sexp_dl_handle(dl));
|
||||||
return SEXP_VOID;
|
return SEXP_VOID;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct sexp_type_struct _sexp_type_specs[] = {
|
static struct sexp_type_struct _sexp_type_specs[] = {
|
||||||
{SEXP_OBJECT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (sexp)"Object", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, NULL},
|
{SEXP_OBJECT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (sexp)"Object", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, NULL},
|
||||||
|
@ -386,7 +393,7 @@ static const char* sexp_initial_features[] = {
|
||||||
#if SEXP_BSD
|
#if SEXP_BSD
|
||||||
"bsd",
|
"bsd",
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32) || defined(__MINGW32__)
|
#if defined(_WIN32)
|
||||||
"windows",
|
"windows",
|
||||||
#endif
|
#endif
|
||||||
#if SEXP_USE_DL
|
#if SEXP_USE_DL
|
||||||
|
@ -1224,7 +1231,7 @@ sexp sexp_string_concatenate_op (sexp ctx, sexp self, sexp_sint_t n, sexp str_ls
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FNV_PRIME 16777619
|
#define FNV_PRIME 16777619
|
||||||
#define FNV_OFFSET_BASIS 2166136261uL
|
#define FNV_OFFSET_BASIS ((sexp_sint_t)2166136261)
|
||||||
|
|
||||||
#if SEXP_USE_HASH_SYMS
|
#if SEXP_USE_HASH_SYMS
|
||||||
|
|
||||||
|
@ -1423,7 +1430,7 @@ int sexp_buffered_write_string (sexp ctx, const char *str, sexp p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int sexp_buffered_flush (sexp ctx, sexp p, int forcep) {
|
int sexp_buffered_flush (sexp ctx, sexp p, int forcep) {
|
||||||
long res = 0, off;
|
sexp_sint_t res = 0, off;
|
||||||
sexp_gc_var1(tmp);
|
sexp_gc_var1(tmp);
|
||||||
if (!sexp_oportp(p) || (!forcep && !sexp_port_openp(p)))
|
if (!sexp_oportp(p) || (!forcep && !sexp_port_openp(p)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1860,10 +1867,10 @@ sexp sexp_apply_writer(sexp ctx, sexp writer, sexp obj, sexp out) {
|
||||||
|
|
||||||
sexp sexp_write_one (sexp ctx, sexp obj, sexp out) {
|
sexp sexp_write_one (sexp ctx, sexp obj, sexp out) {
|
||||||
#if SEXP_USE_HUFF_SYMS
|
#if SEXP_USE_HUFF_SYMS
|
||||||
unsigned long res;
|
sexp_uint_t res;
|
||||||
#endif
|
#endif
|
||||||
unsigned long len, c;
|
sexp_uint_t len, c;
|
||||||
long i=0;
|
sexp_sint_t i=0;
|
||||||
#if SEXP_USE_FLONUMS
|
#if SEXP_USE_FLONUMS
|
||||||
double f, ftmp;
|
double f, ftmp;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1895,7 +1902,7 @@ sexp sexp_write_one (sexp ctx, sexp obj, sexp out) {
|
||||||
} else {
|
} else {
|
||||||
sexp_write_string(ctx, "#(", out);
|
sexp_write_string(ctx, "#(", out);
|
||||||
sexp_write_one(ctx, elts[0], out);
|
sexp_write_one(ctx, elts[0], out);
|
||||||
for (i=1; i<(long)len; i++) {
|
for (i=1; i<(sexp_sint_t)len; i++) {
|
||||||
sexp_write_char(ctx, ' ', out);
|
sexp_write_char(ctx, ' ', out);
|
||||||
sexp_write_one(ctx, elts[i], out);
|
sexp_write_one(ctx, elts[i], out);
|
||||||
}
|
}
|
||||||
|
@ -2045,7 +2052,7 @@ sexp sexp_write_one (sexp ctx, sexp obj, sexp out) {
|
||||||
sexp_write_string(ctx, "#u8(", out);
|
sexp_write_string(ctx, "#u8(", out);
|
||||||
str = sexp_bytes_data(obj);
|
str = sexp_bytes_data(obj);
|
||||||
len = sexp_bytes_length(obj);
|
len = sexp_bytes_length(obj);
|
||||||
for (i=0; i<(long)len; i++) {
|
for (i=0; i<(sexp_sint_t)len; i++) {
|
||||||
if (i!=0) sexp_write_char(ctx, ' ', out);
|
if (i!=0) sexp_write_char(ctx, ' ', out);
|
||||||
sexp_write(ctx, sexp_make_fixnum(((unsigned char*)str)[i]), out);
|
sexp_write(ctx, sexp_make_fixnum(((unsigned char*)str)[i]), out);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue