Exemplo n.º 1
0
Arquivo: fclib.c Projeto: xhub/fclib
/** read solution sizes */
static int read_nvnunrnl (hid_t file_id, int *nv, int *nr, int *nl)
{
  if (H5Lexists (file_id, "/fclib_global", H5P_DEFAULT))
  {
    IO (H5LTread_dataset_int (file_id, "/fclib_global/M/n", nv));
    IO (H5LTread_dataset_int (file_id, "/fclib_global/H/n", nr));
    if (H5Lexists (file_id, "/fclib_global/G", H5P_DEFAULT))
    {
      IO (H5LTread_dataset_int (file_id, "/fclib_global/G/n", nl));
    }
    else *nl = 0;
  }
  else if (H5Lexists (file_id, "/fclib_local", H5P_DEFAULT))
  {
    *nv = 0;
    IO (H5LTread_dataset_int (file_id, "/fclib_local/W/n", nr));
    if (H5Lexists (file_id, "/fclib_local/R", H5P_DEFAULT))
    {
      IO (H5LTread_dataset_int (file_id, "/fclib_local/R/n", nl));
    }
    else *nl = 0;
  }
  else
  {
    fprintf (stderr, "ERROR: neither global nor local problem has been stored. Global or local have to be stored before solutions or guesses\n");
    return 0;
  }

  return 1;
}
Exemplo n.º 2
0
AFFEND

/* XXX - when a file handle opened by pipe-from is up for gc it uses
   fclose instead of pclose! */
value arc_pipe_from(arc *c, value cmd)
{
  FILE *fp;
  int len;
  char *cmdstr;
  value ffp;

  TYPECHECK(cmd, T_STRING);
  len = FIX2INT(arc_strutflen(c, cmd));
  cmdstr = (char *)alloca(sizeof(char)*(len+1));
  arc_str2cstr(c, cmd, cmdstr);

  fp = popen(cmdstr, "r");
  if (fp == NULL) {
    int en = errno;
    arc_err_cstrfmt(c, "pipe-from: error executing command \"%s\", (%s; errno=%d)", cmdstr, strerror(en), en);
  }
  ffp = mkfio(c, T_INPORT, fp, cmd);
  IO(ffp)->io_ops = VINDEX(VINDEX(c->builtins, BI_io), BI_io_pfp);
  IO(ffp)->io_tfn = &procio_tfn;
  return(ffp);
}
Exemplo n.º 3
0
static void io_marker(arc *c, value v, int depth,
		      void (*markfn)(arc *, value, int))
{
  markfn(c, IO(v)->name, depth);
  markfn(c, IO(v)->io_ops, depth);
  IO(v)->io_tfn->marker(c, v, depth, markfn);
}
Exemplo n.º 4
0
static AFFDEF(io_pprint)
{
  AARG(sexpr, disp, fp);
  AOARG(visithash);
  AVAR(dw, wc);
  AFBEGIN;

  WV(dw, arc_mkaff(c, __arc_disp_write, CNIL));
  WV(wc, arc_mkaff(c, arc_writec, CNIL));
  if (TYPE(AV(sexpr)) == T_INPORT) {
    AFCALL(AV(dw), arc_mkstringc(c, "#<input-port:"), CTRUE,
	   AV(fp), AV(visithash));
  } else if (TYPE(AV(sexpr)) == T_OUTPORT) {
    AFCALL(AV(dw), arc_mkstringc(c, "#<output-port:"), CTRUE,
	   AV(fp), AV(visithash));
  } else {
    AFCALL(AV(dw), arc_mkstringc(c, "#<unknown-port:"), CTRUE,
	   AV(fp), AV(visithash));
  }
  if (!NIL_P(IO(AV(sexpr))->name)) {
    AFCALL(AV(dw), IO(AV(sexpr))->name, CTRUE,
	   AV(fp), AV(visithash));
  }
  if (IO(AV(sexpr))->io_tfn->pprint != NULL) {
    AFCALL(arc_mkaff(c, IO(AV(sexpr))->io_tfn->pprint, CNIL), AV(sexpr),
	   AV(disp), AV(fp), AV(visithash));
  }
  AFCALL(AV(wc), arc_mkchar(c, '>'), AV(fp));
  ARETURN(CNIL);
  AFEND;
}
Exemplo n.º 5
0
AFFEND

