Exemplo n.º 1
0
int
main(int argc, char *argv[])
{
	const char *cp, *tp;
	const char *sep;
	int op, i;
	u_int32_t debug, ndebug;
	size_t debuglen;
	char oid[256];

	progname = argv[0];
	setoid(oid, sizeof(oid), "wlan0");
	if (argc > 1) {
		if (strcmp(argv[1], "-d") == 0) {
			setoid(oid, sizeof(oid), NULL);
			argc -= 1, argv += 1;
		} else if (strcmp(argv[1], "-i") == 0) {
			if (argc <= 2)
				errx(1, "missing interface name for -i option");
			get_orig_iface_name(oid, sizeof(oid), argv[2]);
			argc -= 2, argv += 2;
		} else if (strcmp(argv[1], "-?") == 0)
			usage();
	}

	debuglen = sizeof(debug);
	if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0)
		err(1, "sysctl-get(%s)", oid);
	ndebug = debug;
	for (; argc > 1; argc--, argv++) {
		cp = argv[1];
		do {
			u_int bit;

			if (*cp == '-') {
				cp++;
				op = -1;
			} else if (*cp == '+') {
				cp++;
				op = 1;
			} else
				op = 0;
			for (tp = cp; *tp != '\0' && *tp != '+' && *tp != '-';)
				tp++;
			bit = getflag(cp, tp-cp);
			if (op < 0)
				ndebug &= ~bit;
			else if (op > 0)
				ndebug |= bit;
			else {
				if (bit == 0) {
					int c = *cp;
					if (isdigit(c))
						bit = strtoul(cp, NULL, 0);
					else
						errx(1, "unknown flag %.*s",
							(int)(tp-cp), cp);
				}
				ndebug = bit;
			}
		} while (*(cp = tp) != '\0');
	}
	if (debug != ndebug) {
		printf("%s: 0x%x => ", oid, debug);
		if (sysctlbyname(oid, NULL, NULL, &ndebug, sizeof(ndebug)) < 0)
			err(1, "sysctl-set(%s)", oid);
		printf("0x%x", ndebug);
		debug = ndebug;
	} else
		printf("%s: 0x%x", oid, debug);
	sep = "<";
	for (i = 0; i < N(flags); i++)
		if (debug & flags[i].bit) {
			printf("%s%s", sep, flags[i].name);
			sep = ",";
		}
	printf("%s\n", *sep != '<' ? ">" : "");
	return 0;
}
Exemplo n.º 2
0
int
drd_info_rep::get_writability (tree_label l, int nr) {
  if (nr >= N(info[l]->ci)) return WRITABILITY_NORMAL;
  return info[l]->ci[nr].writability;
}
Exemplo n.º 3
0
tree
drd_info_rep::arg_access (tree t, tree arg, tree env, int& type) {
  // returns "" if unaccessible and the env if accessible
  //cout << "  arg_access " << t << ", " << arg << ", " << env << "\n";
  if (is_atomic (t)) return "";
  else if (t == arg) return env;
  else if (is_func (t, QUOTE_ARG, 1) && N(arg) == 1 && t[0] == arg[0])
    return env;
  else if (is_func (t, MAP_ARGS) && (t[2] == arg[0])) {
    if ((N(t) >= 4) && (N(arg) >= 2) && (as_int (t[3]) > as_int (arg[1])))
      return "";
    if ((N(t) == 5) && (N(arg) >= 2) && (as_int (t[3]) <= as_int (arg[1])))
      return "";
    tree_label inner= make_tree_label (as_string (t[0]));
    tree_label outer= make_tree_label (as_string (t[1]));
    if (get_nr_indices (inner) > 0)
      type= get_type_child (tree (inner, arg), 0);
    if ((get_nr_indices (inner) > 0) &&
	(get_accessible (inner, 0) == ACCESSIBLE_ALWAYS) &&
	all_accessible (outer))
      return env;
    return "";
  }
  else if (is_func (t, MACRO)) return "";
  else if (is_func (t, WITH)) {
    int n= N(t)-1;
    //cout << "env= " << drd_env_merge (env, t (0, n)) << "\n";
    return arg_access (t[n], arg, drd_env_merge (env, t (0, n)), type);
  }
  else if (is_func (t, TFORMAT)) {
    int n= N(t)-1;
    tree oldf= drd_env_read (env, CELL_FORMAT, tree (TFORMAT));
    tree newf= oldf * tree (TFORMAT, A (t (0, n)));
    tree w   = tree (ATTR, CELL_FORMAT, newf);
    tree cenv= get_env_child (t, n, drd_env_merge (env, w));
    return arg_access (t[n], arg, cenv, type);
  }
  else if (is_func (t, COMPOUND) && N(t) >= 1 && is_atomic (t[0]))
    return arg_access (compound (t[0]->label, A (t (1, N(t)))),
		       arg, env, type);
  else if ((is_func (t, IF) || is_func (t, VAR_IF)) && N(t) >= 2)
    return arg_access (t[1], arg, env, type);
  else {
    int i, n= N(t);
    for (i=0; i<n; i++) {
      int  ctype= get_type_child (t, i);
      tree cenv = get_env_child (t, i, env);
      tree aenv = arg_access (t[i], arg, cenv, ctype);
      if (aenv != "") {
	if (ctype != TYPE_INVALID) type= ctype;
	if (is_accessible_child (t, i)) return aenv;
      }
      else if (type == TYPE_UNKNOWN &&
               ctype != TYPE_INVALID &&
               ctype != TYPE_UNKNOWN) {
        type= ctype;
        //cout << "  found type " << t << ", " << arg << ", " << type << "\n";
      }
    }
    return "";
  }
}
Exemplo n.º 4
0
bool
drd_info_rep::is_parent_enforcing (tree t) {
  return ((info[L(t)]->pi.border_mode & BORDER_OUTER) != 0) &&
         (N(t) != 0);
}
Exemplo n.º 5
0
int
drd_info_rep::get_type (tree_label l, int nr) {
  if (nr >= N(info[l]->ci)) return TYPE_ADHOC;
  return info[l]->ci[nr].type;
}
sp<MediaPlayerBase>	AmSuperPlayer::CreatePlayer()
{
	sp<MediaPlayerBase> p;
	char *filetype;
	int mvideo,maudio;
	
	player_type newtype=AMLOGIC_PLAYER;
	mTypeReady=false;
	//p= new AmlogicPlayer();
Retry:
	{
		Mutex::Autolock N(mNotifyMutex);
		oldmsg_num=0;
		memset(oldmsg,0,sizeof(oldmsg));
	}
	p=android::createPlayer(newtype, this,notify);
	if (!p->hardwareOutput()) {
        static_cast<MediaPlayerInterface*>(p.get())->setAudioSink(mAudioSink);
    }
	TRACE();
	if(url_valid)
		p->setDataSource(muri,&mheaders);
	else if(fd_valid)
		p->setDataSource(mfd,moffset,mlength);
	else 
		return NULL;
    if(mSurface != NULL)
        p->setVideoSurface(mSurface);
	p->prepareAsync();
	if(!mTypeReady && p->playerType()==AMLOGIC_PLAYER){
		AmlogicPlayer* amplayer; 
		bool FileTypeReady=false;
		amplayer=(AmlogicPlayer *)p.get();
		while(!mTypeReady)
		{
			int ret;
			Mutex::Autolock l(mMutex);
			mCondition.wait(mMutex);
			if(mEXIT)
				break;
		}
		if(mTypeReady){
				FileTypeReady=!amplayer->GetFileType(&filetype,&mvideo,&maudio);
				TRACE();		
		}
		if(FileTypeReady){
			LOGV("SuperGetPlayerType:type=%s,videos=%d,audios=%d\n",filetype,mvideo,maudio);
			newtype=SuperGetPlayerType(filetype,mvideo,maudio);
			LOGV("GET New type =%d\n",newtype);
		}
		else{
			newtype=SuperGetPlayerType(NULL,0,0);
		}
	}
	TRACE();
	if(mEXIT){
		p->stop();
		p.clear();
		p=NULL;
	}
	else if(newtype!=p->playerType()){
		LOGV("Need to creat new player=%d\n",newtype);
		p->stop();
		p.clear();
		if(fd_valid){
			lseek(mfd,moffset,SEEK_SET);/*reset to before*/
		}
		p=NULL;
		goto Retry;
	}
	TRACE();
	LOGV("Start new player now=%d\n",newtype);
	return p;
}
Exemplo n.º 7
0
int
drd_info_rep::get_nr_indices (tree_label l) {
  return N(info[l]->ci);
}
Exemplo n.º 8
0
/*
 * Control Adaptive Noise Immunity Parameters
 */
HAL_BOOL
ar5212AniControl(struct ath_hal *ah, HAL_ANI_CMD cmd, int param)
{
#define N(a) (sizeof(a)/sizeof(a[0]))
	typedef int TABLE[];
	struct ath_hal_5212 *ahp = AH5212(ah);
	struct ar5212AniState *aniState = ahp->ah_curani;

	switch (cmd) {
	case HAL_ANI_NOISE_IMMUNITY_LEVEL: {
		u_int level = param;

		if (level >= N(ahp->ah_totalSizeDesired)) {
			HALDEBUG(ah, "%s: level out of range (%u > %u)\n",
				__func__, level, N(ahp->ah_totalSizeDesired));
			return AH_FALSE;
		}

		OS_REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ,
			AR_PHY_DESIRED_SZ_TOT_DES, ahp->ah_totalSizeDesired[level]);
		OS_REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
			  AR_PHY_AGC_CTL1_COARSE_LOW, ahp->ah_coarseLow[level]);
		OS_REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
			  AR_PHY_AGC_CTL1_COARSE_HIGH, ahp->ah_coarseHigh[level]);
		OS_REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
			AR_PHY_FIND_SIG_FIRPWR, ahp->ah_firpwr[level]);

		if (level > aniState->noiseImmunityLevel)
			ahp->ah_stats.ast_ani_niup++;
		else if (level < aniState->noiseImmunityLevel)
			ahp->ah_stats.ast_ani_nidown++;
		aniState->noiseImmunityLevel = level;
		break;
	}
	case HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION: {
		const TABLE m1ThreshLow   = { 127,   50 };
		const TABLE m2ThreshLow   = { 127,   40 };
		const TABLE m1Thresh      = { 127, 0x4d };
		const TABLE m2Thresh      = { 127, 0x40 };
		const TABLE m2CountThr    = {  31,   16 };
		const TABLE m2CountThrLow = {  63,   48 };
		u_int on = param ? 1 : 0;

		OS_REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
			AR_PHY_SFCORR_LOW_M1_THRESH_LOW, m1ThreshLow[on]);
		OS_REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
			AR_PHY_SFCORR_LOW_M2_THRESH_LOW, m2ThreshLow[on]);
		OS_REG_RMW_FIELD(ah, AR_PHY_SFCORR,
			AR_PHY_SFCORR_M1_THRESH, m1Thresh[on]);
		OS_REG_RMW_FIELD(ah, AR_PHY_SFCORR,
			AR_PHY_SFCORR_M2_THRESH, m2Thresh[on]);
		OS_REG_RMW_FIELD(ah, AR_PHY_SFCORR,
			AR_PHY_SFCORR_M2COUNT_THR, m2CountThr[on]);
		OS_REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
			AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW, m2CountThrLow[on]);

		if (on) {
			OS_REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
				AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
		} else {
			OS_REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW,
				AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
		}
		if (!on != aniState->ofdmWeakSigDetectOff) {
			if (on)
				ahp->ah_stats.ast_ani_ofdmon++;
			else
				ahp->ah_stats.ast_ani_ofdmoff++;
			aniState->ofdmWeakSigDetectOff = !on;
		}
		break;
	}
	case HAL_ANI_CCK_WEAK_SIGNAL_THR: {
		const TABLE weakSigThrCck = { 8, 6 };
		u_int high = param ? 1 : 0;

		OS_REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT,
			AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK,
			weakSigThrCck[high]);
		if (high != aniState->cckWeakSigThreshold) {
			if (high)
				ahp->ah_stats.ast_ani_cckhigh++;
			else
				ahp->ah_stats.ast_ani_ccklow++;
			aniState->cckWeakSigThreshold = high;
		}
		break;
	}
	case HAL_ANI_FIRSTEP_LEVEL: {
		const TABLE firstep = { 0, 4, 8 };
		u_int level = param;

		if (level >= N(firstep)) {
			HALDEBUG(ah, "%s: level out of range (%u > %u)\n",
				__func__, level, N(firstep));
			return AH_FALSE;
		}
		OS_REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
			AR_PHY_FIND_SIG_FIRSTEP, firstep[level]);
		if (level > aniState->firstepLevel)
			ahp->ah_stats.ast_ani_stepup++;
		else if (level < aniState->firstepLevel)
			ahp->ah_stats.ast_ani_stepdown++;
		aniState->firstepLevel = level;
		break;
	}
	case HAL_ANI_SPUR_IMMUNITY_LEVEL: {
		const TABLE cycpwrThr1 = { 2, 4, 6, 8, 10, 12, 14, 16 };
		u_int level = param;

		if (level >= N(cycpwrThr1)) {
			HALDEBUG(ah, "%s: level out of range (%u > %u)\n",
				__func__, level, N(cycpwrThr1));
			return AH_FALSE;
		}
		OS_REG_RMW_FIELD(ah, AR_PHY_TIMING5,
			AR_PHY_TIMING5_CYCPWR_THR1, cycpwrThr1[level]);
		if (level > aniState->spurImmunityLevel)
			ahp->ah_stats.ast_ani_spurup++;
		else if (level < aniState->spurImmunityLevel)
			ahp->ah_stats.ast_ani_spurdown++;
		aniState->spurImmunityLevel = level;
		break;
	}
	case HAL_ANI_PRESENT:
		break;
