Exemple #1
0
void
output_cond (const char *condition,
	const char *true_stmt, const char *false_stmt)
{
	output ("if (%s)", condition);
	block_begin ();
	output (true_stmt);
	block_end ();
	output ("else");
	block_begin ();
	output (false_stmt);
	block_end ();
}
Exemple #2
0
void nip::parse::Parser::import_element() {
	block_start();
	while (!is(DEDENT, RIGHT_BRACKET)) {
		import_name();
	}
	block_end();
}
Exemple #3
0
ALWAYS_INLINE void nip::parse::Parser::generic_block() {
	block_start();
	while (!is(RIGHT_BRACKET, DEDENT)) {
		element();
	}
	block_end();
}
Exemple #4
0
static void l2x0_flush_range(unsigned long start, unsigned long end)
{
#ifndef CONFIG_EMXX_L310_NORAM
	void __iomem *base = l2x0_base;
#endif
	unsigned long flags;

	_l2x0_lock(&l2x0_lock, flags);
#ifndef CONFIG_EMXX_L310_NORAM
	start &= ~(CACHE_LINE_SIZE - 1);
	while (start < end) {
		unsigned long blk_end = block_end(start, end);

		while (start < blk_end) {
			l2x0_flush_line(start);
			start += CACHE_LINE_SIZE;
		}

		if (blk_end < end) {
			_l2x0_unlock(&l2x0_lock, flags);
			_l2x0_lock(&l2x0_lock, flags);
		}
	}
	cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1);
