/* 
 * machine.c
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 *
 * $Revision: 1.2 $
 * $Date: 1996/02/01 15:20:28 $
 */

/*****************************************************************************/
#include <sys/time.h>
#include "xk_debug.h"
#include "upi.h"
#include "platform.h"

extern int SignalsPossible;
extern Semaphore master_lock;

int inInterrupt;
void definehandler();

/* don't know how many sockets we should allow for */
/* update this in [udp,tcp].c too */
#define NUMSOCKETSICANUSE 30
extern  int     errno;

void
cancelSignalHandler(sock)
int sock;
{
}

void
installSignalHandler(sock, f)
int sock;
int (*f)();
{
}

void
xholdsignals(sock)
int sock;
{
}

void
xreleasesignals(sock)
int sock;
{
}

void
findsocket()
{
}

void
fixFileMask()
{
}

void
dispatch(interruptNo)
int interruptNo;
{
}

struct itimerval i_value, i_zero;

#define handlerresulttype void
typedef handlerresulttype (*handlertype)();

void
onfault(h)
handlertype h;
{
}

void sig_int_handler();
void event_handler();


void
sig_int_handler()
{

}


/*
int sig_int_handler();
void event_handler();
*/

void
init_clock()
{
  definehandler(SIGPIPE, SIG_IGN);
  definehandler(SIGINT, (handlertype) sig_int_handler);
  definehandler(SIGIO,  (handlertype) dispatch);
  definehandler(SIGURG,  (handlertype) dispatch);

  /* start event processor */
  CreateProcess((int (*)())event_handler, THREAD_MINPRIO, 1, 0); /*LSB*/

  return;
}


#ifdef READ_CLOCK
int
read_clock(msec)        /* returns the number of msec */
long    *msec;          /* since sometime in late 1986 */
{
  struct  timeval   time;
  struct  timezone  zone;

  gettimeofday(&time, &zone);
  *msec = (time.tv_sec - 500000000)*1000 + (time.tv_usec / 1000);
  return(0);
}
#endif READ_CLOCK


void
definehandler(sig, handler)
int sig;
handlertype handler;
{
}

void signal_handler(sigid, handler)
int sigid;
handlertype handler;
{
}

int state;
int state_int;

void event_handler()
{
  xk_master_unlock();

  for (;;) {
    xk_master_lock();
    clock_ih();
    xk_master_unlock();
    scout_thread_yield();
  }
}

/*****************************************************************************/
