コード例 #1
0
ファイル: gplib.c プロジェクト: jkeuffer/pari
void
kill_buffers_upto_including(Buffer *B)
{
  while (s_bufstack.n) {
    if (bufstack[ s_bufstack.n-1 ] == B) { pop_buffer(); break; }
    pop_buffer();
  }
}
コード例 #2
0
ファイル: expression.c プロジェクト: doniexun/Compiler-21
struct Symbol* conditional_expression(struct ConditionalExpression* node)
{
    struct Symbol* symbol = logical_or_expression(node->logicalOrExpression);
    if (node->type == 0)
        return symbol;
    ADDSTRING("  br i1 ");
    code_gen_symbol('%', symbol);
    struct Symbol* label1 = new_symbol("", 0, 0, 0, 0, 0, 0);
    ADDSTRING(", label ");
    code_gen_symbol('%', label1);
    ADDSTRING(", label ");
    char *ch = g_ptr;
    ADDSTRING("      ");
    ADDSTRING("\n; <label>:");
    code_gen_symbol(0, label1);
    ADDSTRING("\n");
    struct Symbol* symbol1 = load_symbol(expression_func(node->expression));
    ADDSTRING("  br label ");
    char *ch1 = g_ptr;
    ADDSTRING("      ");
    ADDSTRING("\n; <label>:");
    struct Symbol* label2 = new_symbol("", 0, 0, 0, 0, 0, 0);
    code_gen_symbol(0, label2);
    ADDSTRING("\n");
    struct Symbol* symbol2 = load_symbol(expression_func(node->expression));
    ADDSTRING("  br label ");
    struct Symbol* label3 = new_symbol("", 0, 0, 0, 0, 0, 0);
    code_gen_symbol('%', label3);
    ADDSTRING("\n; <label>:");
    code_gen_symbol(0, label3);
    ADDSTRING("\n");
    symbol = new_symbol("", symbol2->storage, symbol2->qualifier, symbol2->specifier, symbol2->stars, 0, symbol2->length);
    code_gen_symbol('%', symbol);
    ADDSTRING(" = phi ");
    code_gen_type_specifier(symbol->specifier,0,symbol->length,symbol->stars);
    ADDSTRING(" [ ");
    code_gen_symbol('%', symbol1);
    ADDSTRING(", ");
    code_gen_symbol('%', label1);
    ADDSTRING(" ], [ ");
    code_gen_symbol('%', symbol2);
    ADDSTRING(", ");
    code_gen_symbol('%', label2);
    ADDSTRING(" ]\n");
    push_buffer(ch);
    code_gen_symbol('%', label2);
    *g_ptr = ' ';
    pop_buffer();
    push_buffer(ch1);
    code_gen_symbol('%', label3);
    *g_ptr = ' ';
    pop_buffer();
    return symbol;
}
コード例 #3
0
ファイル: gplib.c プロジェクト: jkeuffer/pari
/* kill all buffers until B is met or nothing is left */
void
kill_buffers_upto(Buffer *B)
{
  while (s_bufstack.n) {
    if (bufstack[ s_bufstack.n-1 ] == B) break;
    pop_buffer();
  }
}
コード例 #4
0
ファイル: buffer_bind.c プロジェクト: kidanger/Drystal
int mlua_free_buffer(lua_State* L)
{
	assert(L);

	Buffer* buffer = pop_buffer(L, 1);
	display_free_buffer(buffer);
	return 0;
}
コード例 #5
0
ファイル: buffer_bind.c プロジェクト: kidanger/Drystal
int mlua_reset_buffer(lua_State* L)
{
	assert(L);

	Buffer* buffer = pop_buffer(L, 1);
	assert_lua_error(L, !buffer_was_freed(buffer), "cannot reset() a freed buffer");
	buffer_reset(buffer);
	return 0;
}
コード例 #6
0
ファイル: buffer_bind.c プロジェクト: kidanger/Drystal
int mlua_use_buffer(lua_State* L)
{
	assert(L);

	Buffer* buffer = pop_buffer(L, 1);
	assert_lua_error(L, !buffer_was_freed(buffer), "cannot use() a freed buffer");
	display_use_buffer(buffer);
	return 0;
}
コード例 #7
0
ファイル: daemon.c プロジェクト: asash/dspam-fork
char *daemon_getline(THREAD_CTX *TTX, int timeout) {
    struct timeval tv;
    char *p, *q, *pop;
    char buf[1024];
    int total_wait = 0;
    long recv_len;
    fd_set fds;
    int i;

    pop = pop_buffer(TTX);
    while(!pop && total_wait<timeout) {
        if (__daemon_run == 0)
            return NULL;
        total_wait++;
        tv.tv_sec = 1;
        tv.tv_usec = 0;
        FD_ZERO(&fds);
        FD_SET(TTX->sockfd, &fds);
        i = select(TTX->sockfd+1, &fds, NULL, NULL, &tv);
        if (i<=0)
            continue;

        recv_len = recv(TTX->sockfd, buf, sizeof(buf)-1, 0);
        buf[recv_len] = 0;
        if (recv_len == 0)
            return NULL;
        for(p=q=buf,i=0; i<recv_len; i++) {
            if (*q) {
                *p = *q;
                p++;
            }
            q++;
        }
        *p = 0;
        buffer_cat(TTX->packet_buffer, buf);
        pop = pop_buffer(TTX);
    }

#ifdef VERBOSE
    LOGDEBUG("SRECV: %s", pop);
#endif

    return pop;
}
コード例 #8
0
ファイル: buffer_bind.c プロジェクト: kidanger/Drystal
int mlua_upload_and_free_buffer(lua_State* L)
{
	assert(L);

	Buffer* buffer = pop_buffer(L, 1);
	assert_lua_error(L, !buffer_was_freed(buffer), "cannot upload_and_free() a freed buffer");
	buffer_upload_and_free(buffer);
	display_use_default_buffer();
	return 0;
}
コード例 #9
0
ファイル: pc.c プロジェクト: RobPiwowarek/Semaphores
void * consumer2()
{
	while(1)
	{
		sem_wait(&sem_empty);
		pthread_mutex_lock(&mutex);
		print_buffer();
		printf("C2: %d\n", pop_buffer());
		
		pthread_mutex_unlock(&mutex);
		sem_post(&sem_full);
	}
}
コード例 #10
0
ファイル: buffer_bind.c プロジェクト: kidanger/Drystal
int mlua_draw_buffer(lua_State* L)
{
	assert(L);

	Buffer* buffer = pop_buffer(L, 1);
	lua_Number dx = 0, dy = 0;
	if (lua_gettop(L) >= 2)
		dx = luaL_checknumber(L, 2);
	if (lua_gettop(L) >= 3)
		dy = luaL_checknumber(L, 3);
	display_draw_buffer(buffer, dx, dy);
	return 0;
}
コード例 #11
0
bool tx0_handler( unsigned char* c )
  {
  bool status;
  unsigned char* head;

  /* get current state of head pointer */
  BSP_CRITICAL_STATEMENT( head = tx0_head );

  /* get data off of the transmit buffer */
  pop_buffer( head, &tx0_tail, tx0_buff, c, 1 );
  
  /* check status of buffer */
  BSP_CRITICAL_STATEMENT( status = tx0_head != tx0_tail );
  
  return status; /* indicate if this is the last byte in the buffer */
  }
