Example #1
0
static long get_integer(char **ptr, long min, long max)
{
    long val = min;
    char *p = *ptr, *s;

    if (volume_percent >= 0)
    {
        val = (int)(max * volume_percent / 100);
        val = check_range(val, min, max);
        return val;
    }
    if (*p == ':')
        p++;
    if (*p == '\0' || (!isdigit(*p) && *p != '-'))
        goto out;

    s = p;
    val = strtol(s, &p, 10);
    if (*p == '.')
    {
        p++;
        strtol(p, &p, 10);
    }
    if (*p == '%')
    {
        val = (long)convert_prange1(strtod(s, NULL), min, max);
        p++;
    }
    val = check_range(val, min, max);
    if (*p == ',')
        p++;
out:
    *ptr = p;
    return val;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
	NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);

	if (!priv->interface_name || !strlen(priv->interface_name)) {
		g_set_error (error,
		             NM_SETTING_BRIDGE_ERROR,
		             NM_SETTING_BRIDGE_ERROR_MISSING_PROPERTY,
		             NM_SETTING_BRIDGE_INTERFACE_NAME);
		return FALSE;
	}

	if (!nm_utils_iface_valid_name (priv->interface_name)) {
		g_set_error (error,
		             NM_SETTING_BRIDGE_ERROR,
		             NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
		             NM_SETTING_BRIDGE_INTERFACE_NAME);
		return FALSE;
	}

	if (!check_range (priv->forward_delay,
	                  BR_MIN_FORWARD_DELAY,
	                  BR_MAX_FORWARD_DELAY,
	                  NM_SETTING_BRIDGE_FORWARD_DELAY,
	                  error))
		return FALSE;

	if (!check_range (priv->hello_time,
	                  BR_MIN_HELLO_TIME,
	                  BR_MAX_HELLO_TIME,
	                  NM_SETTING_BRIDGE_HELLO_TIME,
	                  error))
		return FALSE;

	if (!check_range (priv->max_age,
	                  BR_MIN_MAX_AGE,
	                  BR_MAX_MAX_AGE,
	                  NM_SETTING_BRIDGE_MAX_AGE,
	                  error))
		return FALSE;

	if (!check_range (priv->ageing_time,
	                  BR_MIN_AGEING_TIME,
	                  BR_MAX_AGEING_TIME,
	                  NM_SETTING_BRIDGE_AGEING_TIME,
	                  error))
		return FALSE;

	return TRUE;
}
Example #3
0
int
get_status (double value, thresholds * my_thresholds)
{
  if (my_thresholds->critical != NULL)
    {
      if (check_range (value, my_thresholds->critical) == TRUE)
	return STATE_CRITICAL;
    }
  if (my_thresholds->warning != NULL)
    {
      if (check_range (value, my_thresholds->warning) == TRUE)
	return STATE_WARNING;
    }
  return STATE_OK;
}
Example #4
0
/*
 *  stress_set_bsearch_size()
 *	set bsearch size from given option string
 */
