📄 language.values.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>Values and Expressions</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="The eCos Component Writer's Guide"HREF="cdl-guide.html"><LINKREL="UP"TITLE="The CDL Language"HREF="language.html"><LINKREL="PREVIOUS"TITLE="An Introduction to Tcl"HREF="language.tcl.html"><LINKREL="NEXT"TITLE="Interfaces"HREF="language.interface.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">The <SPANCLASS="APPLICATION">eCos</SPAN> Component Writer's Guide</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="language.tcl.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 3. The CDL Language</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="language.interface.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="LANGUAGE.VALUES">Values and Expressions</H1><P>It is fairly reasonable to expect that enabling or disabling aconfiguration option such as<TTCLASS="VARNAME">CYGVAR_KERNEL_THREADS_DATA</TT> in some way affects its<SPANCLASS="emphasis"><ICLASS="EMPHASIS">value</I></SPAN>. This will have an effect on anyexpressions that reference this option such as<TTCLASS="LITERAL">requires CYGVAR_KERNEL_THREADS_DATA</TT>. It willalso affect the consequences of that option: how it affects the buildprocess and what happens to any constraints that<TTCLASS="VARNAME">CYGVAR_KERNEL_THREADS_DATA</TT> may impose (as opposedto constraints on this option imposed by others).</P><P>In a language like C the handling of variables is relativelystraightforward. If a variable <TTCLASS="VARNAME">x</TT> gets referenced inan expression such as <TTCLASS="LITERAL">if (x != 0)</TT>,and that variable is not defined anywhere, then the code will fail tobuild, typically with an unresolved error at link-time. Also in Ca variable <TTCLASS="VARNAME">x</TT> does not live in any hierarchy, so itsvalue for the purposes of expression evaluation is not affected byanything else. C variables also have a clear type such as<TTCLASS="LITERAL">int</TT> or <TTCLASS="LITERAL">long double</TT>. </P><P>In <SPANCLASS="APPLICATION">CDL</SPAN> things are not so straightforward.</P><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="LANGUAGE.VALUES.VALUE">Option Values</H2><P>There are four factors which go into an option's value:</P><P></P><OLTYPE="1"><LI><P>An option may or may not be loaded.</P></LI><LI><P>If the option is loaded, it may or may not be active.</P></LI><LI><P>Even if the option is active, it may or may not be enabled.</P></LI><LI><P>If the option is loaded, active and enabled then it will have someassociated data which constitutes its value.</P></LI></OL><DIVCLASS="SECT3"><H3CLASS="SECT3"><ANAME="LANGUAGE.VALUES.VALUE.LOADED">Is the Option Loaded?</H3><P>At any one time a configuration will contain only a subset of allpossible packages. In fact it is impossible to combine certainpackages in a single configuration. For example architectural HALpackages should contain a set of options defining endianness, thesizes of basic data types and so on (many of which will of course beconstant for any given architecture). Any attempt to load twoarchitectural HAL packages into a configuration will fail because ofthe resulting name clash. Since <SPANCLASS="APPLICATION">CDL</SPAN> expressions can referenceoptions in other packages, and often need to do so, it is essential todefine the resulting behavior.</P><P>One complication is that the component framework does not know aboutevery single option in every single package. Obviously it cannot knowabout packages from arbitrary third parties which have not beeninstalled. Even for packages which have been installed, the currentrepository database does not hold details of every option, only of thepackages themselves. If a <SPANCLASS="APPLICATION">CDL</SPAN> expression contains a reference tosome option <TTCLASS="VARNAME">CYGSEM_KERNEL_SCHED_TIMESLICE</TT> then thecomponent framework will only know about this option if the kernelpackage is actually loaded into the current configuration. If thepackage is not loaded then theoretically the framework might guessthat the option is somehow related to the kernel by examining theoption name but this would not be robust: the option could easily bepart of some other package that violates the naming convention.</P><P>Assume that the user is building a minimal configuration which doesnot contain the kernel package, but does have other packages whichcontain the following constraints:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> requires CYGPKG_KERNEL requires CYGPKG_KERNEL_THREADS_DATA requires !CYGSEM_KERNEL_SCHED_TIMESLICE</PRE></TD></TR></TABLE><P>Clearly the first constraint is not satisfied because the kernel isnot loaded. The second constraint is also not satisfied. The thirdconstraint is trivially satisfied: if there is no kernel then thekernel's timeslicing support cannot possibly be enabled. </P><P>Any options which are not in the current configuration are handled asfollows: </P><P></P><OLTYPE="1"><LI><P>Any references to that option will evaluate to <TTCLASS="LITERAL">0</TT>,so <TTCLASS="LITERAL">requires !CYGSEM_KERNEL_SCHED_TIMESLICE</TT> willbe satisfied but<TTCLASS="LITERAL">requires CYGSEM_KERNEL_THREADS_DATA</TT> will notbe satisfied.</P></LI><LI><P>An option that is not loaded has no consequences on the build process.It cannot directly result in any <TTCLASS="LITERAL">#define's</TT> in aconfiguration header file, nor in any files being compiled. This isonly reasonable: if the option is not loaded then the componentframework has no way of knowing about any <SPANCLASS="PROPERTY">compile</SPAN> or similarproperties. An option that is not loaded can have indirectconsequences by being referenced in <SPANCLASS="APPLICATION">CDL</SPAN> expressions.</P></LI><LI><P>An option that is not loaded cannot impose any constraints on the restof the configuration. Again this is the only reasonable behavior: ifthe option is not loaded then any associated <SPANCLASS="PROPERTY">requires</SPAN> or<SPANCLASS="PROPERTY">legal_values</SPAN> properties will not be known.</P></LI></OL></DIV><DIVCLASS="SECT3"><H3CLASS="SECT3"><ANAME="LANGUAGE.VALUES.VALUE.ACTIVE">Is the Option Active</H3><P>The next issue to consider is whether or not a particular option isactive. Configuration options are organized in a hierarchy ofcomponents and sub-components. For example the C library packagecontains a component <TTCLASS="VARNAME">CYGPKG_LIBC_STDIO</TT> containingall the options related to standard I/O. If a user disables thecomponent as a whole then all the options below it become inactive: itmakes no sense to disable all stdio functionality and then manipulatethe buffer sizes.</P><P>Inactive is not quite the same as disabled, although the effects aresimilar. The value of an inactive option is preserved. If the usermodifies a buffer size option, then disables the whole stdiocomponent, the buffer size value remains in case the stdio componentis re-enabled later on. Some tools such as the graphical configurationtool will treat inactive options specially, for example such optionsmay be grayed out.</P><P>The active or inactive state of an option may affect other packages.For example a package may use the <TTCLASS="FUNCTION">sprintf</TT>function and require support for floating point conversions, aconstraint that is not satisfied if the relevant option is inactive.It is necessary to define exactly what it means for an option to beinactive:</P><P></P><OLTYPE="1"><LI><P>An option is inactive if its parent is either inactive or disabled.For example if <TTCLASS="VARNAME">CYGPKG_LIBC_STDIO</TT> is disabled thenall the options and sub-components become inactive; since<TTCLASS="VARNAME">CYGPKG_LIBC_STDIO_FLOATING_POINT</TT> is now inactive,<TTCLASS="VARNAME">CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT</TT> is inactiveas well.</P></LI><LI><P>Options may also be inactive as a result of an <SPANCLASS="PROPERTY">active_if</SPAN> property.This is useful if a particular option is only relevant if two or moredisjoint sets of conditions need to be satisfied, since thehierarchical structure can only cope with at most one such set.</P></LI><LI><P>If an option is inactive then any references to that option in <SPANCLASS="APPLICATION">CDL</SPAN>expressions will evaluate to <TTCLASS="LITERAL">0</TT>. Hence a constraintof the form<TTCLASS="LITERAL">requires CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT</TT>is not satisfied if the entire stdio component is disabled.</P></LI><LI><P>An option that is inactive has no consequences on the build process.No <TTCLASS="LITERAL">#define</TT> will be generated. Any <SPANCLASS="PROPERTY">compile</SPAN> orsimilar properties will be ignored.</P></LI><LI><P>An option that is inactive cannot impose any constraints on the restof the configuration. For example<TTCLASS="VARNAME">CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT</TT> has adependency <TTCLASS="LITERAL">requires CYGPKG_LIBM</TT>, but if all ofthe stdio functionality is disabled then this constraint is ignored(although of course there may be other packages which have adependency on <TTCLASS="VARNAME">CYGPKG_LIBM</TT>.</P></LI></OL></DIV><DIVCLASS="SECT3"><H3CLASS="SECT3"><ANAME="LANGUAGE.VALUES.VALUE.ENABLED">Is the Option Enabled? What is the Data?</H3><P>The majority of configuration options are boolean in nature, so theuser can either enable or disable some functionality. Some options aredifferent. For example <TTCLASS="VARNAME">CYGNUM_LIBC_STDIO_BUFSIZE</TT> isa number, and <TTCLASS="VARNAME">CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE</TT> isa string corresponding to a device name. A few options like<TTCLASS="VARNAME">CYGDAT_UITRON_TASK_EXTERNS</TT> can get verycomplicated. <SPANCLASS="APPLICATION">CDL</SPAN> has to cope with this variety, and define the exactbehavior of the system in terms of constraints and build-timeconsequences. </P><P>In <SPANCLASS="APPLICATION">CDL</SPAN> the value of an option consists of two parts. There is aboolean part, controlling whether or not the option is enabled. Thereis also a data part, providing additional information. For mostoptions one of these parts is fixed, as controlled by the option's<SPANCLASS="PROPERTY">flavor</SPAN> property:</P><DIVCLASS="INFORMALTABLE"><ANAME="AEN1413"><P></P><TABLEBORDER="1"CLASS="CALSTABLE"><THEAD><TR><THALIGN="LEFT"VALIGN="TOP">Flavor</TH><THALIGN="LEFT"VALIGN="TOP">Enabled</TH><THALIGN="LEFT"VALIGN="TOP">Data</TH></TR></THEAD><TBODY><TR><TDALIGN="LEFT"VALIGN="TOP"><TTCLASS="LITERAL">none</TT></TD><TDALIGN="LEFT"VALIGN="TOP">Always enabled</TD><TDALIGN="LEFT"VALIGN="TOP"><TTCLASS="LITERAL">1</TT>, not modifiable</TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"><TTCLASS="LITERAL">bool</TT></TD><TDALIGN="LEFT"VALIGN="TOP">User-modifiable</TD><TDALIGN="LEFT"VALIGN="TOP"><TTCLASS="LITERAL">1</TT>, not modifiable</TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"><TTCLASS="LITERAL">data</TT></TD><TDALIGN="LEFT"VALIGN="TOP">Always enabled</TD><TDALIGN="LEFT"VALIGN="TOP">User-modifiable</TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"><TTCLASS="LITERAL">booldata</TT></TD><TDALIGN="LEFT"VALIGN="TOP">User-modifiable</TD><TDALIGN="LEFT"VALIGN="TOP">User-modifiable</TD></TR></TBODY></TABLE><P></P></DIV><P>The effects of the boolean and data parts are as follows:</P><P></P><OLTYPE="1"><LI><P>If an option is disabled, in other words if the boolean part is false,then any references to that option in <SPANCLASS="APPLICATION">CDL</SPAN> expressions will evaluateto <TTCLASS="LITERAL">0</TT>. This is the same behavior as for inactiveoptions. The data part is not relevant. The <TTCLASS="LITERAL">none</TT>and <TTCLASS="LITERAL">data</TT> flavors specify that the option is alwaysenabled, in which case this rule is not applicable.</P></LI><LI><P
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -