⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 language.values.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 5 页
字号:
NAME="LANGUAGE.FUNCTIONS">Functions</H2><P>CDL expressions can contain calls to a set of built-in functionsusing the usual syntax, for example;</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, "-fno-rtti") }</PRE></TD></TR></TABLE><P>The available function calls are as follows:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="LITERAL">get_data(option)</TT></DT><DD><P>This function can be used to obtain just the data part of a loadedconfiguration option, ignoring other factors such as whether or notthe option is active and enabled. It takes a single argument whichshould be the name of a configuration option. If the specified optionis not loaded in the current configuration then the function returns0, otherwise it returns the data part. Typically this function willonly be used in conjunction with <TTCLASS="FUNCTION">is_active</TT> and<TTCLASS="FUNCTION">is_enabled</TT> for fine-grained control over thevarious factors that make up an option's value.</P></DD><DT><TTCLASS="LITERAL">is_active(option)</TT></DT><DD><P>This function can be used to determine whether or not a particularconfiguration option is active. It takes a single argument whichshould be the name of an option, and returns a boolean. If thespecified option is not loaded then the function will return false.Otherwise it will consider the state of the option's parents andevaluate any <SPANCLASS="PROPERTY">active_if</SPAN> properties, and return the option's currentactive state. A typical use might be:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { is_active(CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE) implies                   (CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE &#62;= (16 * 1024)) }</PRE></TD></TR></TABLE><P>In other words either the specified configuration option must beinactive, for example because the current application does not useany related C library or POSIX functionality, or the stack size mustbe at least 16K.</P><P>The configuration system's inference engine can attempt to satisfyconstraints involving <TTCLASS="FUNCTION">is_active</TT> in variousdifferent ways, for example by enabling or disabling parentcomponents, or by examining <SPANCLASS="PROPERTY">active_if</SPAN> properties and manipulatingterms in the associated expressions.</P></DD><DT><TTCLASS="LITERAL">is_enabled(option)</TT></DT><DD><P>This function can be used to determine whether or not a particularconfiguration option is enabled. It takes a single argument whichshould be the name of an option, and returns a boolean. If thespecified option is not loaded then the function will return false.Otherwise it will return the current boolean part of the option'svalue. The option's active or inactive state is ignored. Typicallythis function will be used in conjunction with<TTCLASS="FUNCTION">is_active</TT> and possibly<TTCLASS="FUNCTION">get_data</TT> to provide fine-grained control over thevarious factors that make up an option's value.</P></DD><DT><TTCLASS="LITERAL">is_loaded(option)</TT></DT><DD><P>This function can be used to determine whether or not a particularconfiguration option is loaded. It takes a single argument whichshould be the name of an option, and returns a boolean. If theargument is a package then the <TTCLASS="FUNCTION">is_loaded</TT> functionprovides little or no extra information, for example the following twoconstraints are usually equivalent:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { CYGPKG_KERNEL }    requires { is_loaded(CYGPKG_KERNEL) }</PRE></TD></TR></TABLE><P>However if the specified package is loaded but re-parented below adisabled component, or inactive as a result of an <SPANCLASS="PROPERTY">active_if</SPAN>property, then the first constraint would not be satisfied but thesecond constraint would. In other words the<TTCLASS="FUNCTION">is_loaded</TT> makes it possible to consider inisolation one of the factors that are considered when CDL expressionsare evaluated.</P><P>The configuration system's inference engine will not automaticallyload or unload packages to satisfy <TTCLASS="FUNCTION">is_loaded</TT>constraints. </P></DD><DT><TTCLASS="LITERAL">is_substr(haystack,&nbsp;needle)</TT></DT><DD><P>This can be used to check whether or not a particular string ispresent in another string. It is used mainly for manipulating compilerflags. The function takes two arguments, both of which can bearbitrary expressions, and returns a boolean.</P><P><TTCLASS="FUNCTION">is_substr</TT> has some understanding of wordboundaries. If the second argument starts with a space character thenthat will match either a real space or the start of the string.Similarly if the second argument ends with a space character then thatwill match a real space or the end of the string. For example, all ofthe following conditions are satisfied:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    is_substr("abracadabra", "abra")    is_substr("abracadabra", " abra")    is_substr("hocus pocus", " pocus")    is_substr("abracadabra", "abra ")</PRE></TD></TR></TABLE><P>The first is an exact match. The second is a match because the leadingspace matches the start of the string. The third is an exact match,with the leading space matching an actual space. The fourth is a matchbecause the trailing space matches the end of the string. However, thefollowing condition is not satisfied.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    is_substr("abracadabra", " abra ")</PRE></TD></TR></TABLE><P>This fails to match at the start of the string because the trailingspace is not matched by either a real space or the end of the string.Similarly it fails to match at the end of the string.</P><P>If a constraint involving <TTCLASS="FUNCTION">is_substr</TT> is notsatisfied and the first argument is a reference to a configurationoption, the inference engine will attempt to modify that option'svalue. This can be achieved either by appending the second argument tothe current value, or by removing all occurrences of that argumentfrom the current value.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, " -fno-rtti ") }    requires { is_substr(CYGBLD_GLOBAL_CFLAGS, " -frtti ") }</PRE></TD></TR></TABLE><P>When data is removed the leading and trailing spaces will be left. Forexample, given an initial value of&#60;<TTCLASS="VARNAME">CYGBLD_GLOBAL_CFLAGS</TT> of<TTCLASS="LITERAL">-g&nbsp;-fno-rtti&nbsp;-O2</TT> the result will be<TTCLASS="LITERAL">-g&nbsp;&nbsp;-O2</TT> rather than <TTCLASS="LITERAL">-g-O2</TT>.</P><P>If exact matches are needed, the function<TTCLASS="FUNCTION">is_xsubstr</TT> can be used instead.</P></DD><DT><TTCLASS="LITERAL">is_xsubstr(haystack,&nbsp;needle)</TT></DT><DD><P>This function checks whether or not the pattern string is an exactsubstring of the string being searched. It is similar to<TTCLASS="FUNCTION">is_substr</TT> but uses exact matching only. In otherwords, leading or trailing spaces have to match exactly and will notmatch the beginning or end of the string being searched. The functiontakes two arguments, both of which can be arbitrary expressions, andreturns a boolean. The difference between<TTCLASS="FUNCTION">is_substr</TT> and <TTCLASS="FUNCTION">is_xsubstr</TT> isillustrated by the following examples:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    cdl_option MAGIC {        flavor data        default_value { "abracadabra" }    }    &#8230;    requires { is_substr(MAGIC,  " abra") }    requires { is_xsubstr(MAGIC, " abra") }</PRE></TD></TR></TABLE><P>The first goal will be satisfied because the leading space in thepattern matches the beginning of the string. The second goal will notbe satisfied initialy because there is no exact match, so theinference engine is likely to update the value of<TTCLASS="VARNAME">MAGIC</TT> to <TTCLASS="LITERAL">abracadabra abra</TT> whichdoes give an exact match.</P></DD><DT><TTCLASS="LITERAL">version_cmp(A,&nbsp;B)</TT></DT><DD><P>This function is used primarily to check that a sufficiently recent<AHREF="package.versions.html">version</A> of some other packageis being used. It takes two arguments, both of which can be arbitraryexpressions. In practice usually one of the arguments will be areference to a package and the other will be a constant versionstring. The return value is -1 if the first argument is a more recentversion then the second, 0 if the two arguments correspond toidentical versions, and 1 if the first argument is an older version.For example the following constraint can be used to indicate that thecurrent package depends on kernel functionality that only becameavailable in version 1.3:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { version_cmp(CYGPKG_KERNEL, "v1.3") &#60;= 0 }</PRE></TD></TR></TABLE></DD></DL></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>At this time it is not possible to define new functions inside a CDLscript. Instead functions can only be added at the C++ level, usuallyby extending libcdl itself. This is partly because there is more toCDL functions than simple evaluation: associated with most functionsis support for the inference engine, so that if a constraint involvinga function is not currently satisfied the system may be able to find asolution automatically.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="LANGUAGE.GOAL-EXPRESSION">Goal Expressions</H2><P>The arguments to certain properties, notably <SPANCLASS="PROPERTY">requires</SPAN> and<SPANCLASS="PROPERTY">active_if</SPAN>, constitute a goal expression. As with an ordinaryexpression, all of the arguments get combined and then the expressionparser takes over. The same care has to be taken with constant stringsand anything else that may get processed by the Tcl interpreter, sooften a goal expression is enclosed entirely in braces and theexpression parsing code sees just a single argument.</P><P>A goal expression is basically just a sequence of ordinaryexpressions, for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS               !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT               !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT }</PRE></TD></TR></TABLE><P>This consists of three separate expressions, all of which shouldevaluate to a non-zero result. The same expression could be writtenas: </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS  &#38;&#38;               !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT &#38;&#38;               !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT }</PRE></TD></TR></TABLE><P>Alternatively the following would have much the same effect:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS    requires !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT    requires !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT</PRE></TD></TR></TABLE><P>Selecting between these alternatives is largely a stylistic choice.The first is slightly more concise than the others. The second is morelikely to appeal to mathematical purists. The third is more amenableto cutting and pasting.</P><P>The result of evaluating a goal expression is a boolean. If any partof the goal expression evaluates to the integer <TTCLASS="LITERAL">0</TT>or an equivalent string then the result is false, otherwise it istrue. </P><P>The term &#8220;goal&nbsp;expression&#8221; relates to the componentframework's inference engine: it is a description of a goal thatshould be satisfied for a conflict-free configuration. If a <SPANCLASS="PROPERTY">requires</SPAN>constraint is not satisfied then the inference engine will examine thegoal expression: if there is some way of changing the configurationthat does not introduce new conflicts and that will cause the goalexpression to evaluate to true, the conflict can be resolved.</P><P>The inference engine works with one conflict and hence one goalexpression at a time. This means that there can be slightly differentbehavior if a constraint is specified using a single <SPANCLASS="PROPERTY">requires</SPAN>property or several different ones. Given the above example, supposethat none of the three conditions are satisfied. If a single goalexpression is used then the inference engine might be able to satisfyonly two of the three parts, but since the conflict as a whole cannotbe resolved no part of the solution will be applied. Instead the userwill have to resolve the entire conflict. If three separate goalexpressions are used then the inference engine might well findsolutions to two of them, leaving less work for the user. On the otherhand, if a single goal expression is used then the inference enginehas a bit more information to work with, and it might well find asolution to the entire conflict where it would be unable to findseparate solutions for the three parts. Things can get verycomplicated, and in general component writers should not worry aboutthe subtleties of the inference engine and how to manipulate itsbehavior. </P><P>It is possible to write ambiguous goal expressions, for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires CYGNUM_LIBC_RAND_SEED -CYGNUM_LIBC_RAND_TRACE_LEVEL &gt; 5</PRE></TD></TR></TABLE><P>This could be parsed in two ways:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires ((CYGNUM_LIBC_RAND_SEED - CYGNUM_LIBC_RAND_TRACE_LEVEL) &gt; 5)    requires CYGNUM_LIBC_RAND_SEED &amp;&amp; ((-CYGNUM_LIBC_RAND_TRACE_LEVEL) &gt; 5)</PRE></TD></TR></TABLE><P>The goal expression parsing code will always use the largest ordinaryexpression for each goal, so the first interpretation will be used.In such cases it is a good idea to use brackets and avoid possibleconfusion. </P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="LANGUAGE.LIST-EXPRESSION">List Expressions</H2><P>The arguments to the <SPANCLASS="PROPERTY">legal_values</SPAN> property constitute a goalexpression. As with an ordinary and goal expressions, all of thearguments get combined and then the expression parser takes over. Thesame care has to be taken with constant strings and anything else thatmay get processed by the Tcl interpreter, so often a list expressionis enclosed entirely in braces and the expression parsing code seesjust a single argument.</P><P>Most list expressions take one of two forms:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    legal_values &lt;expr1&gt; &lt;expr2&gt; &lt;expr3&gt; ...    legal_values &lt;expr1&gt; to &lt;expr2&gt;</PRE></TD></TR></TABLE><P><TTCLASS="LITERAL">expr1</TT>, <TTCLASS="LITERAL">expr2</TT> and so on areordinary expressions. Often these will be constants or references tocalculated options in the architectural HAL package, but it ispossible to use arbitrary expressions when necessary. The first syntaxindicates a list of possible values, which need not be numerical. Thesecond syntax indicates a numerical range: both sides of th

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -