当前位置: 首页>>代码示例>>C++>>正文


C++ SC_ASSERT函数代码示例

本文整理汇总了C++中SC_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ SC_ASSERT函数的具体用法?C++ SC_ASSERT怎么用?C++ SC_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SC_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sc_package_rc_count_add

void
sc_package_rc_count_add (int package_id, int toadd)
{
  int                *pcount;
#ifdef SC_ENABLE_DEBUG
  int                 newvalue;
#endif

  if (package_id == -1) {
    pcount = &default_rc_active;
  }
  else {
    SC_ASSERT (sc_package_is_registered (package_id));
    pcount = &sc_packages[package_id].rc_active;
  }

  sc_package_lock (package_id);
#ifdef SC_ENABLE_DEBUG
  newvalue =
#endif
    *pcount += toadd;
  sc_package_unlock (package_id);

  SC_ASSERT (newvalue >= 0);
}
开发者ID:johannrudi,项目名称:libsc,代码行数:25,代码来源:sc.c

示例2: sc_allgather

int
sc_allgather (void *sendbuf, int sendcount, sc_MPI_Datatype sendtype,
              void *recvbuf, int recvcount, sc_MPI_Datatype recvtype,
              sc_MPI_Comm mpicomm)
{
  int                 mpiret;
  int                 mpisize;
  int                 mpirank;
  size_t              datasize;
#ifdef SC_DEBUG
  size_t              datasize2;
#endif

  SC_ASSERT (sendcount >= 0 && recvcount >= 0);

  /* *INDENT-OFF* HORRIBLE indent bug */
  datasize = (size_t) sendcount * sc_mpi_sizeof (sendtype);
#ifdef SC_DEBUG
  datasize2 = (size_t) recvcount * sc_mpi_sizeof (recvtype);
#endif
  /* *INDENT-ON* */

  SC_ASSERT (datasize == datasize2);

  mpiret = sc_MPI_Comm_size (mpicomm, &mpisize);
  SC_CHECK_MPI (mpiret);
  mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank);
  SC_CHECK_MPI (mpiret);

  memcpy (((char *) recvbuf) + mpirank * datasize, sendbuf, datasize);
  sc_allgather_recursive (mpicomm, (char *) recvbuf, (int) datasize,
                          mpisize, mpirank, mpirank);

  return sc_MPI_SUCCESS;
}
开发者ID:holke,项目名称:libsc,代码行数:35,代码来源:sc_allgather.c

示例3: sc_keyvalue_unset

sc_keyvalue_entry_type_t
sc_keyvalue_unset (sc_keyvalue_t * kv, const char *key)
{
    void               *found;
    sc_keyvalue_entry_t svalue, *pvalue = &svalue;
    sc_keyvalue_entry_t *value;

    int                 remove_test;
    sc_keyvalue_entry_type_t type;

    SC_ASSERT (kv != NULL);
    SC_ASSERT (key != NULL);

    pvalue->key = key;
    pvalue->type = SC_KEYVALUE_ENTRY_NONE;

    /* Remove this entry */
    remove_test = sc_hash_remove (kv->hash, pvalue, &found);

    /* Check whether anything was removed */
    if (!remove_test)
        return SC_KEYVALUE_ENTRY_NONE;

    /* Code reaching this point must have found something */
    SC_ASSERT (remove_test);
    SC_ASSERT (found != NULL);

    value = (sc_keyvalue_entry_t *) found;
    type = value->type;

    /* destroy the orignial hash entry */
    sc_mempool_free (kv->value_allocator, value);

    return type;
}
开发者ID:johannrudi,项目名称:libsc,代码行数:35,代码来源:sc_keyvalue.c

示例4: boat_klass_new