AFFDEF(arc_writeb)
{
  AARG(byte);
  AOARG(fd);
  AFBEGIN;

  if (arc_thr_argc(c, thr) == 0) {
    arc_err_cstrfmt(c, "writeb: too few arguments");
    return(CNIL);
  }

  if (!BOUND_P(AV(fd)))
    STDOUT(fd);

  IOW_TYPECHECK(AV(fd));
  CHECK_CLOSED(AV(fd));
  AFCALL(VINDEX(IO(AV(fd))->io_ops, IO_wready), AV(fd));
  if (AFCRV == CNIL) {
    arc_err_cstrfmt(c, "port is not ready for writing");
    ARETURN(CNIL);
  }
  AFTCALL(VINDEX(IO(AV(fd))->io_ops, IO_putb), AV(fd), AV(byte));
  AFEND;
}
char HWI2C_Transfer_read(char bank, char regAdd, char RegVal) 
{
	volatile t_ReqMb5 *p_ReqMB5;
	volatile t_AckMb5 *p_AckMB5;
	volatile unsigned data;
		
  p_ReqMB5  = (t_ReqMb5*)(TCDM_BASE+0xE44); 
  p_AckMB5  = (t_AckMb5*)(TCDM_BASE+0xDF4);
  	
	p_ReqMB5->un.I2CopType = I2CRead;
	p_ReqMB5->un.SlaveAdd = (bank&0x1F)|0x20;		  // To be used with AB8500V2	
	//p_ReqMB5->un.SlaveAdd = bank;								// To be used with AB8500V1
	p_ReqMB5->un.HwGCEn = 0;
	p_ReqMB5->un.StopEn = 1;
	p_ReqMB5->un.RegAdd = regAdd;
	p_ReqMB5->un.RegVal = RegVal;
	
	// Send mb5 (IT17) interrupt
	IO(0x80157100) = 0x20;
	
	// Check IT for ackMB5
	while((IO(0x80157494) & 0x20) != 0x20);

  data = (p_AckMB5->un.RegVal) & 0xFF;

	// Clear IT1 ackmb5
	IO(0x8015748C)=0x20;
	
	return(data);
	
}
Exemplo n.º 7
0
Arquivo: fclib.c Projeto: xhub/fclib
/** write solution */
static void write_solution (hid_t id, struct fclib_solution *solution, hsize_t nv, hsize_t nr, hsize_t nl)
{
  if (nv) IO (H5LTmake_dataset_double (id, "v", 1, &nv, solution->v));
  if (nl) IO (H5LTmake_dataset_double (id, "l", 1, &nl, solution->l));

  ASSERT (nr, "ERROR: contact constraints must be present");
  IO (H5LTmake_dataset_double (id, "u", 1, &nr, solution->u));
  IO (H5LTmake_dataset_double (id, "r", 1, &nr, solution->r));
}
Exemplo n.º 8
0
int extract(FILE *f, ArchFileInfo *info, char *fileName) {
  LOGGING_FUNC_START;
  int _error = 0;
  FILE *fOut = NULL;
  char *buf = malloc(BUF_SIZE*sizeof(char));
  char *buf2Write = malloc(BUF_SIZE*sizeof(char)*8);
  size_t lenBits = 0;
  size_t readBytes = 0;
  size_t returnBytes = 0;
  size_t readedBytes = 0;
  size_t howManyBytesRead = 0;
  Tree *haffTree = NULL;

  if (NULL == (fOut = fopen(fileName, "wb"))) {
    IO(L"Couldnt open file `%s`", fileName);
    __forErrorFileName = fileName;
    LOGGING_FUNC_STOP;
    return FILE_OPEN_ERROR;
  }

  haffTree = decodeTree(info->haffTree,info->haffTreeSize);
  initDecoding(haffTree);

  for (readedBytes=0; readedBytes < info->dataSize;) {
    howManyBytesRead = min(BUF_SIZE, (info->dataSize - readedBytes));
    _error = readNBytes(f, howManyBytesRead, buf, &readBytes);

    readedBytes += readBytes;

    if (_error) {
      IO(L"Error reading archive file");
      LOGGING_FUNC_STOP;
      return ARCHIVE_ERROR;
    }

    lenBits = (howManyBytesRead < BUF_SIZE)
              ? readBytes*8 - info->endUnusedBits
              : readBytes*8;

    decode(buf,lenBits,buf2Write,&returnBytes);

    _error = writeNBytes(fOut, returnBytes, buf2Write);

    if (_error) {
      IO("Write error to `%s`", fileName);
      __forErrorFileName = fileName;
      return _error;
    }
  }

  fclose(fOut);

  free(haffTree);
  LOGGING_FUNC_STOP;
  return 0;
}
Exemplo n.º 9
0
void init_encoder() {
  DDR(PINDEF_ENCA) &= ~(_BV(IO(PINDEF_ENCA)) | _BV(IO(PINDEF_ENCB)));
  // Init is called before interrupts are enabled.
  set_encoder_count_dangerous(0);
  // Set up interrupt.
  PCMSK0 = _BV(PCINT0) | _BV(PCINT4);
  // Just in case.
  PCIFR = _BV(PCIF0);
  // Enable.
  PCICR = _BV(PCIE0);
}
Exemplo n.º 10
0
/* Make a bare I/O object.  Note that one must populate the io_ops structure
   to be able to use it. */
