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


C++ sdbg函数代码示例

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


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

示例1: clock_getres

int clock_getres(clockid_t clock_id, struct timespec *res)
{
  int      ret = OK;

  sdbg("clock_id=%d\n", clock_id);

  /* Only CLOCK_REALTIME is supported */

  if (clock_id != CLOCK_REALTIME)
    {
      sdbg("Returning ERROR\n");
      set_errno(EINVAL);
      ret = ERROR;
    }
  else
    {
      /* Form the timspec using clock resolution in nanoseconds */

      res->tv_sec  = 0;
      res->tv_nsec = NSEC_PER_TICK;

      sdbg("Returning res=(%d,%d)\n", (int)res->tv_sec, (int)res->tv_nsec);
    }

  return ret;
}
开发者ID:justdoitding,项目名称:Nuttx_PSoC4,代码行数:26,代码来源:clock_getres.c

示例2: _exit

void _exit(int status)
{
  struct tcb_s* tcb;

  sdbg("TCB=%p exitting\n", tcb);

  /* Destroy the task at the head of the ready to run list. */

  (void)task_deletecurrent();

  /* Now, perform the context switch to the new ready-to-run task at the
   * head of the list.
   */

  tcb = (struct tcb_s*)g_readytorun.head;
  sdbg("New Active Task TCB=%p\n", tcb);

  /* The way that we handle signals in the simulation is kind of
   * a kludge.  This would be unsafe in a truly multi-threaded, interrupt
   * driven environment.
   */

  if (tcb->xcp.sigdeliver)
    {
      sdbg("Delivering signals TCB=%p\n", tcb);
      ((sig_deliver_t)tcb->xcp.sigdeliver)(tcb);
      tcb->xcp.sigdeliver = NULL;
    }

  /* Then switch contexts */

  up_longjmp(tcb->xcp.regs, 1);
}
开发者ID:nsrango,项目名称:Firmware,代码行数:33,代码来源:up_exit.c

示例3: sem_destroyholder

void sem_destroyholder(FAR sem_t *sem)
{
  /* It is an error if a semaphore is destroyed while there are any holders
   * (except perhaps the thread release the semaphore itself).  Hmmm.. but
   * we actually have to assume that the caller knows what it is doing because
   * could have killed another thread that is the actual holder of the semaphore.
   * We cannot make any assumptions about the state of the semaphore or the
   * state of any of the holder threads.
   *
   * So just recover any stranded holders and hope the task knows what it is
   * doing.
   */

#if CONFIG_SEM_PREALLOCHOLDERS > 0
  if (sem->hhead)
    {
      sdbg("Semaphore destroyed with holders\n");
      (void)sem_foreachholder(sem, sem_recoverholders, NULL);
    }
#else
  if (sem->holder.htcb)
    {
      sdbg("Semaphore destroyed with holder\n");
    }

  sem->holder.htcb = NULL;
#endif
}
开发者ID:KimMui,项目名称:i2sTest,代码行数:28,代码来源:sem_holder.c

示例4: pthread_getschedparam

int pthread_getschedparam(pthread_t thread, FAR int *policy,
                          FAR struct sched_param *param)
{
  int ret;

  sdbg("Thread ID=%d policy=0x%p param=0x%p\n", thread, policy, param);

  if (!policy || !param)
    {
      ret = EINVAL;
    }
  else
    {
      /* Get the schedparams of the thread. */

      ret = sched_getparam((pid_t)thread, param);
      if (ret != OK)
        {
          ret = EINVAL;
        }

      /* Return the policy. */

      *policy = sched_getscheduler((pid_t)thread);
      if (*policy == ERROR)
        {
          ret = get_errno();
        }
    }

  sdbg("Returning %d\n", ret);
  return ret;
}
开发者ID:nodesign,项目名称:nuttx-kernel,代码行数:33,代码来源:pthread_getschedparam.c

示例5: up_sigdeliver