sc_object_t        *
boat_klass_new (sc_object_t * d)
{
  int                 a1, a2, a3, a4, a5;
  sc_object_t        *o;

  SC_ASSERT (d != NULL);
  SC_ASSERT (sc_object_is_type (d, sc_object_type));

  o = sc_object_alloc ();
  sc_object_delegate_push (o, d);

  a1 = sc_object_method_register (o, (sc_object_method_t) sc_object_is_type,
                                  (sc_object_method_t) is_type_fn);
  a2 = sc_object_method_register (o, (sc_object_method_t) sc_object_copy,
                                  (sc_object_method_t) copy_fn);
  a3 =
    sc_object_method_register (o, (sc_object_method_t) sc_object_initialize,
                               (sc_object_method_t) initialize_fn);
  a4 =
    sc_object_method_register (o, (sc_object_method_t) sc_object_write,
                               (sc_object_method_t) write_fn);
  a5 =
    sc_object_method_register (o, (sc_object_method_t) vehicle_accelerate,
                               (sc_object_method_t) accelerate_fn);
  SC_ASSERT (a1 && a2 && a3 && a4 && a5);

  sc_object_initialize (o, NULL);

  return o;
}
开发者ID:ChenShaoning,项目名称:libsc,代码行数:31,代码来源:boat.c

示例5: sc_keyvalue_set_pointer

void
sc_keyvalue_set_pointer (sc_keyvalue_t * kv, const char *key, void *newvalue)
{
    void              **found;
    sc_keyvalue_entry_t svalue, *pvalue = &svalue;
    sc_keyvalue_entry_t *value;

    SC_ASSERT (kv != NULL);
    SC_ASSERT (key != NULL);

    pvalue->key = key;
    pvalue->type = SC_KEYVALUE_ENTRY_NONE;
    if (sc_hash_lookup (kv->hash, pvalue, &found)) {
        /* Key already exists in hash table */
        value = (sc_keyvalue_entry_t *) (*found);
        SC_ASSERT (value->type == SC_KEYVALUE_ENTRY_POINTER);

        value->value.p = (void *) newvalue;
    }
    else {
        /* Key does not exist and must be created */
        value = (sc_keyvalue_entry_t *) sc_mempool_alloc (kv->value_allocator);
        value->key = key;
        value->type = SC_KEYVALUE_ENTRY_POINTER;
        value->value.p = (void *) newvalue;

        /* Insert value into the hash table */
        SC_EXECUTE_ASSERT_TRUE (sc_hash_insert_unique (kv->hash, value, &found));
    }
}
开发者ID:johannrudi,项目名称:libsc,代码行数:30,代码来源:sc_keyvalue.c

示例6: sc_keyvalue_get_int_check

int
sc_keyvalue_get_int_check (sc_keyvalue_t * kv, const char *key, int *status)
{
    int                 result;
    int                 etype;
    void              **found;
    sc_keyvalue_entry_t svalue, *pvalue = &svalue;
    sc_keyvalue_entry_t *value;

    SC_ASSERT (kv != NULL);
    SC_ASSERT (key != NULL);

    result = (status != NULL) ? *status : INT_MIN;
    etype = 1;
    pvalue->key = key;
    pvalue->type = SC_KEYVALUE_ENTRY_NONE;
    if (sc_hash_lookup (kv->hash, pvalue, &found)) {
        value = (sc_keyvalue_entry_t *) (*found);
        if (value->type == SC_KEYVALUE_ENTRY_INT) {
            etype = 0;
            result = value->value.i;
        }
        else {
            etype = 2;
        }
    }
    SC_ASSERT (status != NULL || etype == 0);
    if (status != NULL) {
        *status = etype;
    }
    return result;
}
开发者ID:johannrudi,项目名称:libsc,代码行数:32,代码来源:sc_keyvalue.c

示例7: sc_bspline_derivative_n