#ifdef AH_PRIVATE_DIAG
	case HAL_ANI_MODE:
		if (param == 0) {
			ahp->ah_procPhyErr &= ~HAL_PROCESS_ANI;
			/* Turn off HW counters if we have them */
			ar5212AniDetach(ah);
			ar5212SetRxFilter(ah,
				ar5212GetRxFilter(ah) &~ HAL_RX_FILTER_PHYERR);
		} else {			/* normal/auto mode */
			ahp->ah_procPhyErr |= HAL_PROCESS_ANI;
			if (ahp->ah_hasHwPhyCounters) {
				ar5212SetRxFilter(ah,
					ar5212GetRxFilter(ah) &~ HAL_RX_FILTER_PHYERR);
			} else {
				ar5212SetRxFilter(ah,
					ar5212GetRxFilter(ah) | HAL_RX_FILTER_PHYERR);
			}
		}
		break;
	case HAL_ANI_PHYERR_RESET:
		ahp->ah_stats.ast_ani_ofdmerrs = 0;
		ahp->ah_stats.ast_ani_cckerrs = 0;
		break;
#endif /* AH_PRIVATE_DIAG */
	default:
		HALDEBUG(ah, "%s: invalid cmd %u\n", __func__, cmd);
		return AH_FALSE;
	}
	return AH_TRUE;