value __arc_allocio(arc *c, int type, struct typefn_t *tfn, size_t xdsize)
{
  value io;

  io = arc_mkobject(c, sizeof(struct io_t) - sizeof(char) + xdsize, type);
  IO(io)->name = CNIL;
  IO(io)->flags = 0;
  IO(io)->io_tfn = tfn;
  IO(io)->ungetrune = -1;
  IO(io)->io_ops = CNIL;
  return(io);
}
///////////////////////////////////////
//Modem trace configuration
///////////////////////////////////////
void Modem_STM_config()
{
	//; ##########################################
	//; #       Configure GPIO for STM Modem
	//; ##########################################
	//; Configure GPIOs 70 to 76 in AltCx mode (AltA + AltB = AltC) 
	IO(0x8000e020) |= 0x00001FC0; //GPIO 70 to 76 AFSELA
	IO(0x8000e024) |= 0x00001FC0; //GPIO 70 to 76 AFSELB
	
	//; ##########################################
	//; #       Configure PRCMU for STM Modem
	//; ##########################################
	IO(0x80157138) |= 0x00000801; //Enable AltC3 for STM Modem signals on GPIOs 70 -> 76
}
Exemplo n.º 12
0
AFFEND

static value mkfio(arc *c, int type, FILE *fd, value name)
{
  value fio;

  fio = __arc_allocio(c, type, &fileio_tfn, sizeof(struct fileio_t));
  IO(fio)->flags = 0;
  IO(fio)->io_ops = VINDEX(VINDEX(c->builtins, BI_io), BI_io_fp);
  IO(fio)->name = name;
  FIODATA(fio)->closed = 0;
  FIODATA(fio)->fp = fd;
  return(fio);
}
Exemplo n.º 13
0
Arquivo: fclib.c Projeto: xhub/fclib
/** read local vectors */
static void read_local_vectors (hid_t id, struct fclib_local *problem)
{
  MM (problem->q = malloc (sizeof (double [problem->W->m])));
  IO (H5LTread_dataset_double (id, "q", problem->q));

  ASSERT (problem->W->m % problem->spacedim == 0, "ERROR: number of W rows is not divisble by the spatial dimension");
  MM (problem->mu = malloc (sizeof (double [problem->W->m / problem->spacedim])));
  IO (H5LTread_dataset_double (id, "mu", problem->mu));

  if (problem->R)
  {
    MM (problem->s = malloc (sizeof (double [problem->R->m])));
    IO (H5LTread_dataset_double (id, "s", problem->s));
  }
}
Exemplo n.º 14
0
/******************************************************************************
 * FUNCTION NAME:
 *      DRV_SPI_WriteByte
 * DESCRIPTION:
 *      Write 1 Bytes data, via SPI Bus.
 * PARAMETERS:
 *      vData : Write data buffer.
 * RETURN:
 *      N/A
 * NOTES:
 *      N/A
 * HISTORY:
 *      2009.5.26        Panda.Xiong         Create/Update
 *****************************************************************************/