void
sc_bspline_derivative_n (sc_bspline_t * bs, int order,
                         double t, double *result)
{
  int                 i, k, n;
  int                 iguess;
  int                 toffset;
  double             *wfrom, *wto;
  const double       *knotse = bs->knots->e[0];

  SC_ASSERT (order >= 0);

  if (bs->n < order) {
    memset (result, 0, sizeof (double) * bs->d);
    return;
  }

  iguess = sc_bspline_find_interval (bs, t);

  toffset = 0;
  wfrom = wto = bs->points->e[iguess - bs->n];
  for (n = bs->n; n > 0; --n) {
    wto = bs->works->e[toffset];

    if (bs->n < n + order) {
      for (i = 0; i < n; ++i) {
        const double        tleft = knotse[iguess + i - n + 1];
        const double        tright = knotse[iguess + i + 1];
        const double        tfactor = n / (tright - tleft);

        for (k = 0; k < bs->d; ++k) {
          wto[bs->d * i + k] =
            (wfrom[bs->d * (i + 1) + k] - wfrom[bs->d * i + k]) * tfactor;
        }
      }
    }
    else {
      for (i = 0; i < n; ++i) {
        const double        tleft = knotse[iguess + i - n + 1];
        const double        tright = knotse[iguess + i + 1];
        const double        tfactor = 1. / (tright - tleft);

        for (k = 0; k < bs->d; ++k) {
          wto[bs->d * i + k] =
            ((t - tleft) * wfrom[bs->d * (i + 1) + k] +
             (tright - t) * wfrom[bs->d * i + k]) * tfactor;
        }
      }
    }

    wfrom = wto;
    toffset += n;
  }
  SC_ASSERT (toffset == bs->n * (bs->n + 1) / 2);

  memcpy (result, wfrom, sizeof (double) * bs->d);
}
开发者ID:johannrudi,项目名称:libsc,代码行数:57,代码来源:sc_bspline.c

示例8: sc_free_aligned

static void
sc_free_aligned (void *ptr, size_t alignment)
{
  /* minimum requirements on alignment */
  SC_ASSERT (sizeof (char **) == sizeof (void *));
  SC_ASSERT (sizeof (char **) >= sizeof (size_t));
  SC_ASSERT (alignment > 0 && alignment % sizeof (void *) == 0);

#if defined SC_HAVE_ANY_MEMALIGN && \
   (defined SC_HAVE_POSIX_MEMALIGN || defined SC_HAVE_ALIGNED_ALLOC)
  free (ptr);
#else
  {
#if 0
    int                *datastart = ptr;
    int                 shift = datastart[-1];

    datastart -= shift;
    free ((void *) datastart);
#endif
    /* this mirrors the function sc_malloc_aligned above */
    char               *alloc_ptr;
#ifdef SC_ENABLE_DEBUG
    const ptrdiff_t     extrasize = (const ptrdiff_t) (2 * sizeof (char **));
    const ptrdiff_t     signalign = (const ptrdiff_t) alignment;
    ptrdiff_t           shift, modu, ssize, i;
#endif

    /* we excluded these cases earlier */
    SC_ASSERT (ptr != NULL);
    SC_ASSERT ((ptrdiff_t) ptr % signalign == 0);

    alloc_ptr = ((char **) ptr)[-1];
    SC_ASSERT (alloc_ptr != NULL);

#ifdef SC_ENABLE_DEBUG
    /* compute shift to the right where we put the actual data */
    ssize = (ptrdiff_t) ((char **) ptr)[-2];
    modu = ((ptrdiff_t) alloc_ptr + extrasize) % signalign;
    shift = (signalign - modu) % signalign;
    SC_ASSERT (0 <= shift && shift < signalign);
    SC_ASSERT ((char *) ptr == alloc_ptr + (extrasize + shift));
    for (i = 0; i < shift; ++i) {
      SC_ASSERT (alloc_ptr[i] == -2);
    }
    for (i = 0; i < signalign - shift; ++i) {
      SC_ASSERT (((char *) ptr)[ssize + i] == -2);
    }
#endif

    /* free the original pointer */
    free (alloc_ptr);
  }
#endif
}
开发者ID:johannrudi,项目名称:libsc,代码行数:55,代码来源:sc.c