#undef	N
}
Exemplo n.º 9
0
/*static*/ void
initialize_default_env () {
  if (N(default_env) != 0) return;
  hashmap<string,tree>& env= default_env;

  tree identity_m (MACRO, "x", tree (ARG, "x"));
  tree tabular_m (MACRO, "x", tree (TFORMAT, tree (ARG, "x")));
  tree the_page (MACRO, compound ("page-nr"));

  tree gr_geometry (TUPLE, "geometry", "1par", "0.6par", "center");
  tree gr_frame (TUPLE, "scale", "1cm", tree (TUPLE, "0.5gw", "0.5gh"));

  tree gr_grid ("");
  tree gr_edit_grid ("");
  tree gr_grid_aspect (TUPLE,
		       tuple ("axes", "#808080"),
		       tuple ("1", "#c0c0c0"),
		       tuple ("10", "#e0e0ff"));

  tree gr_transf (TUPLE,
                  tuple ("1.0", "0.0", "0.0", "0.0"),
                  tuple ("0.0", "1.0", "0.0", "0.0"),
                  tuple ("0.0", "0.0", "1.0", "0.0"),
                  tuple ("0.0", "0.0", "0.0", "1.0"));         

  env (DPI)              = "600";       // resolution in dots per inch
  env (ZOOM_FACTOR)      = "1";         // zoom factor on screen
  env (PREAMBLE)         = "false";     // preamble mode ?
  env (SAVE_AUX)         = "true";      // save auxiliary data on disk ?
  env (MODE)             = "text";      // typesetting mode
  env (INFO_FLAG)        = "minimal";   // information about labels, etc.
  env (WINDOW_BARS)      = "auto";      // override menu/icon bar settings
  env (SCROLL_BARS)      = "true";      // allow scroll bars around canvas?
  env (IDENTITY)         = identity_m;  // identity macro
  env (TABULAR)          = tabular_m;   // tabular macro
  env (THE_LABEL)        = "?";         // value of the next label
  env (THE_TAGS)         = tree(TUPLE); // current tags
  env (THE_MODULES)      = tree(TUPLE); // necessary modules and plug-ins
  env (WARN_MISSING)     = "true";      // warn about missing references
  env (GLOBAL_TITLE)     = "";          // global document title
  env (GLOBAL_AUTHOR)    = "";          // global document author
  env (GLOBAL_SUBJECT)   = "";          // global document subject

  env (FONT)             = "roman";     // the font name in text mode
  env (FONT_FAMILY)      = "rm";        // the font family in text mode
  env (FONT_SERIES)      = "medium";    // the font series in text mode
  env (FONT_SHAPE)       = "right";     // the font shape in text mode
  env (FONT_SIZE)        = "1";         // the font size multiplier
  env (FONT_BASE_SIZE)   = "10";        // the font base size
  env (MAGNIFICATION)    = "1";         // magnification (slides for instance)
  env (COLOR)            = "black";     // the color
  env (OPACITY)          = "100%";      // the opacity
  env (BG_COLOR)         = "white";     // the background color
  env (LOCUS_COLOR)      = "global";    // the color of loci
  env (VISITED_COLOR)    = "global";    // the color of visited loci
  env (NO_PATTERNS)      = "false";     // disable background patterns
  env (LANGUAGE)         = "english";   // the language
  env (ATOM_DECORATIONS) = DATOMS;      // dots, underline, hyperlinks?, etc.
  env (LINE_DECORATIONS) = DLINES;      // boxed pars, nested envs, etc.
  env (PAGE_DECORATIONS) = DPAGES;      // future headers, footers, etc.
  env (XOFF_DECORATIONS) = "0tmpt";     // hor. placement of decorations
  env (YOFF_DECORATIONS) = "0tmpt";     // vert. placement of decorations

  env (MATH_LANGUAGE)    = "std-math";  // the default mathematical language
  env (MATH_FONT)        = "roman";     // the font name in math mode
  env (MATH_FONT_FAMILY) = "mr";        // the font family in math mode
  env (MATH_FONT_SERIES) = "medium";    // the font series in math mode
  env (MATH_FONT_SHAPE)  = "normal";    // the font shape in math mode
  env (MATH_LEVEL)       = "0";         // the index level (0, 1 or 2)
  env (MATH_DISPLAY)     = "false";     // true if we are in display style
  env (MATH_CONDENSED)   = "false";     // ignore spaces between operators ?
  env (MATH_VPOS)        = "0";         // used in fractions (-1, 0 or 1)
  env (MATH_NESTING_MODE)= "off";       // color nested brackets?
  env (MATH_NESTING_LEVEL)= "0";        // nesting level inside brackets

  env (PROG_LANGUAGE)    = "scheme";    // the default programming language
  env (PROG_SCRIPTS)     = "scheme";    // the scripting language
  env (PROG_FONT)        = "roman";     // the font name in prog mode
  env (PROG_FONT_FAMILY) = "tt";        // the font family in prog mode
  env (PROG_FONT_SERIES) = "medium";    // the font series in prog mode
  env (PROG_FONT_SHAPE)  = "right";     // the font shape in prog mode
  env (PROG_SESSION)     = "default";   // computer algebra session name

  env (PAR_MODE)         = "justify";   // outline method
  env (PAR_FLEXIBILITY)  = "1000";      // threshold for switching to ragged
  env (PAR_HYPHEN)       = "professional"; // quality of hyphenation
  env (PAR_SPACING)      = "plain";     // spacing mode (for CJK)
  env (PAR_KERNING_STRETCH)= "auto";    // extra kerning around characters
  env (PAR_KERNING_MARGIN) = "false";   // use marginal kerning (protrusion)
  env (PAR_WIDTH)        = "auto";      // width of paragraph
  env (PAR_LEFT)         = "0cm";       // left indentation
  env (PAR_RIGHT)        = "0cm";       // right indentation
  env (PAR_FIRST)        = "1.5fn";     // extra first indentation
  env (PAR_NO_FIRST)     = "false";     // no extra first indent. on next line
  env (PAR_SEP)          = "0.2fn";     // extra space between paragraph lines
  env (PAR_HOR_SEP)      = "0.5fn";     // min. hor. spc. between ink for shove
  env (PAR_VER_SEP)      = "0.2fn";     // min. ver. spc. between ink
  env (PAR_LINE_SEP)     = "0.025fns";  // extra (small) space between lines
  env (PAR_PAR_SEP)      = "0.5fns";    // extra space between paragraphs
  env (PAR_FNOTE_SEP)    = "0.2fn";     // min space between diff footnotes
  env (PAR_COLUMNS)      = "1";         // number of columns
  env (PAR_COLUMNS_SEP)  = "2fn";       // separation between columns

  env (PAGE_MEDIUM)      = "papyrus";   // paper medium: paper, papyrus, auto
  env (PAGE_PRINTED)     = "false";     // printed version?
  env (PAGE_TYPE)        = "a4";        // paper type (-> width & height)
  env (PAGE_ORIENTATION) = "portrait";  // paper orientation
  env (PAGE_WIDTH_MARGIN)  = "false";   // compute margins from par-width?
  env (PAGE_HEIGHT_MARGIN) = "false";   // compute margins from par-width?
  env (PAGE_SCREEN_MARGIN) = "true";    // special margins for screen editing?
  env (PAGE_BREAKING)    = "professional";  // quality of page breaking
  env (PAGE_FLEXIBILITY) = "1";         // flexibility factor of stretch
  env (PAGE_NR)          = "0";         // the page number
  env (PAGE_THE_PAGE)    = the_page;    // the page number as text
  env (PAGE_WIDTH)       = "auto";      // physical width of pages
  env (PAGE_HEIGHT)      = "auto";      // physical height of pages
  env (PAGE_ODD)         = "auto";      // left margin on odd pages
  env (PAGE_EVEN)        = "auto";      // left margin on even pages
  env (PAGE_RIGHT)       = "auto";      // right margin in auto mode
  env (PAGE_TOP)         = "auto";      // top margin
  env (PAGE_BOT)         = "auto";      // bottom margin
  env (PAGE_USER_HEIGHT) = "522pt";     // height of principal text
  env (PAGE_ODD_SHIFT)   = "0mm";       // odd page marginal shift wrt center
  env (PAGE_EVEN_SHIFT)  = "0mm";       // even page marginal shift wrt center
  env (PAGE_SHRINK)      = "1fn";       // emergency page length shrinking
  env (PAGE_EXTEND)      = "0fn";       // emergency page length extension
  env (PAGE_HEAD_SEP)    = "8mm";       // separation between header and text
  env (PAGE_FOOT_SEP)    = "8mm";       // separation between footer and text
  env (PAGE_ODD_HEADER)  = "";          // header on odd pages
  env (PAGE_ODD_FOOTER)  = "";          // footer on odd pages
  env (PAGE_EVEN_HEADER) = "";          // header on even pages
  env (PAGE_EVEN_FOOTER) = "";          // footer on even pages
  env (PAGE_SCREEN_WIDTH)  = "10cm";    // width of current window (for auto)
  env (PAGE_SCREEN_HEIGHT) = "10cm";    // height of current window (for auto)
  env (PAGE_SCREEN_LEFT) = "5mm";       // left margin for screen editing
  env (PAGE_SCREEN_RIGHT)= "5mm";       // right margin for screen editing
  env (PAGE_SCREEN_TOP)  = "15mm";      // top margin for screen editing
  env (PAGE_SCREEN_BOT)  = "15mm";      // bottom margin for screen editing
  env (PAGE_SHOW_HF)     = "true";      // show header and footer
  env (PAGE_FNOTE_SEP)   = "1.0fn";     // space between text & footnotes
  env (PAGE_FNOTE_BARLEN)= "7.5fn";     // length of footnote separating bar
  env (PAGE_FLOAT_SEP)   = "1.5fn";     // space between text & floats
  env (PAGE_MNOTE_SEP)   = "5mm";       // space between text & marginal notes
  env (PAGE_MNOTE_WIDTH) = "15mm";      // width of marginal notes

  env (TABLE_WIDTH)      = "";          // width of table
  env (TABLE_HEIGHT)     = "";          // height of table
  env (TABLE_HMODE)      = "auto";      // width determination mode
  env (TABLE_VMODE)      = "auto";      // height determination mode
  env (TABLE_HALIGN)     = "l";         // horizontal alignment
  env (TABLE_VALIGN)     = "f";         // vertical alignment (fraction height)
  env (TABLE_ROW_ORIGIN) = "0";         // row origin
  env (TABLE_COL_ORIGIN) = "0";         // column origin
  env (TABLE_LSEP)       = "0fn";       // left padding around table
  env (TABLE_RSEP)       = "0fn";       // right padding around table
  env (TABLE_BSEP)       = "0fn";       // bottom padding around table
  env (TABLE_TSEP)       = "0fn";       // top padding around table
  env (TABLE_LBORDER)    = "0ln";       // left table border width
  env (TABLE_RBORDER)    = "0ln";       // right table border width
  env (TABLE_BBORDER)    = "0ln";       // bottom table border width
  env (TABLE_TBORDER)    = "0ln";       // top table border width
  env (TABLE_HYPHEN)     = "n";         // vertical hyphenation
  env (TABLE_MIN_ROWS)   = "";          // suggested minimal number of rows
  env (TABLE_MIN_COLS)   = "";          // suggested minimal number of columns
  env (TABLE_MAX_ROWS)   = "";          // suggested maximal number of rows
  env (TABLE_MAX_COLS)   = "";          // suggested maximal number of columns

  env (CELL_DECORATION)  = "";          // decorating table of cell
  env (CELL_FORMAT)      = TFORMAT;     // format of cell
  env (CELL_BACKGROUND)  = "";          // background color of cell
  env (CELL_ORIENTATION) = "portrait";  // orientation of cell  
  env (CELL_WIDTH)       = "";          // width of cell
  env (CELL_HEIGHT)      = "";          // height of cell
  env (CELL_HPART)       = "";          // take part of unused horizontal space
  env (CELL_VPART)       = "";          // take part of unused vertical space
  env (CELL_HMODE)       = "auto";      // width determination mode
  env (CELL_VMODE)       = "auto";      // height determination mode
  env (CELL_HALIGN)      = "l";         // horizontal alignment
  env (CELL_VALIGN)      = "B";         // vertical alignment
  env (CELL_LSEP)        = "0fn";       // left cell padding
  env (CELL_RSEP)        = "0fn";       // right cell padding
  env (CELL_BSEP)        = "0fn";       // bottom cell padding
  env (CELL_TSEP)        = "0fn";       // top cell padding
  env (CELL_LBORDER)     = "0ln";       // left cell border width
  env (CELL_RBORDER)     = "0ln";       // right cell border width
  env (CELL_BBORDER)     = "0ln";       // bottom cell border width
  env (CELL_TBORDER)     = "0ln";       // top cell border width
  env (CELL_VCORRECT)    = "a";         // vertical limits correction
  env (CELL_HYPHEN)      = "n";         // horizontal hyphenation
  env (CELL_BLOCK)       = "auto";      // cell contains block content?
  env (CELL_ROW_SPAN)    = "1";         // row span of cell
  env (CELL_COL_SPAN)    = "1";         // column span of cell
  env (CELL_ROW_NR)      = "1";         // row coordinate of cell
  env (CELL_COL_NR)      = "1";         // column coordinate of cell

  env (GR_GEOMETRY)         = gr_geometry;    // geometry of graphics
  env (GR_FRAME)            = gr_frame;       // coordinate frame for graphics
  env (GR_MODE)             = "line";         // graphical mode
  env (GR_AUTO_CROP)        = "false";        // auto crop graphics
  env (GR_CROP_PADDING)     = "1spc";         // padding when auto cropping
  env (GR_GRID)             = gr_grid;        // grid for graphics
  env (GR_GRID_ASPECT)      = gr_grid_aspect; // grid aspect
  env (GR_EDIT_GRID)        = gr_edit_grid;   // edit grid
  env (GR_EDIT_GRID_ASPECT) = gr_grid_aspect; // edit grid (subdivisions)
  env (GR_TRANSFORMATION)   = gr_transf;      // 3D transformation

  env (GR_MAGNIFY)       = "default";   // magnify of new objects
  env (GR_OPACITY)       = "default";   // opacity of new objects
  env (GR_COLOR)         = "default";   // color of new objects
  env (GR_POINT_STYLE)   = "default";   // point style of new objects
  env (GR_LINE_WIDTH)    = "default";   // line width for new objects
  env (GR_LINE_JOIN)     = "default";   // line join for new objects
  env (GR_LINE_CAPS)     = "default";   // line caps for new objects
  env (GR_LINE_EFFECTS)    = "default";   // line effects for new objects
  env (GR_DASH_STYLE)      = "default";   // dash style for new objects
  env (GR_DASH_STYLE_UNIT) = "default";   // dash style unit for new objects
  env (GR_ARROW_BEGIN)     = "default";   // arrow begin for new objects
  env (GR_ARROW_END)       = "default";   // arrow end for new objects
  env (GR_ARROW_LENGTH)    = "default";   // arrow length for new objects
  env (GR_ARROW_HEIGHT)    = "default";   // arrow height for new objects
  env (GR_FILL_COLOR)      = "default";   // fill color for new objects
  env (GR_FILL_STYLE)      = "default";   // fill style for new objects
  env (GR_TEXT_AT_HALIGN)  = "default";   // horiz. alignment for new text-ats
  env (GR_TEXT_AT_VALIGN)  = "default";   // vert. alignment for new text-ats
  env (GR_TEXT_AT_MARGIN)  = "default";   // margins for new text-ats

  env (GID)              = "default";   // graphical identifier
  env (MAGNIFY)          = "1";         // magnification for graphical objects
  env (POINT_STYLE)      = "disk";      // point style (square, circle...)
  env (LINE_WIDTH)       = "1ln";       // line width in graphics
  env (LINE_JOIN)        = "normal";    // junctions in multilines
  env (LINE_CAPS)        = "normal";    // caps at ends
  env (LINE_EFFECTS)     = "none";      // effects to be applied on line
  env (DASH_STYLE)       = "none";      // dash style
  env (DASH_STYLE_UNIT)  = "5ln";       // dash style unit
  env (ARROW_BEGIN)      = "none";      // arrow at beginning of line
  env (ARROW_END)        = "none";      // arrow at end of line
  env (ARROW_LENGTH)     = "5ln";       // longitudal length of arrow
  env (ARROW_HEIGHT)     = "5ln";       // transverse height of arrow
  env (FILL_COLOR)       = "none";      // fill color
  env (FILL_STYLE)       = "plain";     // fill style
  env (TEXT_AT_HALIGN)   = "left";      // horizontal text-at alignment
  env (TEXT_AT_VALIGN)   = "base";      // vertical text-at alignment
  env (TEXT_AT_MARGIN)   = "base";      // margin for smart guides

  env (SRC_STYLE)        = "angular";   // style for "source" tags
  env (SRC_SPECIAL)      = "normal";    // special treatment of certain tags
  env (SRC_COMPACT)      = "normal";    // compact inline/multi-paragraph tags?
  env (SRC_CLOSE)        = "compact";   // how to close long tags

  env (CANVAS_TYPE)           = "plain";        // which kind of scrollbars
  env (CANVAS_COLOR)          = "white";        // canvas colour
  env (CANVAS_HPADDING)       = "0px";          // horizontal canvas padding
  env (CANVAS_VPADDING)       = "0px";          // vertical canvas padding
  env (CANVAS_BAR_WIDTH)      = "1em";          // width of scroll bars
  env (CANVAS_BAR_PADDING)    = "0.25em";       // distance of scrollbars
  env (CANVAS_BAR_COLOR)      = "grey";         // color of bar
  env (ORNAMENT_SHAPE)        = "classic";      // shape of the ornament
  env (ORNAMENT_TITLE_STYLE)  = "classic";      // title style
  env (ORNAMENT_BORDER)       = "1ln";          // border width
  env (ORNAMENT_SWELL)        = "0.5";          // border swell
  env (ORNAMENT_HPADDING)     = "1spc";         // horizontal padding of body
  env (ORNAMENT_VPADDING)     = "1spc";         // vertical padding of body
  env (ORNAMENT_COLOR)        = "";             // background color
  env (ORNAMENT_EXTRA_COLOR)  = "white";        // background color for titles
  env (ORNAMENT_SUNNY_COLOR)  = "black";        // sunny color
  env (ORNAMENT_SHADOW_COLOR) = "black";        // shadow color

  /* hiding and showing content */
  env ("shown")= identity_m;
  env ("ignore")=
    tree (MACRO, "body", tree (HIDDEN, tree (ARG, "body")));

  /* linking macros */
  tree src_id (ID, tree (HARD_ID, tree (ARG, "body")));
  tree ref_id (ID, tree (HARD_ID, tree (ARG, "Id")));
  tree dest_url (URL, tree (ARG, "destination"));
  tree dest_script (SCRIPT, tree (ARG, "destination"), tree (ARG, "where"));
  tree dest_ref (URL, tree (MERGE, "#", tree (ARG, "Id")));
  tree anchor (ID, tree (MERGE, "#", tree (ARG, "Id")));
  tree ln1 (LINK, "hyperlink", copy (src_id), copy (dest_url));
  tree ln2 (LINK, "action", copy (src_id), copy (dest_script));
  tree ln3 (LINK, "hyperlink", copy (ref_id), copy (dest_ref));
  tree ln4 (LINK, "anchor", anchor);
  tree labflag (FLAG, tree (ARG, "Id"), "blue", "Id");
  tree labtxt (SET_BINDING, tree (ARG, "Id"), tree (VALUE, THE_LABEL));
  tree merged (MERGE, tree (VALUE, THE_TAGS), tuple (tree (ARG, "Id")));
  tree tagflag (FLAG, tree (ARG, "Id"), "blue", "Id");
  tree reftxt (GET_BINDING, tree (ARG, "Id"));
  tree preftxt (GET_BINDING, tree (ARG, "Id"), "1");
  tree act_id (ID, tree (HARD_ID, tree (ARG, "args", "0")));
  tree act_script (MAP_ARGS, "find-accessible", "script", "args", "1");
  tree act_ln (LINK, "action", copy (act_id), copy (act_script));
  env ("hlink")= tree (MACRO, "body", "destination",
		       tree (LOCUS, copy (src_id), ln1,
                             tree (ARG, "body")));
  env ("action")= tree (XMACRO, "args",
			tree (LOCUS, copy (act_id), copy (act_ln),
                              tree (ARG, "args", "0")));
  env ("label")= tree (MACRO, "Id", 
		       tree (LOCUS, copy (ref_id), ln4,
			     tree (CONCAT, labflag, labtxt)));
  env ("tag")= tree (MACRO, "Id", "body",
		     tree (WITH, "the-tags", merged,
			   tree (SURROUND, tagflag, "",
                                 tree (ARG, "body"))));
  env ("reference")= tree (MACRO, "Id",
			   tree (LOCUS, copy (ref_id), ln3, reftxt));
  env ("pageref")= tree (MACRO, "Id",
			 tree (LOCUS, copy (ref_id), copy (ln3), preftxt));

  /* further standard macros */
  env ("error")=
    tree (MACRO, "message",
          tree (REWRITE_INACTIVE, tree (ARG, "message"), "error"));
  env ("style-only")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("style-only*")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("active")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("active*")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("inactive")=
    tree (MACRO, "body",
          tree (REWRITE_INACTIVE, tree (ARG, "body"), "once"));
  env ("inactive*")=
    tree (MACRO, "body",
          tree (REWRITE_INACTIVE, tree (ARG, "body"), "recurse"));
  env ("right-flush")=
    tree (MACRO, tree (HTAB, "0fn", "first"));
  env ("indent*")=
    tree (MACRO, "body",
	  tree (WITH, PAR_LEFT, tree (PLUS, tree (VALUE, PAR_LEFT), "1.5fn"),
		tree (ARG, "body")));
  env ("indent")=
    tree (MACRO, "body",
	  tree (SURROUND, "", compound ("right-flush"),
		compound ("indent*", tree (ARG, "body"))));
  env ("math")=
    tree (MACRO, "body", tree (WITH, MODE, "math", tree (ARG, "body")));
  env ("text")=
    tree (MACRO, "body", tree (WITH, MODE, "text", tree (ARG, "body")));
  env ("pre-edit")=
    tree (MACRO, "body", tree (WITH, COLOR, "#4040c0", tree (ARG, "body")));
  env ("mutator")=
    tree (MACRO, "body", "y", tree (ARG, "body"));

  /* syntactic highlighting */
  env ("src-regular")=
    tree (MACRO, "body", tree (WITH, COLOR, "black", tree (ARG, "body")));
  env ("src-macro")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "blue",
                               FONT_FAMILY, "ss", tree (ARG, "body")));
  env ("src-var")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "dark green",
                               FONT_SHAPE, "italic", tree (ARG, "body")));
  env ("src-arg")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "brown",
                               FONT_SHAPE, "italic", tree (ARG, "body")));
  env ("src-tt")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "#228",
                               FONT_FAMILY, "tt", tree (ARG, "body")));
  env ("src-numeric")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "#848",
                               tree (ARG, "body")));
  env ("src-textual")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "black",
                               tree (ARG, "body")));
  env ("src-length")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "#288",
                               tree (ARG, "body")));
  env ("src-unknown")=
    tree (MACRO, "body", tree (WITH, COLOR, "#C68", tree (ARG, "body")));
  env ("src-error")=
    tree (MACRO, "body", tree (WITH, COLOR, "red", tree (ARG, "body")));

  /* for correct importation of style files and packages */
  env ("src-title")= identity_m;
  env ("src-style-file")=
    tree (MACRO, "style", "version",
	  tree (ASSIGN,
		tree (MERGE, tree (ARG, "style"), "-style"),
		tree (ARG, "version")));
  env ("src-package")=
    tree (MACRO, "package", "version",
	  tree (CONCAT,
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "package"), "-package"),
		      tree (ARG, "version")),
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "package"), "-dtd"),
		      tree (ARG, "version"))));
  env ("src-package-dtd")=
    tree (MACRO, "package", "version", "drd", "drd-version",
	  tree (CONCAT,
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "package"), "-package"),
		      tree (ARG, "version")),
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "drd"), "-dtd"),
		      tree (ARG, "drd-version"))));
}
Exemplo n.º 10
0
Bool WeatherPronounAir(Obj *obj)
{
  return(WeatherPronoun(obj) || N("air") == obj);
}
Exemplo n.º 11
0
Bool WeatherPronounSky(Obj *obj)
{
  return(WeatherPronoun(obj) || N("sky") == obj);
}
Exemplo n.º 12
0
Bool WeatherPronoun(Obj *obj)
{
  return(ISA(N("pronoun-it-expletive"), obj) ||
         ISA(N("pronoun-ce-expletive"), obj));
}
Exemplo n.º 13
0
void
Beam<nDim,nOrder>::run()
{

    this->changeRepository( boost::format( "doc/manual/solid/%1%/%2%/P%3%/h_%4%/" )
                            % this->about().appName()
                            % entity_type::name()
                            % nOrder
                            % meshSize );
    /*
     * First we create the mesh
     */
    mesh_ptrtype mesh = createGMSHMesh( _mesh=new mesh_type,
                                        _update=MESH_UPDATE_EDGES|MESH_UPDATE_FACES|MESH_CHECK,
                                        _desc=domain( _name=( boost::format( "beam-%1%" ) % nDim ).str() ,

                                                      _shape="hypercube",
                                                      _xmin=0., _xmax=0.351,
                                                      _ymin=0., _ymax=0.02,
                                                      _zmin=0., _zmax=0.02,
                                                      _h=meshSize ) );
    // add marker clamped to the mesh
    mesh->addMarkerName( "clamped",( nDim==2 )?1:19, (nDim==2)?1:2);
    mesh->addMarkerName( "tip",( nDim==2)?3:27, (nDim==2)?1:2);
    /*
     * The function space and some associate elements are then defined
     */
    timers["init"].first.restart();
    space_ptrtype Xh = space_type::New( mesh );
    Xh->printInfo();

    element_type u( Xh, "u" );
    element_type v( Xh, "v" );
    timers["init"].second = timers["init"].first.elapsed();

    /*
     * Data associated with the simulation
     */
    auto E = doption(_name="E")*pascal;
    const double nu = doption(_name="nu");

    auto mu = E/( 2*( 1+nu ) );
    auto lambda = E*nu/( ( 1+nu )*( 1-2*nu ) );
    auto density = 1e3;
    auto gravity = -2*newton/pow<Dim>(meter);//-density*0.05;
    LOG(INFO) << "lambda = " << lambda << "\n"
          << "mu     = " << mu << "\n"
          << "gravity= " << gravity << "\n";

    /*
     * Construction of the right hand side
     *
     * \f$ f = \int_\Omega g * v \f$ where \f$ g \f$ is a vector
     * directed in the \f$ y \f$ direction.
     */
    auto F = backend()->newVector( Xh );
    F->zero();
    timers["assembly"].first.restart();

    if ( Dim == 3 )
        form1( _test=Xh, _vector=F ) = integrate( elements( mesh ), trans( gravity.value()*oneZ() )*id( v ) );
    else
        form1( _test=Xh, _vector=F ) = integrate( elements( mesh ), trans( gravity.value()*oneY() )*id( v ) );

    timers["assembly"].second = timers["assembly"].first.elapsed();

    /*
     * Construction of the left hand side
     */
    auto D = backend()->newMatrix( Xh, Xh );
    timers["assembly"].first.restart();
    auto deft = sym(gradt(u));
    auto def = sym(grad(u));
    auto a = form2( _test=Xh, _trial=Xh, _matrix=D );
    a = integrate( elements( mesh ),
                   lambda.value()*divt( u )*div( v )  +
                   2.*mu.value()*trace( trans( deft )*def ) );

    if ( M_bctype == 1 ) // weak Dirichlet bc
    {
        auto Id = eye<nDim>();
        a += integrate( markedfaces( mesh, "clamped" ),
                        - trans( ( 2.*mu.value()*deft+lambda.value()*trace( deft )*Id )*N() )*id( v )
                        - trans( ( 2.*mu.value()*def+lambda.value()*trace( def )*Id )*N() )*idt( u )
                        + bcCoeff*std::max(2.*mu.value(),lambda.value())*trans( idt( u ) )*id( v )/hFace() );
    }

    if ( M_bctype == 0 )
        a += on( markedfaces( mesh, "clamped" ), u, F, zero<nDim,1>() );

    timers["assembly"].second += timers["assembly"].first.elapsed();

    backend(_rebuild=true)->solve( _matrix=D, _solution=u, _rhs=F );

    v = vf::project( Xh, elements( Xh->mesh() ), P() );
    this->exportResults( 0, u, v );

    auto i1 = mean( _range=markedfaces( mesh, "tip"  ), _expr=idv( u ) );
    LOG(INFO) << "deflection: " << i1 << "\n";

} // Beam::run
Exemplo n.º 14
0
    return TRUE;

  /* Finally check for the default architecture.  */
  if (strcasecmp (string, "aarch64") == 0)
    return info->the_default;

  return FALSE;
}

