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


C++ q_init函数代码示例

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


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

示例1: test_big_big

/*
 * Test 4: a is large, b is large
 */
static void test_big_big(void) {
  rational_t a, b, c;
  uint32_t i, j;

  q_init(&a);
  q_init(&b);
  q_init(&c);

  for (i=0; i<NBIGS; i++) {
    q_set_from_string(&b, large_divisor[i]);
    for (j=0; j<NBIGS; j++) {
      q_set_from_string(&a, large_signed[j]);
      q_set(&c, &a);
      q_integer_div(&a, &b);
      q_integer_rem(&c, &b);

      printf("div[%s, %s]: quotient = ", large_signed[j], large_divisor[i]);
      q_print(stdout, &a);
      printf(", remainder = ");
      q_print(stdout, &c);
      printf("\n");
    }
    printf("\n");
  }

  q_clear(&a);
  q_clear(&b);
  q_clear(&c);
}
开发者ID:polazarus,项目名称:ocamlyices2,代码行数:32,代码来源:test_rational_divrem.c

示例2: test_small_small

/*
 * Test 1: a divided by b
 * - both a and b are small integers
 */
static void test_small_small(void) {
  rational_t a, b, c;
  int32_t x, y;

  q_init(&a);
  q_init(&b);
  q_init(&c);

  for (y=1; y<8; y++) {
    q_set32(&b, y);
    for (x=-20; x<=20; x++) {
      q_set32(&a, x);
      q_integer_div(&a, &b);
      q_set32(&c, x);
      q_integer_rem(&c, &b);

      printf("div[%3"PRId32", %"PRId32"]: quotient = ", x, y);
      q_print(stdout, &a);
      printf(", remainder = ");
      q_print(stdout, &c);
      printf("\n");
    }
    printf("\n");
  }

  q_clear(&a);
  q_clear(&b);
  q_clear(&c);
}
开发者ID:polazarus,项目名称:ocamlyices2,代码行数:33,代码来源:test_rational_divrem.c

示例3: test_small_big

/*
 * Test 3: a is small, b is large
 */
static void test_small_big(void) {
  rational_t a, b, c;
  uint32_t i;
  int32_t x;

  q_init(&a);
  q_init(&b);
  q_init(&c);

  for (i=0; i<NBIGS; i++) {
    q_set_from_string(&b, large_divisor[i]);
    for (x=-10; x<=10; x++) {
      q_set32(&a, x);
      q_set32(&c, x);
      q_integer_div(&a, &b);
      q_integer_rem(&c, &b);

      printf("div[%"PRId32", %s]: quotient = ", x, large_divisor[i]);
      q_print(stdout, &a);
      printf(", remainder = ");
      q_print(stdout, &c);
      printf("\n");
    }
    printf("\n");
  }

  q_clear(&a);
  q_clear(&b);
  q_clear(&c);
}
开发者ID:polazarus,项目名称:ocamlyices2,代码行数:33,代码来源:test_rational_divrem.c

示例4: test_big_small

/*
 * Test 2: a is large, b is small
 */
static void test_big_small(void) {
  rational_t a, b, c;
  uint32_t i;
  int32_t y;

  q_init(&a);
  q_init(&b);
  q_init(&c);

  for (y=1; y<8; y++) {
    q_set32(&b, y);
    for (i=0; i<NBIGS; i++) {
      q_set_from_string(&a, large_signed[i]);
      q_set(&c, &a);
      q_integer_div(&a, &b);
      q_integer_rem(&c, &b);

      printf("div[%s, %"PRId32"]: quotient = ", large_signed[i], y);
      q_print(stdout, &a);
      printf(", remainder = ");
      q_print(stdout, &c);
      printf("\n");
    }
    printf("\n");
  }

  q_clear(&a);
  q_clear(&b);
  q_clear(&c);
}
开发者ID:polazarus,项目名称:ocamlyices2,代码行数:33,代码来源:test_rational_divrem.c

示例5: dsi_task_init