void stress_set_bsearch_size(const char *optarg)
{
	set_bsearch_size = true;
	opt_bsearch_size = get_uint64_byte(optarg);
	check_range("bsearch-size", opt_bsearch_size,
		MIN_BSEARCH_SIZE, MAX_BSEARCH_SIZE);
}
Example #5
0
static int run_teacher_task ( void ) 
{
	if (startFlag==1) 
	{ 
		temp_time1 = gettime();
 	 	startFlag=0;
	}
	
	temp_time2 = gettime();

	if ((temp_time2-temp_time1)/1000.0 > 2.0)  //save teach-data every 10 ms
 	{
		startFlag=1;
		saveUnifyData(); // save vision data and joint state
		//saveJoint_state(1, 1, 1, 1, 1, 1); // save jointPos,jointVel,jointAcc:(actual and desired); save cartpos,vel,acc:(actual); 
	}

	int i = 0;
	for ( i = 1; i <= N_DOFS; i++ ) 
	{
		joint_des_state[i].th = joint_state[i].th+joint_state[i].thd/task_servo_rate; //+joint_state[i].thdd/task_servo_rate/task_servo_rate; 
		joint_des_state[i].thd = 0.0;
		joint_des_state[i].thdd = 0.0;
		joint_des_state[i].uff = 0.0;
	}

	SL_InvDyn( NULL, joint_des_state, endeff, &base_state, &base_orient );

	check_range( joint_des_state );

	return TRUE;
}
/* DA9034 specific operations */
static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
				  int min_uV, int max_uV)
{
	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
	struct device *da9034_dev = to_da903x_dev(rdev);
	uint8_t val, mask;
	int ret;

	if (check_range(info, min_uV, max_uV)) {
		pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
		return -EINVAL;
	}

	val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
	val <<= info->vol_shift;
	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;

	ret = da903x_update(da9034_dev, info->vol_reg, val, mask);
	if (ret)
		return ret;

	ret = da903x_set_bits(da9034_dev, info->update_reg,
					1 << info->update_bit);
	return ret;
}
Example #7
0
/*
 *  stress_set_bigheap_growth()
 *  	Set bigheap growth from given opt arg string
 */