#define N(NUMBER, PRINT, DEFAULT, NEXT)				\
  { 64, 64, 8, bfd_arch_aarch64, NUMBER,			\
    "aarch64", PRINT, 4, DEFAULT, compatible, scan,		\
    bfd_arch_default_fill, NEXT }

const bfd_arch_info_type bfd_aarch64_arch =
  N (0, "aarch64", TRUE, NULL);


bfd_boolean
bfd_is_aarch64_special_symbol_name (const char *name, int type)
{
  if (!name || name[0] != '$')
    return FALSE;
  if (name[1] == 'x' || name[1] == 'd')
    type &= BFD_AARCH64_SPECIAL_SYM_TYPE_MAP;
  else if (name[1] == 'm' || name[1] == 'f' || name[1] == 'p')
    type &= BFD_AARCH64_SPECIAL_SYM_TYPE_TAG;
  else
    return FALSE;

  return (type != 0 && (name[2] == 0 || name[2] == '.'));
Exemplo n.º 15
0
int main(int argc, char** argv)
{
  double taubin_radius = 0.03; // radius of curvature-estimation neighborhood

  std::string file = "/home/andreas/data/mlaffordance/round21l_reg.pcd";
  PointCloud::Ptr cloud(new PointCloud);
  if (pcl::io::loadPCDFile<pcl::PointXYZRGBA>(file, *cloud) == -1) //* load the file
  {
    PCL_ERROR("Couldn't read input PCD file\n");
    return (-1);
  }

  pcl::search::OrganizedNeighbor<pcl::PointXYZRGBA>::Ptr organized_neighbor(
      new pcl::search::OrganizedNeighbor<pcl::PointXYZRGBA>());
  std::vector<int> nn_outer_indices;
  std::vector<float> nn_outer_dists;
  pcl::KdTreeFLANN<pcl::PointXYZRGBA>::Ptr tree(new pcl::KdTreeFLANN<pcl::PointXYZRGBA>());

  int sample_index = 0;
  if (cloud->isOrganized())
  {
    organized_neighbor->setInputCloud(cloud);
    organized_neighbor->radiusSearch(cloud->points[sample_index], taubin_radius, nn_outer_indices, nn_outer_dists);
  }
  else
  {
    tree->setInputCloud(cloud);
    tree->radiusSearch(cloud->points[sample_index], taubin_radius, nn_outer_indices, nn_outer_dists);
  }

  Eigen::Matrix4d T_base, T_sqrt;
  T_base << 0, 0.445417, 0.895323, 0.22, 1, 0, 0, -0.02, 0, 0.895323, -0.445417, 0.24, 0, 0, 0, 1;

  T_sqrt << 0.9366, -0.0162, 0.3500, -0.2863, 0.0151, 0.9999, 0.0058, 0.0058, -0.3501, -0.0002, 0.9367, 0.0554, 0, 0, 0, 1;

  std::vector<Eigen::Matrix4d, Eigen::aligned_allocator<Eigen::Matrix4d> > T_cams;
  T_cams.push_back(T_base * T_sqrt.inverse());

  Eigen::Vector3d sample = cloud->points[sample_index].getVector3fMap().cast<double>();
  Quadric quadric(T_cams, cloud, sample, true);
  quadric.fitQuadric(nn_outer_indices);

  Eigen::MatrixXi cam_source = Eigen::MatrixXi::Zero(1, cloud->points.size());
  quadric.findTaubinNormalAxis(nn_outer_indices, cam_source);

  quadric.print();

  std::set<Eigen::Vector3i, VectorComparator> s;
  Eigen::Matrix3i M;
  M << 1,1,1,2,3,4,1,1,1;
  for (int i=0; i < M.rows(); i++)
    s.insert(M.row(i));
  std::cout << "M:" << std::endl;
  std::cout << M << std::endl;
  Eigen::Matrix<int, Eigen::Dynamic, 3> N(s.size(), 3);
  int i = 0;
  for (std::set<Eigen::Vector3i, VectorComparator>::iterator it=s.begin(); it!=s.end(); ++it)
  {
    N.row(i) = *it;
    i++;
  }
  std::cout << "N:" << std::endl;
  std::cout << N << std::endl;

  return 0;
}
Exemplo n.º 16
0
//-----------------------------------------------------------------------------
bool CCollision::CollisionTriangleSphere( const CVector3D &v0,const CVector3D &v1,const CVector3D &v2,const CVector3D &center,float radius ,CVector3D *cross,float *length)
{
   
     CVector3D V1(v1-v0);
	 CVector3D V2(v2-v1);
	 CVector3D N(CVector3D::Cross(V1,V2).GetNormalize());
	 
	 CVector3D V = center - v0;
	 //平面と点の距離を求める
	 float Dist = CVector3D::Dot(V,N);
  
	//球の半径より離れている場合は接触無し
	 if(abs(Dist) > radius) return false;

	 //点から平面上に垂直に下ろした地点を求める
	 CVector3D Point =  center - ( N * Dist );
	 
	 
	 //上記の点が三角形ポリゴン内なら接触している
	 if(TriangleIntersect( Point, v0, v1, v2 , N)) {
		if(cross) *cross = Point;
		if(length) *length = Dist;
		return true;
	}



	 //各辺に球がかすっている可能性がある
	 //1辺ごとに球と辺の最短距離を求める

	 //最短距離
	 float l;
	 //最短接触地点
	 CVector3D c;
	 
	 //距離比較用
	 float LengthSq;



	 //辺1(v0→v1)
	 Point = PointOnLineSegmentNearestPoint( v0, v1, center );
	 LengthSq = (center - Point).LengthSq();
	 l  = LengthSq;
	 c = Point;

	 //辺2(v1→v2)
	 Point = PointOnLineSegmentNearestPoint( v1, v2, center );
	 LengthSq = (center - Point).LengthSq();
	 if(l>LengthSq) {
		 l = LengthSq;
		 c = Point;
	 }
	 
	 //辺3(v2→v0)
	 Point = PointOnLineSegmentNearestPoint( v2, v0, center );
	 LengthSq = (center - Point).LengthSq();
	 if(l>LengthSq) {
		 l = LengthSq;
		 c = Point;
	 }


	 l = sqrt(l);
	 //最短距離を確定
	 if(length) *length = l;
	 //最短地点を確定
	 if(cross) *cross = c;
	
    return (l<=radius);
}
Exemplo n.º 17
0
int main(int argc, char** argv)
{
    if(argc != 10) {
        std::cerr << "Usage: " << argv[0] << " w h match.txt good_match.txt ntrials verb noseed mode stop" <<std::endl;
        std::cerr << "w: width of image" <<std::endl;
        std::cerr << "h: height of image" <<std::endl;
        std::cerr << "match.txt: x1 y1 x2 y2 for each line" <<std::endl;
        std::cerr << "good_match.txt: good matchings (x1 y1 x2 y2 for each line)" <<std::endl;
        std::cerr << "ntrials: maximum number of ransac trials" <<std::endl;
        std::cerr << "verb: verbose mode (1 enabled, 0 disabled)" <<std::endl;
        std::cerr << "seed: random seed (0=reinitialize)" <<std::endl;
        std::cerr << "mode: 0=all 1=ransac 2=optimized ransac (ORSA) 3=automatic" <<std::endl;
        std::cerr << "stop: stop when first meaningful F is found (1 enabled, 0 disabled)" <<std::endl;
        return 1;
    }

    int width = 0, height = 0; // dimensions of image
    int ntrials = 0;           // maximum number of ransac trials
    bool verb = false;         // verbose
    unsigned long seed = 0;    // seed value (0=reinitialize)
    int mode = -1;    // 0=all 1=ransac 2=optimized ransac (ORSA) 3=automatic
    bool stop = false;         // stop when first meaningful F is found   

    if(! (std::istringstream(argv[1]) >> width).eof()) width = 0;
    if(! (std::istringstream(argv[2]) >> height).eof()) height = 0;
    if(width <=0 || height <= 0) {
        std::cerr << "Wrong dimensions of image" << std::endl;
        return 1;
    }

    std::vector<Match> match;
    if(! loadMatch(argv[3],match)) {
        std::cerr << "Failed reading " << argv[3] << std::endl;
        return 1;
    }

    if(! (std::istringstream(argv[5]) >> ntrials).eof() || ntrials <= 0) {
        std::cerr << "ntrials should be greater than 0" << std::endl;
        return 1;
    }

    if(! (std::istringstream(argv[6]) >> verb).eof()) {
        std::cerr << "verb can only be 0 or 1" << std::endl;
        return 1;
    }

    if(! (std::istringstream(argv[7]) >> seed).eof()) {
        std::cerr << "seed must be a non-negative integer value" << std::endl;
        return 1;
    }

    if(! (std::istringstream(argv[8]) >> mode).eof() || mode < 0 || mode > 3) {
        std::cerr << "mode can only be 0, 1, 2, or 3" << std::endl;
        return 1;
    }

    if(! (std::istringstream(argv[9]) >> stop).eof()) {
        std::cerr << "stop can only be 0 or 1" << std::endl;
        return 1;
    }

    // Initialize random seed if necessary
    if(seed == 0) {
        seed = (long int)time(NULL);
        if(verb)
            std::cout << "seed: " << seed << std::endl; // Useful for debugging
    }
    srand(seed);

    // Remove duplicates (frequent with SIFT)
    std::sort(match.begin(), match.end());
    std::vector<Match>::iterator end = std::unique(match.begin(), match.end());
    if(end != match.end()) {
        if(verb)
            std::cout << "Remove " << std::distance(end,match.end())
                      << "/" << match.size() << " duplicate matches"<<std::endl;
        match.erase(end, match.end());
    }

    // Normalize coordinates
    std::vector<Match> matchBackup(match);
    float nx = (float)width;
    float ny = (float)height;
    float norm = 1.0f/sqrt((float)(nx*ny));
    for(size_t i=0; i<match.size(); i++) {
        match[i].x1 =  (match[i].x1-0.5f*nx)*norm;
        match[i].y1 =  (match[i].y1-0.5f*ny)*norm;
        match[i].x2 =  (match[i].x2-0.5f*nx)*norm;
        match[i].y2 =  (match[i].y2-0.5f*ny)*norm;
    }
    libNumerics::matrix<float> N(3,3); // Normalization matrix
    N = 0;
    N(0,0) = N(1,1) = norm; N(2,2) = 1.0f;
    N(0,2) = -0.5f*nx*norm;
    N(1,2) = -0.5f*ny*norm;

    // log proba of a uniform point in image within a band of 1 pixel from line
    float logalpha0 = log10(2.0f)+0.5f*log10((nx*nx+ny*ny)/float(nx*ny));
    std::vector<size_t> inliers;
    float error;

	libNumerics::matrix<float> F = orsa(match, ntrials, verb, mode, stop, logalpha0, inliers, error);
    error /= norm;
    if(verb) {
        std::cout << "F= " << N.t()*F*N <<std::endl; // Denormalization
        std::cout << "Geometric error threshold: " << error <<std::endl;
    }

    // Write the good matchings into a file
    std::vector<Match> good_match;
    std::vector<size_t>::const_iterator it = inliers.begin();
    for(; it != inliers.end(); it++)
        good_match.push_back(matchBackup[*it]);

    if(! saveMatch(argv[4], good_match)) {
        std::cerr << "Failed saving good matchings into " <<argv[4] <<std::endl;
        return 1;
    }

    return 0;
}
Exemplo n.º 18
0
bool CCollision::CollisionTriangleCapsule(const CVector3D &v0,const CVector3D &v1,const CVector3D &v2,const CVector3D &top,const CVector3D &bottom,float radius,CVector3D *cross,float *length ){
	
	CVector3D V(top-bottom);

	CVector3D  VP;
	float Dist = 1e10;

	//ポリゴンの法線を求める
	CVector3D N(CVector3D::Cross(v1 - v0, v2 - v0).GetNormalize());

	//始点からポリゴン上のある地点(どこでもいい)へのベクトル
	CVector3D PV1 = top-v0;
	//終点からポリゴン上のある地点(どこでもいい)へのベクトル
	CVector3D PV2 = bottom-v0;

	//ポリゴンの法線との内積を求める
	float d1 = CVector3D::Dot(PV1,N);
	float d2 = CVector3D::Dot(PV2,N);

	if(d1*d2<0) {
		//貫通している場合は線とポリゴンの判定を行う
		if(IntersectTriangleRay(cross,top+CVector3D(0,radius,0),bottom+CVector3D(0,-radius,0),v0,v1,v2,&Dist)) {
			if(length) {
				//貫通点までの距離を求める
				float lt = (*cross - top).LengthSq();
				float lb = (*cross - bottom).LengthSq();
				if(lt<lb) *length = sqrt(lt);
				else *length = sqrt(lb);
			}
			return true;
		}
	}

	d1=abs(d1);
	d2=abs(d2);
	//平面上の点との最短地点を求める
	CVector3D C1(top-N*d1);
	CVector3D C2(bottom-N*d2);
	//点が平面上にない場合は無効、後の辺との接触で調べる
	if(!TriangleIntersect(C1,v0,v1,v2,N)) d1=1e10;
	if(!TriangleIntersect(C2,v0,v1,v2,N)) d2=1e10;


	//面との距離が近い点の距離を選択
	Dist = (d1<d2) ? d1:d2; 
	if(Dist<=radius) {
		//追加
		if(length) *length = Dist;
		return true;
	}
	

	//各辺との距離を求める
	Dist = min(min(DistanceLine(v0,v1,top,bottom),DistanceLine(v1,v2,top,bottom)),DistanceLine(v2,v0,top,bottom));

	if(length) *length = Dist;

    return (Dist<=radius);
	




}
Exemplo n.º 19
0
ENetError pnGateKeeperClient::performConnect()
{
    uint8_t connectHeader[51];  // ConnectHeader + GateKeeperConnectHeader
    /* Begin ConnectHeader */
    *(uint8_t* )(connectHeader     ) = kConnTypeCliToGateKeeper;
    *(uint16_t*)(connectHeader +  1) = 31;
    *(uint32_t*)(connectHeader +  3) = fBuildId;
    *(uint32_t*)(connectHeader +  7) = fBuildType;
    *(uint32_t*)(connectHeader + 11) = fBranchId;
    fProductId.write(connectHeader + 15);
    /* Begin GateKeeperConnectHeader */
    *(uint32_t*)(connectHeader + 31) = 20;
    memset(connectHeader + 35, 0, 16);
    fSock->send(connectHeader, 51);

    if (!fSock->isConnected()) {
        delete fSock;
        fSock = NULL;
        plDebug::Error("Error establishing GateKeeper connection");
        return kNetErrConnectFailed;
    }

    /* Set up encryption */
    uint8_t y_data[64];
    pnBigInteger clientSeed;
    {
        pnBigInteger X(fKeyX, 64, fLittleEndianKeys);
        pnBigInteger N(fKeyN, 64, fLittleEndianKeys);
        pnBigInteger b = pnBigInteger::Random(512);
        clientSeed = X.PowMod(b, N);
        pnBigInteger serverSeed = pnBigInteger(4).PowMod(b, N);
        serverSeed.getData(y_data, 64);
    }

    uint8_t cryptHeader[66];
    *(uint8_t*)(cryptHeader    ) = kNetCliCli2SrvConnect;
    *(uint8_t*)(cryptHeader + 1) = 66;
    memcpy(cryptHeader + 2, y_data, 64);
    fSock->send(cryptHeader, 66);

    uint8_t msg, len;
    if (fSock->recv(&msg, 1) <= 0 || fSock->recv(&len, 1) <= 0) {
        delete fSock;
        fSock = NULL;
        plDebug::Error("Error negotiating GateKeeper connection");
        return kNetErrConnectFailed;
    }

    if (msg == kNetCliSrv2CliEncrypt) {
        uint8_t serverSeed[7];
        fSock->recv(serverSeed, 7);
        uint8_t seedData[64];
        clientSeed.getData(seedData, 64);
        for (size_t i=0; i<7; i++)
            serverSeed[i] ^= seedData[i];
        fSock->init(7, serverSeed);
    } else if (msg == kNetCliSrv2CliError) {
        uint32_t errorCode;
        fSock->recv(&errorCode, sizeof(uint32_t));
        delete fSock;
        fSock = NULL;
        plDebug::Error("Error connecting to GateKeeper server: %s",
                       GetNetErrorString(errorCode));
        return (ENetError)errorCode;
    } else {
        delete fSock;
        fSock = NULL;
        plDebug::Error("Got junk response from server");
        return kNetErrConnectFailed;
    }
    fDispatch = new Dispatch(this);
    if (fThreaded)
        fIface = new pnThreadedSocket(fDispatch, fSock);
    else
        fIface = new pnPolledSocket(fDispatch, fSock);
    fIface->run();
    return kNetSuccess;
}
Exemplo n.º 20
0
  I_mips12000,
  I_mips16,
  I_mips5,
  I_mipsisa32,
  I_mipsisa32r2,
  I_mipsisa64,
  I_mipsisa64r2,
  I_mipsocteon,
  I_sb1,
};