示例9: sc_bspline_knots_new_length_periodic

sc_dmatrix_t       *
sc_bspline_knots_new_length_periodic (int n, sc_dmatrix_t * points)
{
  const int           d = points->n;
  const int           p = points->m - 1;
  const int           m = n + p + 1;
  const int           l = m - 2 * n;
  int                 i, k;
  double              distsqr, distsum, distalln;
  double             *knotse;
  sc_dmatrix_t       *knots;

  SC_ASSERT (n >= 1);
  SC_ASSERT (n >= 0 && m >= 1 && d >= 1 && l >= 1);

  knots = sc_dmatrix_new_zero (m + 1, 1);
  knotse = knots->e[0];

  /* compute cumulative distance from P_0 and hide inside knots */
  distsum = 0.;
  for (i = 0; i < p; ++i) {
    SC_ASSERT (n + i + 2 >= 0 && n + i + 2 <= m);
    distsqr = 0.;
    for (k = 0; k < d; ++k) {
      distsqr += SC_SQR (points->e[i + 1][k] - points->e[i][k]);
    }
    knotse[n + i + 2] = sqrt (distsqr);
    if (i < l) {
      distsum += knotse[n + i + 2];
    }
  }
  distalln = distsum * n;

  /* assign average cumulative distance to knot value */
  knotse[n] = 0.;
  for (i = 1; i < l; ++i) {
    distsum = 0.;
    for (k = 0; k < n; ++k) {
      SC_ASSERT (n + i + k + 1 <= m);
      distsum += knotse[n + i + k + 1];
    }
    knotse[n + i] = knotse[n + i - 1] + distsum / distalln;
  }
  knotse[n + l] = 1.;

  /* fill in the beginning and end values */
  for (i = 0; i < n; ++i) {
    knotse[i] = knotse[i + l] - 1.;
    knotse[m - i] = knotse[2 * n - i] + 1.;
  }

  return knots;
}
开发者ID:johannrudi,项目名称:libsc,代码行数:53,代码来源:sc_bspline.c

示例10: sc_finalize

void
sc_finalize (void)
{
  int                 i;
  int                 retval;

  /* sc_packages is static and thus initialized to all zeros */
  for (i = SC_MAX_PACKAGES - 1; i >= 0; --i)
    if (sc_packages[i].is_registered)
      sc_package_unregister (i);

  SC_ASSERT (sc_num_packages == 0);
  sc_memory_check (-1);

  sc_set_signal_handler (0);
  sc_mpicomm = MPI_COMM_NULL;

  sc_print_backtrace = 0;
  sc_identifier = -1;

  /* close trace file */
  if (sc_trace_file != NULL) {
    retval = fclose (sc_trace_file);
    SC_CHECK_ABORT (!retval, "Trace file close");

    sc_trace_file = NULL;
  }
}
开发者ID:aseyboldt,项目名称:libsc,代码行数:28,代码来源:sc.c

示例11: _SC_process_out_reject

void _SC_process_out_reject(int fd, int mask, void *a)
   {int i, n, nr;
    PROCESS *pp;
    taskdesc *job;
    parstate *state;
    asyncstate *as;

    GET_SERVER_STATE(as);

    state = (parstate *) a;

    SC_START_ACTIVITY(state, EXEC_OUT_REJECT);

    nr = SC_running_children();
    SC_ASSERT(nr >= 0);

    n = SC_array_get_n(state->tasks);
    for (i = 0; i < n; i++)
        {job = *(taskdesc **) SC_array_get(state->tasks, i);
	 if (job != NULL)
	    {pp = job->pp;
	     if (SC_process_alive(pp))
	        {
/*
fprintf(stderr, "%-16s: %4d %8d (%d/%d)\n", "out_reject", SC_current_thread(), pp->id, pp->status, pp->reason);
*/
                 if ((pp->io[0] == fd) && (SC_status(pp) == SC_RUNNING))
		    _SC_rejected_process(as, state, job, mask);};};};

    SC_END_ACTIVITY(state);

    return;}