void DRV_SPI_WriteByte(IN UINT8 vData)
{
	UINT8   vBitIndex;

    for (vBitIndex = 8; vBitIndex != 0; vBitIndex--)
    {
        /* Transmitting data, MSB first, LSB last */
        CROL(vData, 1);
        DRV_SPI_IO_Write(IO(SPI_MOSI), (vData & 0x1));

        /* Generate one clock, to tell SPI Slave one bit data is ready */
        DRV_SPI_IO_Write(IO(SPI_SCK), IO_SPI_SCK_ACTIVE);
        DRV_SPI_FixWriteDutyCycle();
        DRV_SPI_IO_Write(IO(SPI_SCK), IO_SPI_SCK_INACTIVE);
	}
}
Exemplo n.º 15
0
bool YSE::DSP::fileBuffer::save(const char * fileName) {
  std::string fn = fileName;
  fn += ".wav";

  if (IO().getActive()) {
    return false; // not implemented yet
  }
  else {
    // check if file exists
    /*File file;
    file = File::getCurrentWorkingDirectory().getChildFile(fn.c_str());
    file.deleteFile();
    ScopedPointer<FileOutputStream> fileStream(file.createOutputStream());

    if (fileStream != nullptr) {
      WavAudioFormat wavFormat;
      AudioFormatWriter * writer = wavFormat.createWriterFor(fileStream, SAMPLERATE, 1, 16, StringPairArray(), 0);

      if (writer != nullptr) {
        fileStream.release();

        float ** array = new float*[1];
        array[0] = getPtr();

        writer->writeFromFloatArrays(array, 1, getLength());
        writer->flush();
        delete[] array;
      }
    }
	*/
  }

  return true;
}
Exemplo n.º 16
0
//---------------------------------------------------------------------------//
  void SerialSaver::IO(std::string& p_Value) 
  {
    uint32_t lgth = p_Value.length();
    IO(lgth);
    if (lgth > 0)
        m_streamer->Write(p_Value.c_str(), lgth);
  }
Exemplo n.º 17
0
void YSE::INTERNAL::soundFile::loadNonStreaming() {
  // load non streaming sounds in one go
  ScopedPointer<AudioFormatReader> reader;
  File file;

  if (IO().getActive()) {
    // will be deleted by AudioFormatReader
    customFileReader * cfr = new customFileReader;
    cfr->create(fileName.c_str());
    reader = SOUND::Manager().getReader(cfr);
  }
  else {
    file = File::getCurrentWorkingDirectory().getChildFile(juce::String(fileName));
    reader = SOUND::Manager().getReader(file);
  }

  if (reader != nullptr) {
    _fileBuffer.setSize(reader->numChannels, (Int)reader->lengthInSamples);
    reader->read(&_fileBuffer, 0, (Int)reader->lengthInSamples, 0, true, true);
    // sample rate adjustment
    _sampleRateAdjustment = static_cast<Flt>(reader->sampleRate) / static_cast<Flt>(SAMPLERATE);
    _length = _fileBuffer.getNumSamples();
    _buffer = _fileBuffer.getArrayOfReadPointers();
    _channels = _fileBuffer.getNumChannels();

    // file is ready for use now
    state = READY;
  }
  else {
    LogImpl().emit(E_FILEREADER, "Unable to read " + file.getFullPathName().toStdString());
    state = INVALID;
  }
}
Exemplo n.º 18
0
void tee_time_rtt_interrupt(void)
{
	if (IO(RTT0_MIS) & RTT_MIS_MIS)
		tee_time_rtt0_wrap++;

	/* No need to clear the interrupt as ROM code is handling that. */
}
Exemplo n.º 19
0
int main()
{
    init();
    IO();
    grammar();
    return 0;
}
Exemplo n.º 20
0
AFFEND