#define NN(index) (&arch_info_struct[(index) + 1])

static const bfd_arch_info_type arch_info_struct[] =
{
  N (32, 32, bfd_mach_mips3000, "mips:3000",      FALSE, NN(I_mips3000)),
  N (32, 32, bfd_mach_mips3900, "mips:3900",      FALSE, NN(I_mips3900)),
  N (64, 64, bfd_mach_mips4000, "mips:4000",      FALSE, NN(I_mips4000)),
  N (64, 64, bfd_mach_mips4010, "mips:4010",      FALSE, NN(I_mips4010)),
  N (64, 64, bfd_mach_mips4100, "mips:4100",      FALSE, NN(I_mips4100)),
  N (64, 64, bfd_mach_mips4111, "mips:4111",      FALSE, NN(I_mips4111)),
  N (64, 64, bfd_mach_mips4120, "mips:4120",      FALSE, NN(I_mips4120)),
  N (64, 64, bfd_mach_mips4300, "mips:4300",      FALSE, NN(I_mips4300)),
  N (64, 64, bfd_mach_mips4400, "mips:4400",      FALSE, NN(I_mips4400)),
  N (64, 64, bfd_mach_mips4600, "mips:4600",      FALSE, NN(I_mips4600)),
  N (64, 64, bfd_mach_mips4650, "mips:4650",      FALSE, NN(I_mips4650)),
  N (64, 64, bfd_mach_mips5000, "mips:5000",      FALSE, NN(I_mips5000)),
  N (64, 64, bfd_mach_mips5400, "mips:5400",      FALSE, NN(I_mips5400)),
  N (64, 64, bfd_mach_mips5500, "mips:5500",      FALSE, NN(I_mips5500)),
  N (32, 32, bfd_mach_mips6000, "mips:6000",      FALSE, NN(I_mips6000)),
  N (64, 64, bfd_mach_mips7000, "mips:7000",      FALSE, NN(I_mips7000)),
Exemplo n.º 21
0
bool
drd_info_rep::is_child_enforcing (tree t) {
  return ((info[L(t)]->pi.border_mode & BORDER_INNER) != 0) &&
         (N(t) != 0);
}
Exemplo n.º 22
0
/*
 * Control Adaptive Noise Immunity Parameters
 */
u8_t zfHpAniControl(zdev_t *dev, ZM_HAL_ANI_CMD cmd, int param)
{
#define N(a) (sizeof(a)/sizeof(a[0]))
    typedef s32_t TABLE[];
    struct zsHpPriv *HpPriv;
    struct zsAniState *aniState;

    zmw_get_wlan_dev(dev);
    HpPriv = (struct zsHpPriv *)wd->hpPrivate;
    aniState = HpPriv->curani;

    switch (cmd)
    {
    case ZM_HAL_ANI_NOISE_IMMUNITY_LEVEL:
    {
        u32_t level = param;

        if (level >= N(HpPriv->totalSizeDesired)) {
          zm_debug_msg1("level out of range, desired level : ", level);
          zm_debug_msg1("max level : ", N(HpPriv->totalSizeDesired));
          return FALSE;
        }

        zfDelayWriteInternalReg(dev, AR_PHY_DESIRED_SZ,
                (HpPriv->regPHYDesiredSZ & ~AR_PHY_DESIRED_SZ_TOT_DES)
                | ((HpPriv->totalSizeDesired[level] << AR_PHY_DESIRED_SZ_TOT_DES_S)
                & AR_PHY_DESIRED_SZ_TOT_DES));
        zfDelayWriteInternalReg(dev, AR_PHY_AGC_CTL1,
                (HpPriv->regPHYAgcCtl1 & ~AR_PHY_AGC_CTL1_COARSE_LOW)
                | ((HpPriv->coarseLow[level] << AR_PHY_AGC_CTL1_COARSE_LOW_S)
                & AR_PHY_AGC_CTL1_COARSE_LOW));
        zfDelayWriteInternalReg(dev, AR_PHY_AGC_CTL1,
                (HpPriv->regPHYAgcCtl1 & ~AR_PHY_AGC_CTL1_COARSE_HIGH)
                | ((HpPriv->coarseHigh[level] << AR_PHY_AGC_CTL1_COARSE_HIGH_S)
                & AR_PHY_AGC_CTL1_COARSE_HIGH));
        zfDelayWriteInternalReg(dev, AR_PHY_FIND_SIG,
                (HpPriv->regPHYFindSig & ~AR_PHY_FIND_SIG_FIRPWR)
                | ((HpPriv->firpwr[level] << AR_PHY_FIND_SIG_FIRPWR_S)
                & AR_PHY_FIND_SIG_FIRPWR));
        zfFlushDelayWrite(dev);

        if (level > aniState->noiseImmunityLevel)
            HpPriv->stats.ast_ani_niup++;
        else if (level < aniState->noiseImmunityLevel)
            HpPriv->stats.ast_ani_nidown++;
        aniState->noiseImmunityLevel = (u8_t)level;
        break;
    }
    case ZM_HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION:
    {
        const TABLE m1ThreshLow   = { 127,   50 };
        const TABLE m2ThreshLow   = { 127,   40 };
        const TABLE m1Thresh      = { 127, 0x4d };
        const TABLE m2Thresh      = { 127, 0x40 };
        const TABLE m2CountThr    = {  31,   16 };
        const TABLE m2CountThrLow = {  63,   48 };
        u32_t on = param ? 1 : 0;

        zfDelayWriteInternalReg(dev, AR_PHY_SFCORR_LOW,
                (HpPriv->regPHYSfcorrLow & ~AR_PHY_SFCORR_LOW_M1_THRESH_LOW)
                | ((m1ThreshLow[on] << AR_PHY_SFCORR_LOW_M1_THRESH_LOW_S)
                & AR_PHY_SFCORR_LOW_M1_THRESH_LOW));
        zfDelayWriteInternalReg(dev, AR_PHY_SFCORR_LOW,
                (HpPriv->regPHYSfcorrLow & ~AR_PHY_SFCORR_LOW_M2_THRESH_LOW)
                | ((m2ThreshLow[on] << AR_PHY_SFCORR_LOW_M2_THRESH_LOW_S)
                & AR_PHY_SFCORR_LOW_M2_THRESH_LOW));
        zfDelayWriteInternalReg(dev, AR_PHY_SFCORR,
                (HpPriv->regPHYSfcorr & ~AR_PHY_SFCORR_M1_THRESH)
                | ((m1Thresh[on] << AR_PHY_SFCORR_M1_THRESH_S)
                & AR_PHY_SFCORR_M1_THRESH));
        zfDelayWriteInternalReg(dev, AR_PHY_SFCORR,
                (HpPriv->regPHYSfcorr & ~AR_PHY_SFCORR_M2_THRESH)
                | ((m2Thresh[on] << AR_PHY_SFCORR_M2_THRESH_S)
                & AR_PHY_SFCORR_M2_THRESH));
        zfDelayWriteInternalReg(dev, AR_PHY_SFCORR,
                (HpPriv->regPHYSfcorr & ~AR_PHY_SFCORR_M2COUNT_THR)
                | ((m2CountThr[on] << AR_PHY_SFCORR_M2COUNT_THR_S)
                & AR_PHY_SFCORR_M2COUNT_THR));
        zfDelayWriteInternalReg(dev, AR_PHY_SFCORR_LOW,
                (HpPriv->regPHYSfcorrLow & ~AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW)
                | ((m2CountThrLow[on] << AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW_S)
                & AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW));

        if (on)
        {
            zfDelayWriteInternalReg(dev, AR_PHY_SFCORR_LOW,
                    HpPriv->regPHYSfcorrLow | AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
        }
        else
        {
            zfDelayWriteInternalReg(dev, AR_PHY_SFCORR_LOW,
                    HpPriv->regPHYSfcorrLow & ~AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
        }
        zfFlushDelayWrite(dev);
        if (!on != aniState->ofdmWeakSigDetectOff)
        {
            if (on)
                HpPriv->stats.ast_ani_ofdmon++;
            else
                HpPriv->stats.ast_ani_ofdmoff++;
            aniState->ofdmWeakSigDetectOff = !on;
        }
        break;
    }
    case ZM_HAL_ANI_CCK_WEAK_SIGNAL_THR:
    {
        const TABLE weakSigThrCck = { 8, 6 };
        u32_t high = param ? 1 : 0;

        zfDelayWriteInternalReg(dev, AR_PHY_CCK_DETECT,
                (HpPriv->regPHYCckDetect & ~AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK)
                | ((weakSigThrCck[high] << AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK_S)
                & AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK));
        zfFlushDelayWrite(dev);
        if (high != aniState->cckWeakSigThreshold)
        {
            if (high)
                HpPriv->stats.ast_ani_cckhigh++;
            else
                HpPriv->stats.ast_ani_ccklow++;
            aniState->cckWeakSigThreshold = (u8_t)high;
        }
        break;
    }
    case ZM_HAL_ANI_FIRSTEP_LEVEL:
    {
        const TABLE firstep = { 0, 4, 8 };
        u32_t level = param;

        if (level >= N(firstep))
        {
            zm_debug_msg1("level out of range, desired level : ", level);
            zm_debug_msg1("max level : ", N(firstep));
            return FALSE;
        }
        zfDelayWriteInternalReg(dev, AR_PHY_FIND_SIG,
                (HpPriv->regPHYFindSig & ~AR_PHY_FIND_SIG_FIRSTEP)
                | ((firstep[level] << AR_PHY_FIND_SIG_FIRSTEP_S)
                & AR_PHY_FIND_SIG_FIRSTEP));
        zfFlushDelayWrite(dev);
        if (level > aniState->firstepLevel)
            HpPriv->stats.ast_ani_stepup++;
        else if (level < aniState->firstepLevel)
            HpPriv->stats.ast_ani_stepdown++;
        aniState->firstepLevel = (u8_t)level;
        break;
    }
    case ZM_HAL_ANI_SPUR_IMMUNITY_LEVEL:
    {
        const TABLE cycpwrThr1 = { 2, 4, 6, 8, 10, 12, 14, 16 };
        u32_t level = param;

        if (level >= N(cycpwrThr1))
        {
            zm_debug_msg1("level out of range, desired level : ", level);
            zm_debug_msg1("max level : ", N(cycpwrThr1));
            return FALSE;
        }
        zfDelayWriteInternalReg(dev, AR_PHY_TIMING5,
                (HpPriv->regPHYTiming5 & ~AR_PHY_TIMING5_CYCPWR_THR1)
                | ((cycpwrThr1[level] << AR_PHY_TIMING5_CYCPWR_THR1_S)
                & AR_PHY_TIMING5_CYCPWR_THR1));
        zfFlushDelayWrite(dev);
        if (level > aniState->spurImmunityLevel)
            HpPriv->stats.ast_ani_spurup++;
        else if (level < aniState->spurImmunityLevel)
            HpPriv->stats.ast_ani_spurdown++;
        aniState->spurImmunityLevel = (u8_t)level;
        break;
    }
    case ZM_HAL_ANI_PRESENT:
        break;
#ifdef AH_PRIVATE_DIAG
    case ZM_HAL_ANI_MODE:
        if (param == 0)
        {
            HpPriv->procPhyErr &= ~ZM_HAL_PROCESS_ANI;
            /* Turn off HW counters if we have them */
            zfHpAniDetach(dev);
            //zfHpSetRxFilter(dev, zfHpGetRxFilter(dev) &~ HAL_RX_FILTER_PHYERR);
        }
        else
        {           /* normal/auto mode */
            HpPriv->procPhyErr |= ZM_HAL_PROCESS_ANI;
            if (HpPriv->hasHwPhyCounters)
            {
                //zfHpSetRxFilter(dev, zfHpGetRxFilter(dev) &~ HAL_RX_FILTER_PHYERR);
            }
            else
            {
                //zfHpSetRxFilter(dev, zfHpGetRxFilter(dev) | HAL_RX_FILTER_PHYERR);
            }
        }
        break;
    case ZM_HAL_ANI_PHYERR_RESET:
        HpPriv->stats.ast_ani_ofdmerrs = 0;
        HpPriv->stats.ast_ani_cckerrs = 0;
        break;
#endif /* AH_PRIVATE_DIAG */
    default:
        zm_debug_msg1("invalid cmd ", cmd);
        return FALSE;
    }
    return TRUE;
#undef  N
}
Exemplo n.º 23
0
bool
drd_info_rep::is_with_like (tree t) {
  return info[L(t)]->pi.with_like && N(t) > 0;
}
Exemplo n.º 24
0
xml_html_parser::xml_html_parser (): entities ("") {
  if (N(html_empty_tag_table) == 0) {
    html_empty_tag_table->insert ("basefont");
    html_empty_tag_table->insert ("br");
    html_empty_tag_table->insert ("area");
    html_empty_tag_table->insert ("link");
    html_empty_tag_table->insert ("param");
    html_empty_tag_table->insert ("hr");
    html_empty_tag_table->insert ("input");
    html_empty_tag_table->insert ("col");
    html_empty_tag_table->insert ("frame");
    html_empty_tag_table->insert ("isindex");
    html_empty_tag_table->insert ("base");
    html_empty_tag_table->insert ("meta");
    html_empty_tag_table->insert ("img");
  }

  if (N(html_auto_close_table) == 0) {
    html_auto_close_table->insert ("body");
    html_auto_close_table->insert ("p");
    html_auto_close_table->insert ("dt");
    html_auto_close_table->insert ("dd");
    html_auto_close_table->insert ("li");
    html_auto_close_table->insert ("option");
    html_auto_close_table->insert ("thead");
    html_auto_close_table->insert ("tfoot");
    html_auto_close_table->insert ("tbody");
    html_auto_close_table->insert ("colgroup");
    html_auto_close_table->insert ("tr");
    html_auto_close_table->insert ("th");
    html_auto_close_table->insert ("td");
    html_auto_close_table->insert ("head");
    html_auto_close_table->insert ("html");
  }

  if (N(html_block_table) == 0) {
    html_block_table->insert ("h1");
    html_block_table->insert ("h2");
    html_block_table->insert ("h3");
    html_block_table->insert ("h4");
    html_block_table->insert ("h5");
    html_block_table->insert ("h6");
    html_block_table->insert ("ul");
    html_block_table->insert ("ol");
    html_block_table->insert ("li");
    html_block_table->insert ("dl");
    html_block_table->insert ("dd");
    html_block_table->insert ("dt");
    html_block_table->insert ("pre");
    html_block_table->insert ("div");
    html_block_table->insert ("p");
    html_block_table->insert ("noscript");
    html_block_table->insert ("blockquote");
    html_block_table->insert ("form");
    html_block_table->insert ("hr");
    html_block_table->insert ("table");
    html_block_table->insert ("fieldset");
    html_block_table->insert ("address");
  }

  if (N (html_entity) == 0) {
    load_html_entities (html_entity, "HTMLlat1.scm");
    load_html_entities (html_entity, "HTMLspecial.scm");
    load_html_entities (html_entity, "HTMLsymbol.scm");
  }
}
Exemplo n.º 25
0
int
drd_info_rep::get_accessible (tree_label l, int nr) {
  if (nr >= N(info[l]->ci)) return ACCESSIBLE_NEVER;
  return info[l]->ci[nr].accessible;
}
Exemplo n.º 26
0
namespace avmplus
{

#ifdef AVMPLUS_WORD_CODE

#if defined _DEBUG || defined DEBUGGER
#  define N(x)  , x
#else
#  define N(x)
#endif

	const WordOpcodeAttr wopAttrs[] = 
	{
		// The table is sorted by WordOpcode (see wopcodes.h).
		//
		// The word opcodes will be re-sorted in the near future, please
		// do not depend on ranges that are implicit in this table (eg for
		// the jump opcodes).  Always check the attribute bits.

		// PLEASE NOTE that utils/peephole.as extract information from this
		// table, so keep each row on a separate line, and keep the BEGIN
		// and END lines in place.  Comment lines, blank lines, and
		// trailing '//' comments are OK.  If you add fields you may also
		// need to change the regex that parses this table, in peephole.as,
		// as it knows the order and extracts some of them.
		//
		// DO NOT INSERT #ifdef ... #endif BLOCKS!!

		// width=0 means the instruction is not used in the word-code interpreter; other 
		//    attrs should be 0.  Otherwise it's the width in words of the instruction
		//    including the opcode.  Current limit is 7.  Only lookupswitch is variable length
		// jumps=1 means a branch relative to the end of the instruction, offset is 2nd word always
		// term=1  means the instruction terminates control flow (return, throw, lookupswitch)
		// thro=1  means the instruction may throw an exception
		// calls=1 means the topmost value on the stack is an argument count
		// push=n means the instruction pushes n values (after popping).  Current limit is 3
		// pop=n means the instruction pops n values.  Current limit is 3
		// pop_ex=1 means the instruction may pop more values than shown in the pop column,
		//    there is custom logic elsewhere to handle it.  Usually it means there is a
		//    multiname operand
		// use_l=1 means the instruction reads a local slot
		// def_l=1 means the instruction writes a local slot

		// You may assume that the instructions that may invoke user code is a subset of
	    // the ones that are marked as thro=1.  A few of the latter will not call user code, 
		// but at this point we have no formal definition of whether e.g. embedders may
		// or may not subclass MethodEnv in such a way that MethodEnv::findproperty()
		// may call user code.  So there is no separate column for whether such a call may
		// take place.

		// DO NOT ALTER OR MOVE THE NEXT LINE.
		// BEGIN
		// width jumps term thro calls push pop pop_ex use_l def_l       name
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x00") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x01") },
		{    1,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("nop") },             // nop
		{    1,    0,    1,   1,    0,   0,   1,   0,    0,    0         N("throw") },
		{    2,    0,    0,   1,    0,   1,   1,   1,    0,    0         N("getsuper") },
		{    2,    0,    0,   1,    0,   0,   2,   1,    0,    0         N("setsuper") },
		{    2,    0,    0,   1,    0,   0,   0,   0,    0,    0         N("dxns") },
		{    1,    0,    0,   1,    0,   0,   1,   0,    0,    0         N("dxnslate") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x08") },            // kill
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x09") },            // label
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x0A") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x0B") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifnlt") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifnle") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifngt") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifnge") },
		{    2,    1,    1,   0,    0,   0,   0,   0,    0,    0         N("jump") },            // 0x10
		{    2,    1,    0,   0,    0,   0,   1,   0,    0,    0         N("iftrue") },
		{    2,    1,    0,   0,    0,   0,   1,   0,    0,    0         N("iffalse") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifeq") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifne") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("iflt") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifle") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifgt") },
		{    2,    1,    0,   1,    0,   0,   2,   0,    0,    0         N("ifge") },
		{    2,    1,    0,   0,    0,   0,   2,   0,    0,    0         N("ifstricteq") },
		{    2,    1,    0,   0,    0,   0,   2,   0,    0,    0         N("ifstrictne") },
		{    3,    1,    1,   0,    0,   0,   1,   0,    0,    0         N("lookupswitch") },    // NOTE, variable length beyond 3rd word
		{    1,    0,    0,   0,    0,   0,   1,   0,    0,    0         N("pushwith") },
		{    1,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("popscope") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("nextname") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("hasnext") },
		{    1,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushnull") },        // 0x20
		{    1,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushundefined") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x22") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("nextvalue") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x24") },            // pushbyte
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x25") },            // pushshort
		{    1,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushtrue") },
		{    1,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushfalse") },
		{    1,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushnan") },
		{    1,    0,    0,   0,    0,   0,   1,   0,    0,    0         N("pop") },
		{    1,    0,    0,   0,    0,   2,   1,   0,    0,    0         N("dup") },
		{    1,    0,    0,   0,    0,   2,   2,   0,    0,    0         N("swap") },
		{    2,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushstring") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x2D") },            // pushint
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x2E") },            // pushuint
		{    2,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushdouble") },
		{    1,    0,    0,   0,    0,   0,   1,   0,    0,    0         N("pushscope") },       // 0x30
		{    2,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushnamespace") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("hasnext2") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x33") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x34") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("li8") }, 
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("li16") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("li32") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("lf32") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("lf64") },
		{    1,    0,    0,   1,    0,   0,   2,   0,    0,    0         N("si8") },
		{    1,    0,    0,   1,    0,   0,   2,   0,    0,    0         N("si16") },
		{    1,    0,    0,   1,    0,   0,   2,   0,    0,    0         N("si32") },
		{    1,    0,    0,   1,    0,   0,   2,   0,    0,    0         N("sf32") },
		{    1,    0,    0,   1,    0,   0,   2,   0,    0,    0         N("sf64") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x3F") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("newfunction") },     // 0x40
		{    2,    0,    0,   1,    1,   1,   2,   0,    0,    0         N("call") },
		{    2,    0,    0,   1,    1,   1,   1,   0,    0,    0         N("construct") },
		{    3,    0,    0,   1,    1,   1,   1,   0,    0,    0         N("callmethod") },
		{    3,    0,    0,   1,    1,   1,   1,   0,    0,    0         N("callstatic") },
		{    3,    0,    0,   1,    1,   1,   1,   1,    0,    0         N("callsuper") },
		{    3,    0,    0,   1,    1,   1,   1,   1,    0,    0         N("callproperty") },
		{    1,    0,    1,   0,    0,   0,   0,   0,    0,    0         N("returnvoid") },
		{    1,    0,    1,   0,    0,   0,   1,   0,    0,    0         N("returnvalue") },
		{    2,    0,    0,   1,    1,   0,   1,   0,    0,    0         N("constructsuper") },
		{    3,    0,    0,   1,    1,   1,   1,   1,    0,    0         N("constructprop") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x4B") },            // callsuperid
		{    3,    0,    0,   1,    1,   1,   1,   1,    0,    0         N("callproplex") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x4D") },            // callinterface
		{    3,    0,    0,   1,    1,   0,   1,   1,    0,    0         N("callsupervoid") },
		{    3,    0,    0,   1,    1,   0,   1,   1,    0,    0         N("callpropvoid") },
		{    1,    0,    0,   0,    0,   1,   1,   0,    0,    0         N("sxi1") },    
		{    1,    0,    0,   0,    0,   1,   1,   0,    0,    0         N("sxi8") },
		{    1,    0,    0,   0,    0,   1,   1,   0,    0,    0         N("sxi16") },
		{    2,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("applytype") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x54") },
		{    2,    0,    0,   1,    1,   1,   0,   0,    0,    0         N("newobject") },
		{    2,    0,    0,   1,    1,   1,   0,   0,    0,    0         N("newarray") },
		{    1,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("newactivation") },
		{    2,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("newclass") },
		{    2,    0,    0,   1,    0,   1,   1,   1,    0,    0         N("getdescendants") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("newcatch") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x5B") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x5C") },
		{    2,    0,    0,   1,    0,   1,   0,   1,    0,    0         N("findpropstrict") },
		{    2,    0,    0,   1,    0,   1,   0,   1,    0,    0         N("findproperty") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("finddef") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("getlex") },          // 0x60
		{    2,    0,    0,   1,    0,   0,   2,   1,    0,    0         N("setproperty") },
		{    2,    0,    0,   0,    0,   1,   0,   0,    1,    0         N("getlocal") },
		{    2,    0,    0,   0,    0,   0,   1,   0,    0,    1         N("setlocal") },
		{    1,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("getglobalscope") },
		{    2,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("getscopeobject") },
		{    2,    0,    0,   1,    0,   1,   1,   1,    0,    0         N("getproperty") },
		{    2,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("getouterscope") },
		{    2,    0,    0,   1,    0,   0,   2,   1,    0,    0         N("initproperty") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x69") },
		{    2,    0,    0,   1,    0,   1,   1,   1,    0,    0         N("deleteproperty") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x6B") },
		{    2,    0,    0,   0,    0,   1,   1,   0,    0,    0         N("getslot") },
		{    2,    0,    0,   0,    0,   0,   2,   0,    0,    0         N("setslot") },
		{    2,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("getglobalslot") },
		{    2,    0,    0,   0,    0,   0,   1,   0,    0,    0         N("setglobalslot") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("convert_s") },       // 0x70
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("esc_xelem") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("esc_xattr") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("convert_i") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("convert_u") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("convert_d") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("convert_b") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("convert_o") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("checkfilter") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x79") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x7A") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x7B") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x7C") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x7D") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x7E") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x7F") },
		{    2,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("coerce") },          // 0x80
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x81") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x82") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x83") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x84") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("coerce_s") },
		{    2,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("astype") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("astypelate") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x88") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("coerce_o") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x8A") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x8B") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x8C") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x8D") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x8E") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x8F") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("negate") },          // 0x90
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("increment") },
		{    2,    0,    0,   1,    0,   0,   0,   0,    1,    1         N("inclocal") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("decrement") },
		{    2,    0,    0,   1,    0,   0,   0,   0,    1,    1         N("declocal") },
		{    1,    0,    0,   0,    0,   1,   1,   0,    0,    0         N("typeof") },
		{    1,    0,    0,   0,    0,   1,   1,   0,    0,    0         N("not") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("bitnot") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x98") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x99") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x9A") },            // concat
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x9B") },            // add_d
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x9C") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x9D") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x9E") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x9F") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("add") },             // 0xA0
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("subtract") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("multiply") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("divide") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("modulo") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("lshift") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("rshift") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("urshift") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("bitand") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("bitor") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("bitxor") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("equals") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("strictequals") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("lessthan") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("lessequals") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("greaterthan") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("greaterequals") },   // 0xB0
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("instanceof") },
		{    2,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("istype") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("istypelate") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("in") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xB5") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xB6") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xB7") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xB8") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xB9") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xBA") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xBB") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xBC") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xBD") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xBE") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xBF") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("increment_i") },     // 0xC0
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("decrement_i") },
		{    2,    0,    0,   1,    0,   0,   0,   0,    1,    1         N("inclocal_i") },
		{    2,    0,    0,   1,    0,   0,   0,   0,    1,    1         N("declocal_i") },
		{    1,    0,    0,   1,    0,   1,   1,   0,    0,    0         N("negate_i") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("add_i") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("subtract_i") },
		{    1,    0,    0,   1,    0,   1,   2,   0,    0,    0         N("multiply_i") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xC8") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xC9") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xCA") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xCB") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xCC") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xCD") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xCE") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xCF") },
		{    1,    0,    0,   0,    0,   1,   0,   0,    1,    0         N("getlocal0") },       // 0xD0
		{    1,    0,    0,   0,    0,   1,   0,   0,    1,    0         N("getlocal1") },
		{    1,    0,    0,   0,    0,   1,   0,   0,    1,    0         N("getlocal2") },
		{    1,    0,    0,   0,    0,   1,   0,   0,    1,    0         N("getlocal3") },
		{    1,    0,    0,   0,    0,   0,   1,   0,    0,    1         N("setlocal0") },
		{    1,    0,    0,   0,    0,   0,   1,   0,    0,    1         N("setlocal1") },
		{    1,    0,    0,   0,    0,   0,   1,   0,    0,    1         N("setlocal2") },
		{    1,    0,    0,   0,    0,   0,   1,   0,    0,    1         N("setlocal3") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xD8") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xD9") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xDA") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xDB") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xDC") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xDD") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xDE") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xDF") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE0") },            // 0xE0
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE1") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE2") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE3") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE4") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE5") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE6") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE7") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE8") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xE9") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xEA") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xEB") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xEC") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xED") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xEE") },            // abs_jump
		{    5,    0,    0,   1,    0,   0,   0,   0,    0,    0         N("debug") },
		{    2,    0,    0,   1,    0,   0,   0,   0,    0,    0         N("debugline") },       // 0xF0
		{    2,    0,    0,   1,    0,   0,   0,   0,    0,    0         N("debugfile") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF2") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF3") },            // timestamp
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF4") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF5") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF6") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF7") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF8") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xF9") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xFA") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xFB") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xFC") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xFD") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xFE") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0xFF") },
		{    0,    0,    0,   0,    0,   0,   0,   0,    0,    0         N("0x100") },           // 0x100
		{    2,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("pushbits") },
		{    3,    0,    0,   0,    0,   1,   0,   0,    0,    0         N("push_doublebits") },
		{    2,    0,    0,   0,    0,   2,   0,   0,    1,    0         N("get2locals") },
		{    2,    0,    0,   0,    0,   3,   0,   0,    1,    0         N("get3locals") },
		{    2,    0,    0,   0,    0,   4,   0,   0,    1,    0         N("get4locals") },
		{    2,    0,    0,   0,    0,   5,   0,   0,    1,    0         N("get5locals") },
		{    2,    0,    0,   0,    0,   0,   0,   0,    0,    1         N("storelocal") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("add_ll") },
		{    2,    0,    0,   1,    0,   0,   0,   0,    1,    1         N("add_set_lll") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("subtract_ll") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("multiply_ll") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("divide_ll") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("modulo_ll") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("bitand_ll") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("bitor_ll") },
		{    2,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("bitxor_ll") },       // 0x110
		{    3,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("add_lb") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("subtract_lb") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("multiply_lb") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("divide_lb") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("bitand_lb") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("bitor_lb") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    1,    0         N("bitxor_lb") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("iflt_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifnlt_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifle_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifnle_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifgt_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifngt_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifge_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifnge_ll") },
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifeq_ll") },         // 0x120
		{    3,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifne_ll") },
		{    3,    1,    0,   0,    0,   0,   0,   0,    1,    0         N("ifstricteq_ll") },
		{    3,    1,    0,   0,    0,   0,   0,   0,    1,    0         N("ifstrictne_ll") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("iflt_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifnlt_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifle_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifnle_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifgt_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifngt_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifge_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifnge_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifeq_lb") },
		{    4,    1,    0,   1,    0,   0,   0,   0,    1,    0         N("ifne_lb") },
		{    4,    1,    0,   0,    0,   0,   0,   0,    1,    0         N("ifstricteq_lb") },
		{    4,    1,    0,   0,    0,   0,   0,   0,    1,    0         N("ifstrictne_lb") },
		{    1,    0,    0,   0,    0,   1,   2,   0,    0,    0         N("swap_pop") },        // 0x130
		{    3,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("findpropglobal") },
		{    3,    0,    0,   1,    0,   1,   0,   0,    0,    0         N("findpropglobalstrict") },
		// DO NOT ALTER OR MOVE THE NEXT LINE.
		// END
	};