void stress_set_bigheap_growth(const char *optarg)
{
	set_bigheap_growth = true;
	opt_bigheap_growth = get_uint64_byte(optarg);
	check_range("bigheap-growth", opt_bigheap_growth,
		MIN_BIGHEAP_GROWTH, MAX_BIGHEAP_GROWTH);
}
Example #8
0
void stress_set_vm_rw_bytes(const char *optarg)
{
	set_vm_rw_bytes = true;
	opt_vm_rw_bytes = (size_t)get_uint64_byte(optarg);
	check_range("vm-rw-bytes", opt_vm_rw_bytes,
		MIN_VM_RW_BYTES, MAX_VM_RW_BYTES);
}
/* DA9030 specific operations */
static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
				       int min_uV, int max_uV)
{
	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
	struct device *da903x_dev = to_da903x_dev(rdev);
	uint8_t val, mask;
	int ret;

	if (check_range(info, min_uV, max_uV)) {
		pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
		return -EINVAL;
	}

	val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
	val <<= info->vol_shift;
	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
	val |= DA9030_LDO_UNLOCK; /* have to set UNLOCK bits */
	mask |= DA9030_LDO_UNLOCK_MASK;

	/* write twice */
	ret = da903x_update(da903x_dev, info->vol_reg, val, mask);
	if (ret)
		return ret;

	return da903x_update(da903x_dev, info->vol_reg, val, mask);
}
Example #10
0
int
gx_concretize_CIEABC(const gs_client_color * pc, const gs_color_space * pcs_in,
                     frac * pconc, const gs_imager_state * pis, gx_device *dev)
{
    gs_color_space *pcs_icc;
    gs_client_color scale_pc;
    bool islab;
    gs_color_space *pcs = (gs_color_space *) pcs_in;

    if_debug3('c', "[c]concretize CIEABC [%g %g %g]\n",
              pc->paint.values[0], pc->paint.values[1],
              pc->paint.values[2]);
    /* If we are comming in here then we have not completed
       the conversion of the ABC space to an ICC type.  We
       will finish that process now. */
    if (pcs->icc_equivalent == NULL) {
        gx_cieabc_to_icc(&pcs_icc, pcs, &islab, pis->memory->stable_memory);
    } else {
        pcs_icc = pcs->icc_equivalent;
    }
    /* Rescale the input based upon the input range since profile is
       created to remap this range from 0 to 1 */
    if (check_range(&(pcs->params.abc->RangeABC.ranges[0]), 3)) {
        return((pcs_icc->type->concretize_color)(pc, pcs_icc, pconc, pis, dev));
    }
    /* Do the rescale from 0 to 1 */
    rescale_input_color(&(pcs->params.abc->RangeABC.ranges[0]), 3, pc, &scale_pc);
    /* Now the icc remap */
    return((pcs_icc->type->concretize_color)(&scale_pc, pcs_icc, pconc, pis, dev));
}
Example #11
0
static int axp_set_ldo4_voltage(struct regulator_dev *rdev,
				  int min_uV, int max_uV, unsigned *selector)
{
	struct axp_regulator_info *info = rdev_get_drvdata(rdev);
	struct device *axp_dev = to_axp_dev(rdev);
	uint8_t val, mask;
	int i;
	
	if (check_range(info, min_uV, max_uV)) {
		pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
		return -EINVAL;
	}

	for(i = 0,val = 0; i < sizeof(axp_ldo4_data);i++){
		if(min_uV <= axp_ldo4_data[i] * 1000){
			val = i;
			break;
		}
	}
	
	*selector = val;
	val <<= info->vol_shift;
	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
	return axp_update(axp_dev, info->vol_reg, val, mask);
}
Example #12
0
/* Render a CIEBasedDEF color. */
int
gx_concretize_CIEDEF(const gs_client_color * pc, const gs_color_space * pcs_in,
                     frac * pconc, const gs_imager_state * pis, gx_device *dev)
{
    int code = 0;
    gs_color_space *pcs_icc;
    gs_client_color scale_pc;
    gs_color_space *pcs = (gs_color_space *) pcs_in;

    if_debug3m('c', pis->memory, "[c]concretize DEF [%g %g %g]\n",
               pc->paint.values[0], pc->paint.values[1],
               pc->paint.values[2]);
    /* If we are comming in here then we have not completed
       the conversion of the DEF space to an ICC type.  We
       will finish that process now. */
    if (pcs->icc_equivalent == NULL) {
        code = gx_ciedef_to_icc(&pcs_icc, pcs, pis->memory->stable_memory);
        if (code < 0)
            return gs_rethrow(code, "Failed to build ICC profile from CIEDEF");
    } else {
        pcs_icc = pcs->icc_equivalent;
    }
    /* Rescale the input based upon the input range since profile is
       created to remap this range from 0 to 1 */
    if (check_range(&(pcs->params.def->RangeDEF.ranges[0]), 3)) {
        return (pcs_icc->type->concretize_color)(pc, pcs_icc, pconc, pis, dev);
}
    /* Do the rescale from 0 to 1 */
    rescale_input_color(&(pcs->params.def->RangeDEF.ranges[0]), 3, pc, &scale_pc);
    /* Now the icc remap */
    return (pcs_icc->type->concretize_color)(&scale_pc, pcs_icc, pconc, pis, dev);
}
Example #13
0
/* Returns false if range is not 0 1 */
bool
check_cie_range( const gs_color_space * pcs )
{
    switch(gs_color_space_get_index(pcs)){
        case gs_color_space_index_CIEDEFG:
            return(check_range(&(pcs->params.defg->RangeDEFG.ranges[0]), 4));
        case gs_color_space_index_CIEDEF:
            return(check_range(&(pcs->params.def->RangeDEF.ranges[0]), 3));
        case gs_color_space_index_CIEABC:
            return(check_range(&(pcs->params.abc->RangeABC.ranges[0]), 3));
        case gs_color_space_index_CIEA:
            return(check_range(&(pcs->params.a->RangeA), 1));
        default:
            return true;
    }
}
Example #14
0
void stress_set_vm_splice_bytes(const char *optarg)
{
    set_vm_splice_bytes = true;
    opt_vm_splice_bytes = (size_t)get_uint64_byte(optarg);
    check_range("vm-splice-bytes", opt_vm_splice_bytes,
                MIN_VM_SPLICE_BYTES, MAX_VM_SPLICE_BYTES);
}
Example #15
0
static long long get_integer64(const char **ptr, long long min, long long max)
{
	long long val = min;
	char *p = (char *)*ptr, *s;

	if (*p == ':')
		p++;
	if (*p == '\0' || (!isdigit(*p) && *p != '-'))
		goto out;

	s = p;
	val = strtol(s, &p, 0);
	if (*p == '.') {
		p++;
		(void)strtol(p, &p, 10);
	}
	if (*p == '%') {
		val = (long long)convert_prange1(strtod(s, NULL), min, max);
		p++;
	}
	val = check_range(val, min, max);
	if (*p == ',')
		p++;
 out:
	*ptr = p;
	return val;
}
static int feature_index_lua_get_features_for_range(lua_State *L)
{
  GtFeatureIndex **feature_index;
  const char *seqid;
  GtRange *range;
  GtError *err;
  bool has_seqid;
  GtArray *features;
  GT_UNUSED int had_err;

  feature_index = check_feature_index(L, 1);
  seqid = luaL_checkstring(L, 2);
  err = gt_error_new();
  if (gt_feature_index_has_seqid(*feature_index, &has_seqid, seqid, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  luaL_argcheck(L, has_seqid, 2,
                "feature_index does not contain seqid");
  range = check_range(L, 3);
  features = gt_array_new(sizeof (GtGenomeNode*));
  err = gt_error_new();
  had_err = gt_feature_index_get_features_for_range(*feature_index, features,
                                                    seqid, range, err);
  if (had_err)
    return gt_lua_error(L, err);
  gt_error_delete(err);
  push_features_as_table(L, features);
  gt_array_delete(features);
  return 1;
}
Example #17
0
static int pm8607_set_voltage(struct regulator_dev *rdev,
			      int min_uV, int max_uV)
{
	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
	uint8_t val, mask;
	int ret;

	if (check_range(info, min_uV, max_uV)) {
		pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
		return -EINVAL;
	}

	ret = choose_voltage(rdev, min_uV, max_uV);
	if (ret < 0)
		return -EINVAL;
	val = (uint8_t)(ret << info->vol_shift);
	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;

	ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
	if (ret)
		return ret;
	switch (info->desc.id) {
	case PM8607_ID_BUCK1:
	case PM8607_ID_BUCK3:
		ret = pm860x_set_bits(info->i2c, info->update_reg,
				      1 << info->update_bit,
				      1 << info->update_bit);
		break;
	}
	return ret;
}
Example #18
0
int
gx_remap_CIEA(const gs_client_color * pc, const gs_color_space * pcs_in,
        gx_device_color * pdc, const gs_imager_state * pis, gx_device * dev,
                gs_color_select_t select)
{
    int code;
    gs_color_space *pcs_icc;
    gs_client_color scale_pc;
    gs_color_space *pcs = (gs_color_space *) pcs_in;

    if_debug1('c', "[c]remap CIEA [%g]\n",pc->paint.values[0]);
   /* If we are coming in here then we may have not completed
       the conversion of the CIE A space to an ICC type.  We
       will finish that process now. */
    if (pcs->icc_equivalent == NULL) {
        code = gx_ciea_to_icc(&pcs_icc, pcs, pis->memory->stable_memory);
    } else {
        /* Once the ICC color space is set, we should be doing all the remaps through the ICC equivalent */
        pcs_icc = pcs->icc_equivalent;
    }
    /* Rescale the input based upon the input range since profile is
       created to remap this range from 0 to 1 */
    if (check_range(&(pcs->params.a->RangeA), 1)) {
        return((pcs_icc->type->remap_color)(pc,pcs_icc,pdc,pis,dev,select));
    }
    /* Do the rescale from 0 to 1 */
    rescale_input_color(&(pcs->params.a->RangeA), 1, pc, &scale_pc);
    /* Now the icc remap */
    code = (pcs_icc->type->remap_color)(&scale_pc,pcs_icc,pdc,pis,dev,select);
    /* Save unscaled data for high level device (e.g. pdfwrite) */
    pdc->ccolor.paint.values[0] = pc->paint.values[0];
    pdc->ccolor_valid = true;
    return(code);
}
void stress_set_copy_file_bytes(const char *optarg)
{
	set_copy_file_bytes = true;
	opt_copy_file_bytes =  get_uint64_byte(optarg);
	check_range("copy-file-bytes", opt_copy_file_bytes,
		MIN_COPY_FILE_BYTES, MAX_COPY_FILE_BYTES);
}
Example #20
0
/* Render a CIEBasedA color. */
int
gx_concretize_CIEA(const gs_client_color * pc, const gs_color_space * pcs_in,
                   frac * pconc, const gs_imager_state * pis, gx_device *dev)
{
    int code;
    gs_color_space *pcs_icc;
    gs_client_color scale_pc;
    gs_color_space *pcs = (gs_color_space *) pcs_in;

    if_debug1('c', "[c]concretize CIEA %g\n", pc->paint.values[0]);
    /* If we are comming in here then we have not completed
       the conversion of the CIE A space to an ICC type.  We
       will finish that process now. */
    if (pcs->icc_equivalent == NULL) {
        code = gx_ciea_to_icc(&pcs_icc, pcs, pis->memory->stable_memory);
    } else {
        /* Once the ICC color space is set, we should be doing all the remaps through the ICC equivalent */
        pcs_icc = pcs->icc_equivalent;
    }
    /* Rescale the input based upon the input range since profile is
       created to remap this range from 0 to 1 */
    if (check_range(&(pcs->params.a->RangeA), 1)) {
        return((pcs_icc->type->concretize_color)(pc, pcs_icc, pconc, pis, dev));
    }
    /* Do the rescale from 0 to 1 */
    rescale_input_color(&(pcs->params.a->RangeA), 1, pc, &scale_pc);
    /* Now the icc remap */
    return((pcs_icc->type->concretize_color)(&scale_pc, pcs_icc, pconc, pis, dev));
}
/* AXP common operations */
static int axp_set_voltage(struct regulator_dev *rdev,
                           int min_uV, int max_uV)
{
    struct axp_regulator_info *info = rdev_get_drvdata(rdev);
    struct device *axp_dev = to_axp_dev(rdev);
    uint8_t val, mask;


    if (check_range(info, min_uV, max_uV)) {
        pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
        return -EINVAL;
    }

    //axp18 LDO5
    if (AXP18_ID_LDO5 == info->desc.id) {
        if(min_uV < 2800000)
            val = 0;
        else if (min_uV < 3000000)
            val = 1;
        else if (min_uV < 3300000)
            val = 2;
        else
            val = 3;
        val <<= info->vol_shift;
        mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
        return axp_update(axp_dev, info->vol_reg, val, mask);
    }

    val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
    val <<= info->vol_shift;
    mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;

    return axp_update(axp_dev, info->vol_reg, val, mask);
}
Example #22
0
static void
hook_check_thres(packet_info_t *packet, iprecord_t *irec, int *threshold_trigger, int pps, int mbps, int globalpps, int globalmbps)
{
    int enabled = check_range(packet, irec);
    if(!enabled)
    {
        DPRINTF("thres: not enabled for this range, skipping. %d\n", 0);
        return;
    }
    else
    {
        threshold_t *temp = find_range_definition(packet, irec);
        if(temp == NULL)
        {
            DPRINTF("thres: failed to find range definition, this is not meant to happen. %d\n", 0);
            return;
        }
        DPRINTF("thres: defined custom values are -> mbps: %d, pps: %d\n", temp->mbps, temp->pps);
        if(temp->pps && pps > temp->pps)
        {
            DPRINTF("thres: pps match found, %d is higher than %d. Global pps: %d\n", pps, temp->pps, globalpps);
            *threshold_trigger = 1;
        }

        if(temp->mbps && mbps > temp->mbps)
        {
            DPRINTF("thres: mbps match found, %d is higher than %d. Global mbps: %d\n", mbps, temp->mbps, globalmbps);
            *threshold_trigger = 1;
        }
    }
}
    /** set current row **/
    void set_current_row( dom::element& table, dom::element& row, UINT keyboardStates, bool dblClick = false )
    {
      if(is_multiple(table))
      {
		     if (keyboardStates & SHIFT_KEY_PRESSED)
         {
			      checkall(table, false);
				    check_range(table,row.index(),TRUE); // from current to new
         } 
         else 
         {			
				   if (keyboardStates & CONTROL_KEY_PRESSED)
				     set_checked_row (table,row, true); // toggle
           else
             checkall(table, false);
           set_anchor(table,row.index ());
         }
      }

      // get previously selected row:
      dom::element prev = get_current_row( table );
      if( prev.is_valid() )
      {
        if( prev != row ) 
          prev.set_state(0,STATE_CURRENT, false); // drop state flags
      }
      row.set_state(STATE_CURRENT); // set state flags
      row.scroll_to_view();
      ::UpdateWindow(row.get_element_hwnd(false));
      table.post_event( dblClick? TABLE_ROW_DBL_CLICK:TABLE_ROW_CLICK, row.index(), row); 
    }
Example #24
0
/*
 *  stress_set_vfork_max()
 *	set maximum number of vforks allowed
 */
void stress_set_vfork_max(const char *optarg)
{
	set_vfork_max = true;
	opt_vfork_max = get_uint64_byte(optarg);
	check_range("vfork-max", opt_vfork_max,
		MIN_VFORKS, MAX_VFORKS);
}
static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
				  int min_uV, int max_uV)
{
	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
	struct device *da903x_dev = to_da903x_dev(rdev);
	uint8_t val, mask;
	int thresh;

	if (check_range(info, min_uV, max_uV)) {
		pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
		return -EINVAL;
	}

	thresh = (info->max_uV + info->min_uV) / 2;
	if (min_uV < thresh) {
		val = (thresh - min_uV + info->step_uV - 1) / info->step_uV;
		val |= 0x4;
	} else {
		val = (min_uV - thresh + info->step_uV - 1) / info->step_uV;
	}

	val <<= info->vol_shift;
	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;

	return da903x_update(da903x_dev, info->vol_reg, val, mask);
}
Example #26
0
void stress_set_fifo_readers(const char *optarg)
{
	set_fifo_readers = true;
	opt_fifo_readers = get_uint64(optarg);
	check_range("fifo-readers", opt_fifo_readers,
		MIN_FIFO_READERS, MAX_FIFO_READERS);
}
void stress_set_fiemap_size(const char *optarg)
{
	set_fiemap_size = true;
	opt_fiemap_size = get_uint64_byte(optarg);
	check_range("fiemap-size", opt_fiemap_size,
		MIN_FIEMAP_SIZE, MAX_FIEMAP_SIZE);
}
Example #28
0
void stress_set_sendfile_size(const char *optarg)
{
	set_sendfile_size = true;
	opt_sendfile_size = get_uint64_byte(optarg);
	check_range("sendfile-size", opt_sendfile_size,
		MIN_SENDFILE_SIZE, MAX_SENDFILE_SIZE);
}
Example #29
0
void stress_set_msync_bytes(const char *optarg)
{
	set_msync_bytes = true;
	opt_msync_bytes = (size_t)get_uint64_byte(optarg);
	check_range("mmap-bytes", opt_msync_bytes,
		MIN_MSYNC_BYTES, MAX_MSYNC_BYTES);
}
Example #30
0
/*
 *  stress_set_timer_freq()
 *	set timer frequency from given option
 */
void stress_set_timer_freq(const char *optarg)
{
	set_timer_freq = true;
	opt_timer_freq = get_uint64(optarg);
	check_range("timer-freq", opt_timer_freq,
		MIN_TIMER_FREQ, MAX_TIMER_FREQ);
}