void up_sigdeliver(void)
{
#ifndef CONFIG_DISABLE_SIGNALS
  FAR _TCB  *rtcb = (_TCB*)g_readytorun.head;
  chipreg_t regs[XCPTCONTEXT_REGS];
  sig_deliver_t sigdeliver;

  /* Save the errno.  This must be preserved throughout the signal handling
   * so that the user code final gets the correct errno value (probably
   * EINTR).
   */

  int saved_errno = rtcb->pterrno;

  up_ledon(LED_SIGNAL);

  sdbg("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
        rtcb, rtcb->xcp.sigdeliver, rtcb->sigpendactionq.head);
  ASSERT(rtcb->xcp.sigdeliver != NULL);

  /* Save the real return state on the stack. */

  ez80_copystate(regs, rtcb->xcp.regs);
  regs[XCPT_PC] = rtcb->xcp.saved_pc;
  regs[XCPT_I]  = rtcb->xcp.saved_i;

  /* Get a local copy of the sigdeliver function pointer.  We do this so
   * that we can nullify the sigdeliver function pointer in the TCB and 
   * accept more signal deliveries while processing the current pending
   * signals.
   */

  sigdeliver           = rtcb->xcp.sigdeliver;
  rtcb->xcp.sigdeliver = NULL;

  /* Then restore the task interrupt state. */

  irqrestore(regs[XCPT_I]);

  /* Deliver the signals */

  sigdeliver(rtcb);

  /* Output any debug messages BEFORE restoring errno (because they may
   * alter errno), then disable interrupts again and restore the original
   * errno that is needed by the user logic (it is probably EINTR).
   */

  sdbg("Resuming\n");
  (void)irqsave();
  rtcb->pterrno = saved_errno;

  /* Then restore the correct state for this thread of
   * execution.
   */

  up_ledoff(LED_SIGNAL);
  ez80_restorecontext(regs);
#endif
}
开发者ID:airlink,项目名称:nuttx,代码行数:60,代码来源:ez80_sigdeliver.c

示例6: mod_filelen

static inline int mod_filelen(FAR struct mod_loadinfo_s *loadinfo,
                              FAR const char *filename)
{
  struct stat buf;
  int ret;

  /* Get the file stats */

  ret = stat(filename, &buf);
  if (ret < 0)
    {
      int errval = errno;
      sdbg("Failed to stat file: %d\n", errval);
      return -errval;
    }

  /* Verify that it is a regular file */

  if (!S_ISREG(buf.st_mode))
    {
      sdbg("Not a regular file.  mode: %d\n", buf.st_mode);
      return -ENOENT;
    }

  /* TODO:  Verify that the file is readable.  Not really important because
   * we will detect this when we try to open the file read-only.
   */

  /* Return the size of the file in the loadinfo structure */

  loadinfo->filelen = buf.st_size;
  return OK;
}
开发者ID:acassis,项目名称:ros2_nuttx,代码行数:33,代码来源:mod_init.c

示例7: clock_settime

int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
{
  irqstate_t flags;
  int ret = OK;

  sdbg("clock_id=%d\n", clock_id);
  DEBUGASSERT(tp != NULL);

  /* CLOCK_REALTIME - POSIX demands this to be present. This is the wall
   * time clock.
   */

#ifdef CONFIG_RTC
  if (clock_id == CLOCK_REALTIME || clock_id == CLOCK_ACTIVETIME)
#else
  if (clock_id == CLOCK_REALTIME)
#endif
    {
      /* Interrupts are disabled here so that the in-memory time
       * representation and the RTC setting will be as close as
       * possible.
       */

      flags = irqsave();

      /* Save the new base time. */

      g_basetime.tv_sec  = tp->tv_sec;
      g_basetime.tv_nsec = tp->tv_nsec;

      /* Get the elapsed time since power up (in milliseconds) biased
       * as appropriate.
       */

      g_tickbias = g_system_timer;

      /* Setup the RTC (lo- or high-res) */

#ifdef CONFIG_RTC
      if (g_rtc_enabled && clock_id != CLOCK_ACTIVETIME)
        {
          up_rtc_settime(tp);
        } 
#endif
      irqrestore(flags);

      sdbg("basetime=(%d,%d) tickbias=%d\n",
          (int)g_basetime.tv_sec, (int)g_basetime.tv_nsec,
          (int)g_tickbias);
    }
  else 
    {
      sdbg("Returning ERROR\n");
      set_errno(EINVAL);
      ret = ERROR;
    }

  return ret;
}
开发者ID:andrewms,项目名称:nuttx_ap,代码行数:59,代码来源:clock_settime.c

