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


C++ ierr函数代码示例

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


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

示例1: djoy_open

static int djoy_open(FAR struct file *filep)
{
  FAR struct inode *inode;
  FAR struct djoy_upperhalf_s *priv;
  FAR const struct djoy_lowerhalf_s *lower;
  FAR struct djoy_open_s *opriv;
#ifndef CONFIG_DISABLE_POLL
  djoy_buttonset_t supported;
#endif
  int ret;

  DEBUGASSERT(filep && filep->f_inode);
  inode = filep->f_inode;
  DEBUGASSERT(inode->i_private);
  priv = (FAR struct djoy_upperhalf_s *)inode->i_private;

  /* Get exclusive access to the driver structure */

  ret = djoy_takesem(&priv->du_exclsem);
  if (ret < 0)
    {
      ierr("ERROR: djoy_takesem failed: %d\n", ret);
      return ret;
    }

  /* Allocate a new open structure */

  opriv = (FAR struct djoy_open_s *)kmm_zalloc(sizeof(struct djoy_open_s));
  if (!opriv)
    {
      ierr("ERROR: Failled to allocate open structure\n");
      ret = -ENOMEM;
      goto errout_with_sem;
    }

  /* Initialize the open structure */

#ifndef CONFIG_DISABLE_POLL
  lower = priv->du_lower;
  DEBUGASSERT(lower && lower->dl_supported);
  supported = lower->dl_supported(lower);

  opriv->do_pollevents.dp_press   = supported;
  opriv->do_pollevents.dp_release = supported;
#endif

  /* Attach the open structure to the device */

  opriv->do_flink = priv->du_open;
  priv->du_open = opriv;

  /* Attach the open structure to the file structure */

  filep->f_priv = (FAR void *)opriv;
  ret = OK;

errout_with_sem:
  djoy_givesem(&priv->du_exclsem);
  return ret;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:60,代码来源:djoystick.c

示例2: sam_ajoy_initialization

int sam_ajoy_initialization(void)
{
  int ret;
  int fd;
  int i;

  /* NOTE: The ADC driver was initialized earlier in the bring-up sequence. */
  /* Open the ADC driver for reading. */

  fd = open("/dev/adc0", O_RDONLY);
  if (fd < 0)
    {
      int errcode = get_errno();
      ierr("ERROR: Failed to open /dev/adc0: %d\n", errcode);
      return -errcode;
    }

  /* Detach the file structure from the file descriptor so that it can be
   * used on any thread.
   */

  ret = file_detach(fd, &g_adcfile);
  if (ret < 0)
    {
      ierr("ERROR: Failed to detach from file descriptor: %d\n", ret);
      (void)close(fd);
      return ret;
    }

  /* Configure the GPIO pins as interrupting inputs. */

  for (i = 0; i < AJOY_NGPIOS; i++)
    {
      /* Configure the PIO as an input */

      sam_configpio(g_joypio[i]);

      /* Configure PIO interrupts, attach the interrupt handler, but leave
       * the interrupt disabled.
       */

      sam_pioirq(g_joypio[i]);
      (void)irq_attach(g_joyirq[i], ajoy_interrupt);
      sam_pioirqdisable(g_joyirq[i]);
    }

  /* Register the joystick device as /dev/ajoy0 */

  ret = ajoy_register("/dev/ajoy0", &g_ajoylower);
  if (ret < 0)
    {
      ierr("ERROR: ajoy_register failed: %d\n", ret);
      file_close_detached(&g_adcfile);
    }

  return ret;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:57,代码来源:sam_ajoystick.c

示例3: btn_register

int btn_register(FAR const char *devname,
                 FAR const struct btn_lowerhalf_s *lower)

{
  FAR struct btn_upperhalf_s *priv;
  int ret;

  DEBUGASSERT(devname && lower);

  /* Allocate a new button driver instance */

  priv = (FAR struct btn_upperhalf_s *)
    kmm_zalloc(sizeof(struct btn_upperhalf_s));

  if (!priv)
    {
      ierr("ERROR: Failed to allocate device structure\n");
      return -ENOMEM;
    }

  /* Make sure that all button interrupts are disabled */

  DEBUGASSERT(lower->bl_enable);
  lower->bl_enable(lower, 0, 0, NULL, NULL);

  /* Initialize the new button driver instance */

  priv->bu_lower = lower;
  nxsem_init(&priv->bu_exclsem, 0, 1);

  DEBUGASSERT(lower->bl_buttons);
  priv->bu_sample = lower->bl_buttons(lower);

  /* And register the button driver */

  ret = register_driver(devname, &btn_fops, 0666, priv);
  if (ret < 0)
    {
      ierr("ERROR: register_driver failed: %d\n", ret);
      goto errout_with_priv;
    }

  return OK;

errout_with_priv:
  nxsem_destroy(&priv->bu_exclsem);
  kmm_free(priv);
  return ret;
}
开发者ID:AlexShiLucky,项目名称:NuttX,代码行数:49,代码来源:button_upper.c

示例4: sep

// -------------------------------------------------------------
// PETScConfigurable::p_unprocessOptions
// -------------------------------------------------------------
void
PETScConfigurable::p_unprocessOptions(void)
{
  boost::char_separator<char> sep(" \t\f\n\r\v", "");
  boost::tokenizer<boost::char_separator<char> > 
    opttok(p_loadedOptions, sep);
  boost::tokenizer<boost::char_separator<char> >::iterator o;
  for (o = opttok.begin(); o != opttok.end(); ++o) {
    if ((*o)[0] == '-' && islower((*o)[1])) {
      PetscErrorCode ierr(0);
      try {
        if (verbose) {
          std::cout << "p_unprocessOptions: removing \"" 
                    << *o << "\"" << std::endl;
        }
        ierr = PetscOptionsClearValue(
#if PETSC_VERSION_GE(3,7,0)
                                    NULL,
#endif
                                    o->c_str());
      } catch (const PETSC_EXCEPTION_TYPE& e) {
        throw PETScException(ierr, e);
      }
    }
  } 
  p_loadedOptions.clear();
}
开发者ID:Anastien,项目名称:GridPACK,代码行数:30,代码来源:petsc_configurable.cpp

示例5: stmpe811_timeout

static void stmpe811_timeout(int argc, uint32_t arg1, ...)
{
  FAR struct stmpe811_dev_s *priv = (FAR struct stmpe811_dev_s *)((uintptr_t)arg1);
  int ret;

  /* Are we still stuck in the pen down state? */

  if (priv->sample.contact == CONTACT_DOWN ||
      priv->sample.contact == CONTACT_MOVE)
    {
      /* Yes... is the worker thread available?   If not, then apparently
       * we have work already pending?
       */

      if (work_available(&priv->timeout))
        {
          /* Yes.. Transfer processing to the worker thread.  Since STMPE811
           * interrupts are disabled while the work is pending, no special
           * action should be required to protect the work queue.
           */

          ret = work_queue(HPWORK, &priv->timeout, stmpe811_timeoutworker, priv, 0);
          if (ret != 0)
            {
              ierr("ERROR: Failed to queue work: %d\n", ret);
            }
        }
    }
}
开发者ID:a1ien,项目名称:nuttx,代码行数:29,代码来源:stmpe811_tsc.c

示例6: ierr

PetscErrorCode 
PetscNonlinearSolverImplementation::FormJacobian(SNES snes, Vec x, 
                                                 Mat jac, Mat B, 
                                                 void *dummy)
{
  PetscErrorCode ierr(0);

  // Necessary C cast
  PetscNonlinearSolverImplementation *solver =
    (PetscNonlinearSolverImplementation *)dummy;

  // Copy PETSc's current estimate into 

  // Should be the case, but just make sure
  BOOST_ASSERT(jac == *(solver->p_petsc_J));
  BOOST_ASSERT(B == *(solver->p_petsc_J));

  // Not sure about this
  BOOST_ASSERT(x == *(solver->p_petsc_X));

  // May need to do this, which seems slow.
  // ierr = VecCopy(x, *(solver->p_petsc_X)); CHKERRQ(ierr);

  // Call the user-specified function (object) to form the Jacobian
  (solver->p_jacobian)(*(solver->p_X), *(solver->p_J));

  return ierr;
}
开发者ID:kglass,项目名称:GridPACK,代码行数:28,代码来源:petsc_nonlinear_solver_implementation.cpp

示例7: main

int main(int argc, char* argv[])
{
    // Instantiating a boost::mpi::environment here calls MPI_Init() so
    // PETSc won't
    mpi::environment env(argc, argv);
    mpi::communicator world;

    int nproc = world.size();
    int me = world.rank();

    PetscErrorCode ierr(0);

    ierr = PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
    CHKERRQ(ierr);

    std::cout << "I am process " << me << " of " << nproc << "." << std::endl;

    world.barrier();

    VWrap *v(new VWrap(world));

    v->view();

    PetscBool ok;

    delete v;

    ierr = PetscFinalize();
    CHKERRQ(ierr);

    world.barrier();

    return 0;
}
开发者ID:GridOPTICS,项目名称:GridPACK,代码行数:34,代码来源:vwrap.cpp

示例8: p_resolveImpl

  /// Solve again w/ the specified RHS, put result in specified vector (specialized)
  void p_resolveImpl(const VectorType& b, VectorType& x) const
  {
    PetscErrorCode ierr(0);
    int me(this->processor_rank());
    try {
      const Vec *bvec(PETScVector(b));
      Vec *xvec(PETScVector(x));

      ierr = KSPSolve(p_KSP, *bvec, *xvec); CHKERRXX(ierr);
      int its;
      KSPConvergedReason reason;
      PetscReal rnorm;
      ierr = KSPGetIterationNumber(p_KSP, &its); CHKERRXX(ierr);
      ierr = KSPGetConvergedReason(p_KSP, &reason); CHKERRXX(ierr);
      ierr = KSPGetResidualNorm(p_KSP, &rnorm); CHKERRXX(ierr);
      std::string msg;
      if (reason < 0) {
        msg = 
          boost::str(boost::format("%d: PETSc KSP diverged after %d iterations, reason: %d") % 
                     me % its % reason);
        throw Exception(msg);
      } else if (me == 0) {
        msg = 
          boost::str(boost::format("%d: PETSc KSP converged after %d iterations, reason: %d") % 
                     me % its % reason);
        std::cerr << msg << std::endl;
      }
    } catch (const PETSC_EXCEPTION_TYPE& e) {
      throw PETScException(ierr, e);
    } catch (const Exception& e) {
      throw e;
    }
  }    
开发者ID:Anastien,项目名称:GridPACK,代码行数:34,代码来源:petsc_linear_solver_implementation.hpp

示例9: p_solveImpl

  /// Solve w/ the specified RHS and estimate (result in x)
  void p_solveImpl(MatrixType& A, const VectorType& b, VectorType& x) const
  {
    PetscErrorCode ierr(0);
    try {
      Mat *Amat(PETScMatrix(A));

      if (p_matrixSet && this->p_constSerialMatrix) {
        // KSPSetOperators can be skipped
      } else {
#if PETSC_VERSION_LT(3,5,0)
        ierr = KSPSetOperators(p_KSP, *Amat, *Amat, SAME_NONZERO_PATTERN); CHKERRXX(ierr);
#else
        ierr = KSPSetOperators(p_KSP, *Amat, *Amat); CHKERRXX(ierr);
#endif
        p_matrixSet = true;
      }

      this->p_resolveImpl(b, x);
          
    } catch (const PETSC_EXCEPTION_TYPE& e) {
      throw PETScException(ierr, e);
    } catch (const Exception& e) {
      throw e;
    }
  }
开发者ID:Anastien,项目名称:GridPACK,代码行数:26,代码来源:petsc_linear_solver_implementation.hpp

示例10: bytes

/*
 * bytes -- read bytes to an offset from the end and display.
 *
 * This is the function that reads to a byte offset from the end of the input,
 * storing the data in a wrap-around buffer which is then displayed.  If the
 * rflag is set, the data is displayed in lines in reverse order, and this
 * routine has the usual nastiness of trying to find the newlines.  Otherwise,
 * it is displayed from the character closest to the beginning of the input to
 * the end.
 */
int
bytes(FILE *fp, const char *fn, off_t off)
{
	int ch, len, tlen;
	char *ep, *p, *t;
	int wrap;
	char *sp;

	if ((sp = p = malloc(off)) == NULL)
		err(1, "malloc");

	for (wrap = 0, ep = p + off; (ch = getc(fp)) != EOF;) {
		*p = ch;
		if (++p == ep) {
			wrap = 1;
			p = sp;
		}
	}
	if (ferror(fp)) {
		ierr(fn);
		free(sp);
		return 1;
	}

	if (rflag) {
		for (t = p - 1, len = 0; t >= sp; --t, ++len)
			if (*t == '\n' && len) {
				WR(t + 1, len);
				len = 0;
		}
		if (wrap) {
			tlen = len;
			for (t = ep - 1, len = 0; t >= p; --t, ++len)
				if (*t == '\n') {
					if (len) {
						WR(t + 1, len);
						len = 0;
					}
					if (tlen) {
						WR(sp, tlen);
						tlen = 0;
					}
				}
			if (len)
				WR(t + 1, len);
			if (tlen)
				WR(sp, tlen);
		}
	} else {
		if (wrap && (len = ep - p))
			WR(p, len);
		len = p - sp;
		if (len)
			WR(sp, len);
	}

	free(sp);
	return 0;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:69,代码来源:read.c

示例11: r_reg

/*
 * r_reg -- display a regular file in reverse order by line.
 */
static int
r_reg(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
{
	off_t start, pos, end;
	int ch;

	end = sbp->st_size;
	if (end == 0)
		return (0);

	/* Position before char, ignore last char whether newline or not */
	pos = end-2;
	ch = EOF;
	start = 0;

	if (style == RBYTES && off < end)
		start = end - off;

	for (; pos >= start; pos--) {
		/* A seek per char isn't a problem with a smart stdio */
		if (fseeko(fp, pos, SEEK_SET) != 0) {
			ierr();
			return (0);
		}
		if ((ch = getc(fp)) == '\n') {
			while (--end > pos) 
				COPYCHAR(fp, ch);
			end++;
			if (style == RLINES && --off == 0)
				break;
		}
		else if (ch == EOF) {
			ierr();
			return (0);
		}
	}
	if (pos < start) {
		if (ch != EOF && ungetc(ch, fp) == EOF) {
			ierr();
			return (0);
		}
		while (--end >= start)
			COPYCHAR(fp, ch);
	}
	return (0);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:49,代码来源:reverse.c

示例12: djoy_register

int djoy_register(FAR const char *devname,
                  FAR const struct djoy_lowerhalf_s *lower)

{
  FAR struct djoy_upperhalf_s *priv;
  int ret;

  DEBUGASSERT(devname && lower);

  /* Allocate a new djoystick driver instance */

  priv = (FAR struct djoy_upperhalf_s *)
    kmm_zalloc(sizeof(struct djoy_upperhalf_s));

  if (!priv)
    {
      ierr("ERROR: Failed to allocate device structure\n");
      return -ENOMEM;
    }

  /* Make sure that all djoystick interrupts are disabled */

  DEBUGASSERT(lower->dl_enable);
  lower->dl_enable(lower, 0, 0, NULL, NULL);

  /* Initialize the new djoystick driver instance */

  priv->du_lower = lower;
  sem_init(&priv->du_exclsem, 0, 1);

  DEBUGASSERT(lower->dl_sample);
  priv->du_sample = lower->dl_sample(lower);

  /* And register the djoystick driver */

  ret = register_driver(devname, &djoy_fops, 0666, priv);
  if (ret < 0)
    {
      ierr("ERROR: register_driver failed: %d\n", ret);
      sem_destroy(&priv->du_exclsem);
      kmm_free(priv);
    }

  return ret;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:45,代码来源:djoystick.c

示例13: btn_read

static ssize_t btn_read(FAR struct file *filep, FAR char *buffer,
                        size_t len)
{
  FAR struct inode *inode;
  FAR struct btn_upperhalf_s *priv;
  FAR const struct btn_lowerhalf_s *lower;
  int ret;

  DEBUGASSERT(filep && filep->f_inode);
  inode = filep->f_inode;
  DEBUGASSERT(inode->i_private);
  priv  = (FAR struct btn_upperhalf_s *)inode->i_private;

  /* Make sure that the buffer is sufficiently large to hold at least one
   * complete sample.
   *
   * REVISIT:  Should also check buffer alignment.
   */

  if (len < sizeof(btn_buttonset_t))
    {
      ierr("ERROR: buffer too small: %lu\n", (unsigned long)len);
      return -EINVAL;
    }

  /* Get exclusive access to the driver structure */

  ret = btn_takesem(&priv->bu_exclsem);
  if (ret < 0)
    {
      ierr("ERROR: btn_takesem failed: %d\n", ret);
      return ret;
    }

  /* Read and return the current state of the buttons */

  lower = priv->bu_lower;
  DEBUGASSERT(lower && lower->bl_buttons);
  *(FAR btn_buttonset_t *)buffer = lower->bl_buttons(lower);

  btn_givesem(&priv->bu_exclsem);
  return (ssize_t)sizeof(btn_buttonset_t);
}
开发者ID:AlexShiLucky,项目名称:NuttX,代码行数:43,代码来源:button_upper.c

示例14: djoy_read

static ssize_t djoy_read(FAR struct file *filep, FAR char *buffer,
                         size_t len)
{
  FAR struct inode *inode;
  FAR struct djoy_upperhalf_s *priv;
  FAR const struct djoy_lowerhalf_s *lower;
  int ret;

  DEBUGASSERT(filep && filep->f_inode);
  inode = filep->f_inode;
  DEBUGASSERT(inode->i_private);
  priv  = (FAR struct djoy_upperhalf_s *)inode->i_private;

  /* Make sure that the buffer is sufficiently large to hold at least one
   * complete sample.
   */

  if (len < sizeof(djoy_buttonset_t))
    {
      ierr("ERROR: buffer too small: %lu\n", (unsigned long)len);
      return -EINVAL;
    }

  /* Get exclusive access to the driver structure */

  ret = djoy_takesem(&priv->du_exclsem);
  if (ret < 0)
    {
      ierr("ERROR: djoy_takesem failed: %d\n", ret);
      return ret;
    }

  /* Read and return the current state of the joystick buttons */

  lower = priv->du_lower;
  DEBUGASSERT(lower && lower->dl_sample);
  priv->du_sample = lower->dl_sample(lower);
  *(FAR djoy_buttonset_t *)buffer = priv->du_sample;
  ret = sizeof(djoy_buttonset_t);

  djoy_givesem(&priv->du_exclsem);
  return (ssize_t)ret;
}
开发者ID:a1ien,项目名称:nuttx,代码行数:43,代码来源:djoystick.c

示例15: Finalize

// -------------------------------------------------------------
// Finalize
// -------------------------------------------------------------
/// Does whatever is necessary to shut down the PETSc library
void
Finalize(void)
{
  if (!Initialized()) return;
  PetscErrorCode ierr(0);
  try {
    ierr = PetscFinalize(); CHKERRXX(ierr);
  } catch (const PETSC_EXCEPTION_TYPE& e) {
    throw PETScException(ierr, e);
  }
}
开发者ID:Anastien,项目名称:GridPACK,代码行数:15,代码来源:petsc_math.cpp


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