#endif // AVMPLUS_WORD_CODE

}
Exemplo n.º 27
0
tree
drd_info_rep::get_env (tree_label l, int nr) {
  if (nr >= N(info[l]->ci)) return tree (ATTR);
  return drd_decode (info[l]->ci[nr].env);
}
Exemplo n.º 28
0
tree
evaluate_impl (tree t) {
  //cout << "Really evaluate " << t << LF;
  switch (L(t)) {
  /* Typesetting primitives with side effects */
  case DATOMS:
    return evaluate_formatting (t, ATOM_DECORATIONS);
  case DLINES:
    return evaluate_formatting (t, LINE_DECORATIONS);
  case DPAGES:
    return evaluate_formatting (t, PAGE_DECORATIONS);
  case TFORMAT:
    return evaluate_formatting (t, CELL_FORMAT);
  case TABLE:
    return evaluate_table (t);

  /* Primitives for macro expansion */
  case ASSIGN:
    return evaluate_assign (t);
  case WITH:
    return evaluate_with (t);
  case PROVIDES:
    return evaluate_provides (t);
  case VALUE:
    return evaluate_value (t);
  case QUOTE_VALUE:
    return evaluate_quote_value (t);
  case MACRO:
    return copy (t);
  case DRD_PROPS:
    return evaluate_drd_props (t);
#ifdef CLASSICAL_MACRO_EXPANSION
  case ARG:
    return evaluate_arg (t);
  case QUOTE_ARG:
    return evaluate_quote_arg (t);
#endif
  case COMPOUND:
    return evaluate_compound (t);
  case XMACRO:
    return copy (t);
  case GET_LABEL:
    return evaluate_get_label (t);
  case GET_ARITY:
    return evaluate_get_arity (t);

  /* Primitives for quoting and evaluation */
  case MAP_ARGS:
    return evaluate_rewrite (t);
  case EVAL_ARGS:
    return evaluate_eval_args (t);
  case MARK:
    return tree (MARK, copy (t[0]), evaluate (t[1]));
  case EXPAND_AS:
    return evaluate (t[1]);
  case EVAL:
    return evaluate (evaluate (t[0]));
  case QUOTE:
    return t[0];
  case QUASI:
    return evaluate (evaluate_quasiquote (t[0]));
  case QUASIQUOTE:
    return evaluate_quasiquote (t[0]);
  case UNQUOTE:
  case VAR_UNQUOTE:
    return evaluate (t[0]);
  case COPY:
    return copy (evaluate (t[0]));    

  /* Control structures */
  case IF:
  case VAR_IF:
    return evaluate_if (t);
  case CASE:
    return evaluate_case (t);
  case WHILE:
    return evaluate_while (t);
  case FOR_EACH:
    return evaluate_for_each (t);
  case EXTERN:
    return evaluate_rewrite (t);
  case VAR_INCLUDE:
    return evaluate_include (t);
  case WITH_PACKAGE:
    return evaluate_rewrite (t);
  case USE_PACKAGE:
    return evaluate_use_package (t);
  case USE_MODULE:
    return evaluate_use_module (t);

  /* Computational markup */
  case OR:
    return evaluate_or (t);
  case XOR:
    return evaluate_xor (t);
  case AND:
    return evaluate_and (t);
  case NOT:
    return evaluate_not (t);
  case PLUS:
  case MINUS:
    return evaluate_plus_minus (t);
  case TIMES:
  case OVER:
    return evaluate_times_over (t);
  case DIV:
    return evaluate_divide (t);
  case MOD:
    return evaluate_modulo (t);
  case MATH_SQRT:
    return evaluate_math_sqrt (t);
  case EXP:
    return evaluate_exp (t);
  case LOG:
    return evaluate_log (t);
  case POW:
    return evaluate_pow (t);
  case COS:
    return evaluate_cos (t);
  case SIN:
    return evaluate_sin (t);
  case TAN:
    return evaluate_tan (t);
  case MERGE:
    return evaluate_merge (t);
  case LENGTH:
    return evaluate_length (t);
  case RANGE:
    return evaluate_range (t);
  case NUMBER:
    return evaluate_number (t);
  case _DATE:
    return evaluate_date (t);
  case TRANSLATE:
    return evaluate_translate (t);
  case CHANGE_CASE:
    return evaluate_change_case (t);
  case FIND_FILE:
    return evaluate_find_file (t);
  case IS_TUPLE:
    return evaluate_is_tuple (t);
  case LOOK_UP:
    return evaluate_lookup (t);
  case EQUAL:
    return evaluate_equal (t);
  case UNEQUAL:
    return evaluate_unequal (t);
  case LESS:
    return evaluate_less (t);
  case LESSEQ:
    return evaluate_lesseq (t);
  case GREATER:
    return evaluate_greater (t);
  case GREATEREQ:
    return evaluate_greatereq (t);
  case BLEND:
    return evaluate_blend (t);

  /* Length units */
  case CM_LENGTH:
    return evaluate_cm_length ();
  case MM_LENGTH:
    return evaluate_mm_length ();
  case IN_LENGTH:
    return evaluate_in_length ();
  case PT_LENGTH:
    return evaluate_pt_length ();
  case BP_LENGTH:
    return evaluate_bp_length ();
  case DD_LENGTH:
    return evaluate_dd_length ();
  case PC_LENGTH:
    return evaluate_pc_length ();
  case CC_LENGTH:
    return evaluate_cc_length ();
  case FS_LENGTH:
    return evaluate_fs_length ();
  case FBS_LENGTH:
    return evaluate_fbs_length ();
  case EM_LENGTH:
    return evaluate_em_length ();
  case LN_LENGTH:
    return evaluate_ln_length ();
  case SEP_LENGTH:
    return evaluate_sep_length ();
  case YFRAC_LENGTH:
    return evaluate_yfrac_length ();
  case EX_LENGTH:
    return evaluate_ex_length ();
  case FN_LENGTH:
    return evaluate_fn_length ();
  case FNS_LENGTH:
    return evaluate_fns_length ();
  case BLS_LENGTH:
    return evaluate_bls_length ();
  case FNBOT_LENGTH:
    return evaluate_fnbot_length ();
  case FNTOP_LENGTH:
    return evaluate_fntop_length ();
  case SPC_LENGTH:
    return evaluate_spc_length ();
  case XSPC_LENGTH:
    return evaluate_xspc_length ();
  case PAR_LENGTH:
    return evaluate_par_length ();
  case PAG_LENGTH:
    return evaluate_pag_length ();
  case GW_LENGTH:
    return evaluate_gw_length ();
  case GH_LENGTH:
    return evaluate_gh_length ();
  case GU_LENGTH:
    return evaluate_gu_length ();
  case TMPT_LENGTH:
    return evaluate_tmpt_length ();
  case PX_LENGTH:
    return evaluate_px_length ();
  case MSEC_LENGTH:
    return evaluate_msec_length ();
  case SEC_LENGTH:
    return evaluate_sec_length ();
  case MIN_LENGTH:
    return evaluate_min_length ();
  case HR_LENGTH:
    return evaluate_hr_length ();

  /* Primitives for stylesheet editing */
  case STYLE_WITH:
  case VAR_STYLE_WITH:
    return evaluate (t[N(t)-1]);
  case STYLE_ONLY:
  case VAR_STYLE_ONLY:
  case ACTIVE:
  case VAR_ACTIVE:
  case INACTIVE:
  case VAR_INACTIVE:
    return evaluate_compound (t);
  case REWRITE_INACTIVE:
    return evaluate_rewrite (t);

  /* Linking primitives */
  case HARD_ID:
    return evaluate_hard_id (t[0]);
  case SCRIPT:
    return evaluate_script (t);
  case HLINK:
  case ACTION:
    return evaluate_compound (t);
  case SET_BINDING:
    return evaluate_set_binding (t);
  case GET_BINDING:
    return evaluate_get_binding (t);

  /* Graphical primitives */
  case PATTERN:
    return evaluate_pattern (t);
  case _POINT:
    return evaluate_point (t);
    /*
  case BOX_INFO:
    return evaluate_box_info (t);
  case FRAME_DIRECT:
    return evaluate_frame_direct (t);
  case FRAME_INVERSE:
    return evaluate_frame_inverse (t);
    */

  /* User extensions */
  default:
    if (L(t) < START_EXTENSIONS) {
      int i, n= N(t);
      tree r (t, n);
      for (i=0; i<n; i++)
	r[i]= evaluate (t[i]);
      transfer_ip (t, r);
      return r;
    }
    else {
      tree r= evaluate_compound (t);
      return r;
    }      
  }
}
Exemplo n.º 29
0
/*
 * Establish a relationship between the specified key and cipher
 * and, if necessary, allocate a hardware index from the driver.
 * Note that when a fixed key index is required it must be specified
 * and we blindly assign it w/o consulting the driver (XXX).
 *
 * This must be the first call applied to a key; all the other key
 * routines assume wk_cipher is setup.
 *
 * Locking must be handled by the caller using:
 *	ieee80211_key_update_begin(vap);
 *	ieee80211_key_update_end(vap);
 */
