示例#1
0
AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
{
	int spdAddress;
	DEVTREE_CONST struct device *dev = dev_find_slot(0, PCI_DEVFN(0x18, 2));
	DEVTREE_CONST struct northbridge_amd_pi_00730F01_config *config = dev->chip_info;

	if ((dev == 0) || (config == 0))
		return AGESA_ERROR;

	if (info->SocketId     >= DIMENSION(config->spdAddrLookup      ))
		return AGESA_ERROR;
	if (info->MemChannelId >= DIMENSION(config->spdAddrLookup[0]   ))
		return AGESA_ERROR;
	if (info->DimmId       >= DIMENSION(config->spdAddrLookup[0][0]))
		return AGESA_ERROR;

	spdAddress = config->spdAddrLookup
		[info->SocketId] [info->MemChannelId] [info->DimmId];

	if (spdAddress == 0)
		return AGESA_ERROR;

	int err = hudson_readSpd(spdAddress, (void *) info->Buffer, 128);
	if (err)
		return AGESA_ERROR;
	return AGESA_SUCCESS;
}
示例#2
0
文件: dobj_menu.c 项目: nasa/QuIP
static COMMAND_FUNC( equivalence )
{
	const char *obj_name;
	Data_Obj *dp;
	Precision * prec_p;
	Dimension_Set ds1, *dsp=(&ds1);
	long ns,nf,nr,nc,nd;

	obj_name=NAMEOF("name for equivalent image");

	dp=pick_obj(PARENT_PROMPT);

	ns=(long) how_many("number of sequences");
	nf=(long) how_many("number of frames");
	nr=(long) how_many("number of rows");
	nc=(long) how_many("number of columns");
	nd=(long) how_many("number of components");

	prec_p = get_precision(SINGLE_QSP_ARG);

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

	INSIST_POSITIVE_DIM(ns,"sequence","equivalence")
	INSIST_POSITIVE_DIM(nf,"frame","equivalence")
	INSIST_POSITIVE_DIM(nr,"row","equivalence")
	INSIST_POSITIVE_DIM(nc,"column","equivalence")
	INSIST_POSITIVE_DIM(nd,"component","equivalence")

	SET_DIMENSION(dsp,4,ns);
	SET_DIMENSION(dsp,3,nf);
	SET_DIMENSION(dsp,2,nr);
	SET_DIMENSION(dsp,1,nc);
	SET_DIMENSION(dsp,0,nd);

	if( COMPLEX_PRECISION(PREC_CODE(prec_p)) ){
		if( DIMENSION(dsp,0) != 1 ){
			warn("Sorry, can only have 1 complex component");
			return;
		}
		//SET_DIMENSION(dsp,0,2);
	} else if( QUAT_PRECISION(PREC_CODE(prec_p)) ){
		if( DIMENSION(dsp,0) != 1 ){
			warn("Sorry, can only have 1 quaternion component");
			return;
		}
		//SET_DIMENSION(dsp,0,2);
	} else if( COLOR_PRECISION(PREC_CODE(prec_p)) ){
		if( DIMENSION(dsp,0) != 1 ){
			warn("Sorry, can only have 1 color triple per pixel");
			return;
		}
advise("component dim 3 for color");
		//SET_DIMENSION(dsp,0,3);
	}

	if( make_equivalence(obj_name,dp,dsp,prec_p) == NULL )
		warn("error making equivalence");
}
示例#3
0
文件: cuda.cpp 项目: jbmulligan/quip
int _setup_slow_len(QSP_ARG_DECL  dim3 *len_p,Size_Info *szi_p,dimension_t start_dim,int *dim_indices,int i_first,int n_vec)
{
	int i_dim;
	dimension_t max_d;
	int n_set=0;

	for(i_dim=start_dim;i_dim<N_DIMENSIONS;i_dim++){
		int i_src;

		/* Find the max len of all the objects at this level */
		max_d=DIMENSION(SZI_DST_DIMS(*szi_p),i_dim);
		for(i_src=i_first;i_src<(i_first+n_vec-1);i_src++)
			max_d=MAXD(max_d,DIMENSION(SZI_SRC_DIMS(*szi_p,i_src),i_dim));

		if( max_d > 1 ){
			if( n_set == 0 ){
				len_p->x = max_d;
				dim_indices[n_set] = i_dim;
				n_set ++;
			} else if ( n_set == 1 ){
				len_p->y = max_d;
				dim_indices[n_set] = i_dim;
				n_set ++;
			} else if( n_set == 2 ){
	/* CUDA compute capability 1.3 and below can't use 3-D grids; So here
	 * we need to conditionally complain if the number set is 3.
	 */
#if CUDA_COMP_CAP >= 20
				len_p->z = max_d;
				dim_indices[n_set] = i_dim;
				n_set ++;
#else /* CUDA_COMP_CAP < 20 */
				warn("Sorry, CUDA compute capability >= 2.0 required for 3-D array operations");
				return(-1);
#endif /* CUDA_COMP_CAP < 20 */
			} else {
				warn("Too many CUDA dimensions requested.");
				return(-1);
			}
		}
	}
	if( n_set == 0 ){
		len_p->x = len_p->y = len_p->z = 1;
		dim_indices[0] = dim_indices[1] = dim_indices[2] = (-1);
	} else if( n_set == 1 ){
		len_p->y = len_p->z = 1;
		dim_indices[1] = dim_indices[2] = (-1);
	} else if( n_set == 2 ){
		len_p->z = 1;
		dim_indices[2] = (-1);
	}
	return(n_set);
}
示例#4
0
static void stpui_spin_changed(GtkWidget *w,gpointer *ud)
{
	stpui_Slider *s=STPUI_SLIDER(ud);
	double value;
	
	switch(s->type)
	{
		case STP_PARAMETER_TYPE_DOUBLE:
			value=gtk_spin_button_get_value(GTK_SPIN_BUTTON(s->spin));
			stp_set_float_parameter(s->vars,s->optionname,value);
			break;
		case STP_PARAMETER_TYPE_INT:
			value=gtk_spin_button_get_value(GTK_SPIN_BUTTON(s->spin));
			stp_set_int_parameter(s->vars,s->optionname,value);
			break;
		case STP_PARAMETER_TYPE_DIMENSION:
			value=dimension_get_pt(DIMENSION(s->spin));
			stp_set_dimension_parameter(s->vars,s->optionname,value);
			break;
		default:
			break;
	}	

	stpui_slider_refresh(s);

//	g_signal_emit(G_OBJECT (s),
//		stpui_slider_signals[CHANGED_SIGNAL], 0);
}
示例#5
0
AGESA_STATUS
AmdMemoryReadSPD (
  IN UINT32 Func,
  IN UINT32 Data,
  IN OUT AGESA_READ_SPD_PARAMS *SpdData
  )
{
   UINT8  SmBusAddress = 0;
   UINTN  Index;
   UINTN  MaxSocket = DIMENSION (SpdAddrLookup);
   for (Index = 0; Index < MaxSocket; Index ++){
     if ((SpdData->SocketId     == SpdAddrLookup[Index].SocketId)     &&
         (SpdData->MemChannelId == SpdAddrLookup[Index].MemChannelId) &&
         (SpdData->DimmId       == SpdAddrLookup[Index].DimmId)) {
        SmBusAddress = SpdAddrLookup[Index].SmbusAddress;
        break;
      }
   }

	if (SmBusAddress == 0)
		return AGESA_ERROR;

	int err = smbus_readSpd(SmBusAddress, (char *) SpdData->Buffer, 128);
	if (err)
		return AGESA_ERROR;
	return AGESA_SUCCESS;
}
示例#6
0
static void tmargin_changed(GtkWidget *wid,gpointer *ob)
{
	pp_PageExtent *lo=(pp_PageExtent *)ob;
	PageExtent *pe=lo->pe;
	Dimension *d=DIMENSION(lo->tmargin);
	int v=int(dimension_get_pt(d));
	pe->SetMargins(pe->leftmargin,pe->rightmargin,v,pe->bottommargin);
	g_signal_emit(G_OBJECT (ob),pp_pageextent_signals[CHANGED_SIGNAL], 0);
}
示例#7
0
static void setcustomsizewidgets(pp_PageExtent *lo)
{
	lo->blocksignals=true;
	GPrinter *p=&lo->state->printer;
	int nw=0,mw=0,nh=0,mh=0;
	Debug[TRACE] << "Getting size limits..." << endl;
	p->GetSizeLimits(nw,mw,nh,mh);
	Debug[TRACE] << "Comparing min and max width:" << endl;
	if(nw==mw)
	{
		Debug[TRACE] << "No width adjustment possible..." << endl;
		gtk_widget_hide(lo->customwidth);
		gtk_widget_hide(lo->customwidthlabel);
	}
	else
	{
		Debug[TRACE] << "Allowing width adjustment..." << endl;
		gtk_widget_show(lo->customwidth);
		gtk_widget_show(lo->customwidthlabel);
		Debug[TRACE] << "Setting range to :" << nw << " -> " << mw << endl;
		dimension_set_range_pt(DIMENSION(lo->customwidth),nw,mw);
		dimension_set_pt(DIMENSION(lo->customwidth),p->pagewidth);
	}

	Debug[TRACE] << "Comparing min and max height:" << endl;
	if(nh==mh)
	{
		Debug[TRACE] << "No height adjustment possible..." << endl;
		gtk_widget_hide(lo->customheight);
		gtk_widget_hide(lo->customheightlabel);
	}
	else
	{
		Debug[TRACE] << "Allowing height adjustment..." << endl;
		gtk_widget_show(lo->customheight);
		gtk_widget_show(lo->customheightlabel);
		Debug[TRACE] << "Setting range to :" << nh << " -> " << mh << endl;
		dimension_set_range_pt(DIMENSION(lo->customheight),nh,mh);
		dimension_set_pt(DIMENSION(lo->customheight),p->pageheight);
	}
	lo->blocksignals=false;
}
示例#8
0
AGESA_STATUS
AmdMemoryReadSPD (
		IN UINT32 Func,
		IN UINT32 Data,
		IN OUT AGESA_READ_SPD_PARAMS *SpdData
		)
{
	AGESA_STATUS Status;
	UINT8  SmBusAddress = 0;
	UINTN  Index;
	UINTN  MaxSocket = DIMENSION (SpdAddrLookup);

	for (Index = 0; Index < MaxSocket; Index ++){
		if ((SpdData->SocketId     == SpdAddrLookup[Index].SocketId)     &&
				(SpdData->MemChannelId == SpdAddrLookup[Index].MemChannelId) &&
				(SpdData->DimmId       == SpdAddrLookup[Index].DimmId)) {
			SmBusAddress = SpdAddrLookup[Index].SmbusAddress;
			break;
		}
	}


	if (SmBusAddress == 0) return AGESA_ERROR;

	SetupFch (SMBUS_BASE_ADDR);

	Status = WriteSmbusByteData (SMBUS_BASE_ADDR, LTC4305_SMBUS_ADDR, 0x80, 0x03);

	switch (SpdData->SocketId) {
		case 0:
			/* Switch onto the  First CPU Socket SMBUS */
			WriteSmbusByteData (SMBUS_BASE_ADDR, LTC4305_SMBUS_ADDR, 0x80, 0x03);
			break;
		case 1:
			/* Switch onto the  Second CPU Socket SMBUS */
			WriteSmbusByteData (SMBUS_BASE_ADDR, LTC4305_SMBUS_ADDR, 0x40, 0x03);
			break;
		default:
			/* Switch off two CPU Sockets SMBUS */
			WriteSmbusByteData (SMBUS_BASE_ADDR, LTC4305_SMBUS_ADDR, 0x00, 0x03);
			break;
	}
	Status =  ReadSpd (SMBUS_BASE_ADDR, SmBusAddress, SpdData->Buffer, 256);

	/*Output SPD Debug Message*/
	printk(BIOS_EMERG, "file '%s',line %d, %s()\n", __FILE__, __LINE__, __func__);
	printk(BIOS_DEBUG, " Status = %d\n",Status);
	printk(BIOS_DEBUG, "SocketId MemChannelId SpdData->DimmId SmBusAddress Buffer\n");
	printk(BIOS_DEBUG, "%x, %x, %x, %x, %x\n", SpdData->SocketId, SpdData->MemChannelId, SpdData->DimmId, SmBusAddress, SpdData->Buffer);

	/* Switch off two CPU Sockets SMBUS */
	WriteSmbusByteData (SMBUS_BASE_ADDR, LTC4305_SMBUS_ADDR, 0x00, 0x03);
	return Status;
}
示例#9
0
static void customheight_changed(GtkWidget *wid,gpointer *ob)
{
	pp_PageExtent *lo=(pp_PageExtent *)ob;
	if(lo->blocksignals)
		return;
	Dimension *d=DIMENSION(lo->customheight);
	int v=int(dimension_get_pt(d));
	Debug[TRACE] << "Setting custom height to " << v << endl;
	lo->state->printer.SetCustomHeight(v);
	lo->state->layout->UpdatePageSize();
	pp_pageextent_refresh(lo);
	g_signal_emit(G_OBJECT (ob),pp_pageextent_signals[CHANGED_SIGNAL], 0);
}
示例#10
0
void pp_pageextent_set_unit(pp_PageExtent *ob,enum Units unit)
{
	dimension_set_unit(DIMENSION(ob->lmargin),unit);
	dimension_set_unit(DIMENSION(ob->rmargin),unit);
	dimension_set_unit(DIMENSION(ob->tmargin),unit);
	dimension_set_unit(DIMENSION(ob->bmargin),unit);
	dimension_set_unit(DIMENSION(ob->customwidth),unit);
	dimension_set_unit(DIMENSION(ob->customheight),unit);
}
示例#11
0
void e820_info(void)
{
  unsigned long long e820_start;
  unsigned long long e820_end;
  char e820_type[256];
  unsigned int e820_index = 0;
  FILE *e820_handle;
  char szline[256];
  char szfilename[256];

  for(;;)
  {
    //Open /sys/firmware/memmap/#/start
    snprintf(szfilename, DIMENSION(szfilename), "/sys/firmware/memmap/%d/start", e820_index);
    e820_handle = fopen(szfilename, "rb");
    if (e820_handle != NULL)
    {
      fgets(szline, DIMENSION(szline), e820_handle);
      sscanf(szline, "%llX", &e820_start);
      fclose(e820_handle);
    }
    else
    {
      break;
    }

    //Open /sys/firmware/memmap/#/end
    snprintf(szfilename, DIMENSION(szfilename), "/sys/firmware/memmap/%d/end", e820_index);
    e820_handle = fopen(szfilename, "rb");
    if (e820_handle != NULL)
    {
      fgets(szline, DIMENSION(szline), e820_handle);
      sscanf(szline, "%llX", &e820_end);
      fclose(e820_handle);
    }
    else
    {
      break;
    }
    
    //Open /sys/firmware/memmap/#/type
    snprintf(szfilename, DIMENSION(szfilename), "/sys/firmware/memmap/%d/type", e820_index);
    e820_handle = fopen(szfilename, "rb");
    if (e820_handle != NULL)
    {
      fgets(e820_type, DIMENSION(szline), e820_handle);
      fclose(e820_handle);
    }
    else
    {
      break;
    }

    printf("%d: START 0x%llX, END 0x%llX, TYPE %s\n", e820_index, e820_start, e820_end, e820_type);
    e820_index++;
  }
}
示例#12
0
static int32_t qb_validate_operands_blend(qb_compiler_context *cxt, qb_op_factory *f, qb_primitive_type expr_type, uint32_t flags, qb_operand *operands, uint32_t operand_count, qb_result_destination *result_destination) {
	qb_operand *operand1 = &operands[0];

	if(HAS_CONSTANT_DIMENSION(operand1->address, -1)) {
		uint32_t channel_count = DIMENSION(operand1->address, -1);
		if(channel_count != 2 && channel_count != 4) {
			qb_report_missing_alpha_channel_exception(cxt->line_id, cxt->intrinsic_function, channel_count);
			return FALSE;
		}
	} else {
		qb_report_variable_pixel_width_exception(cxt->line_id, cxt->intrinsic_function);
		return FALSE;
	}
	return TRUE;
}
示例#13
0
文件: dobj_menu.c 项目: nasa/QuIP
static void _finish_obj(QSP_ARG_DECL  const char *obj_name, Dimension_Set *dsp, Precision *prec_p, uint32_t type_flag)
{
	assert(prec_p!=NULL);

	if( COLOR_PRECISION(PREC_CODE(prec_p)) ){
		if( DIMENSION(dsp,0) != 1 ){
			sprintf(ERROR_STRING,"object %s, number of rgb triples per pixel should be 1",obj_name);
			warn(ERROR_STRING);
		}
		SET_DIMENSION(dsp,0,3);
		prec_p = get_prec("float");
	}

	if( make_dobj_with_shape(obj_name,dsp,prec_p,type_flag) == NULL ) {
		sprintf(ERROR_STRING,"couldn't create data object \"%s\"", obj_name);
		warn(ERROR_STRING);
	}
}
示例#14
0
void pp_pageextent_refresh(pp_PageExtent *ob)
{
	ob->blocksignals=true;
	dimension_set_pt(DIMENSION(ob->lmargin),ob->pe->leftmargin);
	dimension_set_pt(DIMENSION(ob->rmargin),ob->pe->rightmargin);
	dimension_set_pt(DIMENSION(ob->tmargin),ob->pe->topmargin);
	dimension_set_pt(DIMENSION(ob->bmargin),ob->pe->bottommargin);
	dimension_set_pt(DIMENSION(ob->customwidth),ob->pe->pagewidth);
	dimension_set_pt(DIMENSION(ob->customheight),ob->pe->pageheight);

	stpui_combo_refresh(STPUI_COMBO(ob->pagesize));
	ob->blocksignals=false;
}
示例#15
0
static int32_t qb_validate_operands_sampling(qb_compiler_context *cxt, qb_op_factory *f, qb_primitive_type expr_type, uint32_t flags, qb_operand *operands, uint32_t operand_count, qb_result_destination *result_destination) {
	qb_operand *image = &operands[0];
	uint32_t channel_count = 0;

	if(image->address->dimension_count != 3) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "three-dimensional array");
	}
	if(HAS_CONSTANT_DIMENSION(image->address, -1)) {
		channel_count = DIMENSION(image->address, -1);
	}
	if(!(1 <= channel_count && channel_count <= 4)) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "array whose last dimension is between 1 and 4");
		return FALSE;
	}
	if(!(image->address->type >= QB_TYPE_F32)) {
		qb_report_unmet_intrinsic_condition_exception(cxt->line_id, cxt->intrinsic_function, "array in floating-point representation");
		return FALSE;
	}
	return TRUE;
}
示例#16
0
文件: pword.c 项目: mingpen/OpenNT
/*
 * Name: 	LUI_ParseWeekDay
 *			Takes a string and parses it for a week day
 * Args:	PTCHAR inbuf - string to parse
 *		PUSHORT answer - set to 0-6, if inbuf is a weekday,
 *				 undefined otherwise.
 * Returns:	0 if ok,
 *		ERROR_INVALID_PARAMETER or NERR_InternalError otherwise.
 * Globals: 	(none)
 * Statics:	(none)
 * Remarks:	
 * Updates:	(none)
 */
