#line 1170 "/home/travis/build/felix-lang/felix/src/packages/io.fdoc"
  
  class Faio {
    requires package "demux";
    requires package "faio";
  
    open C_hack;
  
    proc faio_req[t](x:&t) {
      val y : &address = reinterpret[&address] x;
      svc (svc_general y);
    }
  
    proc get_thread(thread: &fthread) {
        svc (svc_get_fthread thread );
    }
  
    type sel_param = "flx::demux::sel_param";
    type sel_param_ptr = "flx::demux::sel_param*";
  
    fun get_bytes_done : sel_param_ptr -> int = '$1->bytes_written';
    proc init_pb : sel_param*address*int
    = '{$1.buffer=(char*)$2;$1.buffer_size=$3;$1.bytes_written=0;}';
  
    proc calc_eof(pb: sel_param_ptr, len: &int, eof: &bool)
    {
        //println "Calc_eof ..";
        var bytes_done = pb.get_bytes_done;
        //println$ "Bytes done = "+ str bytes_done;
        //println$ "Req len= "+ str (*len);
        *eof = (bytes_done != *len);
        //println$ "Eof = " + str (*eof);
        *len = bytes_done;
        //println$ "Reset len to bytes done ..";
    }
  
    type sleep_request = 'flx::faio::sleep_request' requires package "timer";
    type alarm_clock = 'flx::demux::timer_queue*' requires package "timer";
  
    fun mk_alarm_clock: 1 -> alarm_clock = '::flx::demux::mk_timer_queue()';
    fun mk_sleep_request: alarm_clock * double -> sleep_request = '::flx::faio::sleep_request($1,$2)';
  
    proc sleep(clock: alarm_clock, delta: double)
    {
      var sr = mk_sleep_request$ clock,delta;
      faio_req$ &sr;
    }
  } // class faio