int
ieee80211_crypto_newkey(struct ieee80211vap *vap,
	int cipher, int flags, struct ieee80211_key *key)
{
#define	N(a)	(sizeof(a) / sizeof(a[0]))
	const struct ieee80211_cipher *cip;
	void *keyctx;
	int oflags;

	/*
	 * Validate cipher and set reference to cipher routines.
	 */
	if (cipher >= IEEE80211_CIPHER_MAX) {
		IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
			"%s: invalid cipher %u\n", __func__, cipher);
		vap->iv_stats.is_crypto_badcipher++;
		return 0;
	}
	cip = ciphers[cipher];
	if (cip == NULL) {
		/*
		 * Auto-load cipher module if we have a well-known name
		 * for it.  It might be better to use string names rather
		 * than numbers and craft a module name based on the cipher
		 * name; e.g. wlan_cipher_<cipher-name>.
		 */
		if (cipher < N(cipher_modnames)) {
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
				"%s: unregistered cipher %u, load module %s\n",
				__func__, cipher, cipher_modnames[cipher]);
			ieee80211_load_module(cipher_modnames[cipher]);
			/*
			 * If cipher module loaded it should immediately
			 * call ieee80211_crypto_register which will fill
			 * in the entry in the ciphers array.
			 */
			cip = ciphers[cipher];
		}
		if (cip == NULL) {
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
				"%s: unable to load cipher %u, module %s\n",
				__func__, cipher,
				cipher < N(cipher_modnames) ?
					cipher_modnames[cipher] : "<unknown>");
			vap->iv_stats.is_crypto_nocipher++;
			return 0;
		}
	}

	oflags = key->wk_flags;
	flags &= IEEE80211_KEY_COMMON;
	/*
	 * If the hardware does not support the cipher then
	 * fallback to a host-based implementation.
	 */
	if ((vap->iv_caps & (1<<cipher)) == 0) {
		IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
		    "%s: no h/w support for cipher %s, falling back to s/w\n",
		    __func__, cip->ic_name);
		flags |= IEEE80211_KEY_SWCRYPT;
	}
	/*
	 * Hardware TKIP with software MIC is an important
	 * combination; we handle it by flagging each key,
	 * the cipher modules honor it.
	 */
	if (cipher == IEEE80211_CIPHER_TKIP) {
		if ((vap->iv_caps & IEEE80211_C_TKIPMIC) == 0) {
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
				"%s: no h/w support for TKIP MIC, falling back to s/w\n",
			 __func__);        
			flags |= IEEE80211_KEY_SWMIC;
        }
		else if (((vap->iv_caps & IEEE80211_C_WME_TKIPMIC) == 0) &&
				 (vap->iv_flags & IEEE80211_F_WME)) {
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
			  "%s: no h/w support for TKIP MIC when WMM is turned on, falling back to s/w\n",
			__func__);
			flags |= IEEE80211_KEY_SWMIC;            
		}
	}

	/*
	 * Bind cipher to key instance.  Note we do this
	 * after checking the device capabilities so the
	 * cipher module can optimize space usage based on
	 * whether or not it needs to do the cipher work.
	 */
	if (key->wk_cipher != cip || key->wk_flags != flags) {
again:
		/*
		 * Fillin the flags so cipher modules can see s/w
		 * crypto requirements and potentially allocate
		 * different state and/or attach different method
		 * pointers.
		 *
		 * XXX this is not right when s/w crypto fallback
		 *     fails and we try to restore previous state.
		 */
		key->wk_flags = flags;
		keyctx = cip->ic_attach(vap, key);
		if (keyctx == NULL) {
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
				"%s: unable to attach cipher %s\n",
				__func__, cip->ic_name);
			key->wk_flags = oflags;	/* restore old flags */
			vap->iv_stats.is_crypto_attachfail++;
			return 0;
		}
		cipher_detach(key);
		key->wk_cipher = cip;		/* XXX refcnt? */
		key->wk_private = keyctx;
	}
	/*
	 * Commit to requested usage so driver can see the flags.
	 */
	key->wk_flags = flags;

	/*
	 * Ask the driver for a key index if we don't have one.
	 * Note that entries in the global key table always have
	 * an index; this means it's safe to call this routine
	 * for these entries just to setup the reference to the
	 * cipher template.  Note also that when using software
	 * crypto we also call the driver to give us a key index.
	 */
	if (key->wk_keyix == IEEE80211_KEYIX_NONE) {
		key->wk_keyix = dev_key_alloc(vap, key);
		if (key->wk_keyix == IEEE80211_KEYIX_NONE) {
			/*
			 * Driver has no room; fallback to doing crypto
			 * in the host.  We change the flags and start the
			 * procedure over.  If we get back here then there's
			 * no hope and we bail.  Note that this can leave
			 * the key in a inconsistent state if the caller
			 * continues to use it.
			 */
			if ((key->wk_flags & IEEE80211_KEY_SWCRYPT) == 0) {
				vap->iv_stats.is_crypto_swfallback++;
				IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
				    "%s: no h/w resources for cipher %s, "
				    "falling back to s/w\n", __func__,
				    cip->ic_name);
				oflags = key->wk_flags;
				flags |= IEEE80211_KEY_SWCRYPT;
				if (cipher == IEEE80211_CIPHER_TKIP)
					flags |= IEEE80211_KEY_SWMIC;
				goto again;
			}
			vap->iv_stats.is_crypto_keyfail++;
			IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
			    "%s: unable to setup cipher %s\n",
			    __func__, cip->ic_name);
			return 0;
		}
	}
	return 1;