USHORT
LUI_ParseWeekDay(
    PTCHAR inbuf,
    PUSHORT answer
    )
{
    TCHAR buffer[256] ;
    USHORT bytesread ;
    SHORT result ;

    if ( inbuf == NULL || inbuf[0] == NULLC)
	return(ERROR_INVALID_PARAMETER) ;
    if (ILUI_setup_listW(buffer, DIMENSION(buffer), 2, &bytesread,
			week_data,week_list))
	return(NERR_InternalError) ;
    if ( ILUI_traverse_slistW(inbuf, week_list, &result) )
	return(ERROR_INVALID_PARAMETER) ;
    *answer = result ;
    return(0) ;
}
示例#17
0
文件: pword.c 项目: mingpen/OpenNT
/*
 * Name: 	LUI_ParseYesNo
 *			Takes a string and parses it for YES or NO.
 * Args:	PTCHAR inbuf - string to parse
 *		PUSHORT answer - set to LUI_YES_VAL or LUI_NO_VAL
 *			if inbuf matches YES/NO, undefined otherwise.
 * Returns:	0 if ok,
 *		ERROR_INVALID_PARAMETER or NERR_InternalError otherwise.
 * Globals: 	yesno_data, yesno_list
 * Statics:	(none)
 * Remarks:	
 * Updates:	(none)
 */
