void update_internal(int k, int start, int end, int i, int val) {
     if (k >= 4*n) {
         return;
     }
     
     if (start == end) {
         tree[k].val = val;
     } else {
         int mid = floor((start + end) /2);
         if (i <= mid) {
             update_internal(2*k, start, mid, i, val);
         } else {
             update_internal(2*k+1, mid+1, end, i, val);
         }
         tree[k].val = tree[2*k].val + tree[2*k+1].val;
     }
 }
예제 #2
0
파일: update.c 프로젝트: Alkzndr/freebsd
svn_error_t *
svn_client__update_internal(svn_revnum_t *result_rev,
                            const char *local_abspath,
                            const svn_opt_revision_t *revision,
                            svn_depth_t depth,
                            svn_boolean_t depth_is_sticky,
                            svn_boolean_t ignore_externals,
                            svn_boolean_t allow_unver_obstructions,
                            svn_boolean_t adds_as_modification,
                            svn_boolean_t make_parents,
                            svn_boolean_t innerupdate,
                            svn_boolean_t *timestamp_sleep,
                            svn_client_ctx_t *ctx,
                            apr_pool_t *pool)
{
  const char *anchor_abspath, *lockroot_abspath;
  svn_error_t *err;
  svn_opt_revision_t peg_revision = *revision;
  apr_hash_t *conflicted_paths
    = ctx->conflict_func2 ? apr_hash_make(pool) : NULL;

  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
  SVN_ERR_ASSERT(! (innerupdate && make_parents));

  if (make_parents)
    {
      int i;
      const char *parent_abspath = local_abspath;
      apr_array_header_t *missing_parents =
        apr_array_make(pool, 4, sizeof(const char *));

      while (1)
        {
          /* Try to lock.  If we can't lock because our target (or its
             parent) isn't a working copy, we'll try to walk up the
             tree to find a working copy, remembering this path's
             parent as one we need to flesh out.  */
          err = svn_wc__acquire_write_lock(&lockroot_abspath, ctx->wc_ctx,
                                           parent_abspath, !innerupdate,
                                           pool, pool);
          if (!err)
            break;
          if ((err->apr_err != SVN_ERR_WC_NOT_WORKING_COPY)
              || svn_dirent_is_root(parent_abspath, strlen(parent_abspath)))
            return err;
          svn_error_clear(err);

          /* Remember the parent of our update target as a missing
             parent. */
          parent_abspath = svn_dirent_dirname(parent_abspath, pool);
          APR_ARRAY_PUSH(missing_parents, const char *) = parent_abspath;
        }

      /* Run 'svn up --depth=empty' (effectively) on the missing
         parents, if any. */
      anchor_abspath = lockroot_abspath;
      for (i = missing_parents->nelts - 1; i >= 0; i--)
        {
          const char *missing_parent =
            APR_ARRAY_IDX(missing_parents, i, const char *);

          err = update_internal(result_rev, conflicted_paths,
                                missing_parent, anchor_abspath,
                                &peg_revision, svn_depth_empty, FALSE,
                                ignore_externals, allow_unver_obstructions,
                                adds_as_modification, timestamp_sleep,
                                FALSE, ctx, pool);
          if (err)
            goto cleanup;
          anchor_abspath = missing_parent;

          /* If we successfully updated a missing parent, let's re-use
             the returned revision number for future updates for the
             sake of consistency. */
          peg_revision.kind = svn_opt_revision_number;
          peg_revision.value.number = *result_rev;
        }
    }
  else
    {
 void update(int i, int val) {
     update_internal(1, 0, n-1, i, val);
 }
예제 #4
0
void Device::write_log(log_entry &entry)
{
    if (!entry.is_irq) {
        update_internal(entry);
    }

    bool log_is_full = m_log.write(entry);
    emit layoutChanged();

    if (log_is_full) {
        emit itemInserted();
    }

    if (entry.is_error) {
        m_dev_errs_nb++;
        m_errs_stat_dirty = true;
        updateName();
        emit ErrorUnknownReg(m_name, entry);
        emit errorStatUpdated(this->id);
    } else if (!entry.is_irq) {

        if (entry.is_write &&
                is_undef_changed(entry.offset, entry.value, entry.new_value)) {
            QString text = "changing undefined bits ";
                    text += get_register_name(entry) + " ";
                    text += QString().sprintf("0x%08X -> 0x%08X",
                                        entry.value, entry.new_value) + " ";
                    text += QString().sprintf("cpu=0x%08X", entry.cpu_pc);
            emit ErrorCustom(m_name, text, entry.time);
        }

        if (entry.clk_disabled || entry.in_reset) {
            m_dev_errs_nb++;
            m_errs_stat_dirty = true;
            updateName();
            emit errorStatUpdated(this->id);
        }
    }

    if (entry.is_irq) {
        m_irq_act = !!entry.value;
        m_dev_irqs_nb++;
        m_irqs_stat_dirty = true;
    } else if (entry.is_write) {
        m_dev_writes_nb++;
        m_writes_stat_dirty = true;
    } else {
        m_dev_reads_nb++;
        m_reads_stat_dirty = true;
    }

    if (!m_stats_changed) {
        m_stats_changed = true;
        emit firstTimeStatUpdated(this->id);
    }

    if (!update_dev_stats_timer.isActive()) {
        update_dev_stats_timer.start(300);
    }

    blink_reset_timer.start(1500);

    if (m_record_dev)
        m_record_dev->write_log(entry);
}