AFFDEF(arc_readc)
{
  AOARG(fd);
  AVAR(chr, buf, i, readb);
  char cbuf[UTFmax];    /* this is always destroyed */
  Rune ch;
  int j;
  AFBEGIN;

  if (!BOUND_P(AV(fd)))
    STDIN(fd);

  IO_TYPECHECK(AV(fd));
  CHECK_CLOSED(AV(fd));
  if (IO(AV(fd))->ungetrune >= 0) {
    ch = IO(AV(fd))->ungetrune;
    IO(AV(fd))->ungetrune = -1;
    ARETURN(arc_mkchar(c, ch));
  }
  if (IO(AV(fd))->flags & IO_FLAG_GETB_IS_GETC) {
    AFCALL(VINDEX(IO(AV(fd))->io_ops, IO_getb), AV(fd));
    if (NIL_P(AFCRV))
      ARETURN(CNIL);
    ARETURN(arc_mkchar(c, FIX2INT(AFCRV)));
  }
  WV(buf, arc_mkvector(c, UTFmax));
  /* XXX - should put this in builtins */
  WV(readb, arc_mkaff(c, arc_readb, CNIL));
  for (WV(i, INT2FIX(0)); FIX2INT(AV(i)) < UTFmax; WV(i, INT2FIX(FIX2INT(AV(i)) + 1))) {
    AFCALL(AV(readb), AV(fd));
    WV(chr, AFCRV);
    if (NIL_P(AV(chr)))
      ARETURN(CNIL);
    SVINDEX(AV(buf), FIX2INT(AV(i)), AV(chr));
    /* Arcueid fixnum vector to C array of chars */
    for (j=0; j<=FIX2INT(AV(i)); j++)
      cbuf[j] = FIX2INT(VINDEX(AV(buf), j));
    if (fullrune(cbuf, FIX2INT(AV(i)) + 1)) {
      chartorune(&ch, cbuf);
      ARETURN(arc_mkchar(c, ch));
    }
  }
  ARETURN(CNIL);
  AFEND;
}
Exemplo n.º 21
0
Arquivo: fclib.c Projeto: xhub/fclib
/** read global vectors */
static void read_global_vectors (hid_t id, struct fclib_global *problem)
{
  MM (problem->f = malloc (sizeof (double [problem->M->m])));
  IO (H5LTread_dataset_double (id, "f", problem->f));

  ASSERT (problem->H->n % problem->spacedim == 0, "ERROR: number of H columns is not divisble by the spatial dimension");
  MM (problem->w = malloc (sizeof (double [problem->H->n])));
  MM (problem->mu = malloc (sizeof (double [problem->H->n / problem->spacedim])));
  IO (H5LTread_dataset_double (id, "w", problem->w));
  IO (H5LTread_dataset_double (id, "mu", problem->mu));

  if (problem->G)
  {
    MM (problem->b = malloc (sizeof (double [problem->G->n])));
    IO (H5LTread_dataset_double (id, "b", problem->b));
  }
}
Exemplo n.º 22
0
AFFEND

