Changeset 2296885 for doc/user


Ignore:
Timestamp:
Apr 14, 2018, 7:09:55 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
82df430
Parents:
9ca94af
Message:

add time documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r9ca94af r2296885  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Tue Feb 13 08:31:21 2018
    14 %% Update Count     : 3161
     13%% Last Modified On : Sat Apr 14 19:04:30 2018
     14%% Update Count     : 3318
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    283283
    284284double key = 5.0, vals[10] = { /* 10 sorted floating values */ };
    285 double * val = (double *)bsearch( &key, vals, 10, sizeof(vals[0]), comp );      $\C{// search sorted array}$
     285double * val = (double *)bsearch( &key, vals, 10, sizeof(vals[0]), comp );      §\C{// search sorted array}§
    286286\end{lstlisting}
    287287which can be augmented simply with a polymorphic, type-safe, \CFA-overloaded wrappers:
     
    292292
    293293forall( otype T | { int ?<?( T, T ); } ) unsigned int bsearch( T key, const T * arr, size_t size ) {
    294         T * result = bsearch( key, arr, size ); $\C{// call first version}$
    295         return result ? result - arr : size; }  $\C{// pointer subtraction includes sizeof(T)}$
    296 
    297 double * val = bsearch( 5.0, vals, 10 );        $\C{// selection based on return type}$
     294        T * result = bsearch( key, arr, size ); §\C{// call first version}§
     295        return result ? result - arr : size; }  §\C{// pointer subtraction includes sizeof(T)}§
     296
     297double * val = bsearch( 5.0, vals, 10 );        §\C{// selection based on return type}§
    298298int posn = bsearch( 5.0, vals, 10 );
    299299\end{lstlisting}
     
    353353The 1999 C standard plus GNU extensions.
    354354\item
    355 \Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]$-fgnu89-inline$}}
     355\Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]@-fgnu89-inline@}}
    356356Use the traditional GNU semantics for inline routines in C99 mode, which allows inline routines in header files.
    357357\end{description}
     
    506506
    507507C, \CC, and Java (and many other programming languages) have no exponentiation operator\index{exponentiation!operator}\index{operator!exponentiation}, \ie $x^y$, and instead use a routine, like \Indexc{pow}, to perform the exponentiation operation.
    508 \CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@\lstinline$?\?$} and ©?\=?©\index{?\\=?@\lstinline$?\=?$}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$.
     508\CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@\lstinline@?\?@} and ©?\=?©\index{?\\=?@\lstinline@?\=?@}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$.
    509509The priority of the exponentiation operator is between the cast and multiplicative operators, so that ©w * (int)x \ (int)y * z© is parenthesized as ©((w * (((int)x) \ ((int)y))) * z)©.
    510510
     
    524524
    525525
    526 \section{\texorpdfstring{Labelled \LstKeywordStyle{continue} / \LstKeywordStyle{break}}{Labelled continue / break}}
     526\section{\texorpdfstring{Labelled \protect\lstinline@continue@ / \protect\lstinline@break@}{Labelled continue / break}}
    527527
    528528While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    529529Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting.
    530 To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@\lstinline $continue$!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@\lstinline $break$!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}, as in Java.
     530To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@\lstinline@continue@!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@\lstinline@break@!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}, as in Java.
    531531For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    532532for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement.
     
    613613\end{figure}
    614614
    615 Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline $goto$!restricted} restricted in the following ways:
     615Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline@goto@!restricted} restricted in the following ways:
    616616\begin{itemize}
    617617\item
     
    629629
    630630
    631 \section{\texorpdfstring{\LstKeywordStyle{switch} Statement}{switch Statement}}
     631\section{\texorpdfstring{\protect\lstinline@switch@ Statement}{switch Statement}}
    632632
    633633C allows a number of questionable forms for the ©switch© statement:
     
    834834
    835835
    836 \section{\texorpdfstring{\LstKeywordStyle{case} Clause}{case Clause}}
     836\section{\texorpdfstring{\protect\lstinline@case@ Clause}{case Clause}}
    837837
    838838C restricts the ©case© clause of a ©switch© statement to a single value.
     
    871871\end{tabular}
    872872\end{cquote}
    873 In addition, two forms of subranges are allowed to specify case values: a new \CFA form and an existing GNU C form.\footnote{
    874 The GNU C form \emph{requires} spaces around the ellipse.}
    875 \begin{cquote}
    876 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}}
    877 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{GNU C}}     \\
     873In addition, subranges are allowed to specify case values.\footnote{
     874gcc has the same mechanism but awkward syntax, \lstinline@2 ...42@, because a space is required after a number, otherwise the period is a decimal point.}
    878875\begin{cfa}
    879876switch ( i ) {
    880   case ®1~5:®
     877  case ®1~5:®                                   §\C{// 1, 2, 3, 4, 5}§
    881878        ...
    882   case ®10~15:®
     879  case ®10~15:®                                 §\C{// 10, 11, 12, 13, 14, 15}§
    883880        ...
    884881}
    885882\end{cfa}
    886 &
    887 \begin{cfa}
    888 switch ( i )
    889   case ®1 ... 5®:
    890         ...
    891   case ®10 ... 15®:
    892         ...
    893 }
    894 \end{cfa}
    895 &
    896 \begin{cfa}
    897 
    898 // 1, 2, 3, 4, 5
    899 
    900 // 10, 11, 12, 13, 14, 15
    901 
    902 
    903 \end{cfa}
    904 \end{tabular}
    905 \end{cquote}
    906883Lists of subranges are also allowed.
    907884\begin{cfa}
     
    910887
    911888
    912 \section{\texorpdfstring{\LstKeywordStyle{with} Clause / Statement}{with Clause / Statement}}
    913 \label{s:WithClauseStatement}
     889\section{\texorpdfstring{\protect\lstinline@with@ Statement}{with Statement}}
     890\label{s:WithStatement}
     891
     892Grouping heterogeneous data into \newterm{aggregate}s (structure/union) is a common programming practice, and an aggregate can be further organized into more complex structures, such as arrays and containers:
     893\begin{cfa}
     894struct S {                                                                      §\C{// aggregate}§
     895        char c;                                                                 §\C{// fields}§
     896        int i;
     897        double d;
     898};
     899S s, as[10];
     900\end{cfa}
     901However, functions manipulating aggregates must repeat the aggregate name to access its containing fields:
     902\begin{cfa}
     903void f( S s ) {
     904        `s.`c; `s.`i; `s.`d;                                    §\C{// access containing fields}§
     905}
     906\end{cfa}
     907which extends to multiple levels of qualification for nested aggregates.
     908A similar situation occurs in object-oriented programming, \eg \CC:
     909\begin{C++}
     910struct S {
     911        char c;                                                                 §\C{// fields}§
     912        int i;
     913        double d;
     914        void f() {                                                              §\C{// implicit ``this'' aggregate}§
     915                `this->`c; `this->`i; `this->`d;        §\C{// access containing fields}§
     916        }
     917}
     918\end{C++}
     919Object-oriented nesting of member functions in a \lstinline[language=C++]@class/struct@ allows eliding \lstinline[language=C++]$this->$ because of lexical scoping.
     920However, for other aggregate parameters, qualification is necessary:
     921\begin{cfa}
     922struct T { double m, n; };
     923int S::f( T & t ) {                                                     §\C{// multiple aggregate parameters}§
     924        c; i; d;                                                                §\C{\color{red}// this--{\textgreater}.c, this--{\textgreater}.i, this--{\textgreater}.d}§
     925        `t.`m; `t.`n;                                                   §\C{// must qualify}§
     926}
     927\end{cfa}
     928
     929To simplify the programmer experience, \CFA provides a @with@ statement (see Pascal~\cite[\S~4.F]{Pascal}) to elide aggregate qualification to fields by opening a scope containing the field identifiers.
     930Hence, the qualified fields become variables with the side-effect that it is easier to optimizing field references in a block.
     931\begin{cfa}
     932void f( S & this ) `with ( this )` {            §\C{// with statement}§
     933        c; i; d;                                                                §\C{\color{red}// this.c, this.i, this.d}§
     934}
     935\end{cfa}
     936with the generality of opening multiple aggregate-parameters:
     937\begin{cfa}
     938void f( S & s, T & t ) `with ( s, t )` {                §\C{// multiple aggregate parameters}§
     939        c; i; d;                                                                §\C{\color{red}// s.c, s.i, s.d}§
     940        m; n;                                                                   §\C{\color{red}// t.m, t.n}§
     941}
     942\end{cfa}
     943
     944In detail, the @with@ statement has the form:
     945\begin{cfa}
     946§\emph{with-statement}§:
     947        'with' '(' §\emph{expression-list}§ ')' §\emph{compound-statement}§
     948\end{cfa}
     949and may appear as the body of a function or nested within a function body.
     950Each expression in the expression-list provides a type and object.
     951The type must be an aggregate type.
     952(Enumerations are already opened.)
     953The object is the implicit qualifier for the open structure-fields.
     954
     955All expressions in the expression list are open in parallel within the compound statement.
     956This semantic is different from Pascal, which nests the openings from left to right.
     957The difference between parallel and nesting occurs for fields with the same name and type:
     958\begin{cfa}
     959struct S { int `i`; int j; double m; } s, w;
     960struct T { int `i`; int k; int m; } t, w;
     961with ( s, t ) {
     962        j + k;                                                                  §\C{// unambiguous, s.j + t.k}§
     963        m = 5.0;                                                                §\C{// unambiguous, t.m = 5.0}§
     964        m = 1;                                                                  §\C{// unambiguous, s.m = 1}§
     965        int a = m;                                                              §\C{// unambiguous, a = s.i }§
     966        double b = m;                                                   §\C{// unambiguous, b = t.m}§
     967        int c = s.i + t.i;                                              §\C{// unambiguous, qualification}§
     968        (double)m;                                                              §\C{// unambiguous, cast}§
     969}
     970\end{cfa}
     971For parallel semantics, both @s.i@ and @t.i@ are visible, so @i@ is ambiguous without qualification;
     972for nested semantics, @t.i@ hides @s.i@, so @i@ implies @t.i@.
     973\CFA's ability to overload variables means fields with the same name but different types are automatically disambiguated, eliminating most qualification when opening multiple aggregates.
     974Qualification or a cast is used to disambiguate.
     975
     976There is an interesting problem between parameters and the function-body @with@, \eg:
     977\begin{cfa}
     978void ?{}( S & s, int i ) with ( s ) {           §\C{// constructor}§
     979        `s.i = i;`  j = 3;  m = 5.5;                    §\C{// initialize fields}§
     980}
     981\end{cfa}
     982Here, the assignment @s.i = i@ means @s.i = s.i@, which is meaningless, and there is no mechanism to qualify the parameter @i@, making the assignment impossible using the function-body @with@.
     983To solve this problem, parameters are treated like an initialized aggregate:
     984\begin{cfa}
     985struct Params {
     986        S & s;
     987        int i;
     988} params;
     989\end{cfa}
     990and implicitly opened \emph{after} a function-body open, to give them higher priority:
     991\begin{cfa}
     992void ?{}( S & s, int `i` ) with ( s ) `with( §\emph{\color{red}params}§ )` {
     993        s.i = `i`; j = 3; m = 5.5;
     994}
     995\end{cfa}
     996Finally, a cast may be used to disambiguate among overload variables in a @with@ expression:
     997\begin{cfa}
     998with ( w ) { ... }                                                      §\C{// ambiguous, same name and no context}§
     999with ( (S)w ) { ... }                                           §\C{// unambiguous, cast}§
     1000\end{cfa}
     1001and @with@ expressions may be complex expressions with type reference (see Section~\ref{s:References}) to aggregate:
     1002% \begin{cfa}
     1003% struct S { int i, j; } sv;
     1004% with ( sv ) {                                                         §\C{// implicit reference}§
     1005%       S & sr = sv;
     1006%       with ( sr ) {                                                   §\C{// explicit reference}§
     1007%               S * sp = &sv;
     1008%               with ( *sp ) {                                          §\C{// computed reference}§
     1009%                       i = 3; j = 4;                                   §\C{\color{red}// sp--{\textgreater}i, sp--{\textgreater}j}§
     1010%               }
     1011%               i = 2; j = 3;                                           §\C{\color{red}// sr.i, sr.j}§
     1012%       }
     1013%       i = 1; j = 2;                                                   §\C{\color{red}// sv.i, sv.j}§
     1014% }
     1015% \end{cfa}
    9141016
    9151017In \Index{object-oriented} programming, there is an implicit first parameter, often names \textbf{©self©} or \textbf{©this©}, which is elided.
     
    9351037\CFA provides a ©with© clause/statement (see Pascal~\cite[\S~4.F]{Pascal}) to elided the "©this.©" by opening a scope containing field identifiers, changing the qualified fields into variables and giving an opportunity for optimizing qualified references.
    9361038\begin{cfa}
    937 int mem( S & this ) ®with this® { §\C{// with clause}§
     1039int mem( S & this ) ®with( this )® { §\C{// with clause}§
    9381040        i = 1;                                          §\C{\color{red}// this.i}§
    9391041        j = 2;                                          §\C{\color{red}// this.j}§
     
    9431045\begin{cfa}
    9441046struct T { double m, n; };
    945 int mem2( S & this1, T & this2 ) ®with this1, this2® {
     1047int mem2( S & this1, T & this2 ) ®with( this1, this2 )® {
    9461048        i = 1; j = 2;
    9471049        m = 1.0; n = 2.0;
     
    9541056        struct S1 { ... } s1;
    9551057        struct S2 { ... } s2;
    956         ®with s1® {                                     §\C{// with statement}§
     1058        ®with( s1 )® {                          §\C{// with statement}§
    9571059                // access fields of s1 without qualification
    9581060                ®with s2® {                             §\C{// nesting}§
     
    9711073struct S { int i; int j; double m; } a, c;
    9721074struct T { int i; int k; int m } b, c;
    973 ®with a, b® {
    974         j + k;                                          §\C{// unambiguous, unique names define unique types}§
    975         i;                                                      §\C{// ambiguous, same name and type}§
    976         a.i + b.i;                                      §\C{// unambiguous, qualification defines unique names}§
    977         m;                                                      §\C{// ambiguous, same name and no context to define unique type}§
    978         m = 5.0;                                        §\C{// unambiguous, same name and context defines unique type}§
    979         m = 1;                                          §\C{// unambiguous, same name and context defines unique type}§
    980 }
    981 ®with c® { ... }                                §\C{// ambiguous, same name and no context}§
    982 ®with (S)c® { ... }                             §\C{// unambiguous, same name and cast defines unique type}§
    983 \end{cfa}
    984 
     1075with( a, b )
     1076{
     1077}
     1078\end{cfa}
     1079
     1080\begin{comment}
    9851081The components in the "with" clause
    9861082
     
    10071103the "with" to be implemented because I hate having to type all those object
    10081104names for fields. It's a great way to drive people away from the language.
     1105\end{comment}
    10091106
    10101107
     
    15951692
    15961693\item
    1597 lvalue to reference conversion: \lstinline[deletekeywords=lvalue]$lvalue-type cv1 T$ converts to ©cv2 T &©, which allows implicitly converting variables to references.
     1694lvalue to reference conversion: \lstinline[deletekeywords=lvalue]@lvalue-type cv1 T@ converts to ©cv2 T &©, which allows implicitly converting variables to references.
    15981695\begin{cfa}
    15991696int x, &r = ®x®, f( int & p ); // lvalue variable (int) convert to reference (int &)
     
    63616458
    63626459
     6460\section{Time}
     6461\label{s:TimeLib}
     6462
     6463
     6464%\subsection{\texorpdfstring{\protect\lstinline@Duration@}{Duration}}
     6465\subsection{\texorpdfstring{\LstKeywordStyle{\textmd{Duration}}}{Duration}}
     6466\label{s:Duration}
     6467
     6468\leavevmode
     6469\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6470struct Duration {
     6471        int64_t tv;                                                     §\C{// nanoseconds}§
     6472};
     6473
     6474void ?{}( Duration & dur );
     6475void ?{}( Duration & dur, zero_t );
     6476
     6477Duration ?=?( Duration & dur, zero_t );
     6478
     6479Duration +?( Duration rhs );
     6480Duration ?+?( Duration & lhs, Duration rhs );
     6481Duration ?+=?( Duration & lhs, Duration rhs );
     6482
     6483Duration -?( Duration rhs );
     6484Duration ?-?( Duration & lhs, Duration rhs );
     6485Duration ?-=?( Duration & lhs, Duration rhs );
     6486
     6487Duration ?*?( Duration lhs, int64_t rhs );
     6488Duration ?*?( int64_t lhs, Duration rhs );
     6489Duration ?*=?( Duration & lhs, int64_t rhs );
     6490
     6491int64_t ?/?( Duration lhs, Duration rhs );
     6492Duration ?/?( Duration lhs, int64_t rhs );
     6493Duration ?/=?( Duration & lhs, int64_t rhs );
     6494double div( Duration lhs, Duration rhs );
     6495
     6496Duration ?%?( Duration lhs, Duration rhs );
     6497Duration ?%=?( Duration & lhs, Duration rhs );
     6498
     6499_Bool ?==?( Duration lhs, Duration rhs );
     6500_Bool ?!=?( Duration lhs, Duration rhs );
     6501_Bool ?<? ( Duration lhs, Duration rhs );
     6502_Bool ?<=?( Duration lhs, Duration rhs );
     6503_Bool ?>? ( Duration lhs, Duration rhs );
     6504_Bool ?>=?( Duration lhs, Duration rhs );
     6505
     6506_Bool ?==?( Duration lhs, zero_t );
     6507_Bool ?!=?( Duration lhs, zero_t );
     6508_Bool ?<? ( Duration lhs, zero_t );
     6509_Bool ?<=?( Duration lhs, zero_t );
     6510_Bool ?>? ( Duration lhs, zero_t );
     6511_Bool ?>=?( Duration lhs, zero_t );
     6512
     6513Duration abs( Duration rhs );
     6514
     6515forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
     6516
     6517Duration ?`ns( int64_t nsec );
     6518Duration ?`us( int64_t usec );
     6519Duration ?`ms( int64_t msec );
     6520Duration ?`s( int64_t sec );
     6521Duration ?`s( double sec );
     6522Duration ?`m( int64_t min );
     6523Duration ?`m( double min );
     6524Duration ?`h( int64_t hours );
     6525Duration ?`h( double hours );
     6526Duration ?`d( int64_t days );
     6527Duration ?`d( double days );
     6528Duration ?`w( int64_t weeks );
     6529Duration ?`w( double weeks );
     6530
     6531int64_t ?`ns( Duration dur );
     6532int64_t ?`us( Duration dur );
     6533int64_t ?`ms( Duration dur );
     6534int64_t ?`s( Duration dur );
     6535int64_t ?`m( Duration dur );
     6536int64_t ?`h( Duration dur );
     6537int64_t ?`d( Duration dur );
     6538int64_t ?`w( Duration dur );
     6539\end{cfa}
     6540
     6541
     6542%\subsection{\texorpdfstring{\protect\lstinline@\timeval@}{timeval}}
     6543\subsection{\texorpdfstring{\LstKeywordStyle{\textmd{timeval}}}{timeval}}
     6544\label{s:timeval}
     6545
     6546\leavevmode
     6547\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6548void ?{}( timeval & t );
     6549void ?{}( timeval & t, time_t sec, suseconds_t usec );
     6550void ?{}( timeval & t, time_t sec );
     6551void ?{}( timeval & t, zero_t );
     6552void ?{}( timeval & t, Time time );
     6553
     6554timeval ?=?( timeval & t, zero_t );
     6555timeval ?+?( timeval & lhs, timeval rhs );
     6556timeval ?-?( timeval & lhs, timeval rhs );
     6557_Bool ?==?( timeval lhs, timeval rhs );
     6558_Bool ?!=?( timeval lhs, timeval rhs );
     6559\end{cfa}
     6560
     6561
     6562\subsection{\texorpdfstring{\protect\lstinline@timespec@}{timespec}}
     6563\label{s:timespec}
     6564
     6565\leavevmode
     6566\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6567void ?{}( timespec & t );
     6568void ?{}( timespec & t, time_t sec, __syscall_slong_t nsec );
     6569void ?{}( timespec & t, time_t sec );
     6570void ?{}( timespec & t, zero_t );
     6571void ?{}( timespec & t, Time time );
     6572
     6573timespec ?=?( timespec & t, zero_t );
     6574timespec ?+?( timespec & lhs, timespec rhs );
     6575timespec ?-?( timespec & lhs, timespec rhs );
     6576_Bool ?==?( timespec lhs, timespec rhs );
     6577_Bool ?!=?( timespec lhs, timespec rhs );
     6578\end{cfa}
     6579
     6580
     6581\subsection{\texorpdfstring{\protect\lstinline@itimerval@}{itimerval}}
     6582\label{s:itimerval}
     6583
     6584\leavevmode
     6585\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6586void ?{}( itimerval & itv, Duration alarm );
     6587void ?{}( itimerval & itv, Duration alarm, Duration interval );
     6588\end{cfa}
     6589
     6590
     6591\subsection{\texorpdfstring{\protect\lstinline@Time@}{Time}}
     6592\label{s:Time}
     6593
     6594\leavevmode
     6595\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6596struct Time {
     6597        uint64_t tv;                                            §\C{// nanoseconds since UNIX epoch}§
     6598};
     6599
     6600void ?{}( Time & time );
     6601void ?{}( Time & time, zero_t );
     6602void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 );
     6603Time ?=?( Time & time, zero_t );
     6604
     6605void ?{}( Time & time, timeval t );
     6606Time ?=?( Time & time, timeval t );
     6607
     6608void ?{}( Time & time, timespec t );
     6609Time ?=?( Time & time, timespec t );
     6610
     6611Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
     6612Time ?+?( Duration lhs, Time rhs ) { return rhs + lhs; }
     6613Time ?+=?( Time & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
     6614
     6615Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
     6616Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; }
     6617Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
     6618_Bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; }
     6619_Bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; }
     6620_Bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; }
     6621_Bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; }
     6622_Bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; }
     6623_Bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; }
     6624
     6625forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
     6626
     6627char * yy_mm_dd( Time time, char * buf );
     6628char * ?`ymd( Time time, char * buf ) { // short form
     6629        return yy_mm_dd( time, buf );
     6630} // ymd
     6631
     6632char * mm_dd_yy( Time time, char * buf );
     6633char * ?`mdy( Time time, char * buf ) { // short form
     6634        return mm_dd_yy( time, buf );
     6635} // mdy
     6636
     6637char * dd_mm_yy( Time time, char * buf );
     6638char * ?`dmy( Time time, char * buf ) { // short form
     6639        return dd_mm_yy( time, buf );;
     6640} // dmy
     6641
     6642size_t strftime( char * buf, size_t size, const char * fmt, Time time );
     6643\end{cfa}
     6644
     6645
     6646\section{Clock}
     6647
     6648\subsection{C time}
     6649\label{s:Ctime}
     6650
     6651\leavevmode
     6652\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6653char * ctime( time_t tp );
     6654char * ctime_r( time_t tp, char * buf );
     6655tm * gmtime( time_t tp );
     6656tm * gmtime_r( time_t tp, tm * result );
     6657tm * localtime( time_t tp );
     6658tm * localtime_r( time_t tp, tm * result );
     6659\end{cfa}
     6660
     6661
     6662%\subsection{\texorpdfstring{\protect\lstinline@Clock@}{Clock}}
     6663\subsection{\texorpdfstring{\LstKeywordStyle{\textmd{Clock}}}{Clock}}
     6664\label{s:Clock}
     6665
     6666\leavevmode
     6667\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     6668struct Clock {
     6669        Duration offset;                                        §\C{// for virtual clock: contains offset from real-time}§
     6670        int clocktype;                                          §\C{// implementation only -1 (virtual), CLOCK\_REALTIME}§
     6671};
     6672
     6673void resetClock( Clock & clk );
     6674void resetClock( Clock & clk, Duration adj );
     6675void ?{}( Clock & clk );
     6676void ?{}( Clock & clk, Duration adj );
     6677Duration getRes();
     6678Time getTimeNsec();                                             §\C{// with nanoseconds}§
     6679Time getTime();                                                 §\C{// without nanoseconds}§
     6680Time getTime( Clock & clk );
     6681Time ?()( Clock & clk );
     6682timeval getTime( Clock & clk );
     6683tm getTime( Clock & clk );
     6684\end{cfa}
     6685
     6686
    63636687\section{Multi-precision Integers}
    63646688\label{s:MultiPrecisionIntegers}
     
    66586982\end{cfa}
    66596983
    6660 
    66616984\bibliographystyle{plain}
    66626985\bibliography{pl}
Note: See TracChangeset for help on using the changeset viewer.