Exemplo n.º 1
0
    int RingBufferRecordLogger::add_record(int32_t index, int32_t type,
                                           data_entry* key, data_entry* value)
    {
      UNUSED(index);
      log_debug("@@ ab %ld %ld", *w_offset_, *r_offset_);
      int ret = TAIR_RETURN_SUCCESS;
      char* buf = NULL;
      int total_size = RecordLogger::common_encode_record(buf, type, key, value);

      tbsys::CThreadGuard guard(&mutex_);
      char* mem_pos = calc_mem_pos(total_size);
      if (mem_pos == NULL)
      {
        log_debug("@@ not space left");
        ret = TAIR_RETURN_FAILED;
      }
      else
      {
        log_debug("@@ %lx pos: %lx %d %ld %ld", base_, mem_pos, total_size, *w_offset_, *r_offset_);
        memcpy(mem_pos, buf, total_size);
        *w_offset_ = mem_pos - base_ + total_size;
      }

      if (buf != NULL)
      {
        delete [] buf;
      }
      log_debug("@@ ae %ld %ld", *w_offset_, *r_offset_);
      return ret;
    }
Exemplo n.º 2
0
void	create_corline_wl(t_corline tmp, t_corline *corline, op_t op)
{
  op = checkOp(tmp.args[0]);
  tmp.instruction = op.mnemonique;
  tmp.nbr = count_args(tmp.args);
  tmp.tab_args = get_args(tmp.args + 1, -1);
  tmp.mempos = calc_mem_pos(&tmp, corline);
  tmp.label = NULL;
  create_line(corline, tmp);
}
Exemplo n.º 3
0
void	create_corline_l(t_corline tmp, t_corline *corline,
			 t_corlabel *corlabel, op_t op)
{
  t_corlabel	label;

  op = checkOp(tmp.args[1]);
  tmp.instruction = op.mnemonique;
  tmp.nbr = count_args(tmp.args);
  tmp.tab_args = get_args(tmp.args + 2, -1);
  tmp.mempos = calc_mem_pos(&tmp, corline);
  tmp.label = line_is_label(tmp.args[0]);
  label.mempos = tmp.mempos;
  label.name = tmp.label;
  create_label(corlabel, label);
  create_line(corline, tmp);
}