AFFDEF(arc_tell)
{
  AARG(fp);
  AFBEGIN;
  AFTCALL(VINDEX(IO(AV(fp))->io_ops, IO_tell), AV(fp));
  AFEND;
}
Exemplo n.º 23
0
void CSharpTabCodeGen::LOCATE_TRANS()
{
    out <<
        "	_keys = " << KO() + "[" + vCS() + "]" << ";\n"
        "	_trans = " << CAST(transType) << IO() << "[" << vCS() << "];\n"
        "\n"
        "	_klen = " << SL() << "[" << vCS() << "];\n"
        "	if ( _klen > 0 ) {\n"
        "		" << signedKeysType << " _lower = _keys;\n"
        "		" << signedKeysType << " _mid;\n"
        "		" << signedKeysType << " _upper = " << CAST(signedKeysType) <<
        " (_keys + _klen - 1);\n"
        "		while (true) {\n"
        "			if ( _upper < _lower )\n"
        "				break;\n"
        "\n"
        "			_mid = " << CAST(signedKeysType) <<
        " (_lower + ((_upper-_lower) >> 1));\n"
        "			if ( " << GET_WIDE_KEY() << " < " << K() << "[_mid] )\n"
        "				_upper = " << CAST(signedKeysType) << " (_mid - 1);\n"
        "			else if ( " << GET_WIDE_KEY() << " > " << K() << "[_mid] )\n"
        "				_lower = " << CAST(signedKeysType) << " (_mid + 1);\n"
        "			else {\n"
        "				_trans += " << CAST(transType) << " (_mid - _keys);\n"
        "				goto _match;\n"
        "			}\n"
        "		}\n"
        "		_keys += " << CAST(keysType) << " _klen;\n"
        "		_trans += " << CAST(transType) << " _klen;\n"
        "	}\n"
        "\n"
        "	_klen = " << RL() << "[" << vCS() << "];\n"
        "	if ( _klen > 0 ) {\n"
        "		" << signedKeysType << " _lower = _keys;\n"
        "		" << signedKeysType << " _mid;\n"
        "		" << signedKeysType << " _upper = " << CAST(signedKeysType) <<
        " (_keys + (_klen<<1) - 2);\n"
        "		while (true) {\n"
        "			if ( _upper < _lower )\n"
        "				break;\n"
        "\n"
        "			_mid = " << CAST(signedKeysType) <<
        " (_lower + (((_upper-_lower) >> 1) & ~1));\n"
        "			if ( " << GET_WIDE_KEY() << " < " << K() << "[_mid] )\n"
        "				_upper = " << CAST(signedKeysType) << " (_mid - 2);\n"
        "			else if ( " << GET_WIDE_KEY() << " > " << K() << "[_mid+1] )\n"
        "				_lower = " << CAST(signedKeysType) << " (_mid + 2);\n"
        "			else {\n"
        "				_trans += " << CAST(transType) << "((_mid - _keys)>>1);\n"
        "				goto _match;\n"
        "			}\n"
        "		}\n"
        "		_trans += " << CAST(transType) << " _klen;\n"
        "	}\n"
        "\n";
}
Exemplo n.º 24
0
Arquivo: fclib.c Projeto: xhub/fclib
/** write local vectors */
static void write_local_vectors (hid_t id, struct fclib_local *problem)
{
  hsize_t dim;

  dim = problem->W->m;
  ASSERT (problem->q, "ERROR: q must be given");
  IO (H5LTmake_dataset_double (id, "q", 1, &dim, problem->q));

  ASSERT (dim % problem->spacedim == 0, "ERROR: number of W rows is not divisble by the spatial dimension");
  dim /= problem->spacedim;
  IO (H5LTmake_dataset_double (id, "mu", 1, &dim, problem->mu));

  if (problem->V)
  {
    dim = problem->R->m;
    ASSERT (problem->s, "ERROR: s must be given if R is present");
    IO (H5LTmake_dataset_double (id, "s", 1, &dim, problem->s));
  }
}
Exemplo n.º 25
0
/******************************************************************************
 * FUNCTION NAME:
 *      DRV_SPI_ReadByte
 * DESCRIPTION:
 *      Read 1 Bytes data, via SPI Bus.
 * PARAMETERS:
 *      N/A
 * RETURN:
 *      The read 1 Byte data.
 * NOTES:
 *      N/A
 * HISTORY:
 *      2009.5.26        Panda.Xiong         Create/Update
 *****************************************************************************/