示例8: sigqueue

int sigqueue(int pid, int signo, void *sival_ptr)
#endif
{
#ifdef CONFIG_SCHED_HAVE_PARENT
  FAR struct tcb_s *rtcb = this_task();
#endif
  siginfo_t info;
  int ret;

#ifdef CONFIG_CAN_PASS_STRUCTS
  sdbg("pid=0x%08x signo=%d value=%d\n", pid, signo, value.sival_int);
#else
  sdbg("pid=0x%08x signo=%d value=%p\n", pid, signo, sival_ptr);
#endif

  /* Sanity checks */

  if (!GOOD_SIGNO(signo))
    {
      ret = -EINVAL;
      goto errout;
    }

  /* Create the siginfo structure */

  info.si_signo           = signo;
  info.si_code            = SI_QUEUE;
  info.si_errno           = OK;
#ifdef CONFIG_CAN_PASS_STRUCTS
  info.si_value           = value;
#else
  info.si_value.sival_ptr = sival_ptr;
#endif
#ifdef CONFIG_SCHED_HAVE_PARENT
  info.si_pid             = rtcb->pid;
  info.si_status          = OK;
#endif

  /* Send the signal */

  sched_lock();
  ret = sig_dispatch(pid, &info);
  sched_unlock();

  /* Check for errors */

  if (ret < 0)
    {
      goto errout;
    }

  return OK;

errout:
  set_errno(-ret);
  return ERROR;
}
开发者ID:acassis,项目名称:ros2_nuttx,代码行数:57,代码来源:sig_queue.c

示例9: sdbg

FAR struct tm *gmtime_r(FAR const time_t *timer, FAR struct tm *result)
{
  time_t epoch;
  time_t jdn;
  int    year;
  int    month;
  int    day;
  int    hour;
  int    min;
  int    sec;

  /* Get the seconds since the EPOCH */

  epoch = *timer;
  sdbg("timer=%d\n", (int)epoch);

  /* Convert to days, hours, minutes, and seconds since the EPOCH */

  jdn    = epoch / SEC_PER_DAY;
  epoch -= SEC_PER_DAY * jdn;

  hour   = epoch / SEC_PER_HOUR;
  epoch -= SEC_PER_HOUR * hour;

  min    = epoch / SEC_PER_MIN;
  epoch -= SEC_PER_MIN * min;

  sec    = epoch;

  sdbg("hour=%d min=%d sec=%d\n",
       (int)hour, (int)min, (int)sec);

  /* Convert the days since the EPOCH to calendar day */

  clock_utc2calendar(jdn, &year, &month, &day);

  sdbg("jdn=%d year=%d month=%d day=%d\n",
       (int)jdn, (int)year, (int)month, (int)day);

  /* Then return the struct tm contents */

  result->tm_year  = (int)year - 1900; /* Relative to 1900 */
  result->tm_mon   = (int)month - 1;   /* zero-based */
  result->tm_mday  = (int)day;         /* one-based */
  result->tm_hour  = (int)hour;
  result->tm_min   = (int)min;
  result->tm_sec   = (int)sec;

#if defined(CONFIG_TIME_EXTENDED)
  result->tm_wday  = clock_dayoftheweek(day, month, year);
  result->tm_yday  = day + clock_daysbeforemonth(result->tm_mon, clock_isleapyear(year));
  result->tm_isdst = 0;
#endif

  return result;
}
开发者ID:acassis,项目名称:ros2_nuttx,代码行数:56,代码来源:lib_gmtimer.c

示例10: pthread_cond_broadcast

