mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 05:27:35 +02:00
Removing warnings and fixing some build configurations from the last fd gc change.
This commit is contained in:
parent
3a511302c4
commit
32763cd214
3 changed files with 24 additions and 22 deletions
30
eval.c
30
eval.c
|
@ -1011,17 +1011,12 @@ sexp sexp_open_input_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
|
|||
FILE *in;
|
||||
int count = 0;
|
||||
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path);
|
||||
loop:
|
||||
in = fopen(sexp_string_data(path), "r");
|
||||
if (!in) {
|
||||
#if SEXP_USE_GC_FILE_DESCRIPTORS
|
||||
if (errno == EMFILE && !count++) {
|
||||
sexp_gc(ctx, NULL);
|
||||
goto loop;
|
||||
}
|
||||
#endif
|
||||
do {
|
||||
if (count != 0) sexp_gc(ctx, NULL);
|
||||
in = fopen(sexp_string_data(path), "r");
|
||||
} while (!in && sexp_out_of_file_descriptors() && !count++);
|
||||
if (!in)
|
||||
return sexp_user_exception(ctx, self, "couldn't open input file", path);
|
||||
}
|
||||
#if SEXP_USE_GREEN_THREADS
|
||||
fcntl(fileno(in), F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
|
@ -1032,17 +1027,12 @@ sexp sexp_open_output_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp path) {
|
|||
FILE *out;
|
||||
int count = 0;
|
||||
sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path);
|
||||
loop:
|
||||
out = fopen(sexp_string_data(path), "w");
|
||||
if (!out) {
|
||||
#if SEXP_USE_GC_FILE_DESCRIPTORS
|
||||
if (errno == EMFILE && !count++) {
|
||||
sexp_gc(ctx, NULL);
|
||||
goto loop;
|
||||
}
|
||||
#endif
|
||||
do {
|
||||
if (count != 0) sexp_gc(ctx, NULL);
|
||||
out = fopen(sexp_string_data(path), "w");
|
||||
} while (!out && sexp_out_of_file_descriptors() && !count++);
|
||||
if (!out)
|
||||
return sexp_user_exception(ctx, self, "couldn't open output file", path);
|
||||
}
|
||||
return sexp_make_output_port(ctx, out, path);
|
||||
}
|
||||
|
||||
|
|
|
@ -507,7 +507,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef SEXP_USE_GC_FILE_DESCRIPTORS
|
||||
#define SEXP_USE_GC_FILE_DESCRIPTORS (SEXP_USE_AUTOCLOSE_PORTS &&!SEXP_USE_BOEHM)
|
||||
#define SEXP_USE_GC_FILE_DESCRIPTORS (SEXP_USE_AUTOCLOSE_PORTS &&!SEXP_USE_BOEHM && !defined(PLAN9))
|
||||
#endif
|
||||
|
||||
#ifndef SEXP_USE_2010_EPOCH
|
||||
|
|
|
@ -25,9 +25,11 @@ extern "C" {
|
|||
#if SEXP_USE_DL
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#if SEXP_USE_GREEN_THREADS || SEXP_USE_GC_FILE_DESCRIPTORS
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#if SEXP_USE_GREEN_THREADS
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#define sexp_isalpha(x) (isalpha(x))
|
||||
|
@ -37,6 +39,12 @@ extern "C" {
|
|||
#define sexp_toupper(x) (toupper(x))
|
||||
#endif
|
||||
|
||||
#if SEXP_USE_GC_FILE_DESCRIPTORS
|
||||
#define sexp_out_of_file_descriptors() (errno == EMFILE)
|
||||
#else
|
||||
#define sexp_out_of_file_descriptors() (0)
|
||||
#endif
|
||||
|
||||
#ifdef PLAN9
|
||||
#include <u.h>
|
||||
#include <libc.h>
|
||||
|
@ -430,6 +438,8 @@ void sexp_free(void* ptr);
|
|||
|
||||
#if SEXP_USE_BOEHM
|
||||
|
||||
#define sexp_gc(ctx, sum)
|
||||
|
||||
#define sexp_gc_var(ctx, x, y) sexp x;
|
||||
#define sexp_gc_preserve(ctx, x, y)
|
||||
#define sexp_gc_release(ctx, x, y)
|
||||
|
@ -443,6 +453,8 @@ void sexp_free(void* ptr);
|
|||
|
||||
#else
|
||||
|
||||
SEXP_API sexp sexp_gc(sexp ctx, size_t *sum_freed);
|
||||
|
||||
#define sexp_gc_var(ctx, x, y) \
|
||||
sexp x = SEXP_VOID; \
|
||||
struct sexp_gc_var_t y = {NULL, NULL};
|
||||
|
|
Loading…
Add table
Reference in a new issue