コード例 #12
0
int rx_receive( void* data, int max_len )
  {
  int cnt;
  unsigned char* head;
  
  /* get current state of head pointer */
  BSP_CRITICAL_STATEMENT( head = rx_head );
  
  /* retrieve data from buffer */
  cnt = pop_buffer( head, &rx_tail, rx_buff, data, max_len );

#if( defined UART_HARDWARE_HANDSHAKE_IN_SOFTWARE )
  /* if we need to hold off the remote transmitter */
  if( rx_peek( ) < RX_TX_BUFFER_THROTTLE_LIMIT )
     UART_ASSERT_RTS( UART_RTS_DEASSERTED ); /* deassert the RTS line */
#endif

  return cnt; /* indicate the number of bytes retrieved from the buffer */
  }
コード例 #13
0
ファイル: expression.c プロジェクト: doniexun/Compiler-21
struct Symbol* logical_or_expression(struct LogicalOrExpression* node)
{
    if (node->type == 0)
        return logical_and_expression(node->logicalAndExpression);
    struct Symbol* symbol1 = load_symbol(logical_or_expression(node->logicalOrExpression));
    struct Symbol* symbol2 = load_symbol(logical_and_expression(node->logicalAndExpression));
    struct Symbol* symbol3 = test_calculable2(&symbol1, &symbol2, 'a');
    if (symbol3)
        return symbol3;
    symbol3 = new_symbol("0", 0, 2, 16, 0, 2, 0);
    symbol3 = equality_symbol(symbol1, symbol3, 2, 1);
    ADDSTRING("  br i1 ");
    code_gen_symbol('%', symbol3);
    struct Symbol* label1 = new_symbol("", 0, 0, 0, 0, 0, 0);
    struct Symbol* label2 = new_symbol("", 0, 0, 0, 0, 0, 0);
    ADDSTRING(", label ");
    char *ch = g_ptr;
    ADDSTRING("      ");
    ADDSTRING(", label ");
    code_gen_symbol('%', label1);
    ADDSTRING("\n; <label>:");
    code_gen_symbol(0, label1);
    ADDSTRING("\n");
    symbol1 = equality_symbol(symbol2, symbol3, 2, 1);
    ADDSTRING("  br label ");
    code_gen_symbol('%', label2);
    ADDSTRING("\n; <label>:");
    code_gen_symbol(0, label2);
    ADDSTRING("\n");
    ADDSTRING("  ");
    symbol2 = new_symbol("", 0, 2, 2, 0, 0, 0);
    code_gen_symbol('%', symbol2);
    ADDSTRING(" = phi i1 [ true, %0 ], [ ");
    code_gen_symbol('%', symbol1);
    ADDSTRING(", ");
    code_gen_symbol('%', label2);
    ADDSTRING(" ]\n");
    push_buffer(ch);
    code_gen_symbol('%', label2);
    *g_ptr = ' ';
    pop_buffer();
    return symbol2;
}
コード例 #14
0
	void CommandLexer::update(const std::string& in)
	{
		for (unsigned int n=0;n<in.size();n++)
		{
			char c = in[n];
			switch (_state)
			{
				case EscapedParseState:
					_buffer << c;
					_state = NormalParseState;
					break;
				case NormalParseState:
					switch (c)
					{
						case '\\':
							_state = EscapedParseState;
							break;
						case '\'':
							_state = QuotedParseState;
							//pop_buffer();
							break;
						case '"':
							_state = DoubleQuotedParseState;
							//pop_buffer();
							break;
						case ' ':
							pop_buffer();
							break;
						default:
							_buffer << c;
					}
					break;
				case QuotedParseState:
					switch (c)
					{
						case '\\':
							_state = EscapedParseState;
							break;
						case '\'':
							_state = NormalParseState;
							//pop_buffer();
							break;
						default:
							_buffer << c;
					}
					break;
				case DoubleQuotedParseState:
					switch (c)
					{
						case '\\':
							_state = EscapedParseState;
							break;
						case '"':
							_state = NormalParseState;
							//pop_buffer();
							break;
						default:
							_buffer << c;
					}
					break;
			}
		}
		pop_buffer();
	}