void  dsi_task_init( void )
{
  uint8    i;                                                /* Loop index */

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/


  /*-------------------------------------------------------------------------
    Initialize the command queue and the free command queue, and link the
    command items onto the free command queue.
  -------------------------------------------------------------------------*/  
  (void)q_init( &dsi_cmd_q );
  (void)q_init( &dsi_cmd_free_q );

  for( i = 0; i < DSI_CMD_BUF_COUNT; i++ )
  {
    (void)q_link( &dsi_cmd_buf[i], &dsi_cmd_buf[i].hdr.link );
    q_put( &dsi_cmd_free_q, &dsi_cmd_buf[i].hdr.link );
  }

  /*-------------------------------------------------------------------------
    Define the watchdog timer, and start the timer.
  -------------------------------------------------------------------------*/
  rex_def_timer( &ds_dog_rpt_timer, &ds_tcb, DS_DOG_RPT_TIMER_SIG );
  (void)rex_set_timer( &ds_dog_rpt_timer, DOG_DS_RPT_TIME );

} /* dsi_task_init() */
开发者ID:bgtwoigu,项目名称:1110,代码行数:27,代码来源:dstask.c

示例6: buffers_init

void buffers_init() {
#   if (OT_FEATURE(SERVER) == ENABLED)
    q_init(&rxq,    otbuf,              TXRX_SIZE);
    q_init(&txq,    otbuf+TXRX_SIZE,    TXRX_SIZE);    
#   endif
#   if (ALP_ENABLED)
    q_init(&otmpin,     otbuf+(TXRX_SIZE*2),            ALP_SIZE );
    q_init(&otmpout,    otbuf+(TXRX_SIZE*2)+ALP_SIZE,   ALP_SIZE );
#   endif
}
开发者ID:jpnorair,项目名称:OpenTag,代码行数:10,代码来源:buffers.c

示例7: uart_init

void uart_init(void) {
  /* Supply the clock for UART0 and PORTA */
  SIM->SCGC4 |= SIM_SCGC4_UART0_MASK;
  SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK;
  
  /* Set PORTA1 as Rx and PORTA2 as Tx */
  PORTA->PCR[1] &= ~PORT_PCR_MUX_MASK; // Make sure that MUX is clear
  PORTA->PCR[1] |= PORT_PCR_MUX(2);
  PORTA->PCR[2] &= ~PORT_PCR_MUX_MASK; // Make sure that MUX is clear
  PORTA->PCR[2] |= PORT_PCR_MUX(2);
  
  /* Choose external 8MHz crystal as a reference clock for UART0 */
  /* Asynch Module Clock = 8 MHz */
  SIM->SOPT2 |= SIM_SOPT2_UART0SRC(2);
  
  /* Disable the reciever and transmitter of UART0 */
  UART0->C2 &= ~(UART0_C2_TE_MASK | UART0_C2_RE_MASK); // turn off the Tx and Rx
  
  /* Set the oversampling ratio to 4 */
  UART0->C4 = UART0_C4_OSR(3);
  
  /* Set SBr to 139 in order to achieve Baud Rate euqal to 14400 */
  UART0->BDH |= UART0_BDH_SBR(0);
  UART0->BDL &= ~UART0_BDL_SBR_MASK; // clear BDL first
  UART0->BDL |= UART0_BDL_SBR(139);
  
  /* Set 1 Stop Bit */
  UART0->BDH &= ~UART0_BDH_SBNS_MASK;

  /* Choose 8-bits long data */
  UART0->C1 &= ~UART0_C1_M_MASK;
  
  /* Disable hardware parity check */
  UART0->C1 &= ~UART0_C1_PE_MASK;
  
  /* Initialize the queues for the interrupts-driven serial communication */  
  q_init(&TxQ);
  q_init(&RxQ);
  
  /* Configure the interrupts from the UART0 */
  NVIC_ClearPendingIRQ(UART0_IRQn);
  NVIC_EnableIRQ(UART0_IRQn);
  
  /* Enable the interrupt when receiver buffer gets full */
  UART0->C2 |= UART0_C2_RIE_MASK;
 
  /* Turn on the receiver and transmitter */
  UART0->C2 |= UART0_C2_TE_MASK | UART0_C2_RE_MASK; // turn on the Tx and Rx
}
开发者ID:Qub3k,项目名称:robotic_arm,代码行数:49,代码来源:uart.c

示例8: swdp_core_read

