mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-04-27 19:50:44 -07:00
The single-threaded code did not build. file_listen() does not work on actual files.
This commit is contained in:
parent
f7c965c3be
commit
2abb769a7a
2 changed files with 24 additions and 3 deletions
22
src/c/file.d
22
src/c/file.d
|
|
@ -2041,6 +2041,25 @@ io_file_listen(cl_object strm)
|
|||
{
|
||||
if (strm->stream.unread != EOF)
|
||||
return ECL_LISTEN_AVAILABLE;
|
||||
if (strm->stream.flags & ECL_STREAM_MIGHT_SEEK) {
|
||||
cl_env_ptr the_env = ecl_process_env();
|
||||
int f = IO_FILE_DESCRIPTOR(strm);
|
||||
ecl_off_t disp, new;
|
||||
ecl_disable_interrupts_env(the_env);
|
||||
disp = lseek(f, 0, SEEK_CUR);
|
||||
ecl_enable_interrupts_env(the_env);
|
||||
if (disp != (ecl_off_t)-1) {
|
||||
ecl_disable_interrupts_env(the_env);
|
||||
new = lseek(f, 0, SEEK_END);
|
||||
ecl_enable_interrupts_env(the_env);
|
||||
lseek(f, disp, SEEK_SET);
|
||||
if (new == disp) {
|
||||
return ECL_LISTEN_NO_CHAR;
|
||||
} else if (new != (ecl_off_t)-1) {
|
||||
return ECL_LISTEN_AVAILABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return file_listen(IO_FILE_DESCRIPTOR(strm));
|
||||
}
|
||||
|
||||
|
|
@ -2135,7 +2154,7 @@ io_file_set_position(cl_object strm, cl_object large_disp)
|
|||
disp = ecl_integer_to_off_t(large_disp);
|
||||
mode = SEEK_SET;
|
||||
}
|
||||
disp = lseek(f, 0, SEEK_END);
|
||||
disp = lseek(f, disp, mode);
|
||||
return (disp == (ecl_off_t)-1)? Cnil : Ct;
|
||||
}
|
||||
|
||||
|
|
@ -3511,6 +3530,7 @@ ecl_open_stream(cl_object fn, enum ecl_smmode smm, cl_object if_exists,
|
|||
if (smm == smm_probe) {
|
||||
cl_close(1, x);
|
||||
} else {
|
||||
x->stream.flags |= ECL_STREAM_MIGHT_SEEK;
|
||||
si_set_finalizer(x, Ct);
|
||||
/* Set file pointer to the correct position */
|
||||
ecl_file_position_set(x, appending? Cnil : MAKE_FIXNUM(0));
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ typedef struct bds_bd {
|
|||
#define ecl_bds_check(env) \
|
||||
((env->bds_top >= env->bds_limit)? ecl_bds_overflow() : (void)0)
|
||||
|
||||
#ifdef ECL_THREADS
|
||||
typedef struct cl_env_struct *cl_env_ptr;
|
||||
|
||||
#ifdef ECL_THREADS
|
||||
extern ECL_API void ecl_bds_bind(cl_env_ptr env, cl_object symbol, cl_object v);
|
||||
extern ECL_API void ecl_bds_push(cl_env_ptr env, cl_object symbol);
|
||||
extern ECL_API void ecl_bds_unwind1(cl_env_ptr env);
|
||||
|
|
@ -66,7 +67,7 @@ extern ECL_API cl_object ecl_set_symbol(cl_env_ptr env, cl_object s, cl_object v
|
|||
#define ecl_bds_push(env,sym) do { \
|
||||
const cl_env_ptr env_copy = (env); \
|
||||
const cl_object s = (sym); \
|
||||
const cl_object v = (val); \
|
||||
const cl_object v = s->symbol.value; \
|
||||
ecl_bds_check(env_copy); \
|
||||
(++(env_copy->bds_top))->symbol = s, \
|
||||
env_copy->bds_top->value = s->symbol.value; } while (0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue