remove configure from repositry

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-05-16 02:46:57 +00:00
parent 816779043d
commit a5b607c895
9 changed files with 218 additions and 5530 deletions

View File

@ -1,5 +1,10 @@
Mon May 15 15:38:09 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* ruby.h: exported symbols should be for xmalloc etc. are now
prefixed by 'ruby_', e.g. ruby_xmalloc().
* eval.c (rb_thread_select): remove busy wait for select.
* dir.c (glob): trailing path may be null, e.g. glob("**").
Mon May 15 01:18:20 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

5416
configure vendored

File diff suppressed because it is too large Load Diff

223
eval.c
View File

@ -6235,8 +6235,10 @@ enum thread_status {
};
#define WAIT_FD (1<<0)
#define WAIT_TIME (1<<1)
#define WAIT_JOIN (1<<2)
#define WAIT_SELECT (1<<1)
#define WAIT_TIME (1<<2)
#define WAIT_JOIN (1<<3)
#define WAIT_PID (1<<4)
/* +infty, for this purpose */
#define DELAY_INFTY 1E30
@ -6279,6 +6281,9 @@ struct thread {
enum thread_status status;
int wait_for;
int fd;
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
double delay;
thread_t join;
@ -6296,10 +6301,6 @@ struct thread {
static thread_t main_thread;
static thread_t curr_thread = 0;
static int num_waiting_on_fd = 0;
static int num_waiting_on_timer = 0;
static int num_waiting_on_join = 0;
#define FOREACH_THREAD_FROM(f,x) x = f; do { x = x->next;
#define END_FOREACH_FROM(f,x) } while (x != f)
@ -6565,16 +6566,6 @@ static void
rb_thread_ready(th)
thread_t th;
{
/* The thread is no longer waiting on anything */
if (th->wait_for & WAIT_FD) {
num_waiting_on_fd--;
}
if (th->wait_for & WAIT_TIME) {
num_waiting_on_timer--;
}
if (th->wait_for & WAIT_JOIN) {
num_waiting_on_join--;
}
th->wait_for = 0;
th->status = THREAD_RUNNABLE;
}
@ -6602,7 +6593,7 @@ rb_thread_fd_close(fd)
thread_t th;
FOREACH_THREAD(th) {
if ((th->wait_for & WAIT_FD) && th->fd == fd) {
if ((th->wait_for & WAIT_FD) && fd == th->fd) {
th_raise_argc = 1;
th_raise_argv[0] = rb_exc_new2(rb_eIOError, "stream closed");
th_raise_file = ruby_sourcefile;
@ -6637,6 +6628,59 @@ rb_thread_deadlock()
#endif
}
static void
copy_fds(dst, src, max)
fd_set *dst, *src;
int max;
{
int n = 0;
int i;
for (i=0; i<=max; i++) {
if (FD_ISSET(i, src)) {
n = i;
FD_SET(i, dst);
}
}
}
static int
match_fds(dst, src, max)
fd_set *dst, *src;
int max;
{
int i;
for (i=0; i<=max; i++) {
if (FD_ISSET(i, src) && FD_ISSET(i, dst)) {
return Qtrue;
}
}
return Qfalse;
}
static int
intersect_fds(dst, src, max)
fd_set *dst, *src;
int max;
{
int i;
for (i=0; i<=max; i++) {
if (FD_ISSET(i, src)) {
if (FD_ISSET(i, dst)) {
/* Wake up only one thread per fd. */
FD_CLR(i, dst);
}
else {
FD_CLR(i, src);
}
return Qtrue;
}
}
return Qfalse;
}
void
rb_thread_schedule()
{
@ -6645,6 +6689,9 @@ rb_thread_schedule()
thread_t curr;
int found = 0;
int waiting_on_fd = 0;
int waiting_on_timer = 0;
select_err:
rb_thread_pending = 0;
if (curr_thread == curr_thread->next
@ -6659,55 +6706,59 @@ rb_thread_schedule()
}
FOREACH_THREAD_FROM(curr, th) {
if (th->status == THREAD_RUNNABLE || th->status == THREAD_TO_KILL) {
found = 1;
break;
}
}
END_FOREACH_FROM(curr, th);
if (num_waiting_on_join) {
FOREACH_THREAD_FROM(curr, th) {
if ((th->wait_for&WAIT_JOIN) && rb_thread_dead(th->join)) {
th->join = 0;
th->wait_for &= ~WAIT_JOIN;
th->status = THREAD_RUNNABLE;
num_waiting_on_join--;
found = 1;
}
if (!found && (th->status == THREAD_RUNNABLE || th->status == THREAD_TO_KILL)) {
found = 1;
}
END_FOREACH_FROM(curr, th);
if ((th->wait_for&WAIT_JOIN) && rb_thread_dead(th->join)) {
th->join = 0;
th->wait_for = 0;
th->status = THREAD_RUNNABLE;
found = 1;
}
if (th->wait_for&(WAIT_FD|WAIT_SELECT)) waiting_on_fd = 1;
if (th->wait_for&WAIT_TIME) waiting_on_timer = 1;
}
END_FOREACH_FROM(curr, th);
if (num_waiting_on_fd > 0 || num_waiting_on_timer > 0) {
if (waiting_on_fd || waiting_on_timer) {
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
struct timeval delay_tv, *delay_ptr;
double delay, now; /* OK */
int n, max;
do {
max = 0;
FD_ZERO(&readfds);
if (num_waiting_on_fd > 0) {
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
if (waiting_on_fd) {
FOREACH_THREAD_FROM(curr, th) {
if (max < th->fd) max = th->fd;
if (th->wait_for & WAIT_FD) {
FD_SET(th->fd, &readfds);
if (th->fd > max) max = th->fd;
}
if (th->wait_for & WAIT_SELECT) {
copy_fds(&readfds, &th->readfds, th->fd);
copy_fds(&writefds, &th->writefds, th->fd);
copy_fds(&exceptfds, &th->exceptfds, th->fd);
th->fd = 0;
}
}
END_FOREACH_FROM(curr, th);
}
delay = DELAY_INFTY;
if (num_waiting_on_timer > 0) {
if (waiting_on_timer) {
now = timeofday();
FOREACH_THREAD_FROM(curr, th) {
if (th->wait_for & WAIT_TIME) {
if (th->delay <= now) {
th->delay = 0.0;
th->wait_for &= ~WAIT_TIME;
th->wait_for = 0;
th->status = THREAD_RUNNABLE;
num_waiting_on_timer--;
found = 1;
} else if (th->delay < delay) {
delay = th->delay;
@ -6717,7 +6768,7 @@ rb_thread_schedule()
END_FOREACH_FROM(curr, th);
}
/* Do the select if needed */
if (num_waiting_on_fd > 0 || !found) {
if (waiting_on_fd || !found) {
/* Convert delay to a timeval */
/* If a thread is runnable, just poll */
if (found) {
@ -6735,11 +6786,12 @@ rb_thread_schedule()
delay_ptr = &delay_tv;
}
n = select(max+1, &readfds, 0, 0, delay_ptr);
n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
if (n < 0) {
if (rb_trap_pending) rb_trap_exec();
switch (errno) {
case EBADF:
/* xxx */
case ENOMEM:
n = 0;
break;
@ -6751,14 +6803,25 @@ rb_thread_schedule()
/* Some descriptors are ready.
Make the corresponding threads runnable. */
FOREACH_THREAD_FROM(curr, th) {
if ((th->wait_for&WAIT_FD)
&& FD_ISSET(th->fd, &readfds)) {
if ((th->wait_for&WAIT_FD) && FD_ISSET(th->fd, &readfds)) {
/* Wake up only one thread per fd. */
FD_CLR(th->fd, &readfds);
th->status = THREAD_RUNNABLE;
th->fd = 0;
th->wait_for &= ~WAIT_FD;
num_waiting_on_fd--;
th->wait_for = 0;
found = 1;
}
if ((th->wait_for&WAIT_SELECT) &&
(match_fds(&readfds, &th->readfds, max) ||
match_fds(&writefds, &th->writefds, max) ||
match_fds(&exceptfds, &th->exceptfds, max))) {
/* Wake up only one thread per fd. */
th->status = THREAD_RUNNABLE;
th->wait_for = 0;
intersect_fds(&readfds, &th->readfds, max);
intersect_fds(&writefds, &th->writefds, max);
intersect_fds(&exceptfds, &th->exceptfds, max);
th->fd = n;
found = 1;
}
}
@ -6821,8 +6884,7 @@ rb_thread_wait_fd(fd)
if (curr_thread == curr_thread->next) return;
curr_thread->status = THREAD_STOPPED;
curr_thread->fd = fd;
num_waiting_on_fd++;
FD_SET(fd, &curr_thread->readfds);
curr_thread->wait_for |= WAIT_FD;
rb_thread_schedule();
}
@ -6831,18 +6893,15 @@ int
rb_thread_fd_writable(fd)
int fd;
{
struct timeval zero;
fd_set fds;
if (curr_thread == curr_thread->next) return;
if (curr_thread == curr_thread->next) return 1;
zero.tv_sec = zero.tv_usec = 0;
for (;;) {
FD_ZERO(&fds);
FD_SET(fd, &fds);
if (select(fd+1, 0, &fds, 0, &zero) == 1) return 0;
rb_thread_schedule();
}
curr_thread->status = THREAD_STOPPED;
FD_ZERO(&curr_thread->readfds);
FD_ZERO(&curr_thread->writefds);
FD_ZERO(&curr_thread->exceptfds);
FD_SET(fd, &curr_thread->writefds);
curr_thread->wait_for |= WAIT_SELECT;
rb_thread_schedule();
}
void
@ -6880,7 +6939,6 @@ rb_thread_wait_for(time)
date = timeofday() + (double)time.tv_sec + (double)time.tv_usec*1e-6;
curr_thread->status = THREAD_STOPPED;
curr_thread->delay = date;
num_waiting_on_timer++;
curr_thread->wait_for |= WAIT_TIME;
rb_thread_schedule();
}
@ -6901,7 +6959,6 @@ rb_thread_select(max, read, write, except, timeout)
{
double limit;
struct timeval zero;
fd_set r, *rp, w, *wp, x, *xp;
int n;
if (!read && !write && !except) {
@ -6955,30 +7012,22 @@ rb_thread_select(max, read, write, except, timeout)
}
for (;;) {
zero.tv_sec = zero.tv_usec = 0;
if (read) {rp = &r; r = *read;} else {rp = 0;}
if (write) {wp = &w; w = *write;} else {wp = 0;}
if (except) {xp = &x; x = *except;} else {xp = 0;}
n = select(max, rp, wp, xp, &zero);
if (n > 0) {
/* write back fds */
if (read) {*read = r;}
if (write) {*write = w;}
if (except) {*except = x;}
return n;
}
if (n < 0 && errno != EINTR) {
return n;
}
if (timeout) {
if (timeout->tv_sec == 0 && timeout->tv_usec == 0) return 0;
if (limit <= timeofday()) return 0;
}
rb_thread_schedule();
CHECK_INTS;
curr_thread->status = THREAD_STOPPED;
curr_thread->readfds = *read;
curr_thread->writefds = *write;
curr_thread->exceptfds = *except;
curr_thread->fd = max;
curr_thread->wait_for = WAIT_SELECT;
if (timeout) {
curr_thread->delay = timeofday() +
(double)timeout->tv_sec + (double)timeout->tv_usec*1e-6;
curr_thread->wait_for |= WAIT_TIME;
}
rb_thread_schedule();
*read = curr_thread->readfds;
*write = curr_thread->writefds;
*except = curr_thread->exceptfds;
return curr_thread->fd;
}
static VALUE
@ -6994,7 +7043,6 @@ rb_thread_join(thread)
rb_raise(rb_eThreadError, "Thread#join: deadlock - mutual join");
curr_thread->status = THREAD_STOPPED;
curr_thread->join = th;
num_waiting_on_join++;
curr_thread->wait_for |= WAIT_JOIN;
rb_thread_schedule();
}
@ -7146,7 +7194,6 @@ rb_thread_sleep_forever()
return;
}
num_waiting_on_timer++;
curr_thread->delay = DELAY_INFTY;
curr_thread->wait_for |= WAIT_TIME;
curr_thread->status = THREAD_STOPPED;
@ -7236,7 +7283,9 @@ rb_thread_abort_exc_set(thread, val)
th->stk_len = 0;\
th->stk_max = 0;\
th->wait_for = 0;\
th->fd = 0;\
FD_ZERO(&th->readfds);\
FD_ZERO(&th->writefds);\
FD_ZERO(&th->exceptfds);\
th->delay = 0.0;\
th->join = 0;\
\

45
gc.c
View File

@ -63,9 +63,8 @@ mem_error(mesg)
rb_fatal(mesg);
}
#ifndef xmalloc
void *
xmalloc(size)
ruby_xmalloc(size)
size_t size;
{
void *mem;
@ -95,7 +94,7 @@ xmalloc(size)
}
void *
xcalloc(n, size)
ruby_xcalloc(n, size)
size_t n, size;
{
void *mem;
@ -107,7 +106,7 @@ xcalloc(n, size)
}
void *
xrealloc(ptr, size)
ruby_xrealloc(ptr, size)
void *ptr;
size_t size;
{
@ -134,12 +133,11 @@ xrealloc(ptr, size)
}
void
xfree(x)
ruby_xfree(x)
void *x;
{
if (x) free(x);
}
#endif
extern int ruby_in_compile;
static int dont_gc;
@ -1220,3 +1218,38 @@ Init_GC()
rb_gc_unregister_address(&rb_mObSpace);
finalizers = rb_ary_new();
}
#undef xmalloc
#undef xcalloc
#undef xrealloc
#undef xfree
void*
xmalloc(size)
size_t size;
{
return ruby_xmalloc(size);
}
void*
xcalloc(n,size)
size_t n,size;
{
return ruby_xcalloc(n, size);
}
void*
xrealloc(ptr,size)
void *ptr;
size_t size;
{
return ruby_xrealloc(ptr, size);
}
void
xfree(ptr)
void *ptr;
{
return ruby_xfree(ptr);
}

2
io.c
View File

@ -63,7 +63,7 @@ char *strdup();
extern void Init_File _((void));
#ifdef __BEOS__
# ifdef NOFILE
# ifndef NOFILE
# define NOFILE (OPEN_MAX)
# endif
#include <net/socket.h>

39
regex.c
View File

@ -70,13 +70,16 @@ void rb_trap_exec _((void));
# define CHECK_INTS if (!rb_prohibit_interrupt) {\
if (rb_trap_pending) rb_trap_exec();\
}
#endif
#ifndef xmalloc
#define xmalloc ruby_xmalloc
#define xcalloc ruby_xcalloc
#define xrealloc ruby_xrealloc
#define xfree ruby_xfree
void *xmalloc _((size_t));
void *xcalloc _((size_t,size_t));
void *xrealloc _((void*,size_t));
void free _((void*));
void xfree _((void*));
#endif
#define NO_ALLOCA /* try it out for now */
@ -125,8 +128,8 @@ char *alloca();
#define FREE_VARIABLES()
#define FREE_AND_RETURN_VOID(stackb) do { free(stackb); return; } while(0)
#define FREE_AND_RETURN(stackb,val) do { free(stackb); return(val); } while(0)
#define FREE_AND_RETURN_VOID(stackb) do { xfree(stackb); return; } while(0)
#define FREE_AND_RETURN(stackb,val) do { xfree(stackb); return(val); } while(0)
#define DOUBLE_STACK(stackx,stackb,len,type) do { \
stackx = (type*)xrealloc(stackb, 2 * len * sizeof(type)); \
} while (0)
@ -2410,18 +2413,18 @@ void
re_free_pattern(bufp)
struct re_pattern_buffer *bufp;
{
free(bufp->buffer);
free(bufp->fastmap);
if (bufp->must_skip) free(bufp->must_skip);
xfree(bufp->buffer);
xfree(bufp->fastmap);
if (bufp->must_skip) xfree(bufp->must_skip);
free(bufp->regstart);
free(bufp->regend);
free(bufp->old_regstart);
free(bufp->old_regend);
free(bufp->best_regstart);
free(bufp->best_regend);
free(bufp->reg_info);
free(bufp);
xfree(bufp->regstart);
xfree(bufp->regend);
xfree(bufp->old_regstart);
xfree(bufp->old_regend);
xfree(bufp->best_regstart);
xfree(bufp->best_regend);
xfree(bufp->reg_info);
xfree(bufp);
}
/* Store a jump of the form <OPCODE> <relative address>.
@ -4347,8 +4350,8 @@ re_free_registers(regs)
struct re_registers *regs;
{
if (regs->allocated == 0) return;
if (regs->beg) free(regs->beg);
if (regs->end) free(regs->end);
if (regs->beg) xfree(regs->beg);
if (regs->end) xfree(regs->end);
}
/* Functions for multi-byte support.

7
ruby.h
View File

@ -369,9 +369,16 @@ struct RBignum {
#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
#define xmalloc ruby_xmalloc
#define xcalloc ruby_xcalloc
#define xrealloc ruby_xrealloc
#define xfree ruby_xfree
void *xmalloc _((size_t));
void *xcalloc _((size_t,size_t));
void *xrealloc _((void*,size_t));
void xfree _((void*));
#define ALLOC_N(type,n) (type*)xmalloc(sizeof(type)*(n))
#define ALLOC(type) (type*)xmalloc(sizeof(type))
#define REALLOC_N(var,type,n) (var)=(type*)xrealloc((char*)(var),sizeof(type)*(n))

View File

@ -969,7 +969,7 @@ File.unlink "script_tmp" or `/bin/rm -f "script_tmp"`
File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
$bad = false
for script in Dir["{lib,sample}/*.rb"]
for script in Dir["{lib,sample}/**/*.rb"]
unless `./miniruby -c #{script}`.chomp == "Syntax OK"
p `./miniruby -c #{script}`.chomp
$bad = true

9
st.c
View File

@ -45,11 +45,18 @@ static struct st_hash_type type_strhash = {
strhash,
};
#ifndef xmalloc
#ifdef RUBY_PLATFORM
#define xmalloc ruby_xmalloc
#define xcalloc ruby_xcalloc
#define xrealloc ruby_xrealloc
#define xfree ruby_xfree
void *xmalloc();
void *xcalloc();
void *xrealloc();
void xfree();
#endif
static void rehash();
#define alloc(type) (type*)xmalloc((unsigned)sizeof(type))