UINT8 DRV_SPI_ReadByte(void)
{
	UINT8   vData;
	UINT8   vBitIndex;

	vData = 0x00;
    for (vBitIndex = 8; vBitIndex != 0; vBitIndex--)
    {
        /* Generate one clock, to tell SPI Slave to send one bit data */
        DRV_SPI_IO_Write(IO(SPI_SCK), IO_SPI_SCK_ACTIVE);
        DRV_SPI_FixReadDutyCycle();
        DRV_SPI_IO_Write(IO(SPI_SCK), IO_SPI_SCK_INACTIVE);

        /* Sample data: MSB first, LSB last */
        vData <<= 1;
        vData |= DRV_SPI_IO_Read(IO(SPI_MISO));
	}

	return vData;
}
Exemplo n.º 26
0
AFFEND

AFFDEF(arc_writec)
{
  AARG(chr);
  AOARG(fd);
  AVAR(buf, i, writeb, nbytes);
  char cbuf[UTFmax];
  Rune ch;
  int j;
  AFBEGIN;

  if (arc_thr_argc(c, thr) == 0) {
    arc_err_cstrfmt(c, "writec: too few arguments");
    return(CNIL);
  }

  if (!BOUND_P(AV(fd)))
    STDOUT(fd);

  IOW_TYPECHECK(AV(fd));
  CHECK_CLOSED(AV(fd));
  if (IO(AV(fd))->flags & IO_FLAG_GETB_IS_GETC) {
    AFCALL(VINDEX(IO(AV(fd))->io_ops, IO_putb), AV(fd),
	   INT2FIX(arc_char2rune(c, AV(chr))));
    ARETURN(arc_mkchar(c, FIX2INT(AFCRV)));
  }
  /* XXX - should put this in builtins */
  WV(writeb, arc_mkaff(c, arc_writeb, CNIL));
  ch = arc_char2rune(c, AV(chr));
  WV(nbytes, INT2FIX(runetochar(cbuf, &ch)));
  /* Convert C char array into Arcueid vector of fixnums */
  WV(buf, arc_mkvector(c, FIX2INT(AV(nbytes))));
  for (j=0; j<FIX2INT(AV(nbytes)); j++)
    SVINDEX(AV(buf), j, INT2FIX(cbuf[j]));
  for (WV(i, INT2FIX(0)); FIX2INT(AV(i)) < FIX2INT(AV(nbytes)); WV(i, INT2FIX(FIX2INT(AV(i)) + 1))) {
    AFCALL(AV(writeb),VINDEX(AV(buf), FIX2INT(AV(i))), AV(fd));
  }
  ARETURN(AV(chr));
  AFEND;
}
Exemplo n.º 27
0
void	avm(char *file)
{
  try
    {
      Io	IO(file);
      std::list<std::string> listf = IO.getList();
      Chipset chip(listf);
      std::list<std::string> instru = chip.getInstruct();
      Cpu cpu(instru);
    }
  catch (const std::exception & e ) { std::cerr << e.what();}
}
Exemplo n.º 28
0
General::General(int typicalCount, int deviceCount, int ioCount) {
    communication = Communication();
    time = Time();

    io = IO(ioCount);

    _typicalCount = 0;
    _deviceCount = 0;

    _communicationLost = false;
    _canContinueWithoutCommunication = false;
}
Exemplo n.º 29
0
AFFEND

AFFDEF(arc_close)
{
  ARARG(list);
  AFBEGIN;
  for (; !NIL_P(AV(list)); WV(list, cdr(AV(list)))) {
    AFCALL(VINDEX(IO(car(AV(list)))->io_ops, IO_close), car(AV(list)));
  }
  ARETURN(CNIL);
  AFEND;
}
Exemplo n.º 30
0
void FlatCodeGen::LOCATE_TRANS()
{
	out <<
		"	_keys = " << ARR_OFF( K(), "(" + vCS() + "<<1)" ) << ";\n"
		"	_inds = " << ARR_OFF( I(), IO() + "[" + vCS() + "]" ) << ";\n"
		"\n"
		"	_slen = " << SP() << "[" << vCS() << "];\n"
		"	_trans = _inds[ _slen > 0 && _keys[0] <=" << GET_WIDE_KEY() << " &&\n"
		"		" << GET_WIDE_KEY() << " <= _keys[1] ?\n"
		"		" << GET_WIDE_KEY() << " - _keys[0] : _slen ];\n"
		"\n";
}