#endif
	cache_sync();
	_l2x0_unlock(&l2x0_lock, flags);
}
Exemple #5
0
static void l2x0_flush_range(unsigned long start, unsigned long end)
{
	void __iomem *base = l2x0_base;
	unsigned long flags;

	l2x0_lock(&l2x0_lock, flags);
	start &= ~(CACHE_LINE_SIZE - 1);
	while (start < end) {
		unsigned long blk_end = block_end(start, end);

		debug_writel(0x03);
		while (start < blk_end) {
			l2x0_flush_line(start);
			start += CACHE_LINE_SIZE;
		}
		debug_writel(0x00);

		if (blk_end < end) {
			l2x0_unlock(&l2x0_lock, flags);
			l2x0_lock(&l2x0_lock, flags);
		}
	}
	cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1);
	cache_sync();
	l2x0_unlock(&l2x0_lock, flags);
}
void ContinuousMosaicRV::change_value(ChangeValue& move, Variable::Signal sgl) {
	int pos = block_start(move.position);
	if(sgl==Variable::_SET || sgl==Variable::_PROPOSE) {
		_last_move = CHANGE_VALUE;
		_last_change_value = move;
		_value[pos] = move.to;
		int i;
		for(i=pos;i<=block_end(pos);i++) {
			_has_changed[i] = true;
		}
	}
	else if(sgl==Variable::_ACCEPT) {
		if(_last_move!=CHANGE_VALUE) error("ContinuousMosaicRV::change_value(): inconsistency in move");
		_last_move = NO_CHANGE;
		_has_changed = vector<bool>(_n,false);
	}
	else if(sgl==Variable::_REVERT) {
		if(_last_move!=CHANGE_VALUE) error("ContinuousMosaicRV::change_value(): inconsistency in move");
		_last_move = NO_CHANGE;
		_value[pos] = move.from;
		_has_changed = vector<bool>(_n,false);
	}
	else {
		error("ContinuousMosaicRV::change_value(): unexpected Variable signal");
	}
	act_on_signal(sgl);
	send_signal_to_children(sgl);
}
Exemple #7
0
void nip::parse::Parser::about_section() {
	if (expect(IDENTIFIER, "expected identifier")) {
		block_start();
		while (is(DEDENT, RIGHT_BRACKET)) {
			metadata_field();
		}
		block_end();
	}
}
Exemple #8
0
// add block to free list
static inline void add_block(memory_block* block){
    if(freelist_start != freelist_end){
        // find superseding memory block
        // and insert current one before it
        memory_block* b = freelist_start;
        while(1){
            // superseding memory block will have higher memory address
            if(b > block){
                block_link_left(block,b);
                break;            
            }
            // check if we hit end
            if(b->next == freelist_end){
                block_link_right(b,block);
                break;            
            }else{
                b = b->next;
            }
        }

        // merge adjacent blocks
        bool merged = true;
        while(merged){
            // merge right adjacent block
            if(block_end(block) == block->next){
                block->size += block->next->size;
                block_unlink_right(block);
                continue;
            }                    
            // merge left adjacent block
            if(block_end(block->prev) == block){
                block = block->prev;
                block->size += block->next->size;
                block_unlink_right(block);
                continue;
            }
            merged = false;
        }
    }else{
        // add first memory block
        memory_block* b = freelist_begin;
        block_link_right(b, block);
    }
}
Exemple #9
0
static inline void truncate (struct inode * inode)
{
	struct super_block *sb = inode->i_sb;
	block_t *idata = i_data(inode);
	int offsets[DEPTH];
	Indirect chain[DEPTH];
	Indirect *partial;
	block_t nr = 0;
	int n;
	int first_whole;
	long iblock;

	iblock = (inode->i_size + sb->s_blocksize -1) >> sb->s_blocksize_bits;
	block_truncate_page(inode->i_mapping, inode->i_size, get_block);

	n = block_to_path(inode, iblock, offsets);
	if (!n)
		return;

	if (n == 1) {
		free_data(inode, idata+offsets[0], idata + DIRECT);
		first_whole = 0;
		goto do_indirects;
	}

	first_whole = offsets[0] + 1 - DIRECT;
	partial = find_shared(inode, n, offsets, chain, &nr);
	if (nr) {
		if (partial == chain)
			mark_inode_dirty(inode);
		else
			mark_buffer_dirty_inode(partial->bh, inode);
		free_branches(inode, &nr, &nr+1, (chain+n-1) - partial);
	}
	/* Clear the ends of indirect blocks on the shared branch */
	while (partial > chain) {
		free_branches(inode, partial->p + 1, block_end(partial->bh),
				(chain+n-1) - partial);
		mark_buffer_dirty_inode(partial->bh, inode);
		brelse (partial->bh);
		partial--;
	}
do_indirects:
	/* Kill the remaining (whole) subtrees */
	while (first_whole < DEPTH-1) {
		nr = idata[DIRECT+first_whole];
		if (nr) {
			idata[DIRECT+first_whole] = 0;
			mark_inode_dirty(inode);
			free_branches(inode, &nr, &nr+1, first_whole+1);
		}
		first_whole++;
	}
	inode->i_mtime = inode->i_ctime = current_time(inode);
	mark_inode_dirty(inode);
}
Exemple #10
0
void
emit_effect (void)
{
	output ("void %s_deff (void)", current_effect->c_name);
	block_begin (); /* begin function */
	emit_deff_init ();

	output ("while (1)");
	block_begin (); /* begin main loop */
	emit_loop_init ();
	dcc_label *label;
	if (last_label)
		for (label = label_list; label <= last_label; label++)
			emit_label (label);
	emit_loop_exit ();
	block_end (); /* end main loop */

	emit_deff_exit ();
	block_end (); /* end function */
	output ("\n");
}
Exemple #11
0
/******************************************************************************
**  huffman_encode

**  --------------------------------------------------------------------------
**  Quantize and Encode a 8x8 DCT block by JPEG Huffman lossless coding.
**  This function writes encoded bit-stream into bit-buffer.
**  
**  ARGUMENTS:
**      ctx     - pointer to encoder context;
**      data    - pointer to 8x8 DCT block;
**
**  RETURN: -
******************************************************************************/
void huffman_encode(huffman_t *const ctx, const short data[], unsigned block_num)
{
	unsigned magn, bits;
	unsigned zerorun, i;
	short    diff;
	short    dc = quantize(data[0], ctx->qtable[0]);

	// WARNING: in order to everything to work correctly
	// the get_DC_value must be called before the block_start
	// otherwise it returns a wrong DC value in case of megablocks
	// (the block_start reset the force_marker variable, which is
	// used by get_DC_value
	diff = get_DC_value(dc, block_num);
	block_start(block_num);

	bits = huffman_bits(diff);
	magn = huffman_magnitude(diff);

	add_to_block(ctx->hdcbit[magn], ctx->hdclen[magn]);
	add_to_block(bits, magn);
	
	for (zerorun = 0, i = 1; i < 64; i++)
	{
		const short ac = quantize(data[zig[i]], ctx->qtable[zig[i]]);

		if (ac) {
			while (zerorun >= 16) {
				zerorun -= 16;
				// ZRL
				add_to_block(ctx->hacbit[15][0], ctx->haclen[15][0]);
			}

			bits = huffman_bits(ac);
			magn = huffman_magnitude(ac);
			add_to_block(ctx->hacbit[zerorun][magn], ctx->haclen[zerorun][magn]);
			add_to_block(bits, magn);

			zerorun = 0;
		}
		else zerorun++;
	}

	if (zerorun) { // EOB - End Of Block
		add_to_block(ctx->hacbit[0][0], ctx->haclen[0][0]);
	}
	block_end(&bitbuf);
}
void ContinuousMosaicRV::implement_merge_blocks(const int right_block_start, const double to) {
	if(block_start(right_block_start)!=right_block_start) error("ContinuousMosaicRV::implement_merge_blocks(): right block does not start at right_block_start");
	if(right_block_start==0) error("ContinuousMosaicRV::implement_merge_blocks(): cannot left-merge the leftmost block");
	const int left_block_start = block_start(right_block_start-1);
	// Update _value
	_value[left_block_start] = to;
	// Update _block_start and _block_end
	int i;
	const int merged_block_end = block_end(right_block_start);
	for(i=left_block_start;i<right_block_start;i++) {
		_block_end[i] = merged_block_end;
		_has_changed[i] = true;
	}
	for(;i<=merged_block_end;i++) {
		_block_start[i] = left_block_start;
		_has_changed[i] = true;
	}
	--_nblocks;
}
void ContinuousMosaicRV::implement_split_block(const int right_block_start, const double to[2]) {
	const int left_block_start = block_start(right_block_start);
	if(left_block_start==right_block_start) error("ContinuousMosaicRV::implement_split_block(): left block starts at right_block_start");
	// Update _value
	_value[left_block_start] = to[0];
	_value[right_block_start] = to[1];
	// Update _block_start and _block_end
	int i;
	const int right_block_end = block_end(right_block_start);
	for(i=left_block_start;i<right_block_start;i++) {
		_block_end[i] = right_block_start-1;
		_has_changed[i] = true;
	}
	for(;i<=right_block_end;i++) {
		_block_start[i] = right_block_start;
		_has_changed[i] = true;
	}
	++_nblocks;
}
void ContinuousMosaicRV::implement_extend_block(const int old_block_start, const int new_block_start) {
	if(block_start(old_block_start)!=old_block_start) error("ContinuousMosaicRV::implement_extend_block(): block does not start at old_block_start");
	if(old_block_start==0) error("ContinuousMosaicRV::implement_extend_block(): cannot left-extend the leftmost block");
	const int leftmost = block_start(old_block_start-1)+1;
	const int rightmost = block_end(old_block_start);
	if(new_block_start<leftmost || new_block_start>rightmost) error("ContinuousMosaicRV::implement_extend_block(): extension out of range");
	int i;
	// Update _value
	_value[new_block_start] = _value[old_block_start];
	// Update _block_start and _block_end
	if(old_block_start<new_block_start) {
		// Rightwards move
		for(i=leftmost-1;i<new_block_start;i++) {
			_block_end[i] = new_block_start-1;
		}
		for(i=old_block_start;i<new_block_start;i++) {
			_block_start[i] = leftmost-1;
			_has_changed[i] = true;
		}
		// On a right move, define as having changed the first value occurring at the start
		// of the right block (even though it hasn't)
		_has_changed[new_block_start] = true;
		for(i=new_block_start;i<=rightmost;i++) {
			_block_start[i] = new_block_start;
		}
	}
	else if(old_block_start>new_block_start) {
		// Leftwards move
		for(i=leftmost-1;i<new_block_start;i++) {
			_block_end[i] = new_block_start-1;
		}
		// Changed 9:42 15/09/2009
		//for(i=new_block_start;i<=old_block_start;i++) {
		for(i=new_block_start;i<old_block_start;i++) {
			_block_end[i] = rightmost;
			_has_changed[i] = true;
		}
		for(i=new_block_start;i<=rightmost;i++) {
			_block_start[i] = new_block_start;
		}
	}
}
Exemple #15
0
static void free_branches(struct inode *inode, block_t *p, block_t *q, int depth)
{
	struct buffer_head * bh;
	unsigned long nr;

	if (depth--) {
		for ( ; p < q ; p++) {
			nr = block_to_cpu(*p);
			if (!nr)
				continue;
			*p = 0;
			bh = sb_bread(inode->i_sb, nr);
			if (!bh)
				continue;
			free_branches(inode, (block_t*)bh->b_data,
				      block_end(bh), depth);
			bforget(bh);
			xiafs_free_block(inode, nr);
			mark_inode_dirty(inode);
		}
	} else
		free_data(inode, p, q);
}
Exemple #16
0
void
close_if_block (const char *c_cond)
{
	block_end ();
}
/**
 * Parses the file and populates the structures used by this FUSE driver.
 *
 * \param filename The filename to parse
 * \param r The result structure to populate (or NULL if not needed)
 * \returns 0 if successful, -1 if not.
 */