#undef N
}
Exemplo n.º 30
0
/*
 * This is a list of the valid names in the
 * process-specific sub-directories.  It is
 * used in procfs_lookup and procfs_readdir
 */
static struct proc_target {
	u_char	pt_type;
	u_char	pt_namlen;
	char	*pt_name;
	pfstype	pt_pfstype;
	int	(*pt_valid) (struct lwp *p);
} proc_targets[] = {
#define N(s) sizeof(s)-1, s
	/*	  name		type		validp */
	{ DT_DIR, N("."),	Pproc,		NULL },
	{ DT_DIR, N(".."),	Proot,		NULL },
	{ DT_REG, N("mem"),	Pmem,		NULL },
	{ DT_REG, N("regs"),	Pregs,		procfs_validregs },
	{ DT_REG, N("fpregs"),	Pfpregs,	procfs_validfpregs },
	{ DT_REG, N("dbregs"),	Pdbregs,	procfs_validdbregs },
	{ DT_REG, N("ctl"),	Pctl,		NULL },
	{ DT_REG, N("status"),	Pstatus,	NULL },
	{ DT_REG, N("note"),	Pnote,		NULL },
	{ DT_REG, N("notepg"),	Pnotepg,	NULL },
	{ DT_REG, N("map"), 	Pmap,		procfs_validmap },
	{ DT_REG, N("etype"),	Ptype,		procfs_validtype },
	{ DT_REG, N("cmdline"),	Pcmdline,	NULL },
	{ DT_REG, N("rlimit"),	Prlimit,	NULL },
	{ DT_LNK, N("file"),	Pfile,		NULL },
#undef N