Changes in / [331eacbe:5452673]
- Files:
-
- 5 deleted
- 8 edited
-
doc/theses/andrew_beach_MMath/.gitignore (deleted)
-
doc/theses/andrew_beach_MMath/Makefile (deleted)
-
doc/theses/andrew_beach_MMath/thesis-frontpgs.tex (deleted)
-
doc/theses/andrew_beach_MMath/thesis.bib (deleted)
-
doc/theses/andrew_beach_MMath/thesis.tex (deleted)
-
doc/user/user.tex (modified) (11 diffs)
-
libcfa/src/bits/containers.hfa (modified) (1 diff)
-
libcfa/src/concurrency/monitor.cfa (modified) (1 diff)
-
libcfa/src/exception.c (modified) (1 diff)
-
libcfa/src/interpose.cfa (modified) (6 diffs)
-
src/SynTree/LinkageSpec.cc (modified) (2 diffs)
-
src/SynTree/LinkageSpec.h (modified) (2 diffs)
-
tools/cfa.nanorc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
r331eacbe r5452673 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Thu Mar 5 12:09:42 202014 %% Update Count : 38 8513 %% Last Modified On : Sat Jul 13 18:36:18 2019 14 %% Update Count : 3876 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 211 211 Even with all its problems, C continues to be popular because it allows writing software at virtually any level in a computer system without restriction. 212 212 For system programming, where direct access to hardware, storage management, and real-time issues are a requirement, C is usually the only language of choice. 213 The TIOBE index~\cite{TIOBE} for February 2020 ranks the top six most \emph{popular} programming languages as \Index*{Java} 17.4\%, C 16.8\%, Python 9.3\%, \Index*[C++]{\CC{}} 6.2\%, \Csharp 5.9\%, Visual Basic 5.9\% = 61.5\%, where the next 50 languages are less than 2\% each, with a long tail.214 The top 4 rankings over the past 35years are:213 The TIOBE index~\cite{TIOBE} for July 2018 ranks the top five most \emph{popular} programming languages as \Index*{Java} 16\%, C 14\%, \Index*[C++]{\CC{}} 7.5\%, Python 6\%, Visual Basic 4\% = 47.5\%, where the next 50 languages are less than 4\% each, with a long tail. 214 The top 3 rankings over the past 30 years are: 215 215 \begin{center} 216 216 \setlength{\tabcolsep}{10pt} 217 \begin{tabular}{@{}rcccccccc@{}} 218 & 2020 & 2015 & 2010 & 2005 & 2000 & 1995 & 1990 & 1985 \\ \hline 219 Java & 1 & 2 & 1 & 2 & 3 & - & - & - \\ 220 \R{C} & \R{2} & \R{1} & \R{2} & \R{1} & \R{1} & \R{2} & \R{1} & \R{1} \\ 221 Python & 3 & 7 & 6 & 6 & 22 & 21 & - & - \\ 222 \CC & 4 & 4 & 4 & 3 & 2 & 1 & 2 & 12 \\ 217 \begin{tabular}{@{}rccccccc@{}} 218 & 2018 & 2013 & 2008 & 2003 & 1998 & 1993 & 1988 \\ \hline 219 Java & 1 & 2 & 1 & 1 & 16 & - & - \\ 220 \R{C} & \R{2} & \R{1} & \R{2} & \R{2} & \R{1} & \R{1} & \R{1} \\ 221 \CC & 3 & 4 & 3 & 3 & 2 & 2 & 5 \\ 223 222 \end{tabular} 224 223 \end{center} … … 513 512 Keyword clashes are accommodated by syntactic transformations using the \CFA backquote escape-mechanism: 514 513 \begin{cfa} 515 int ®` `®otype= 3; §\C{// make keyword an identifier}§516 double ®` `®forall= 3.5;514 int ®`®otype®`® = 3; §\C{// make keyword an identifier}§ 515 double ®`®forall®`® = 3.5; 517 516 \end{cfa} 518 517 … … 525 524 // include file uses the CFA keyword "with". 526 525 #if ! defined( with ) §\C{// nesting ?}§ 527 #define with ®` `®with§\C{// make keyword an identifier}§526 #define with ®`®with®`® §\C{// make keyword an identifier}§ 528 527 #define __CFA_BFD_H__ 529 528 #endif 530 §{\color{red}\#\textbf{include\_next} <bfdlink.h>}§ §\C{// must have internal check for multiple expansion}§ 529 530 ®#include_next <bfdlink.h> §\C{// must have internal check for multiple expansion}§ 531 ® 531 532 #if defined( with ) && defined( __CFA_BFD_H__ ) §\C{// reset only if set}§ 532 533 #undef with … … 575 576 \section{Exponentiation Operator} 576 577 577 C, \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 (x,y)}, to perform the exponentiation operation.578 \CFA extends the basic operators with the exponentiation operator ©? ®\®?©\index{?\\?@©?®\®?©} and ©?\=?©\index{?\\=?@©®\®=?©}, as in, ©x ®\® y© and ©x ®\®= y©, which means $x^y$ and $x \leftarrow x^y$.578 C, \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. 579 \CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@©?\?©} and ©?\=?©\index{?\\=?@©\=?©}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$. 579 580 The 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)©. 580 581 581 There are exponentiation operators for integral and floating types, including the builtin \Index{complex} types.582 As for \Index{division}, there are exponentiation operators for integral and floating types, including the builtin \Index{complex} types. 582 583 Integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication\footnote{The multiplication computation is $O(\log y)$.} (or shifting if the exponent is 2). 583 Overflow f or a large exponent or negative exponent returnszero.584 Overflow from large exponents or negative exponents return zero. 584 585 Floating exponentiation\index{exponentiation!floating} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the exponent cannot be negative. 585 586 \begin{cfa} … … 588 589 1 1 256 -64 125 ®0® 3273344365508751233 ®0® ®0® -0.015625 18.3791736799526 0.264715-1.1922i 589 590 \end{cfa} 590 Note, ©5 \ 32© and ©5L \ 64© overflow, and ©-4 \-3© is a fraction but stored in an integer so all three computations generate an integral zero.591 Note, ©5 ®\® 32© and ©5L ®\® 64© overflow, and ©-4 ®\® -3© is a fraction but stored in an integer so all three computations generate an integral zero. 591 592 Parenthesis are necessary for complex constants or the expression is parsed as ©1.0f+®(®2.0fi \ 3.0f®)®+2.0fi©. 592 593 The exponentiation operator is available for all the basic types, but for user-defined types, only the integral-computation version is available. … … 597 598 OT ?®\®?( OT ep, unsigned long int y ); 598 599 \end{cfa} 599 The user type ©T© must define multiplication, one (©1©), and©*©.600 The user type ©T© must define multiplication, one, ©1©, and, ©*©. 600 601 601 602 … … 625 626 626 627 627 %\section{\texorpdfstring{\protect\lstinline@case@ Clause}{case Clause}} 628 \subsection{\texorpdfstring{\LstKeywordStyle{case} Clause}{case Clause}} 629 630 C restricts the ©case© clause of a ©switch© statement to a single value. 631 For multiple ©case© clauses associated with the same statement, it is necessary to have multiple ©case© clauses rather than multiple values. 632 Requiring a ©case© clause for each value does not seem to be in the spirit of brevity normally associated with C. 633 Therefore, the ©case© clause is extended with a list of values, as in: 628 \subsection{Loop Control} 629 630 The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges (see Figure~\ref{f:LoopControlExamples}). 631 \begin{itemize} 632 \item 633 An empty conditional implies ©1©. 634 \item 635 The up-to range ©~©\index{~@©~©} means exclusive range [M,N). 636 \item 637 The up-to range ©~=©\index{~=@©~=©} means inclusive range [M,N]. 638 \item 639 The down-to range ©-~©\index{-~@©-~©} means exclusive range [N,M). 640 \item 641 The down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M]. 642 \item 643 ©@© means put nothing in this field. 644 \item 645 ©0© is the implicit start value; 646 \item 647 ©1© is the implicit increment value. 648 \item 649 The up-to range uses ©+=© for increment; 650 \item 651 The down-to range uses ©-=© for decrement. 652 \item 653 The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©. 654 \end{itemize} 655 656 \begin{figure} 634 657 \begin{cquote} 635 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 636 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 637 \begin{cfa} 638 switch ( i ) { 639 case ®1, 3, 5®: 640 ... 641 case ®2, 4, 6®: 642 ... 643 } 658 \begin{tabular}{@{}l|l@{}} 659 \multicolumn{1}{c|}{loop control} & \multicolumn{1}{c}{output} \\ 660 \hline 661 \begin{cfa} 662 sout | nlOff; 663 while ®()® { sout | "empty"; break; } sout | nl; 664 do { sout | "empty"; break; } while ®()®; sout | nl; 665 for ®()® { sout | "empty"; break; } sout | nl; 666 for ( ®0® ) { sout | "A"; } sout | "zero" | nl; 667 for ( ®1® ) { sout | "A"; } sout | nl; 668 for ( ®10® ) { sout | "A"; } sout | nl; 669 for ( ®1 ~= 10 ~ 2® ) { sout | "B"; } sout | nl; 670 for ( ®10 -~= 1 ~ 2® ) { sout | "C"; } sout | nl; 671 for ( ®0.5 ~ 5.5® ) { sout | "D"; } sout | nl; 672 for ( ®5.5 -~ 0.5® ) { sout | "E"; } sout | nl; 673 for ( ®i; 10® ) { sout | i; } sout | nl; 674 for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; } sout | nl; 675 for ( ®i; 10 -~= 1 ~ 2® ) { sout | i; } sout | nl; 676 for ( ®i; 0.5 ~ 5.5® ) { sout | i; } sout | nl; 677 for ( ®i; 5.5 -~ 0.5® ) { sout | i; } sout | nl; 678 for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; } sout | nl; 679 for ( ®ui; 10u -~= 2u ~ 2u® ) { sout | ui; } sout | nl; 680 enum { N = 10 }; 681 for ( ®N® ) { sout | "N"; } sout | nl; 682 for ( ®i; N® ) { sout | i; } sout | nl; 683 for ( ®i; N -~ 0® ) { sout | i; } sout | nl; 684 const int start = 3, comp = 10, inc = 2; 685 for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; } sout | nl; 686 for ( ®i; 1 ~ @® ) { if ( i > 10 ) break; 687 sout | i; } sout | nl; 688 for ( ®i; 10 -~ @® ) { if ( i < 0 ) break; 689 sout | i; } sout | nl; 690 for ( ®i; 2 ~ @ ~ 2® ) { if ( i > 10 ) break; 691 sout | i; } sout | nl; 692 for ( ®i; 2.1 ~ @ ~ @® ) { if ( i > 10.5 ) break; 693 sout | i; i += 1.7; } sout | nl; 694 for ( ®i; 10 -~ @ ~ 2® ) { if ( i < 0 ) break; 695 sout | i; } sout | nl; 696 for ( ®i; 12.1 ~ @ ~ @® ) { if ( i < 2.5 ) break; 697 sout | i; i -= 1.7; } sout | nl; 698 for ( ®i; 5 : j; -5 ~ @® ) { sout | i | j; } sout | nl; 699 for ( ®i; 5 : j; -5 -~ @® ) { sout | i | j; } sout | nl; 700 for ( ®i; 5 : j; -5 ~ @ ~ 2® ) { sout | i | j; } sout | nl; 701 for ( ®i; 5 : j; -5 -~ @ ~ 2® ) { sout | i | j; } sout | nl; 702 for ( ®j; -5 ~ @ : i; 5® ) { sout | i | j; } sout | nl; 703 for ( ®j; -5 -~ @ : i; 5® ) { sout | i | j; } sout | nl; 704 for ( ®j; -5 ~ @ ~ 2 : i; 5® ) { sout | i | j; } sout | nl; 705 for ( ®j; -5 -~ @ ~ 2 : i; 5® ) { sout | i | j; } sout | nl; 706 for ( ®j; -5 -~ @ ~ 2 : i; 5 : k; 1.5 ~ @® ) { 707 sout | i | j | k; } sout | nl; 708 for ( ®j; -5 -~ @ ~ 2 : k; 1.5 ~ @ : i; 5® ) { 709 sout | i | j | k; } sout | nl; 710 for ( ®k; 1.5 ~ @ : j; -5 -~ @ ~ 2 : i; 5® ) { 711 sout | i | j | k; } sout | nl; 644 712 \end{cfa} 645 713 & 646 714 \begin{cfa} 647 switch ( i ) { 648 case 1: case 3 : case 5: 649 ... 650 case 2: case 4 : case 6: 651 ... 652 } 653 \end{cfa} 654 & 655 \begin{cfa} 656 657 // odd values 658 659 // even values 660 661 715 716 empty 717 empty 718 empty 719 zero 720 A 721 A A A A A A A A A A 722 B B B B B 723 C C C C C 724 D D D D D 725 E E E E E 726 0 1 2 3 4 5 6 7 8 9 727 1 3 5 7 9 728 10 8 6 4 2 729 0.5 1.5 2.5 3.5 4.5 730 5.5 4.5 3.5 2.5 1.5 731 2 4 6 8 10 732 10 8 6 4 2 733 734 N N N N N N N N N N 735 0 1 2 3 4 5 6 7 8 9 736 10 9 8 7 6 5 4 3 2 1 737 738 3 6 9 739 740 1 2 3 4 5 6 7 8 9 10 741 742 10 9 8 7 6 5 4 3 2 1 0 743 744 2 4 6 8 10 745 746 2.1 3.8 5.5 7.2 8.9 747 748 10 8 6 4 2 0 749 750 12.1 10.4 8.7 7 5.3 3.6 751 0 -5 1 -4 2 -3 3 -2 4 -1 752 0 -5 1 -6 2 -7 3 -8 4 -9 753 0 -5 1 -3 2 -1 3 1 4 3 754 0 -5 1 -7 2 -9 3 -11 4 -13 755 0 -5 1 -4 2 -3 3 -2 4 -1 756 0 -5 1 -6 2 -7 3 -8 4 -9 757 0 -5 1 -3 2 -1 3 1 4 3 758 0 -5 1 -7 2 -9 3 -11 4 -13 759 760 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 761 762 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 763 764 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 662 765 \end{cfa} 663 766 \end{tabular} 664 767 \end{cquote} 665 In addition, subranges are allowed to specify case values.\footnote{ 666 gcc 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.} 667 \begin{cfa} 668 switch ( i ) { 669 case ®1~5:® §\C{// 1, 2, 3, 4, 5}§ 670 ... 671 case ®10~15:® §\C{// 10, 11, 12, 13, 14, 15}§ 672 ... 673 } 674 \end{cfa} 675 Lists of subranges are also allowed. 676 \begin{cfa} 677 case ®1~5, 12~21, 35~42®: 678 \end{cfa} 768 \caption{Loop Control Examples} 769 \label{f:LoopControlExamples} 770 \end{figure} 679 771 680 772 … … 885 977 886 978 887 \subsection{Non-terminating and Labelled \texorpdfstring{\LstKeywordStyle{fallthrough}}{Non-terminating and Labelled fallthrough}} 888 889 The ©fallthrough© clause may be non-terminating within a ©case© clause or have a target label to common code from multiple case clauses. 890 \begin{center} 891 \begin{tabular}{@{}lll@{}} 892 \begin{cfa} 893 choose ( ... ) { 894 case 3: 895 if ( ... ) { 896 ... ®fallthru;® // goto case 4 897 } else { 898 ... 899 } 900 // implicit break 901 case 4: 902 903 904 905 979 %\section{\texorpdfstring{\protect\lstinline@case@ Clause}{case Clause}} 980 \subsection{\texorpdfstring{\LstKeywordStyle{case} Statement}{case Statement}} 981 982 C restricts the ©case© clause of a ©switch© statement to a single value. 983 For multiple ©case© clauses associated with the same statement, it is necessary to have multiple ©case© clauses rather than multiple values. 984 Requiring a ©case© clause for each value does not seem to be in the spirit of brevity normally associated with C. 985 Therefore, the ©case© clause is extended with a list of values, as in: 986 \begin{cquote} 987 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 988 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 989 \begin{cfa} 990 switch ( i ) { 991 case ®1, 3, 5®: 992 ... 993 case ®2, 4, 6®: 994 ... 995 } 906 996 \end{cfa} 907 997 & 908 998 \begin{cfa} 909 choose ( ... ) { 910 case 3: 911 ... ®fallthrough common;® 912 case 4: 913 ... ®fallthrough common;® 914 915 ®common:® // below fallthrough 916 // at case-clause level 917 ... // common code for cases 3/4 918 // implicit break 919 case 4: 920 921 999 switch ( i ) { 1000 case 1: case 3 : case 5: 1001 ... 1002 case 2: case 4 : case 6: 1003 ... 1004 } 922 1005 \end{cfa} 923 1006 & 924 1007 \begin{cfa} 925 choose ( ... ) { 926 case 3: 927 choose ( ... ) { 928 case 4: 929 for ( ... ) { 930 // multi-level transfer 931 ... ®fallthru common;® 932 } 933 ... 934 } 1008 1009 // odd values 1010 1011 // even values 1012 1013 1014 \end{cfa} 1015 \end{tabular} 1016 \end{cquote} 1017 In addition, subranges are allowed to specify case values.\footnote{ 1018 gcc 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.} 1019 \begin{cfa} 1020 switch ( i ) { 1021 case ®1~5:® §\C{// 1, 2, 3, 4, 5}§ 935 1022 ... 936 ®common:® // below fallthrough 937 // at case-clause level 938 \end{cfa} 939 \end{tabular} 940 \end{center} 941 The target label must be below the ©fallthrough© and may not be nested in a control structure, and 942 the target label must be at the same or higher level as the containing ©case© clause and located at 943 the same level as a ©case© clause; the target label may be case ©default©, but only associated 944 with the current ©switch©/©choose© statement. 945 946 947 \subsection{Loop Control} 948 949 The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges (see Figure~\ref{f:LoopControlExamples}). 950 \begin{itemize} 951 \item 952 The loop index is polymorphic in the type of the comparison value N (when the start value is implicit) or the start value M. 953 \item 954 An empty conditional implies comparison value of ©1© (true). 955 \item 956 A comparison N is implicit up-to exclusive range [0,N©®)®©. 957 \item 958 A comparison ©=© N is implicit up-to inclusive range [0,N©®]®©. 959 \item 960 The up-to range M ©~©\index{~@©~©} N means exclusive range [M,N©®)®©. 961 \item 962 The up-to range M ©~=©\index{~=@©~=©} N means inclusive range [M,N©®]®©. 963 \item 964 The down-to range M ©-~©\index{-~@©-~©} N means exclusive range [N,M©®)®©. 965 \item 966 The down-to range M ©-~=©\index{-~=@©-~=©} N means inclusive range [N,M©®]®©. 967 \item 968 ©0© is the implicit start value; 969 \item 970 ©1© is the implicit increment value. 971 \item 972 The up-to range uses operator ©+=© for increment; 973 \item 974 The down-to range uses operator ©-=© for decrement. 975 \item 976 ©@© means put nothing in this field. 977 \item 978 ©:© means start another index. 979 \end{itemize} 980 981 \begin{figure} 982 \begin{tabular}{@{}l|l@{}} 983 \multicolumn{1}{c|}{loop control} & \multicolumn{1}{c}{output} \\ 984 \hline 985 \begin{cfa}[xleftmargin=0pt] 986 while ®()® { sout | "empty"; break; } 987 do { sout | "empty"; break; } while ®()®; 988 for ®()® { sout | "empty"; break; } 989 for ( ®0® ) { sout | "A"; } sout | "zero"; 990 for ( ®1® ) { sout | "A"; } 991 for ( ®10® ) { sout | "A"; } 992 for ( ®= 10® ) { sout | "A"; } 993 for ( ®1 ~= 10 ~ 2® ) { sout | "B"; } 994 for ( ®10 -~= 1 ~ 2® ) { sout | "C"; } 995 for ( ®0.5 ~ 5.5® ) { sout | "D"; } 996 for ( ®5.5 -~ 0.5® ) { sout | "E"; } 997 for ( ®i; 10® ) { sout | i; } 998 for ( ®i; = 10® ) { sout | i; } 999 for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; } 1000 for ( ®i; 10 -~= 1 ~ 2® ) { sout | i; } 1001 for ( ®i; 0.5 ~ 5.5® ) { sout | i; } 1002 for ( ®i; 5.5 -~ 0.5® ) { sout | i; } 1003 for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; } 1004 for ( ®ui; 10u -~= 2u ~ 2u® ) { sout | ui; } 1005 enum { N = 10 }; 1006 for ( ®N® ) { sout | "N"; } 1007 for ( ®i; N® ) { sout | i; } 1008 for ( ®i; N -~ 0® ) { sout | i; } 1009 const int start = 3, comp = 10, inc = 2; 1010 for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; } 1011 for ( i; 1 ~ ®@® ) { if ( i > 10 ) break; sout | i; } 1012 for ( i; 10 -~ ®@® ) { if ( i < 0 ) break; sout | i; } 1013 for ( i; 2 ~ ®@® ~ 2 ) { if ( i > 10 ) break; sout | i; } 1014 for ( i; 2.1 ~ ®@® ~ ®@® ) { if ( i > 10.5 ) break; sout | i; i += 1.7; } 1015 for ( i; 10 -~ ®@® ~ 2 ) { if ( i < 0 ) break; sout | i; } 1016 for ( i; 12.1 ~ ®@® ~ ®@® ) { if ( i < 2.5 ) break; sout | i; i -= 1.7; } 1017 for ( i; 5 ®:® j; -5 ~ @ ) { sout | i | j; } 1018 for ( i; 5 ®:® j; -5 -~ @ ) { sout | i | j; } 1019 for ( i; 5 ®:® j; -5 ~ @ ~ 2 ) { sout | i | j; } 1020 for ( i; 5 ®:® j; -5 -~ @ ~ 2 ) { sout | i | j; } 1021 for ( i; 5 ®:® j; -5 ~ @ ) { sout | i | j; } 1022 for ( i; 5 ®:® j; -5 -~ @ ) { sout | i | j; } 1023 for ( i; 5 ®:® j; -5 ~ @ ~ 2 ) { sout | i | j; } 1024 for ( i; 5 ®:® j; -5 -~ @ ~ 2 ) { sout | i | j; } 1025 for ( i; 5 ®:® j; -5 -~ @ ~ 2 ®:® k; 1.5 ~ @ ) { sout | i | j | k; } 1026 for ( i; 5 ®:® j; -5 -~ @ ~ 2 ®:® k; 1.5 ~ @ ) { sout | i | j | k; } 1027 for ( i; 5 ®:® k; 1.5 ~ @ ®:® j; -5 -~ @ ~ 2 ) { sout | i | j | k; } 1028 \end{cfa} 1029 & 1030 \begin{cfa} 1031 empty 1032 empty 1033 empty 1034 zero 1035 A 1036 A A A A A A A A A A 1037 A A A A A A A A A A A 1038 B B B B B 1039 C C C C C 1040 D D D D D 1041 E E E E E 1042 0 1 2 3 4 5 6 7 8 9 1043 0 1 2 3 4 5 6 7 8 9 10 1044 1 3 5 7 9 1045 10 8 6 4 2 1046 0.5 1.5 2.5 3.5 4.5 1047 5.5 4.5 3.5 2.5 1.5 1048 2 4 6 8 10 1049 10 8 6 4 2 1050 1051 N N N N N N N N N N 1052 0 1 2 3 4 5 6 7 8 9 1053 10 9 8 7 6 5 4 3 2 1 1054 1055 3 6 9 1056 1 2 3 4 5 6 7 8 9 10 1057 10 9 8 7 6 5 4 3 2 1 0 1058 2 4 6 8 10 1059 2.1 3.8 5.5 7.2 8.9 1060 10 8 6 4 2 0 1061 12.1 10.4 8.7 7. 5.3 3.6 1062 0 -5 1 -4 2 -3 3 -2 4 -1 1063 0 -5 1 -6 2 -7 3 -8 4 -9 1064 0 -5 1 -3 2 -1 3 1 4 3 1065 0 -5 1 -7 2 -9 3 -11 4 -13 1066 0 -5 1 -4 2 -3 3 -2 4 -1 1067 0 -5 1 -6 2 -7 3 -8 4 -9 1068 0 -5 1 -3 2 -1 3 1 4 3 1069 0 -5 1 -7 2 -9 3 -11 4 -13 1070 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 1071 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 1072 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 1073 \end{cfa} 1074 \end{tabular} 1075 \caption{Loop Control Examples} 1076 \label{f:LoopControlExamples} 1077 \end{figure} 1023 case ®10~15:® §\C{// 10, 11, 12, 13, 14, 15}§ 1024 ... 1025 } 1026 \end{cfa} 1027 Lists of subranges are also allowed. 1028 \begin{cfa} 1029 case ®1~5, 12~21, 35~42®: 1030 \end{cfa} 1031 1078 1032 1079 1033 % for () => for ( ;; ) … … 6593 6547 hence, names in these include files are not mangled\index{mangling!name} (see~\VRef{s:Interoperability}). 6594 6548 All other C header files must be explicitly wrapped in ©extern "C"© to prevent name mangling. 6595 This approach is different from \Index*[C++]{\CC{}} where the name-mangling issue is handled internally inC header-files through checks for preprocessor variable ©__cplusplus©, which adds appropriate ©extern "C"© qualifiers.6549 For \Index*[C++]{\CC{}}, the name-mangling issue is often handled internally in many C header-files through checks for preprocessor variable ©__cplusplus©, which adds appropriate ©extern "C"© qualifiers. 6596 6550 6597 6551 … … 6607 6561 The storage-management routines extend their C equivalents by overloading, alternate names, providing shallow type-safety, and removing the need to specify the allocation size for non-array types. 6608 6562 6609 C storage management provides the following capabilities:6563 Storage management provides the following capabilities: 6610 6564 \begin{description} 6611 \item[fill ed]6612 after allocation with a specified character or value.6565 \item[fill] 6566 after allocation the storage is filled with a specified character. 6613 6567 \item[resize] 6614 an existing allocation to decreased or increased itssize.6615 In either case, new storage may or may not be allocated and, if there is a new allocation, as much data from the existing allocation is copied into the new allocation.6568 an existing allocation is decreased or increased in size. 6569 In either case, new storage may or may not be allocated and, if there is a new allocation, as much data from the existing allocation is copied. 6616 6570 For an increase in storage size, new storage after the copied data may be filled. 6617 \item[align ]6618 an allocation on a specified memory boundary, \eg, an address multiple of 64 or 128 for cache-line purposes.6571 \item[alignment] 6572 an allocation starts on a specified memory boundary, \eg, an address multiple of 64 or 128 for cache-line purposes. 6619 6573 \item[array] 6620 6574 the allocation size is scaled to the specified number of array elements. 6621 6575 An array may be filled, resized, or aligned. 6622 6576 \end{description} 6623 \VRef[Table]{t:AllocationVersusCapabilities} shows allocation routines supporting different combinations of storage-management capabilities: 6624 \begin{table} 6625 \centering 6626 \begin{tabular}{@{}r|l|l|l|l|l@{}} 6577 The table shows allocation routines supporting different combinations of storage-management capabilities: 6578 \begin{center} 6579 \begin{tabular}{@{}r|r|l|l|l|l@{}} 6627 6580 \multicolumn{1}{c}{}& & \multicolumn{1}{c|}{fill} & resize & alignment & array \\ 6628 6581 \hline 6629 6582 C & ©malloc© & no & no & no & no \\ 6630 6583 & ©calloc© & yes (0 only) & no & no & yes \\ 6631 & ©realloc© & copy& yes & no & no \\6584 & ©realloc© & no/copy & yes & no & no \\ 6632 6585 & ©memalign© & no & no & yes & no \\ 6633 & ©aligned_alloc© & no & no & yes & no \\6634 6586 & ©posix_memalign© & no & no & yes & no \\ 6635 6587 \hline 6636 \CFA & ©cmemalign© & yes (0 only) & no & yes & yes \\ 6637 & ©realloc© & copy & yes & yes & no \\ 6638 & ©alloc© & no & no & no & no \\ 6639 & ©alloc© & copy & no/yes & no & yes \\ 6640 & ©alloc© & no/copy/yes & no/yes & no & yes \\ 6641 & ©alloc_set© & no/yes & no & yes & yes \\ 6642 & ©alloc_align© & no/yes & no & yes & yes \\ 6643 & ©alloc_align_set© & no/yes & no & yes & yes \\ 6588 C11 & ©aligned_alloc© & no & no & yes & no \\ 6589 \hline 6590 \CFA & ©alloc© & no/copy/yes & no/yes & no & yes \\ 6591 & ©align_alloc© & no/yes & no & yes & yes \\ 6644 6592 \end{tabular} 6645 \caption{Allocation Routines versus Storage-Management Capabilities} 6646 \label{t:AllocationVersusCapabilities} 6647 \end{table} 6648 6649 \CFA memory management extends the resize capability with the notion of \newterm{sticky properties}. 6650 Hence, initial allocation capabilities are remembered and maintained when resize requires copying. 6651 For example, an initial alignment and fill capability are preserved during a resize copy so the copy has the same alignment and extended storage is filled. 6652 Without sticky properties it is dangerous to use ©realloc©, resulting in an idiom of manually performing the reallocation to maintain correctness. 6653 6593 \end{center} 6594 It is impossible to resize with alignment because the underlying ©realloc© allocates storage if more space is needed, and it does not honour alignment from the original allocation. 6654 6595 6655 6596 \leavevmode 6656 6597 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 6598 // C unsafe allocation 6657 6599 extern "C" { 6658 // C unsafe allocation 6659 void * malloc( size_t size );§\indexc{malloc}§ 6660 void * calloc( size_t dim, size_t size );§\indexc{calloc}§ 6661 void * realloc( void * ptr, size_t size );§\indexc{realloc}§ 6662 void * memalign( size_t align, size_t size );§\indexc{memalign}§ 6663 void * aligned_alloc( size_t align, size_t size );§\indexc{aligned_alloc}§ 6664 int posix_memalign( void ** ptr, size_t align, size_t size );§\indexc{posix_memalign}§ 6665 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize );§\indexc{cmemalign}§ // CFA 6666 6667 // C unsafe initialization/copy 6668 void * memset( void * dest, int c, size_t size );§\indexc{memset}§ 6669 void * memcpy( void * dest, const void * src, size_t size );§\indexc{memcpy}§ 6670 } 6671 6672 void * realloc( void * oaddr, size_t nalign, size_t size ); // CFA heap 6600 void * malloc( size_t size );§\indexc{memset}§ 6601 void * calloc( size_t dim, size_t size );§\indexc{calloc}§ 6602 void * realloc( void * ptr, size_t size );§\indexc{realloc}§ 6603 void * memalign( size_t align, size_t size );§\indexc{memalign}§ 6604 int posix_memalign( void ** ptr, size_t align, size_t size );§\indexc{posix_memalign}§ 6605 6606 // C unsafe initialization/copy 6607 void * memset( void * dest, int c, size_t size ); 6608 void * memcpy( void * dest, const void * src, size_t size ); 6609 } 6673 6610 6674 6611 forall( dtype T | sized(T) ) { 6675 // §\CFA§ safe equivalents, i.e., implicit size specification6612 // §\CFA§ safe equivalents, i.e., implicit size specification 6676 6613 T * malloc( void ); 6677 6614 T * calloc( size_t dim ); 6678 6615 T * realloc( T * ptr, size_t size ); 6679 6616 T * memalign( size_t align ); 6680 T * cmemalign( size_t align, size_t dim );6681 6617 T * aligned_alloc( size_t align ); 6682 6618 int posix_memalign( T ** ptr, size_t align ); 6683 6619 6684 // §\CFA§ safe general allocation, fill, resize, alignment, array6620 // §\CFA§ safe general allocation, fill, resize, array 6685 6621 T * alloc( void );§\indexc{alloc}§ 6622 T * alloc( char fill ); 6686 6623 T * alloc( size_t dim ); 6624 T * alloc( size_t dim, char fill ); 6687 6625 T * alloc( T ptr[], size_t dim ); 6688 T * alloc_set( char fill );§\indexc{alloc_set}§ 6689 T * alloc_set( T fill ); 6690 T * alloc_set( size_t dim, char fill ); 6691 T * alloc_set( size_t dim, T fill ); 6692 T * alloc_set( size_t dim, const T fill[] ); 6693 T * alloc_set( T ptr[], size_t dim, char fill ); 6694 6695 T * alloc_align( size_t align ); 6696 T * alloc_align( size_t align, size_t dim ); 6697 T * alloc_align( T ptr[], size_t align ); // aligned realloc array 6698 T * alloc_align( T ptr[], size_t align, size_t dim ); // aligned realloc array 6699 T * alloc_align_set( size_t align, char fill ); 6700 T * alloc_align_set( size_t align, T fill ); 6701 T * alloc_align_set( size_t align, size_t dim, char fill ); 6702 T * alloc_align_set( size_t align, size_t dim, T fill ); 6703 T * alloc_align_set( size_t align, size_t dim, const T fill[] ); 6704 T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); 6705 6706 // §\CFA§ safe initialization/copy, i.e., implicit size specification 6707 T * memset( T * dest, char fill );§\indexc{memset}§ 6626 T * alloc( T ptr[], size_t dim, char fill ); 6627 6628 // §\CFA§ safe general allocation, align, fill, array 6629 T * align_alloc( size_t align ); 6630 T * align_alloc( size_t align, char fill ); 6631 T * align_alloc( size_t align, size_t dim ); 6632 T * align_alloc( size_t align, size_t dim, char fill ); 6633 6634 // §\CFA§ safe initialization/copy, i.e., implicit size specification 6635 T * memset( T * dest, char c );§\indexc{memset}§ 6708 6636 T * memcpy( T * dest, const T * src );§\indexc{memcpy}§ 6709 6637 6710 // §\CFA§ safe initialization/copy, i.e., implicit size specification, array types 6711 T * amemset( T dest[], char fill, size_t dim );6638 // §\CFA§ safe initialization/copy array 6639 T * amemset( T dest[], char c, size_t dim ); 6712 6640 T * amemcpy( T dest[], const T src[], size_t dim ); 6713 6641 } 6714 6642 6715 // §\CFA§ allocation/deallocation and constructor/destructor , non-array types6716 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) T * new( Params p );§\indexc{new}§6717 forall( dtype T | sized(T) | { void ^?{}( T &); } ) void delete( T * ptr );§\indexc{delete}§6718 forall( dtype T, ttype Params | sized(T) | { void ^?{}( T &); void delete( Params ); } )6643 // §\CFA§ allocation/deallocation and constructor/destructor 6644 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * new( Params p );§\indexc{new}§ 6645 forall( dtype T | { void ^?{}( T * ); } ) void delete( T * ptr );§\indexc{delete}§ 6646 forall( dtype T, ttype Params | { void ^?{}( T * ); void delete( Params ); } ) 6719 6647 void delete( T * ptr, Params rest ); 6720 6648 6721 // §\CFA§ allocation/deallocation and constructor/destructor, array types6722 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) T * anew( size_t dim, Params p );§\indexc{anew}§6723 forall( dtype T | sized(T) | { void ^?{}( T &); } ) void adelete( size_t dim, T arr[] );§\indexc{adelete}§6724 forall( dtype T | sized(T) | { void ^?{}( T &); }, ttype Params | { void adelete( Params ); } )6649 // §\CFA§ allocation/deallocation and constructor/destructor, array 6650 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * anew( size_t dim, Params p );§\indexc{anew}§ 6651 forall( dtype T | sized(T) | { void ^?{}( T * ); } ) void adelete( size_t dim, T arr[] );§\indexc{adelete}§ 6652 forall( dtype T | sized(T) | { void ^?{}( T * ); }, ttype Params | { void adelete( Params ); } ) 6725 6653 void adelete( size_t dim, T arr[], Params rest ); 6726 6654 \end{cfa} -
libcfa/src/bits/containers.hfa
r331eacbe r5452673 169 169 get_next( *head ) = 0p; 170 170 verify(*this.tail == 1p); 171 verify( get_next(*head) == 0p );172 171 return head; 173 172 } -
libcfa/src/concurrency/monitor.cfa
r331eacbe r5452673 534 534 //Find the thread to run 535 535 $thread * signallee = pop_head( this.blocked )->waiting_thread; 536 /* paranoid */ verify( signallee->next == 0p ); 536 537 __set_owner( monitors, count, signallee ); 537 538 -
libcfa/src/exception.c
r331eacbe r5452673 72 72 // Used in the personality function, way down in termination. 73 73 // struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception_t *) 74 #if defined( __x86_64 )75 74 #define MATCHER_FROM_CONTEXT(ptr_to_context) \ 76 75 (*(_Unwind_Reason_Code(**)(exception_t *))(_Unwind_GetCFA(ptr_to_context) + 8)) 77 #elif defined( __i386 ) 78 #define MATCHER_FROM_CONTEXT(ptr_to_context) \ 79 (*(_Unwind_Reason_Code(**)(exception_t *))(_Unwind_GetCFA(ptr_to_context) + 24)) 80 #endif 76 81 77 82 78 // RESUMPTION ================================================================ -
libcfa/src/interpose.cfa
r331eacbe r5452673 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 2 17:37:00202013 // Update Count : 1 7612 // Last Modified On : Mon Feb 17 10:18:53 2020 13 // Update Count : 166 14 14 // 15 15 … … 143 143 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 144 144 void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 145 void __abort( bool signalAbort, const char fmt[], va_list args ) __attribute__(( __nothrow__, __leaf__, __noreturn__ ));146 145 147 146 extern "C" { … … 153 152 va_list argp; 154 153 va_start( argp, fmt ); 155 __abort( false, fmt, argp );154 abort( false, fmt, argp ); 156 155 va_end( argp ); 157 156 } … … 219 218 } 220 219 221 // Cannot forward va_list. 222 void __abort( bool signalAbort, const char fmt[], va_list args ) { 220 void abort( bool signalAbort, const char fmt[], ... ) { 223 221 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 224 222 int len; … … 230 228 231 229 assert( fmt ); 230 va_list args; 231 va_start( args, fmt ); 232 232 233 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 234 va_end( args ); 233 235 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 234 236 … … 246 248 va_list args; 247 249 va_start( args, fmt ); 248 __abort( false, fmt, args ); 249 // CONTROL NEVER REACHES HERE! 250 abort( false, fmt, args ); 250 251 va_end( args ); 251 }252 253 void abort( bool signalAbort, const char fmt[], ... ) {254 va_list args;255 va_start( args, fmt );256 __abort( signalAbort, fmt, args );257 // CONTROL NEVER REACHES HERE!258 va_end( args );259 252 } 260 253 -
src/SynTree/LinkageSpec.cc
r331eacbe r5452673 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:22:09 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Mar 2 16:13:00 202013 // Update Count : 2 911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 15:02:29 2019 13 // Update Count : 28 14 14 // 15 15 … … 20 20 21 21 #include "LinkageSpec.h" 22 #include "Common/CodeLocation.h"23 22 #include "Common/SemanticError.h" 24 23 -
src/SynTree/LinkageSpec.h
r331eacbe r5452673 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:24:28 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Mar 2 16:13:00 202013 // Update Count : 2 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 15:03:43 2019 13 // Update Count : 20 14 14 // 15 15 … … 18 18 #include <string> 19 19 20 struct CodeLocation; 20 #include "Common/CodeLocation.h" 21 21 22 22 namespace LinkageSpec { -
tools/cfa.nanorc
r331eacbe r5452673 26 26 27 27 # Escaped Keywords, now Identifiers. 28 color white "` `\w+"28 color white "`\w+`" 29 29 30 30 # Operator Names
Note:
See TracChangeset
for help on using the changeset viewer.