static int process_file(const char *filename, result_t new_result)
{
  img_info = tsk_img_open_sing(filename, TSK_IMG_TYPE_DETECT, 0);
  if (img_info == NULL)
  {
    info_log("Failed to open image: %s", filename);
    return -1;
  }

  fs_info = tsk_fs_open_img(img_info, 0, TSK_FS_TYPE_DETECT);
  if (fs_info == NULL)
  {
    info_log("Failed to open filesystem: %s", filename);
    return -1;
  }

  const char *fsname = tsk_fs_type_toname(fs_info->ftype);

  result_set_brief_data_description(new_result, fsname);
  mountpoint = g_strdup_printf("%s:mnt-%s", filename, fsname);

  char *description = g_strdup_printf("%" PRIdDADDR " bytes (%" PRIdDADDR " %ss of %u size)", fs_info->block_count * fs_info->block_size, fs_info->block_count, fs_info->duname, fs_info->block_size);

  result_set_data_description(new_result, description);
  g_free(description);

  result_set_confidence(new_result, 100);
  block_start(absolute_offset);

  TSK_FS_DIR_WALK_FLAG_ENUM name_flags = (TSK_FS_DIR_WALK_FLAG_ENUM) (TSK_FS_DIR_WALK_FLAG_ALLOC | TSK_FS_DIR_WALK_FLAG_UNALLOC | TSK_FS_DIR_WALK_FLAG_RECURSE);

  if (tsk_fs_dir_walk(fs_info, fs_info->root_inum, name_flags, examine_dirent, new_result) != 0)
  {
    // Why does this occur? Is it because it's an invalid filesystem structure, or the
    // structure is damaged? I'm going to assume the structure is damaged, but partially available.
    warning_log("Warning, unable to fully walk fs! Probably truncated or not a real FS header.");
  }

  unsigned int size;
  block_range_t *ranges = block_end(&size);

  if (ranges != NULL)
  {
    result_set_block_ranges(new_result, ranges, size);
    for (int i = 0; i < size; i++)
    {
      block_range_close(ranges[i]);
    }
    g_free(ranges);
  }

  if (inode_lookup != NULL)
  {
    g_tree_destroy(inode_lookup);
    inode_lookup = NULL;
  }

  unsigned int num_contracts;
  result_get_new_contracts(new_result, &num_contracts);
  if (num_contracts > 0)
  {
    // Ready to mount!
    int ret = do_mount(mountpoint);

    if (ret != 0)
    {
      error_log("Failed to mount filesystem!");
    }
  }

  remove_all_files();

  return 0;
}
Exemple #18
0
static void
config_parse_line(calipso_config_t *config , char *line, int nline)
{
	char option[MAXOPTLEN]= {0}, value[MAXOPTLEN] = {0};
	char *s, *delim = NULL;

    if(strlen(line) > MAXOPTLEN ) 
		parser_error(nline, PERR_LINE);

	//printf("line '%s' %d\n", line, nline); 
	if(block_begin(line)) {

		if(!strlen(_block)) {
			s = strtok(line, BLOCK_BEGIN);
			if(s) { 
				strncpy(_block, s, MAXOPTLEN);
				trim(_block);
				//mark context begin 
				config_mark_ctx(config, CTX_BLOCK_BEGIN);
			} else 	parser_error(nline, PERR_BLOCK);
		}
		else parser_error(nline, PERR_BEGIN);
		//printf("begin '%s'\n", _block);
		return;
	}

	if(block_end(line)) {
	
		if(strlen(_block) > 0) {
			//mark context end 
			config_mark_ctx(config, CTX_BLOCK_END);
			memset(_block, 0 , MAXOPTLEN);
		}
		else parser_error(nline, PERR_END);
		//printf("end '%s'\n", _block);
		return;
	}

	if(strstr(line , DELIM_EQU)) 
		delim = DELIM_EQU;
	else if(strstr(line , DELIM_SPACE))
		delim = DELIM_SPACE;
	else if(strstr(line, DELIM_TAB))
		delim = DELIM_TAB;
	else 
		parser_error(nline, PERR_DELIM);

	s = strtok (line, delim); 

	if (s) {
		strncpy (option, s, MAXOPTLEN);
	}

	s = strtok (NULL, delim);

    if (s) {
		strncpy (value, s, MAXOPTLEN);
	}

    if ( strlen(option) && strlen(value)) {
		trim(option);
		trim(value);
		config_set_option(config, option, value, strlen(_block) ? _block : NULL );
	} else {
		parser_error(nline, PERR_PAIR);
	}
}
Exemple #19
0
//--------------------------------------------------------------------------
void idaapi footer(void)
{
  if ( !jasmin()) block_end(0 );
}
Exemple #20
0
//----------------------------------------------------------------------
bool block_close(uint32 off, const char *name)
{
  if ( !jasmin()) return(block_end(off) );
  return(printf_line(off, COLSTR(".end %s", SCOLOR_KEYWORD), name));
}