开发者ID:sabrown256,项目名称:pactnew,代码行数:32,代码来源:scsysa.c

示例12: sc_bspline_knots_new

sc_dmatrix_t       *
sc_bspline_knots_new (int n, sc_dmatrix_t * points)
{
#ifdef SC_DEBUG
  const int           d = points->n;
#endif
  const int           p = points->m - 1;
  const int           m = n + p + 1;
  const int           l = m - 2 * n;
  int                 i;
  sc_dmatrix_t       *knots;
  double             *knotse;

  SC_ASSERT (n >= 0 && m >= 1 && d >= 1 && l >= 1);

  knots = sc_dmatrix_new (m + 1, 1);
  knotse = knots->e[0];

  for (i = 0; i < n; ++i) {
    knotse[i] = 0.;
    knotse[m - i] = 1.;
  }
  for (i = 0; i <= l; ++i) {
    knotse[n + i] = i / (double) l;
  }

  return knots;
}
开发者ID:johannrudi,项目名称:libsc,代码行数:28,代码来源:sc_bspline.c

示例13: ASSERT

void *va_get_element (var_array *var_arr, int index)
{
	ASSERT (var_arr);
	SC_ASSERT (index >= 0 &&  index < var_arr->num_elements);
	
	return (var_arr->elements[index]);
}
开发者ID:aevernon,项目名称:triggerman,代码行数:7,代码来源:vararray.c

示例14: sc_allgather_alltoall

void
sc_allgather_alltoall (sc_MPI_Comm mpicomm, char *data, int datasize,
                       int groupsize, int myoffset, int myrank)
{
  int                 j, peer;
  int                 mpiret;
  sc_MPI_Request     *request;

  SC_ASSERT (myoffset >= 0 && myoffset < groupsize);

  request = SC_ALLOC (sc_MPI_Request, 2 * groupsize);

  for (j = 0; j < groupsize; ++j) {
    if (j == myoffset) {
      request[j] = request[groupsize + j] = sc_MPI_REQUEST_NULL;
      continue;
    }
    peer = myrank - (myoffset - j);

    mpiret = sc_MPI_Irecv (data + j * datasize, datasize, sc_MPI_BYTE,
                           peer, SC_TAG_AG_ALLTOALL, mpicomm, request + j);
    SC_CHECK_MPI (mpiret);

    mpiret = sc_MPI_Isend (data + myoffset * datasize, datasize, sc_MPI_BYTE,
                           peer, SC_TAG_AG_ALLTOALL,
                           mpicomm, request + groupsize + j);
    SC_CHECK_MPI (mpiret);
  }

  mpiret = sc_MPI_Waitall (2 * groupsize, request, sc_MPI_STATUSES_IGNORE);
  SC_CHECK_MPI (mpiret);

  SC_FREE (request);
}
开发者ID:holke,项目名称:libsc,代码行数:34,代码来源:sc_allgather.c

示例15: ps_test

static int ps_test(char *name, int color, int debug_mode, int nt, gtest tst)
   {int ok;
    long sc;
    PG_device *dev;

    ok = TRUE;

    sc = test_check(name, -1L, debug_mode);

    register_devices();

    if (color)
       dev = PG_make_device("PS", "COLOR", name);
    else
       dev = PG_make_device("PS", "MONOCHROME PORTRAIT", name);

    PG_open_device(dev, 0.0, 0.0, 0.0, 0.0);

    ok &= (*tst)(dev);

    PG_close_device(dev);

    PG_rl_all();

    sc = test_check(name, 1L, debug_mode);
    SC_ASSERT(sc == TRUE);

    return(ok);}
开发者ID:sabrown256,项目名称:pactnew,代码行数:28,代码来源:tgsgrt.c


注:本文中的SC_ASSERT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。