コード例 #15
0
static GstVaapiDecoderStatus
decode_step (GstVaapiDecoder * decoder)
{
  GstVaapiParserState *const ps = &decoder->parser_state;
  GstVaapiDecoderStatus status;
  GstBuffer *buffer;
  gboolean got_frame;
  guint got_unit_size, input_size;

  status = gst_vaapi_decoder_check_status (decoder);
  if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
    return status;

  /* Fill adapter with all buffers we have in the queue */
  for (;;) {
    buffer = pop_buffer (decoder);
    if (!buffer)
      break;

    ps->at_eos = GST_BUFFER_IS_EOS (buffer);
    if (!ps->at_eos)
      gst_adapter_push (ps->input_adapter, buffer);
  }

  /* Parse and decode all decode units */
  input_size = gst_adapter_available (ps->input_adapter);
  if (input_size == 0) {
    if (ps->at_eos)
      return GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
    return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
  }

  do {
    if (!ps->current_frame) {
      ps->current_frame = g_slice_new0 (GstVideoCodecFrame);
      if (!ps->current_frame)
        return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
      ps->current_frame->ref_count = 1;
      ps->current_frame->system_frame_number = ps->current_frame_number++;
    }

    status = do_parse (decoder, ps->current_frame, ps->input_adapter,
        ps->at_eos, &got_unit_size, &got_frame);
    GST_DEBUG ("parse frame (status = %d)", status);
    if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
      if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA && ps->at_eos)
        status = GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
      break;
    }

    if (got_unit_size > 0) {
      buffer = gst_adapter_take_buffer (ps->input_adapter, got_unit_size);
      input_size -= got_unit_size;

      if (gst_adapter_available (ps->output_adapter) == 0) {
        ps->current_frame->pts = gst_adapter_prev_pts (ps->input_adapter, NULL);
      }
      gst_adapter_push (ps->output_adapter, buffer);
    }

    if (got_frame) {
      ps->current_frame->input_buffer =
          gst_adapter_take_buffer (ps->output_adapter,
          gst_adapter_available (ps->output_adapter));

      status = do_decode (decoder, ps->current_frame);
      GST_DEBUG ("decode frame (status = %d)", status);

      gst_video_codec_frame_unref (ps->current_frame);
      ps->current_frame = NULL;
      break;
    }
  } while (input_size > 0);
  return status;
}
コード例 #16
0
ファイル: gplib.c プロジェクト: jkeuffer/pari
void
gp_initrc(pari_stack *p_A)
{
  FILE *file = gprc_get();
  Buffer *b;
  filtre_t F;
  VOLATILE long c = 0;
  jmp_buf *env;
  pari_stack s_env;

  if (!file) return;
  b = filtered_buffer(&F);
  pari_stack_init(&s_env, sizeof(*env), (void**)&env);
  (void)pari_stack_new(&s_env);
  for(;;)
  {
    char *nexts, *s, *t;
    if (setjmp(env[s_env.n-1])) err_printf("...skipping line %ld.\n", c);
    c++;
    if (!get_line_from_file(NULL,&F,file)) break;
    s = b->buf;
    if (*s == '#')
    { /* preprocessor directive */
      int z, NOT = 0;
      s++;
      if (strncmp(s,"if",2)) err_gprc("unknown directive",s,b->buf);
      s += 2;
      if (!strncmp(s,"not",3)) { NOT = !NOT; s += 3; }
      if (*s == '!')           { NOT = !NOT; s++; }
      t = s;
      z = get_preproc_value(&s);
      if (z < 0) err_gprc("unknown preprocessor variable",t,b->buf);
      if (NOT) z = !z;
      if (!*s)
      { /* make sure at least an expr follows the directive */
        if (!get_line_from_file(NULL,&F,file)) break;
        s = b->buf;
      }
      if (!z) continue; /* dump current line */
    }
    /* parse line */
    for ( ; *s; s = nexts)
    {
      nexts = next_expr(s);
      if (!strncmp(s,"read",4) && (s[4] == ' ' || s[4] == '\t' || s[4] == '"'))
      { /* read file */
        s += 4;
        t = (char*)pari_malloc(strlen(s) + 1);
        if (*s == '"') (void)pari_translate_string(s, t, s-4); else strcpy(t,s);
        pari_stack_pushp(p_A,t);
      }
      else
      { /* set default */
        parse_key_val(s, &s,&t);
        (void)setdefault(s,t,d_INITRC);
      }
    }
  }
  pari_stack_delete(&s_env);
  pop_buffer();
  if (!(GP_DATA->flags & gpd_QUIET)) err_printf("Done.\n\n");
  fclose(file);
}