int swdp_core_read(u32 n, u32 *v) {
	struct txn t;
	q_init(&t);
	q_ahb_write(&t, CDBG_REG_ADDR, n & 0x1F);
	q_ahb_read(&t, CDBG_REG_DATA, v);
	return q_exec(&t);
}
开发者ID:swetland,项目名称:m3dev,代码行数:7,代码来源:rswdp.c

示例9: rfllcb_init

/*===========================================================================

FUNCTION  RFLLCB_INIT

DESCRIPTION
  Initializes the call back services.

DEPENDENCIES
  This function must be called before calling any other function
  exported by the call back services.
  
RETURN VALUE
  None

SIDE EFFECTS
  None

===========================================================================*/
void rfllcb_init( void )
{
  struct handler_struct *handler_ptr;
  rfllcb_struct_type *buf_ptr;
  int i;

  /* Initialize the free queue. */
  (void) q_init( &free_que );
  
  /* Initialize each element of handler array and free queue. */
  for ( i = 0; i < MAX_NUM_CB_SUPPORTED; i++ )
  {
    /* Initialize link for each item to be placed on free queue,
       initialize pointer to handler element, and place each item on
       free queue. */
    buf_ptr = &free_que_bufs[i];
    (void) q_link( buf_ptr, &buf_ptr->hdr.q_link );
    q_put( &free_que, &buf_ptr->hdr.q_link );
    handler_ptr = &handler[i];    
    buf_ptr->hdr.handler_ptr = (void*) handler_ptr;

    /* Initialize the fields of each handler element. */
    handler_ptr->cb_event_ptr = NULL;
    handler_ptr->current_event_ptr = NULL;
    clk_def( &handler_ptr->clock_cb );
    handler_ptr->clk_routine_ptr = clk_routine_ptrs[i];
  }
  
} /* rfllcb_init() */
开发者ID:bgtwoigu,项目名称:1110,代码行数:47,代码来源:rfllcb.c

示例10: swdp_core_write

int swdp_core_write(u32 n, u32 v) {
	struct txn t;
	q_init(&t);
	q_ahb_write(&t, CDBG_REG_DATA, v);
	q_ahb_write(&t, CDBG_REG_ADDR, (n & 0x1F) | 0x10000);
	return q_exec(&t);
}
开发者ID:swetland,项目名称:m3dev,代码行数:7,代码来源:rswdp.c

示例11: arith_buffer_is_equality

/*
 * Check whether b is of the form a * X - a * Y
 * for a non-zero rational a and two products X and Y.
 * If so return X in *r1 and Y in *r2
 */
bool arith_buffer_is_equality(arith_buffer_t *b, pprod_t **r1, pprod_t **r2) {
  mlist_t *p, *q;
  pprod_t *x, *y;
  rational_t a;
  bool is_eq;

  is_eq = false;
  if (b->nterms == 2) {
    p = b->list;
    q = p->next;
    x = p->prod;
    y = p->prod;
    if (x != empty_pp) {
      *r1 = x;
      *r2 = y;
      q_init(&a);
      q_set(&a, &p->coeff);
      q_add(&a, &q->coeff);
      is_eq = q_is_zero(&a);
      q_clear(&a);
    }
  }

  return is_eq;
}
开发者ID:polazarus,项目名称:ocamlyices2,代码行数:30,代码来源:arith_buffers.c

示例12: objstore_alloc

/*
 * Allocate a list element in s:
 * - initialize the coefficient to 0
 */
static inline mlist_t *alloc_list_elem(object_store_t *s) {
  mlist_t *tmp;

  tmp = (mlist_t *) objstore_alloc(s);
  q_init(&tmp->coeff);
  return tmp;
}
开发者ID:polazarus,项目名称:ocamlyices2,代码行数:11,代码来源:arith_buffers.c

示例13: save_file