USHORT
LUI_ParseYesNo(
    PTCHAR inbuf,
    PUSHORT answer
    )
{
    TCHAR buffer[128] ;
    USHORT bytesread ;
    SHORT result ;
    USHORT err ;

    if ( inbuf == NULL || inbuf[0] == NULLC)
	    return(ERROR_INVALID_PARAMETER) ;
    if (err=ILUI_setup_listW(buffer, DIMENSION(buffer), 2,
			&bytesread, yesno_data, yesno_list))
    {
	    return(err) ;
    }
    if ( ILUI_traverse_slistW(inbuf, yesno_list, &result) )
    {
        if (!stricmpf(inbuf, 
                      &swtxt_SW_YES[1]))
        {
            *answer = LUI_YES_VAL ;
            return(0) ;
        }
        else if (!stricmpf(inbuf, 
                           &swtxt_SW_NO[1]))
        {
            *answer = LUI_NO_VAL ;
            return(0) ;
        }
        else
        {
	        return(ERROR_INVALID_PARAMETER) ;
        }
    }
    *answer = result ;
    return(0) ;
}
示例#18
0
int _setup_slow_len(	QSP_ARG_DECL
			Vector_Args *vap,
			dimension_t start_dim,	// 0, or 1 for complex?
			int i_first,		// index of first source vector
			int n_vec,		// number of source vectors
			Platform_Device *pdp )
{
	int i_dim;
	dimension_t max_d;
#ifdef FOOBAR
	int n_set=0;
#endif // FOOBAR

	SET_VA_ITERATION_TOTAL(vap,1);
	for(i_dim=0;i_dim<start_dim;i_dim++)
		SET_VA_SLOW_SIZE_DIM(vap,i_dim,1);

	for(i_dim=start_dim;i_dim<N_DIMENSIONS;i_dim++){
		int i_src;

		/* Find the max len of all the objects at this level */
		max_d=DIMENSION(VA_DEST_DIMSET(vap),i_dim);
		for(i_src=i_first;i_src<(i_first+n_vec-1);i_src++){
			max_d=MAXD(max_d,
				DIMENSION(VARG_DIMSET(VA_SRC(vap,i_src)),i_dim));
//fprintf(stderr,"setup_slow_len:  i_dim = %d, i_src = %d, max_d = %d\n",i_dim,i_src,max_d);
		}
		SET_VA_SLOW_SIZE_DIM(vap,i_dim,max_d);

#ifdef FOOBAR
		if( max_d > 1 ){
			if( n_set == 0 ){
				SET_VA_LEN_X(vap,max_d);
				SET_VA_DIM_INDEX(vap,n_set,i_dim);
				n_set ++;
			} else if ( n_set == 1 ){
				SET_VA_LEN_Y(vap,max_d);
				SET_VA_DIM_INDEX(vap,n_set,i_dim);
				n_set ++;
			} else if( n_set == 2 ){
	/* CUDA compute capability 1.3 and below can't use 3-D grids; So here
	 * we need to conditionally complain if the number set is 3.
	 */
				if( PFDEV_MAX_DIMS(pdp) == 2 ){
warn("Sorry, CUDA compute capability >= 2.0 required for 3-D array operations");
					return(-1);
				}
				SET_VA_LEN_Z(vap,max_d);
				SET_VA_DIM_INDEX(vap,n_set,i_dim);
				n_set ++;
			} else {
				warn("setup_slow_len:  Too many dimensions requested.");
				return(-1);
			}
		}
#endif // FOOBAR
		//SET_VA_ITERATION_COUNT(vap,i_dim,max_d);
		SET_VA_ITERATION_TOTAL(vap,VA_ITERATION_TOTAL(vap)*max_d);
	}
#ifdef FOOBAR
//fprintf(stderr,"setup_slow_len:  n_set = %d\n",n_set);
	if( n_set == 0 ){
		SET_VA_LEN_X(vap,1);
		SET_VA_LEN_Y(vap,1);
		SET_VA_LEN_Z(vap,1);
		SET_VA_DIM_INDEX(vap,0,(-1));
		SET_VA_DIM_INDEX(vap,1,(-1));
		SET_VA_DIM_INDEX(vap,2,(-1));
	} else if( n_set == 1 ){
		SET_VA_LEN_Y(vap,1);
		SET_VA_LEN_Z(vap,1);
		SET_VA_DIM_INDEX(vap,1,(-1));
		SET_VA_DIM_INDEX(vap,2,(-1));
	} else if( n_set == 2 ){
		SET_VA_LEN_Z(vap,1);
		SET_VA_DIM_INDEX(vap,2,(-1));
	}
	return(n_set);
#endif // FOOBAR
	return 1;
}
示例#19
0
文件: listmem.c 项目: mingpen/OpenNT
USHORT
LUI_ListMember(
    PTCHAR server,
    PTCHAR item,
    PTCHAR list,
    ULONG listType,
    PUSHORT member)
{
    TCHAR  tmpList[MAXPATHLEN];    /* temporary list buf         */
    LPTSTR listPtr;                /* ptr into tmp list          */
    LPTSTR element;                /* ptr to element in tmp list */
    ULONG types[64];               /* types for I_NetListCan     */
    ULONG canonFlags;              /* flags for I_NetListCan     */
    ULONG count;                   /* num elements in each list  */
    ULONG err;                     /* API return value           */
    ULONG result;                  /* result from I_NetObjCmp    */

    // Map to portable type.

    canonFlags = (listType | OUTLIST_TYPE_NULL_NULL |
                    INLC_FLAGS_MULTIPLE_DELIMITERS);

    /* first place list in null-null form for comparison */
    if (err = I_NetListCanonicalize(server,
                                    list,
                                    MY_LIST_DELIMITER_STR_UI,
                                    tmpList,
                                    DIMENSION(tmpList),
                                    &count,
                                    types,
                                    DIMENSION(types),
                                    canonFlags) )
    {
            return(LOWORD(err));
    }

    listPtr = tmpList;

    /* look for similar element in second list */
    while (element = I_NelistTraverse(NULL, &listPtr, 0L))
    {
        if (listType == NAMETYPE_PATH)
        {
            /* use PathCompare function */
            result = I_NetPathCompare(server,
                                      item,
                                      element,
                                      (ULONG) NULL,
                                      0L);
        }
        else
        {
            /* use NameCompare function */
            result = I_NetNameCompare(server,
                                      item,
                                      element,
                                      (USHORT) listType,
                                      0L);
        }
        if (!result)     /* found a match */
        {
            (*member) = TRUE;
            return NERR_Success; /* save time, break out of loop */
        }
    }
    /* match was NOT found */
    (*member) = FALSE;
    return NERR_Success;
}
示例#20
0
GtkWidget*
stpui_slider_new (stp_vars_t *vars,const char *optname,GtkWidget *checkbutton)
{
	stp_parameter_t desc;
	double step=1.0;
	stpui_Slider *c=STPUI_SLIDER(g_object_new (stpui_slider_get_type (), NULL));
	gboolean active=FALSE;

	c->vars=vars;
	c->optionname=optname;
	c->checkbutton=NULL;
	c->label=NULL;
	if(GTK_IS_CHECK_BUTTON(checkbutton))
		c->checkbutton=GTK_CHECK_BUTTON(checkbutton);
	else
		c->label=checkbutton;

	stp_describe_parameter(c->vars,c->optionname,&desc);
	c->type=desc.p_type;

	switch(c->type)
	{
		case STP_PARAMETER_TYPE_DOUBLE:
			active=stp_check_float_parameter(c->vars,c->optionname,STP_PARAMETER_DEFAULTED);
			step=0.01;
			break;
		case STP_PARAMETER_TYPE_INT:
			active=stp_check_int_parameter(c->vars,c->optionname,STP_PARAMETER_DEFAULTED);
			step=1.0;
			break;
		case STP_PARAMETER_TYPE_DIMENSION:
			active=stp_check_dimension_parameter(c->vars,c->optionname,STP_PARAMETER_DEFAULTED);
			step=1.0;
			break;
		default:
			break;
	}
	stp_parameter_description_destroy(&desc);

	if(c->checkbutton)
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c->checkbutton),active);
		g_signal_connect(G_OBJECT(c->checkbutton),"toggled",G_CALLBACK(stpui_toggle_changed),c);
	}

	c->scale=gtk_hscale_new_with_range(0,1.0,step);
	gtk_scale_set_draw_value(GTK_SCALE(c->scale),FALSE);
	
	switch(desc.p_type)
	{
		case STP_PARAMETER_TYPE_DOUBLE:
		case STP_PARAMETER_TYPE_INT:
			c->spin=gtk_spin_button_new_with_range(0,1.0,step);
			break;
		case STP_PARAMETER_TYPE_DIMENSION:
			c->spin=dimension_new(0,1.0,UNIT_POINTS);
			dimension_show_unit(DIMENSION(c->spin));
			break;
		default:
			break;
	}
	
	g_signal_connect(GTK_WIDGET(c->scale),"button-release-event",G_CALLBACK(stpui_slider_released),c);
	g_signal_connect(GTK_WIDGET(c->spin),"button-release-event",G_CALLBACK(stpui_spin_released),c);
	g_signal_connect(GTK_WIDGET(c->scale),"value-changed",G_CALLBACK(stpui_slider_changed),c);
	g_signal_connect(GTK_WIDGET(c->spin),"value-changed",G_CALLBACK(stpui_spin_changed),c);

	stpui_slider_refresh(c);

	gtk_box_pack_start(GTK_BOX(c),GTK_WIDGET(c->scale),TRUE,TRUE,0);
	gtk_widget_show(c->scale);

	gtk_box_pack_start(GTK_BOX(c),GTK_WIDGET(c->spin),FALSE,TRUE,0);
	gtk_widget_show(c->spin);
	
	return(GTK_WIDGET(c));
}
示例#21
0
文件: size.c 项目: E-LLP/QuIP
static int change_size(QSP_ARG_DECL  Data_Obj *dst_dp,Data_Obj *src_dp )
{
	Dimension_Set ef, *enlargement_factor=&ef;
	Dimension_Set rf, *reduction_factor=&rf;
	Vec_Obj_Args oa1, *oap=&oa1;
	Dimension_Set size_ds, n_ds;
	Dimension_Set *size_dsp=(&size_ds), *n_dsp=(&n_ds);
	Data_Obj *src_ss_dp, *dst_ss_dp;
	dimension_t i,j,k,l,m;
	index_t offsets[N_DIMENSIONS]={0,0,0,0,0};
	incr_t dst_incrs[N_DIMENSIONS], src_incrs[N_DIMENSIONS];
	index_t dst_indices[N_DIMENSIONS]={0,0,0,0,0}, src_indices[N_DIMENSIONS]={0,0,0,0,0};

	/* For simplicity, we don't allow size changes to be combined with conversions */

	if( !dp_same_prec(QSP_ARG  dst_dp,src_dp,"change_size") )
		return(-1);

	for(i=0;i<N_DIMENSIONS;i++){
		if( OBJ_TYPE_DIM(dst_dp,i) > OBJ_TYPE_DIM(src_dp,i) ){
			/* enlargement - subsample the destination */
			SET_DIMENSION(enlargement_factor,i,
				floor( OBJ_TYPE_DIM(dst_dp,i) / OBJ_TYPE_DIM(src_dp,i) ) );
			SET_DIMENSION(reduction_factor,i, 0);

			SET_DIMENSION(size_dsp,i, OBJ_TYPE_DIM(src_dp,i) );
			SET_DIMENSION(n_dsp,i, DIMENSION(enlargement_factor,i) );
			dst_incrs[i] = DIMENSION(n_dsp,i);
			src_incrs[i] = 1;
		} else {
			/* reduction - subsample the source */
			SET_DIMENSION(reduction_factor,i,
				ceil( OBJ_TYPE_DIM(src_dp,i) / OBJ_TYPE_DIM(dst_dp,i) ) );
			SET_DIMENSION(enlargement_factor,i, 0 );

			SET_DIMENSION(size_dsp,i, floor( OBJ_TYPE_DIM(src_dp,i) /
				DIMENSION(reduction_factor,i) ) );
			/* We don't need to do this multiple times, just pick one and do it */
			/*SET_DIMENSION(n_dsp,i, DIMENSION(reduction_factor,i) ); */
			SET_DIMENSION(n_dsp,i, 1);
			src_incrs[i] = DIMENSION(reduction_factor,i);
			dst_incrs[i] = 1;
		}
	}
	/* make the subsamples.
	 * the column increment is expressed in columns, etc.
	 */
	dst_ss_dp=make_subsamp(QSP_ARG  "chngsize_dst_obj",dst_dp,size_dsp,offsets,dst_incrs);
	src_ss_dp=make_subsamp(QSP_ARG  "chngsize_src_obj",src_dp,size_dsp,offsets,src_incrs);

	clear_obj_args(oap);
	SET_OA_DEST(oap,dst_ss_dp);
	SET_OA_SRC_OBJ(oap,0, src_ss_dp);
	SET_OA_ARGSTYPE(oap, REAL_ARGS);
	SET_OA_PFDEV(oap,OBJ_PFDEV(dst_dp));

	for(i=0;i<DIMENSION(n_dsp,4);i++){		/* foreach sequence to copy */
		if( dst_incrs[4] > 1 )
			dst_indices[4]=i;
		else	src_indices[4]=i;
		for(j=0;j<DIMENSION(n_dsp,3);j++){	/* foreach frame to copy */
			if( dst_incrs[3] > 1 )
				dst_indices[3]=j;
			else	src_indices[3]=j;
			for(k=0;k<DIMENSION(n_dsp,2);k++){	/* foreach row */
				if( dst_incrs[2] > 1 )
					dst_indices[2]=k;
				else	src_indices[2]=k;
				for(l=0;l<DIMENSION(n_dsp,1);l++){	/* foreach col */
					if( dst_incrs[1] > 1 )
						dst_indices[1]=l;
					else	src_indices[1]=l;
					for(m=0;m<DIMENSION(n_dsp,0);m++){ /* foreach comp */
						if( dst_incrs[0] > 1 )
							dst_indices[0]=m;
						else	src_indices[0]=m;
						/* relocate the appropriate subsample */
						SET_OBJ_DATA_PTR(dst_ss_dp, multiply_indexed_data(dst_dp,dst_indices) );
						SET_OBJ_DATA_PTR(src_ss_dp, multiply_indexed_data(src_dp,src_indices) );

						// This doesn't check for cuda obj...
						//vmov(oap);
						perf_vfunc(QSP_ARG  FVMOV, oap );
					}
				}
			}
		}
	}
	delvec(QSP_ARG  dst_ss_dp);
	delvec(QSP_ARG  src_ss_dp);

	SET_OBJ_FLAG_BITS(dst_dp, DT_ASSIGNED);

	return(0);
}
示例#22
0
static gboolean stpui_slider_update(stpui_Slider *c)
{
	stp_parameter_t desc;
	gboolean result;

	gboolean enabled=TRUE;

	if(c->checkbutton)
		enabled=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->checkbutton));

	stp_describe_parameter(c->vars,c->optionname,&desc);
	if(desc.is_active)
	{
		switch(desc.p_type)
		{
			case STP_PARAMETER_TYPE_DOUBLE:
				{
					double min,max,current;
					min=desc.bounds.dbl.lower;
					max=desc.bounds.dbl.upper;
					current=stp_get_float_parameter(c->vars,c->optionname);
					gtk_range_set_range(GTK_RANGE(c->scale),min,max);
					gtk_range_set_value(GTK_RANGE(c->scale),current);
					gtk_spin_button_set_range(GTK_SPIN_BUTTON(c->spin),min,max);
					gtk_spin_button_set_value(GTK_SPIN_BUTTON(c->spin),current);
					break;
				}
			case STP_PARAMETER_TYPE_INT:
				{
					int min,max,current;
					min=desc.bounds.integer.lower;
					max=desc.bounds.integer.upper;
					current=stp_get_int_parameter(c->vars,c->optionname);
					gtk_range_set_range(GTK_RANGE(c->scale),min,max);
					gtk_range_set_value(GTK_RANGE(c->scale),current);
					gtk_spin_button_set_range(GTK_SPIN_BUTTON(c->spin),min,max);
					gtk_spin_button_set_value(GTK_SPIN_BUTTON(c->spin),current);
					break;
				}
			case STP_PARAMETER_TYPE_DIMENSION:
				{
					int min,max,current;
					min=desc.bounds.integer.lower;
					max=desc.bounds.integer.upper;
					current=stp_get_dimension_parameter(c->vars,c->optionname);
					// Convert to correct unit here...
					gtk_range_set_range(GTK_RANGE(c->scale),min,max);
					gtk_range_set_value(GTK_RANGE(c->scale),current);
					dimension_set_range_pt(DIMENSION(c->spin),min,max);
					dimension_set_pt(DIMENSION(c->spin),current);
					break;
				}
			default:
				break;
		}
	}
	if(desc.is_active)
	{
		gtk_widget_show(GTK_WIDGET(c));
		if(c->checkbutton)
			gtk_widget_show(GTK_WIDGET(c->checkbutton));
		if(c->label)
			gtk_widget_show(GTK_WIDGET(c->label));
	}
	else
	{
		gtk_widget_hide(GTK_WIDGET(c));
		if(c->checkbutton)
			gtk_widget_hide(GTK_WIDGET(c->checkbutton));
		if(c->label)
			gtk_widget_hide(GTK_WIDGET(c->label));
	}
	gtk_widget_set_sensitive(GTK_WIDGET(c->scale),desc.is_active);
	gtk_widget_set_sensitive(GTK_WIDGET(c->spin),desc.is_active & enabled);
	if(c->checkbutton)
		gtk_widget_set_sensitive(GTK_WIDGET(c->checkbutton),desc.is_active);
	result=desc.is_active;
	return(result);
}