OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [expect/] [exp_noevent.c] - Diff between revs 578 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 578 Rev 1765
/* interact (with only one process) - give user keyboard control
/* interact (with only one process) - give user keyboard control
 
 
Written by: Don Libes, NIST, 2/6/90
Written by: Don Libes, NIST, 2/6/90
 
 
Design and implementation of this program was paid for by U.S. tax
Design and implementation of this program was paid for by U.S. tax
dollars.  Therefore it is public domain.  However, the author and NIST
dollars.  Therefore it is public domain.  However, the author and NIST
would appreciate credit if this program or parts of it are used.
would appreciate credit if this program or parts of it are used.
*/
*/
 
 
/* This file exists for deficient versions of UNIX that lack select,
/* This file exists for deficient versions of UNIX that lack select,
poll, or some other multiplexing hook.  Instead, this code uses two
poll, or some other multiplexing hook.  Instead, this code uses two
processes per spawned process.  One sends characters from the spawnee
processes per spawned process.  One sends characters from the spawnee
to the spawner; a second send chars the other way.
to the spawner; a second send chars the other way.
 
 
This will work on any UNIX system.  The only sacrifice is that it
This will work on any UNIX system.  The only sacrifice is that it
doesn't support multiple processes.  Eventually, it should catch
doesn't support multiple processes.  Eventually, it should catch
SIGCHLD on dead processes and do the right thing.  But it is pretty
SIGCHLD on dead processes and do the right thing.  But it is pretty
gruesome to imagine so many processes to do all this.  If you change
gruesome to imagine so many processes to do all this.  If you change
it successfully, please mail back the changes to me.  - Don
it successfully, please mail back the changes to me.  - Don
*/
*/
 
 
#include "expect_cf.h"
#include "expect_cf.h"
#include <stdio.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/time.h>
 
 
#ifdef HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#include <sys/wait.h>
#endif
#endif
 
 
#include "tcl.h"
#include "tcl.h"
#include "exp_prog.h"
#include "exp_prog.h"
#include "exp_command.h"        /* for struct exp_f defs */
#include "exp_command.h"        /* for struct exp_f defs */
#include "exp_event.h"
#include "exp_event.h"
 
 
/*ARGSUSED*/
/*ARGSUSED*/
void
void
exp_arm_background_filehandler(m)
exp_arm_background_filehandler(m)
int m;
int m;
{
{
}
}
 
 
/*ARGSUSED*/
/*ARGSUSED*/
void
void
exp_disarm_background_filehandler(m)
exp_disarm_background_filehandler(m)
int m;
int m;
{
{
}
}
 
 
/*ARGSUSED*/
/*ARGSUSED*/
void
void
exp_disarm_background_filehandler_force(m)
exp_disarm_background_filehandler_force(m)
int m;
int m;
{
{
}
}
 
 
/*ARGSUSED*/
/*ARGSUSED*/
void
void
exp_unblock_background_filehandler(m)
exp_unblock_background_filehandler(m)
int m;
int m;
{
{
}
}
 
 
/*ARGSUSED*/
/*ARGSUSED*/
void
void
exp_block_background_filehandler(m)
exp_block_background_filehandler(m)
int m;
int m;
{
{
}
}
 
 
/*ARGSUSED*/
/*ARGSUSED*/
void
void
exp_event_disarm(fd)
exp_event_disarm(fd)
int fd;
int fd;
{
{
}
}
 
 
/* returns status, one of EOF, TIMEOUT, ERROR or DATA */
/* returns status, one of EOF, TIMEOUT, ERROR or DATA */
/*ARGSUSED*/
/*ARGSUSED*/
int
int
exp_get_next_event(interp,masters, n,master_out,timeout,key)
exp_get_next_event(interp,masters, n,master_out,timeout,key)
Tcl_Interp *interp;
Tcl_Interp *interp;
int *masters;
int *masters;
int n;                  /* # of masters */
int n;                  /* # of masters */
int *master_out;        /* 1st event master, not set if none */
int *master_out;        /* 1st event master, not set if none */
int timeout;            /* seconds */
int timeout;            /* seconds */
int key;
int key;
{
{
        int m;
        int m;
        struct exp_f *f;
        struct exp_f *f;
 
 
        if (n > 1) {
        if (n > 1) {
                exp_error(interp,"expect not compiled with multiprocess support");
                exp_error(interp,"expect not compiled with multiprocess support");
                /* select a different INTERACT_TYPE in Makefile */
                /* select a different INTERACT_TYPE in Makefile */
                return(TCL_ERROR);
                return(TCL_ERROR);
        }
        }
 
 
        m = *master_out = masters[0];
        m = *master_out = masters[0];
        f = exp_fs + m;
        f = exp_fs + m;
 
 
        if (f->key != key) {
        if (f->key != key) {
                f->key = key;
                f->key = key;
                f->force_read = FALSE;
                f->force_read = FALSE;
                return(EXP_DATA_OLD);
                return(EXP_DATA_OLD);
        } else if ((!f->force_read) && (f->size != 0)) {
        } else if ((!f->force_read) && (f->size != 0)) {
                return(EXP_DATA_OLD);
                return(EXP_DATA_OLD);
        }
        }
 
 
        return(EXP_DATA_NEW);
        return(EXP_DATA_NEW);
}
}
 
 
/*ARGSUSED*/
/*ARGSUSED*/
int
int
exp_get_next_event_info(interp,fd,ready_mask)
exp_get_next_event_info(interp,fd,ready_mask)
Tcl_Interp *interp;
Tcl_Interp *interp;
int fd;
int fd;
int ready_mask;
int ready_mask;
{
{
}
}
 
 
/* There is no portable way to do sub-second sleeps on such a system, so */
/* There is no portable way to do sub-second sleeps on such a system, so */
/* do the next best thing (without a busy loop) and fake it: sleep the right */
/* do the next best thing (without a busy loop) and fake it: sleep the right */
/* amount of time over the long run.  Note that while "subtotal" isn't */
/* amount of time over the long run.  Note that while "subtotal" isn't */
/* reinitialized, it really doesn't matter for such a gross hack as random */
/* reinitialized, it really doesn't matter for such a gross hack as random */
/* scheduling pauses will easily introduce occasional one second delays. */
/* scheduling pauses will easily introduce occasional one second delays. */
int     /* returns TCL_XXX */
int     /* returns TCL_XXX */
exp_dsleep(interp,sec)
exp_dsleep(interp,sec)
Tcl_Interp *interp;
Tcl_Interp *interp;
double sec;
double sec;
{
{
        static double subtotal = 0;
        static double subtotal = 0;
        int seconds;
        int seconds;
 
 
        subtotal += sec;
        subtotal += sec;
        if (subtotal < 1) return TCL_OK;
        if (subtotal < 1) return TCL_OK;
        seconds = subtotal;
        seconds = subtotal;
        subtotal -= seconds;
        subtotal -= seconds;
 restart:
 restart:
        if (Tcl_AsyncReady()) {
        if (Tcl_AsyncReady()) {
                int rc = Tcl_AsyncInvoke(interp,TCL_OK);
                int rc = Tcl_AsyncInvoke(interp,TCL_OK);
                if (rc != TCL_OK) return(rc);
                if (rc != TCL_OK) return(rc);
        }
        }
        sleep(seconds);
        sleep(seconds);
        return TCL_OK;
        return TCL_OK;
}
}
 
 
#if 0
#if 0
/* There is no portable way to do sub-second sleeps on such a system, so */
/* There is no portable way to do sub-second sleeps on such a system, so */
/* do the next best thing (without a busy loop) and fake it: sleep the right */
/* do the next best thing (without a busy loop) and fake it: sleep the right */
/* amount of time over the long run.  Note that while "subtotal" isn't */
/* amount of time over the long run.  Note that while "subtotal" isn't */
/* reinitialized, it really doesn't matter for such a gross hack as random */
/* reinitialized, it really doesn't matter for such a gross hack as random */
/* scheduling pauses will easily introduce occasional one second delays. */
/* scheduling pauses will easily introduce occasional one second delays. */
int     /* returns TCL_XXX */
int     /* returns TCL_XXX */
exp_usleep(interp,usec)
exp_usleep(interp,usec)
Tcl_Interp *interp;
Tcl_Interp *interp;
long usec;              /* microseconds */
long usec;              /* microseconds */
{
{
        static subtotal = 0;
        static subtotal = 0;
        int seconds;
        int seconds;
 
 
        subtotal += usec;
        subtotal += usec;
        if (subtotal < 1000000) return TCL_OK;
        if (subtotal < 1000000) return TCL_OK;
        seconds = subtotal/1000000;
        seconds = subtotal/1000000;
        subtotal = subtotal%1000000;
        subtotal = subtotal%1000000;
 restart:
 restart:
        if (Tcl_AsyncReady()) {
        if (Tcl_AsyncReady()) {
                int rc = Tcl_AsyncInvoke(interp,TCL_OK);
                int rc = Tcl_AsyncInvoke(interp,TCL_OK);
                if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
                if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
        }
        }
        sleep(seconds);
        sleep(seconds);
        return TCL_OK;
        return TCL_OK;
}
}
#endif /*0*/
#endif /*0*/
 
 
/* set things up for later calls to event handler */
/* set things up for later calls to event handler */
void
void
exp_init_event()
exp_init_event()
{
{
        exp_event_exit = 0;
        exp_event_exit = 0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.