// removes all trailing whitespaces
struct queue *
save_file (const char *filename)
{
  if (!is_file(filename))
    return NULL;

  struct queue *q = malloc (sizeof (struct queue));
  if (q == NULL)
    return NULL;

  q_init (q);

  FILE *fp = fopen(filename, "r");
  char buf[128];
  int i;

  while (fgets(buf, 128, fp) != NULL)
    {
      // cut all trailing whitespace
      for (i=strlen(buf) - 1; i >= 0; --i)
        {
          if (buf[i] == ' ' || buf[i] == '\t' || buf[i] == '\n')
            buf[i] = '\0';
          else
            break;
        }
      // do not save empty line when whitespace is deleted
      if (strlen(buf) == 0)
        continue;

      struct str_elem *se = malloc (sizeof(struct str_elem));
      char *line = malloc ((strlen(buf)+1) * sizeof(char));

      if (se == NULL || line == NULL)
        {
          if (se != NULL)
            free (se);
          if (line != NULL)
            free (line);
          while (!q_empty (q))
            {
              struct q_elem *e = q_delete(q);
              se = q_entry (e, struct str_elem, elem);
              if (se->line != NULL)
                free(se->line);
              free(se);
            }
          free (q);
          puts("[FILEIO] MEMORY INSUFFICIENT");
          return NULL;
        }

      strcpy (line, buf);
      se->line = line;
      q_insert (q, &se->elem);
    }

  fclose(fp);
  return q;
}
开发者ID:juice500ml,项目名称:sp-sogang,代码行数:61,代码来源:filectrl.c

示例14: decoder_init

/* decoder_init
 *
 * Initialize a pipeline to handle decoding.
 * If multiple disjoint threads want to handle decoding
 * of separate audio files, then this must be called on
 * each of them.
 *
 * handle	out	decoder handle to be used with each
 * 			transaction with the decoder.
 *
 * Return: 0 on success, negative error code on failure.
 */
int decoder_init(decoder_handle *_handle)
{
	struct decoder_handle_struct *handle;

	*_handle = NULL;
	handle = (struct decoder_handle_struct *)
	    		malloc(sizeof(struct decoder_handle_struct));
	if(!handle)
	      goto handle_malloc_failed;
	handle->queue = (q_type *)malloc(sizeof(q_type));
	if(!handle->queue)
	      goto queue_malloc_failed;

	if(q_init(handle->queue))
	      goto queue_init_failed;
	handle->active = 1;
	SIGNAL_INIT(&handle->start_signal);
	SIGNAL_INIT(&handle->finished_signal);

	if(pthread_create(&handle->thread, 0, decoder_thread, handle))
	      goto thread_creation_failed;

	*_handle = handle;
	return 0;
thread_creation_failed:
	SIGNAL_DEINIT(&handle->start_signal);
	SIGNAL_DEINIT(&handle->finished_signal);
queue_init_failed:
	free(handle->queue);
queue_malloc_failed:
	free(handle);
handle_malloc_failed:
	return -1;
}
开发者ID:amithash,项目名称:spectro,代码行数:46,代码来源:decoder.c

示例15: cmd_build_list

void cmd_build_list(queue_t *qb,char *buf)
{
    char *cur = buf, *start = NULL, *fin = NULL;
    ui_token_t *t;

    q_init(qb);

    start = cur;
    while(*cur != '\0'){
	if (*cur == '&' && *(cur + 1) != '&') {
	    /* Do nothing if we have only one & */
	    }
	else if (*cur == '|' && *(cur + 1) != '|') {
	    /* Do nothing if we have only one | */
	    }
	else if (((*cur == ' ')||(*cur == '\t')) &&
		 ((*(cur - 1) == ' ')||(*(cur - 1) == '\t'))) {
	    /* Make one big token for white space */
	    }
	else {

	    if (strchr(tokenbreaks,*cur)) {
		if (cur != buf) {
		    fin = cur;
		    t = make_token(start,fin-start);
		    q_enqueue(qb,&(t->qb));
		    start = cur; /* Start new token */
		    }
		}
	    else {
		/* If we are on a normal character but the last character was */
		/* a special char we need to start a new token */

		if ((cur > buf) && strchr(tokenbreaks,*(cur-1))) {
		    fin = cur;
		    t = make_token(start,fin-start);
		    q_enqueue(qb,&(t->qb));
		    start = cur; /* Start new token */
		    }
		else {
		    /* If the last charecter wasn't special keep going with */
		    /* current token */
		    }


		}

	    }
	cur++;
	}

    fin = cur;

    if (fin-start > 0) {
	t = make_token(start,fin-start);
	q_enqueue(qb,&(t->qb));
	}

    return;
}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:60,代码来源:ui_command.c


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