int pthread_cond_broadcast(FAR pthread_cond_t *cond)
{
  int ret = OK;
  int sval;

  sdbg("cond=0x%p\n", cond);

  if (!cond)
    {
      ret = EINVAL;
    }
  else
    {
      /* Disable pre-emption until all of the waiting threads have been
       * restarted. This is necessary to assure that the sval behaves as
       * expected in the following while loop
       */

      sched_lock();

      /* Get the current value of the semaphore */

      if (sem_getvalue((sem_t*)&cond->sem, &sval) != OK)
        {
          ret = EINVAL;
        }
      else
        {
          /* Loop until all of the waiting threads have been restarted. */

          while (sval < 0)
            {
              /* If the value is less than zero (meaning that one or more
               * thread is waiting), then post the condition semaphore.
               * Only the highest priority waiting thread will get to execute
               */

              ret = pthread_givesemaphore((sem_t*)&cond->sem);

              /* Increment the semaphore count (as was done by the
               * above post).
               */

              sval++;
            }
        }

      /* Now we can let the restarted threads run */

      sched_unlock();
    }

  sdbg("Returning %d\n", ret);
  return ret;
}
开发者ID:FreddieChopin,项目名称:NuttX,代码行数:55,代码来源:pthread_condbroadcast.c

示例11: up_release_pending

void up_release_pending(void)
{
  struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;

  sdbg("From TCB=%p\n", rtcb);

  /* Merge the g_pendingtasks list into the g_readytorun task list */

  /* sched_lock(); */
  if (sched_mergepending())
    {
      /* The currently active task has changed!  We will need to switch
       * contexts.
       *
       * Update scheduler parameters.
       */

      sched_suspend_scheduler(rtcb);

      /* Copy the exception context into the TCB of the task that was
       * currently active. if up_setjmp returns a non-zero value, then
       * this is really the previously running task restarting!
       */

      if (!up_setjmp(rtcb->xcp.regs))
        {
          /* Restore the exception context of the rtcb at the (new) head
           * of the g_readytorun task list.
           */

          rtcb = (struct tcb_s*)g_readytorun.head;
          sdbg("New Active Task TCB=%p\n", rtcb);

          /* The way that we handle signals in the simulation is kind of
           * a kludge.  This would be unsafe in a truly multi-threaded, interrupt
           * driven environment.
           */

          if (rtcb->xcp.sigdeliver)
            {
              sdbg("Delivering signals TCB=%p\n", rtcb);
              ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
              rtcb->xcp.sigdeliver = NULL;
            }

          /* Update scheduler parameters */

          sched_resume_scheduler(rtcb);

          /* Then switch contexts */

          up_longjmp(rtcb->xcp.regs, 1);
        }
    }
}
开发者ID:nodesign,项目名称:nuttx-kernel,代码行数:55,代码来源:up_releasepending.c

示例12: up_sigdeliver

void up_sigdeliver(void)
{
  struct tcb_s  *rtcb = this_task();
  uint32_t regs[XCPTCONTEXT_REGS];
  sig_deliver_t sigdeliver;

  /* Save the errno.  This must be preserved throughout the signal handling
   * so that the user code final gets the correct errno value (probably
   * EINTR).
   */

  int saved_errno = rtcb->pterrno;

  board_autoled_on(LED_SIGNAL);

  sdbg("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
        rtcb, rtcb->xcp.sigdeliver, rtcb->sigpendactionq.head);
  ASSERT(rtcb->xcp.sigdeliver != NULL);

  /* Save the real return state on the stack. */

  up_copyfullstate(regs, rtcb->xcp.regs);
  regs[REG_PC]         = rtcb->xcp.saved_pc;
  regs[REG_CPSR]       = rtcb->xcp.saved_cpsr;

  /* Get a local copy of the sigdeliver function pointer. we do this so that
   * we can nullify the sigdeliver function pointer in the TCB and accept
   * more signal deliveries while processing the current pending signals.
   */

  sigdeliver           = rtcb->xcp.sigdeliver;
  rtcb->xcp.sigdeliver = NULL;

  /* Then restore the task interrupt state */

  irqrestore(regs[REG_CPSR]);

  /* Deliver the signals */

  sigdeliver(rtcb);

  /* Output any debug messages BEFORE restoring errno (because they may
   * alter errno), then disable interrupts again and restore the original
   * errno that is needed by the user logic (it is probably EINTR).
   */

  sdbg("Resuming\n");
  (void)irqsave();
  rtcb->pterrno = saved_errno;

  /* Then restore the correct state for this thread of execution. */

  board_autoled_off(LED_SIGNAL);
  up_fullcontextrestore(regs);
}
开发者ID:rohiniku,项目名称:NuttX-nuttx-arch,代码行数:55,代码来源:arm_sigdeliver.c

