コード例 #1
0
ファイル: numrec.c プロジェクト: nasa/QuIP
void dp_jacobi(QSP_ARG_DECL  Data_Obj *v_dp, Data_Obj *d_dp, Data_Obj *a_dp, int *nrotp)
{
	void *a_rowlist[MAX_DIM], *v_rowlist[MAX_DIM];
	int n;

	if( OBJ_COLS(a_dp) != OBJ_ROWS(a_dp) ){
		sprintf(DEFAULT_ERROR_STRING,"dp_jacobi:  matrix %s must be square for jacobi",OBJ_NAME(a_dp));
		NWARN(DEFAULT_ERROR_STRING);
		return;
	}
	if( OBJ_COLS(v_dp) != OBJ_ROWS(v_dp) ){
		sprintf(DEFAULT_ERROR_STRING,"dp_jacobi:  matrix %s must be square for jacobi",OBJ_NAME(v_dp));
		NWARN(DEFAULT_ERROR_STRING);
		return;
	}
	if( OBJ_COLS(v_dp) != OBJ_COLS(a_dp) ){
		sprintf(DEFAULT_ERROR_STRING,"dp_jacobi:  size of eigenvector matrix %s must match input matrix %s for jacobi",
			OBJ_NAME(v_dp),OBJ_NAME(a_dp));
		NWARN(DEFAULT_ERROR_STRING);
		return;
	}
	if( OBJ_COLS(d_dp) != OBJ_COLS(a_dp) ){
		sprintf(DEFAULT_ERROR_STRING,"dp_jacobi:  size of eigenvalue vector %s must match input matrix %s for jacobi",
			OBJ_NAME(d_dp),OBJ_NAME(a_dp));
		NWARN(DEFAULT_ERROR_STRING);
		return;
	}
	if( ! IS_CONTIGUOUS(a_dp) ){
		sprintf(DEFAULT_ERROR_STRING,"dp_jacobi:  Object %s must be contiguous for jacobi",OBJ_NAME(a_dp));
		NWARN(DEFAULT_ERROR_STRING);
		return;
	}
	if( ! IS_CONTIGUOUS(d_dp) ){
		sprintf(DEFAULT_ERROR_STRING,"dp_jacobi:  Object %s must be contiguous for jacobi",OBJ_NAME(d_dp));
		NWARN(DEFAULT_ERROR_STRING);
		return;
	}
	if( ! IS_CONTIGUOUS(v_dp) ){
		sprintf(DEFAULT_ERROR_STRING,"dp_jacobi:  Object %s must be contiguous for jacobi",OBJ_NAME(v_dp));
		NWARN(DEFAULT_ERROR_STRING);
		return;
	}

	n = OBJ_COLS(a_dp);
	/* BUG make sure types match */

	if( OBJ_MACH_PREC(a_dp) == PREC_SP ){
		float_init_rowlist((float **)(void *)a_rowlist,a_dp);
		float_init_rowlist((float **)(void *)v_rowlist,v_dp);

		float_jacobi(((float **)(void *)a_rowlist)-1,n,((float *)(OBJ_DATA_PTR(d_dp)))-1,((float **)(void *)v_rowlist)-1,nrotp);
	} else if( OBJ_MACH_PREC(a_dp) == PREC_DP ){
		double_init_rowlist((double **)(void *)a_rowlist,a_dp);
		double_init_rowlist((double **)(void *)v_rowlist,v_dp);

		double_jacobi(((double **)(void *)a_rowlist)-1,n,((double *)(OBJ_DATA_PTR(d_dp)))-1,((double **)(void *)v_rowlist)-1,nrotp);
	} else {
		NWARN("bad precision in dp_jacobi");
	}
}
コード例 #2
0
ファイル: cluster.c プロジェクト: svn2github/exfat
static int grow_file(struct exfat* ef, struct exfat_node* node,
		uint32_t current, uint32_t difference)
{
	cluster_t previous;
	cluster_t next;
	uint32_t allocated = 0;

	if (difference == 0)
		exfat_bug("zero clusters count passed");

	if (node->start_cluster != EXFAT_CLUSTER_FREE)
	{
		/* get the last cluster of the file */
		previous = exfat_advance_cluster(ef, node, current - 1);
		if (CLUSTER_INVALID(previous))
		{
			exfat_error("invalid cluster 0x%x while growing", previous);
			return -EIO;
		}
	}
	else
	{
		if (node->fptr_index != 0)
			exfat_bug("non-zero pointer index (%u)", node->fptr_index);
		/* file does not have clusters (i.e. is empty), allocate
		   the first one for it */
		previous = allocate_cluster(ef, 0);
		if (CLUSTER_INVALID(previous))
			return -ENOSPC;
		node->fptr_cluster = node->start_cluster = previous;
		allocated = 1;
		/* file consists of only one cluster, so it's contiguous */
		node->flags |= EXFAT_ATTRIB_CONTIGUOUS;
	}

	while (allocated < difference)
	{
		next = allocate_cluster(ef, previous + 1);
		if (CLUSTER_INVALID(next))
		{
			if (allocated != 0)
				shrink_file(ef, node, current + allocated, allocated);
			return -ENOSPC;
		}
		if (next != previous - 1 && IS_CONTIGUOUS(*node))
		{
			/* it's a pity, but we are not able to keep the file contiguous
			   anymore */
			make_noncontiguous(ef, node->start_cluster, previous);
			node->flags &= ~EXFAT_ATTRIB_CONTIGUOUS;
			node->flags |= EXFAT_ATTRIB_DIRTY;
		}
		set_next_cluster(ef, IS_CONTIGUOUS(*node), previous, next);
		previous = next;
		allocated++;
	}

	set_next_cluster(ef, IS_CONTIGUOUS(*node), previous, EXFAT_CLUSTER_END);
	return 0;
}
コード例 #3
0
ファイル: cluster.c プロジェクト: daddy366/anarchy-exfat
static int shrink_file(struct exfat* ef, struct exfat_node* node,
		uint32_t current, uint32_t difference)
{
	cluster_t previous;
	cluster_t next;

	if (difference == 0)
		exfat_bug("zero difference passed");
	if (node->start_cluster == EXFAT_CLUSTER_FREE)
		exfat_bug("unable to shrink empty file (%u clusters)", current);
	if (current < difference)
		exfat_bug("file underflow (%u < %u)", current, difference);

	/* crop the file */
	if (current > difference)
	{
		cluster_t last = exfat_advance_cluster(ef, node,
				current - difference - 1);
		if (CLUSTER_INVALID(last))
		{
			exfat_error("invalid cluster 0x%x while shrinking", last);
			return -EIO;
		}
		previous = exfat_next_cluster(ef, node, last);
		if (!set_next_cluster(ef, IS_CONTIGUOUS(*node), last,
				EXFAT_CLUSTER_END))
			return -EIO;
	}
	else
	{
		previous = node->start_cluster;
		node->start_cluster = EXFAT_CLUSTER_FREE;
	}
	node->fptr_index = 0;
	node->fptr_cluster = node->start_cluster;

	/* free remaining clusters */
	while (difference--)
	{
		if (CLUSTER_INVALID(previous))
		{
			exfat_error("invalid cluster 0x%x while freeing after shrink",
					previous);
			return -EIO;
		}
		next = exfat_next_cluster(ef, node, previous);
		if (!set_next_cluster(ef, IS_CONTIGUOUS(*node), previous,
				EXFAT_CLUSTER_FREE))
			return -EIO;
		free_cluster(ef, previous);
		previous = next;
	}
	return 0;
}
コード例 #4
0
ファイル: fbmenu.c プロジェクト: E-LLP/QuIP
static void fb_save(QSP_ARG_DECL Data_Obj *dp,int x, int y)
{
#ifdef HAVE_FB_DEV
	dimension_t i,j,k;
	char *p,*q;

	/* BUG assume dp is the right kind of object */

	if( ! IS_CONTIGUOUS(dp) ){
		sprintf(ERROR_STRING,"fb_save:  object %s must be contiguous",
			OBJ_NAME(dp));
		WARN(ERROR_STRING);
		return;
	}

	INSURE_FB("fb_save");

	p=(char *)OBJ_DATA_PTR(dp);
	q=(char *)OBJ_DATA_PTR(curr_fbip->fbi_dp);

	/* BUG this byte-at-a-time copy is horribly inefficient */
	for(i=0;i<OBJ_ROWS(dp);i++)
		for(j=0;j<OBJ_COLS(dp);j++)
			for(k=0;k<OBJ_COMPS(dp);k++)
				*p++ = *q++;
#endif /* HAVE_FB_DEV */
}
コード例 #5
0
ファイル: fbmenu.c プロジェクト: E-LLP/QuIP
static void fb_load(QSP_ARG_DECL Data_Obj *dp,int x, int y)
{
#ifdef HAVE_FB_DEV
	dimension_t i,j;
	/* char *p,*q; */	/* BUG probably a lot faster if we cast to long! */
	long *p,*q;
	u_long bytes_per_row, words_per_row;

	/* BUG assume dp is the right kind of object */

	if( ! IS_CONTIGUOUS(dp) ){
		sprintf(ERROR_STRING,"fb_load:  object %s must be contiguous",
			OBJ_NAME(dp));
		WARN(ERROR_STRING);
		return;
	}

	INSURE_FB("fb_load");

	p=(long *)OBJ_DATA_PTR(dp);
	q=(long *)OBJ_DATA_PTR(curr_fbip->fbi_dp);

	bytes_per_row = OBJ_COLS(dp) * OBJ_COMPS(dp);
	words_per_row = bytes_per_row / sizeof(long);

	for(i=0;i<OBJ_ROWS(dp);i++){
		/* BUG we need to correct the row ptr if dp is narrower than the display */
		for(j=0;j<words_per_row;j++)
			*q++ = *p++;
	}
#endif /* HAVE_FB_DEV */
}
コード例 #6
0
ファイル: numrec.c プロジェクト: nasa/QuIP
void dp_moment(QSP_ARG_DECL  Data_Obj *d_dp)
{
	/* std_type *d_rowlist[MAX_DIM]; */
	int n;
	if( ! IS_CONTIGUOUS(d_dp) ){
           	sprintf(DEFAULT_ERROR_STRING,"dp_moment:  Object %s must be contiguous for eigsrt",OBJ_NAME(d_dp));
                NWARN(DEFAULT_ERROR_STRING);
                return;
        }
	n = OBJ_COLS(d_dp);

	if( OBJ_MACH_PREC(d_dp) == PREC_SP ){
       		float adev, var, skew, curt;
		float ave, sdev;
	
		/* BUG - the results don't get passed out anywhere!?
		 */

		float_moment(((float *)(OBJ_DATA_PTR(d_dp))),n,&ave,&adev,&sdev,&var,&skew,&curt);
	} else if( OBJ_MACH_PREC(d_dp) == PREC_DP ){
       		double adev, var, skew, curt;
		double ave, sdev;
	
		double_moment(((double *)(OBJ_DATA_PTR(d_dp))),n,&ave,&adev,&sdev,&var,&skew,&curt);
	}
}
コード例 #7
0
ファイル: main.c プロジェクト: Lurker00/Android-fs
static void dirck(struct exfat* ef, const char* path)
{
	struct exfat_node* parent;
	struct exfat_node* node;
	struct exfat_iterator it;
	int rc;
	size_t path_length;
	char* entry_path;

	if (exfat_lookup(ef, &parent, path) != 0)
		exfat_bug("directory '%s' is not found", path);
	if (!(parent->flags & EXFAT_ATTRIB_DIR))
		exfat_bug("'%s' is not a directory (0x%x)", path, parent->flags);
	if (nodeck(ef, parent) != 0)
	{
		exfat_put_node(ef, parent);
		return;
	}

	path_length = strlen(path);
	entry_path = malloc(path_length + 1 + UTF8_BYTES(EXFAT_NAME_MAX) + 1);
	if (entry_path == NULL)
	{
		exfat_put_node(ef, parent);
		exfat_error("out of memory");
		return;
	}
	strcpy(entry_path, path);
	strcat(entry_path, "/");

	rc = exfat_opendir(ef, parent, &it);
	if (rc != 0)
	{
		free(entry_path);
		exfat_put_node(ef, parent);
		return;
	}
	while ((node = exfat_readdir(ef, &it)))
	{
		exfat_get_name(node, entry_path + path_length + 1,
				UTF8_BYTES(EXFAT_NAME_MAX));
		exfat_debug("%s: %s, %"PRIu64" bytes, cluster %u", entry_path,
				IS_CONTIGUOUS(*node) ? "contiguous" : "fragmented",
				node->size, node->start_cluster);
		if (node->flags & EXFAT_ATTRIB_DIR)
		{
			directories_count++;
			dirck(ef, entry_path);
		}
		else
		{
			files_count++;
			nodeck(ef, node);
		}
		exfat_put_node(ef, node);
	}
	exfat_closedir(ef, &it);
	exfat_put_node(ef, parent);
	free(entry_path);
}
コード例 #8
0
ファイル: acquire.c プロジェクト: nasa/QuIP
static int parse_polh_reading( QSP_ARG_DECL  Data_Obj *dp, char * s )
{
	char str[32];
	float *f_p;

#ifdef QUIP_DEBUG
if( debug & debug_polhemus ){
sprintf(ERROR_STRING,"parse_polh_reading \"%s\"",show_printable(DEFAULT_QSP_ARG  s));
advise(ERROR_STRING);
}
#endif /* QUIP_DEBUG */

	if( OBJ_PREC(dp) != PREC_SP ){
		sprintf(ERROR_STRING,"Object %s has %s precision, should be %s",
			OBJ_NAME(dp),
			PREC_NAME(OBJ_PREC_PTR(dp)),
			PREC_NAME(prec_for_code(PREC_SP)) );
		warn(ERROR_STRING);
		return(-1);
	}
	if( ! IS_CONTIGUOUS(dp) ){
		sprintf(ERROR_STRING,"Object %s should be contiguous",OBJ_NAME(dp));
		warn(ERROR_STRING);
		return(-1);
	}
	if( OBJ_N_MACH_ELTS(dp) < 6 ){
		sprintf(ERROR_STRING,"Object %s should have at least 6 elements",OBJ_NAME(dp));
		warn(ERROR_STRING);
		return(-1);
	}

	f_p = OBJ_DATA_PTR(dp);

	if( sscanf(s,"%s %f %f %f %f %f %f",str,
		f_p+0,
		f_p+1,
		f_p+2,
		f_p+3,
		f_p+4,
		f_p+5
		) != 7 ){
		sprintf(ERROR_STRING,"Error scanning polhemus data string");
		warn(ERROR_STRING);
		sprintf(ERROR_STRING,"String:  \"%s\"",show_printable(DEFAULT_QSP_ARG  s));
		advise(ERROR_STRING);
		return(-1);
	}
	return(0);
}
コード例 #9
0
ファイル: cluster.c プロジェクト: svn2github/exfat
cluster_t exfat_next_cluster(const struct exfat* ef,
		const struct exfat_node* node, cluster_t cluster)
{
	le32_t next;
	off_t fat_offset;

	if (cluster < EXFAT_FIRST_DATA_CLUSTER)
		exfat_bug("bad cluster 0x%x", cluster);

	if (IS_CONTIGUOUS(*node))
		return cluster + 1;
	fat_offset = s2o(ef, le32_to_cpu(ef->sb->fat_sector_start))
		+ cluster * sizeof(cluster_t);
	exfat_pread(ef->dev, &next, sizeof(next), fat_offset);
	return le32_to_cpu(next);
}
コード例 #10
0
void exfat_flush_node(struct exfat* ef, struct exfat_node* node)
{
    cluster_t cluster;
    off64_t offset;
    off64_t meta1_offset, meta2_offset;
    struct exfat_entry_meta1 meta1;
    struct exfat_entry_meta2 meta2;

    if (ef->ro)
        exfat_bug("unable to flush node to read-only FS");

    if (node->parent == NULL)
        return; /* do not flush unlinked node */

    cluster = node->entry_cluster;
    offset = node->entry_offset;
    meta1_offset = co2o(ef, cluster, offset);
    next_entry(ef, node->parent, &cluster, &offset);
    meta2_offset = co2o(ef, cluster, offset);

    exfat_read_raw(&meta1, sizeof(meta1), meta1_offset, ef->fd);
    if (meta1.type != EXFAT_ENTRY_FILE)
        exfat_bug("invalid type of meta1: 0x%hhx", meta1.type);
    meta1.attrib = cpu_to_le16(node->flags);
    exfat_unix2exfat(node->mtime, &meta1.mdate, &meta1.mtime, &meta1.mtime_cs);
    exfat_unix2exfat(node->atime, &meta1.adate, &meta1.atime, NULL);

    exfat_read_raw(&meta2, sizeof(meta2), meta2_offset, ef->fd);
    if (meta2.type != EXFAT_ENTRY_FILE_INFO)
        exfat_bug("invalid type of meta2: 0x%hhx", meta2.type);
    meta2.size = meta2.real_size = cpu_to_le64(node->size);
    meta2.start_cluster = cpu_to_le32(node->start_cluster);
    meta2.flags = EXFAT_FLAG_ALWAYS1;
    /* empty files must not be marked as contiguous */
    if (node->size != 0 && IS_CONTIGUOUS(*node))
        meta2.flags |= EXFAT_FLAG_CONTIGUOUS;
    /* name hash remains unchanged, no need to recalculate it */

    meta1.checksum = exfat_calc_checksum(&meta1, &meta2, node->name);

    exfat_write_raw(&meta1, sizeof(meta1), meta1_offset, ef->fd);
    exfat_write_raw(&meta2, sizeof(meta2), meta2_offset, ef->fd);

    node->flags &= ~EXFAT_ATTRIB_DIRTY;
}
コード例 #11
0
ファイル: cluster.c プロジェクト: daddy366/anarchy-exfat
cluster_t exfat_next_cluster(const struct exfat* ef,
		const struct exfat_node* node, cluster_t cluster)
{
	le32_t next;
	loff_t fat_offset;

	if (cluster < EXFAT_FIRST_DATA_CLUSTER)
		exfat_bug("bad cluster 0x%x", cluster);

	if (IS_CONTIGUOUS(*node))
		return cluster + 1;
	fat_offset = s2o(ef, le32_to_cpu(ef->sb->fat_sector_start))
		+ cluster * sizeof(cluster_t);
	/* FIXME handle I/O error */
	if (exfat_pread(ef->dev, &next, sizeof(next), fat_offset) < 0)
		exfat_bug("failed to read the next cluster after %#x", cluster);
	return le32_to_cpu(next);
}
コード例 #12
0
static int opendir(struct exfat* ef, const struct exfat_node* dir,
                   struct iterator* it)
{
    if (!(dir->flags & EXFAT_ATTRIB_DIR))
        exfat_bug("not a directory");
    it->cluster = dir->start_cluster;
    it->offset = 0;
    it->contiguous = IS_CONTIGUOUS(*dir);
    it->chunk = malloc(CLUSTER_SIZE(*ef->sb));
    if (it->chunk == NULL)
    {
        exfat_error("out of memory");
        return -ENOMEM;
    }
    exfat_read_raw(it->chunk, CLUSTER_SIZE(*ef->sb),
                   exfat_c2o(ef, it->cluster), ef->fd);
    return 0;
}
コード例 #13
0
static int fuse_exfat_readdir(const char* path, void* buffer,
		fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* fi)
{
	struct exfat_node* parent;
	struct exfat_node* node;
	struct exfat_iterator it;
	int rc;
	char name[UTF8_BYTES(EXFAT_NAME_MAX) + 1];

	exfat_debug("[%s] %s", __func__, path);

	rc = exfat_lookup(&ef, &parent, path);
	if (rc != 0)
		return rc;
	if (!(parent->flags & EXFAT_ATTRIB_DIR))
	{
		exfat_put_node(&ef, parent);
		exfat_error("'%s' is not a directory (0x%x)", path, parent->flags);
		return -ENOTDIR;
	}

	filler(buffer, ".", NULL, 0);
	filler(buffer, "..", NULL, 0);

	rc = exfat_opendir(&ef, parent, &it);
	if (rc != 0)
	{
		exfat_put_node(&ef, parent);
		exfat_error("failed to open directory '%s'", path);
		return rc;
	}
	while ((node = exfat_readdir(&ef, &it)))
	{
		exfat_get_name(node, name, sizeof(name) - 1);
		exfat_debug("[%s] %s: %s, %"PRId64" bytes, cluster 0x%x", __func__,
				name, IS_CONTIGUOUS(*node) ? "contiguous" : "fragmented",
				node->size, node->start_cluster);
		filler(buffer, name, NULL, 0);
		exfat_put_node(&ef, node);
	}
	exfat_closedir(&ef, &it);
	exfat_put_node(&ef, parent);
	return 0;
}
コード例 #14
0
ファイル: ascmenu.c プロジェクト: E-LLP/QuIP
static COMMAND_FUNC( do_read_str )
{
	Data_Obj *dp;
	const char *s;

	dp=PICK_OBJ("");
	s=NAMEOF("string");

	if( dp == NO_OBJ ) return;

	INSIST_RAM_OBJ(dp,"read_string")

#ifdef QUIP_DEBUG
//if( debug ) dptrace(dp);
#endif /* QUIP_DEBUG */

	if( ! IS_STRING(dp) ){
		sprintf(ERROR_STRING,"do_read_str:  object %s (%s) does not have string precision",
			OBJ_NAME(dp),OBJ_PREC_NAME(dp));
		WARN(ERROR_STRING);
		return;
	}

	if( (strlen(s)+1) > OBJ_COMPS(dp) ){
		sprintf(ERROR_STRING,
	"Type dimension (%d) of string object %s is too small for string of length %d",
			OBJ_COMPS(dp),OBJ_NAME(dp),(int)strlen(s));
		WARN(ERROR_STRING);
		return;
	}
	if( ! IS_CONTIGUOUS(dp) ){
		sprintf(ERROR_STRING,"Sorry, object %s must be contiguous for string reading",
			OBJ_NAME(dp));
		WARN(ERROR_STRING);
		return;
	}

	strcpy((char *)OBJ_DATA_PTR(dp),s);
}
コード例 #15
0
ファイル: acquire.c プロジェクト: nasa/QuIP
int good_polh_vector(QSP_ARG_DECL  Data_Obj *dp)
{
	int n_expected_words;

	/* The polhemus can output floats, but we'll assume it's all short here... */

	if( dp == NULL ) return(0);

	if( OBJ_PREC(dp) != PREC_IN && OBJ_PREC(dp) != PREC_UIN ) {
		sprintf(ERROR_STRING, "Object %s has %s precision, should be %s or %s for polhemus data",
			OBJ_NAME(dp), OBJ_PREC_NAME(dp), NAME_FOR_PREC_CODE(PREC_IN),
			NAME_FOR_PREC_CODE(PREC_UIN) );
		warn(ERROR_STRING);
		return(0);
	}

	if( n_active_stations == 2 )
		n_expected_words = station_info[0].sd_multi_prf.rf_n_words +
			station_info[1].sd_multi_prf.rf_n_words;
	else
		n_expected_words = station_info[curr_station_idx].sd_multi_prf.rf_n_words ;

	if( OBJ_COMPS(dp) != n_expected_words ) {
		sprintf(ERROR_STRING, "Object %s has bad type dimensions (%d), should be %d",
			OBJ_NAME(dp), OBJ_COMPS(dp), n_expected_words);
		warn(ERROR_STRING);
		return(0);
	}

	if( !IS_CONTIGUOUS(dp) ) {
		sprintf(ERROR_STRING, "good_polh_vector: Object %s must be contiguous", OBJ_NAME(dp));
		warn(ERROR_STRING);
		return(0);
	}
	return(1);
}
コード例 #16
0
ファイル: genlock.c プロジェクト: nasa/QuIP
static void test_parport(void)
{
	int n,s;
	Data_Obj *dp;
	u_long *lp;
	FB_Info *fbip;
	pthread_attr_t attr1;
	VBoard_Info vbi1;
	PPort_Info ppti1;
	u_long l;

	pthread_attr_init(&attr1);	/* initialize to default values */
	pthread_attr_setinheritsched(&attr1,PTHREAD_INHERIT_SCHED);


	fbip = pick_fbi("frame buffer for VSYNC");
	dp = pick_obj("data vector for latencies");

	if( fbip == NULL || dp == NULL ) return;

	INSIST_RAM_OBJ(dp,"test_parport")

	if( OBJ_PREC(dp) != PREC_UDI ){
		sprintf(ERROR_STRING,"latency vector %s (%s) should have precision %s",
			OBJ_NAME(dp),PREC_NAME(OBJ_PREC_PTR(dp)),
				NAME_FOR_PREC_CODE(PREC_UDI));
		WARN(ERROR_STRING);
		return;
	}

	if( OBJ_COMPS(dp) != 2 ){
		sprintf(ERROR_STRING,"latency vector %s (%d) should have 2 components",
			OBJ_NAME(dp),OBJ_COMPS(dp));
		WARN(ERROR_STRING);
		return;
	}

	if( ! IS_CONTIGUOUS(dp) ){
		sprintf(ERROR_STRING,"latency vector %s should be contiguous",OBJ_NAME(dp));
		WARN(ERROR_STRING);
		return;
	}

	n = OBJ_N_MACH_ELTS(dp)/2;
	lp = (u_long *) OBJ_DATA_PTR(dp);

	vbi1.vbi_fbip = fbip;
	vbi1.vbi_buf = lp;
	vbi1.vbi_count = n;
	vbi1.vbi_inc = 2;
#ifdef THREAD_SAFE_QUERY
	vbi1.vbi_qsp = THIS_QSP;
#endif // THREAD_SAFE_QUERY

	lp ++;

	if( the_ppp == NULL ){
		the_ppp=open_parport(NULL);	/* use default */
		if( the_ppp == NULL ) return;
	}

	ppti1.ppti_ppp = the_ppp;
	ppti1.ppti_buf = lp;
	ppti1.ppti_count = n;
	ppti1.ppti_inc = 2;

	tvp = NULL;				/* force re-zero */

	s=read_til_transition(the_ppp,8);
	if( s==0 )
		s=read_til_transition(the_ppp,8);
	/* should now be in the one state */
	/* this is the end of the (negative) pulse */

	l = delta_usecs();	/* zero the clock */

	pthread_create(&vboard_thr,&attr1,vboard_daemon,&vbi1);
	pthread_create(&pport_thr,&attr1,pport_logger,&ppti1);

	/* should wait for threads here... */
	if( pthread_join(vboard_thr,NULL) != 0 ){
		perror("pthread_join");
		WARN("error joining video board thread");
	}
	if( pthread_join(pport_thr,NULL) != 0 ){
		perror("pthread_join");
		WARN("error joining parallel port thread");
	}
}
コード例 #17
0
ファイル: ascmenu.c プロジェクト: E-LLP/QuIP
static Data_Obj *insure_ram_obj(QSP_ARG_DECL  Data_Obj *dp)
{
	Data_Obj *tmp_dp;
	char *tname;
	Data_Area *save_ap;
	Data_Obj *c_dp=NULL;

	if( OBJ_IS_RAM(dp) ) return dp;

	// This object lives on a different platform.
	// We create a copy in RAM, and download the data
	// using the platform download function.

	save_ap = curr_ap;
	curr_ap = ram_area_p;

	tname = getbuf( strlen(OBJ_NAME(dp)) + strlen(DNAME_PREFIX) + 1 );
	sprintf(tname,"%s%s",DNAME_PREFIX,OBJ_NAME(dp));
	tmp_dp = dup_obj(QSP_ARG  dp, tname);
	givbuf(tname);
	if( tmp_dp == NO_OBJ ){
		// This can happen if the object is subscripted,
		// as the bracket characters are illegal in names
		return NO_OBJ;
	}

	curr_ap = save_ap;

	// We can't download if the source data is not contiguous...
	//
	// We have a problem with bit precision, because the bits can
	// be non-contiguous when the long words are - any time the number of columns
	// is not evenly divided by the bits-per-word

	if( (! IS_CONTIGUOUS(dp)) && ! HAS_CONTIGUOUS_DATA(dp) ){
		Vec_Obj_Args oa1, *oap=&oa1;

advise("object is not contiguous, and does not have contiguous data...");
longlist(QSP_ARG  dp);
		save_ap = curr_ap;
		curr_ap = OBJ_AREA( dp );

		tname = getbuf( strlen(OBJ_NAME(dp)) + strlen(CNAME_PREFIX) + 1 );
		sprintf(tname,"%s%s",CNAME_PREFIX,OBJ_NAME(dp));
		c_dp = dup_obj(QSP_ARG  dp, tname );
		givbuf(tname);

		curr_ap = save_ap;

		// Now do the move...

		setvarg2(oap,c_dp,dp);
		if( IS_BITMAP(dp) ){
			SET_OA_SBM(oap,dp);
			SET_OA_SRC1(oap,NO_OBJ);
		}

		if( IS_REAL(dp) ) /* BUG case for QUAT too? */
			OA_ARGSTYPE(oap) = REAL_ARGS;
		else if( IS_COMPLEX(dp) ) /* BUG case for QUAT too? */
			OA_ARGSTYPE(oap) = COMPLEX_ARGS;
		else if( IS_QUAT(dp) ) /* BUG case for QUAT too? */
			OA_ARGSTYPE(oap) = QUATERNION_ARGS;
		else
			//ERROR1("CAUTIOUS:  insure_ram_obj:  bad argset type!?");
			assert( AERROR("insure_ram_obj:  bad argset type!?") );

//fprintf(stderr,"insure_ram_obj:  moving remote data to a contiguous object\n");  
		call_vfunc( QSP_ARG  FIND_VEC_FUNC(FVMOV), oap );
//fprintf(stderr,"insure_ram_obj:  DONE moving remote data to a contiguous object\n");  

		dp = c_dp;
	}

	gen_obj_dnload(QSP_ARG  tmp_dp, dp);

	if( c_dp != NO_OBJ )
		delvec(QSP_ARG  c_dp);

	// BUG - when to delete?
	// We try using the VOLATILE flag.  This will work as long as
	// the input object is not VOLATILE!?

	SET_OBJ_FLAG_BITS(tmp_dp, DT_VOLATILE ) ;

	return tmp_dp;
}
コード例 #18
0
ファイル: cuda_viewer.cpp プロジェクト: jbmulligan/quip
// This function allows us to do a different mapping of the image...
static void map_cuda_viewer(QSP_ARG_DECL  Cuda_Viewer *cvp,
				Data_Obj *img_dp, Data_Obj *coord_dp) 
{
	if( OBJ_PREC(coord_dp) != PREC_SP ){
		sprintf(ERROR_STRING,
	"map_cuda_viewer:  coord object %s must have %s precision!?",
			OBJ_NAME(coord_dp),PREC_NAME(OBJ_PREC_PTR(coord_dp)));
		WARN(ERROR_STRING);
		return;
	}
	if( ! IS_CONTIGUOUS(coord_dp) ){
		sprintf(ERROR_STRING,
	"map_cuda_viewer:  coord object %s must be contiguous!?",
			OBJ_NAME(coord_dp));
		WARN(ERROR_STRING);
		return;
	}
	if( OBJ_COMPS(coord_dp) != 2 ){
		sprintf(ERROR_STRING,
	"map_cuda_viewer:  coord object %s must have 2 components!?",
			OBJ_NAME(coord_dp));
		WARN(ERROR_STRING);
		return;
	}
	if( OBJ_COLS(coord_dp) != 2 ){
		sprintf(ERROR_STRING,
	"map_cuda_viewer:  coord object %s must have 2 columns!?",
			OBJ_NAME(coord_dp));
		WARN(ERROR_STRING);
		return;
	}
	if( OBJ_ROWS(coord_dp) != 2 ){
		sprintf(ERROR_STRING,
	"map_cuda_viewer:  coord object %s must have 2 rows!?",
			OBJ_NAME(coord_dp));
		WARN(ERROR_STRING);
		return;
	}

#ifdef HAVE_OPENGL
	float *f;

	prepare_image_for_mapping(img_dp);

	f=(float *)OBJ_DATA_PTR(coord_dp);

	glBegin(GL_QUADS);
fprintf(stderr,"first vertex at %f, %f (normally -1, -1)\n",f[0],f[1]);
	glTexCoord2f(0, 1); glVertex2f( f[0], f[1] );	// -1, -1
fprintf(stderr,"second vertex at %f, %f (normally -1,  1)\n",f[4],f[5]);
	glTexCoord2f(0, 0); glVertex2f( f[4], f[5] );	// -1,  1
fprintf(stderr,"third vertex at %f, %f (normally  1,  1)\n",f[6],f[7]);
	glTexCoord2f(1, 0); glVertex2f( f[6], f[7] );	//  1,  1
fprintf(stderr,"fourth vertex at %f, %f (normally  1, -1)\n",f[2],f[3]);
	glTexCoord2f(1, 1); glVertex2f( f[2], f[3] );	//  1, -1
	glEnd();
	glBindTexture(GL_TEXTURE_2D, 0);

	cuda_display_finish(QSP_ARG  img_dp);
#else // ! HAVE_OPENGL
	NO_OGL_MSG
#endif // ! HAVE_OPENGL
}