示例13: mod_load

int mod_load(FAR struct mod_loadinfo_s *loadinfo)
{
  int ret;

  svdbg("loadinfo: %p\n", loadinfo);
  DEBUGASSERT(loadinfo && loadinfo->filfd >= 0);

  /* Load section headers into memory */

  ret = mod_loadshdrs(loadinfo);
  if (ret < 0)
    {
      sdbg("ERROR: mod_loadshdrs failed: %d\n", ret);
      goto errout_with_buffers;
    }

  /* Determine total size to allocate */

  mod_elfsize(loadinfo);

  /* Allocate (and zero) memory for the ELF file. */

  /* Allocate memory to hold the ELF image */

  loadinfo->textalloc = (uintptr_t)kmm_zalloc(loadinfo->textsize + loadinfo->datasize);
  if (!loadinfo->textalloc)
    {
      sdbg("ERROR: Failed to allocate memory for the module\n");
      ret = -ENOMEM;
      goto errout_with_buffers;
    }

  loadinfo->datastart = loadinfo->textalloc + loadinfo->textsize;

  /* Load ELF section data into memory */

  ret = mod_loadfile(loadinfo);
  if (ret < 0)
    {
      sdbg("ERROR: mod_loadfile failed: %d\n", ret);
      goto errout_with_buffers;
    }

  return OK;

  /* Error exits */

errout_with_buffers:
  mod_unload(loadinfo);
  return ret;
}
开发者ID:acassis,项目名称:ros2_nuttx,代码行数:51,代码来源:mod_load.c

示例14: sdbg

FAR struct tm *gmtime_r(FAR const time_t *timer, FAR struct tm *result)
{
  time_t epoch;
  time_t jdn;
  int    year;
  int    month;
  int    day;
  int    hour;
  int    min;
  int    sec;

  /* Get the seconds since the EPOCH */

  epoch = *timer;
  sdbg("timer=%d\n", (int)epoch);

  /* Convert to days, hours, minutes, and seconds since the EPOCH */

  jdn    = epoch / SEC_PER_DAY;
  epoch -= SEC_PER_DAY * jdn;

  hour   = epoch / SEC_PER_HOUR;
  epoch -= SEC_PER_HOUR * hour;

  min    = epoch / SEC_PER_MIN;
  epoch -= SEC_PER_MIN * min;

  sec    = epoch;

  sdbg("hour=%d min=%d sec=%d\n",
       (int)hour, (int)min, (int)sec);

  /* Convert the days since the EPOCH to calendar day */

  clock_utc2calendar(jdn, &year, &month, &day);

  sdbg("jdn=%d year=%d month=%d day=%d\n",
       (int)jdn, (int)year, (int)month, (int)day);

  /* Then return the struct tm contents */

  result->tm_year = (int)year - 1900; /* Relative to 1900 */
  result->tm_mon  = (int)month - 1;   /* zero-based */
  result->tm_mday = (int)day;         /* one-based */
  result->tm_hour = (int)hour;
  result->tm_min  = (int)min;
  result->tm_sec  = (int)sec;

  return result;
}
开发者ID:aliniger,项目名称:Firmware_orca,代码行数:50,代码来源:lib_gmtimer.c

示例15: pthread_condattr_destroy

int pthread_condattr_destroy(FAR pthread_condattr_t *attr)
{
  int ret = OK;

  sdbg("attr=0x%p\n", attr);

  if (!attr)
    {
      ret = EINVAL;
    }

  sdbg("Returning %d\n", ret);
  return ret;
}
开发者ID:acassis,项目名称:ros2_nuttx,代码行数:14,代码来源:pthread_condattrdestroy.c


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