Changes in / [2c6c893:93684eb]
- Files:
-
- 8 edited
-
doc/bibliography/cfa.bib (modified) (1 diff)
-
doc/refrat/Makefile (modified) (2 diffs)
-
doc/refrat/refrat.bib (modified) (4 diffs)
-
doc/refrat/refrat.tex (modified) (30 diffs)
-
doc/user/user.tex (modified) (4 diffs)
-
src/libcfa/stdlib (modified) (2 diffs)
-
src/tests/.expect/alloc.txt (modified) (1 diff)
-
src/tests/alloc.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/bibliography/cfa.bib
r2c6c893 r93684eb 4424 4424 keywords = {Plan 9}, 4425 4425 contributer = {pabuhr@plg}, 4426 title = {A New {C}Compiler},4426 title = {A New C Compiler}, 4427 4427 author = {Ken Thompson}, 4428 4428 booktitle = {Proceedings of the Summer 1990 UKUUG Conference}, 4429 4429 year = 1990, 4430 4430 pages = {41--51}, 4431 note = {\href{http://doc.cat-v.org/bell_labs/new_c_compilers/new_c_compiler.pdf}{http://\-doc.cat-v.org/\-bell\_labs/\-new\_c\_compilers/\-new\_c\_compiler.pdf}},4431 url = {http://doc.cat-v.org/bell_labs/new_c_compilers/new_c_compiler.pdf} 4432 4432 } 4433 4433 -
doc/refrat/Makefile
r2c6c893 r93684eb 44 44 45 45 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \ 46 ../LaTeXmacros/common.tex ../LaTeXmacros/ lstlang.sty ../LaTeXmacros/indexstyle ../bibliography/cfa.bib46 ../LaTeXmacros/common.tex ../LaTeXmacros/indexstyle ../bibliography/cfa.bib 47 47 # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run. 48 48 if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi … … 70 70 fig2dev -L ps $< > $@ 71 71 72 %.pstex : %.fig73 fig2dev -L pstex $< > $@74 fig2dev -L pstex_t -p $@ $< > $@_t75 76 72 # Local Variables: # 77 73 # compile-command: "make" # -
doc/refrat/refrat.bib
r2c6c893 r93684eb 2 2 3 3 @manual{ANS:C, 4 keywords = {ANSI C},5 contributer = {gjditchfield@msg},6 title = {American National Standard for Information Systems --4 keywords = {ANSI C}, 5 contributer = {gjditchfield@msg}, 6 title = {American National Standard for Information Systems -- 7 7 Programming Language -- {C}}, 8 organization = {American National Standards Institute},9 address = {1430 Broadway, New York, New York 10018},10 month = dec, year= 1989,11 note = {X3.159-1989}8 organization = {American National Standards Institute}, 9 address = {1430 Broadway, New York, New York 10018}, 10 month = dec, year = 1989, 11 note = {X3.159-1989} 12 12 } 13 13 14 14 @manual{ANS:C11, 15 keywords = {ANS:C11},16 contributer = {gjditchfield@acm.org},17 title = {American National Standard Information Systems --15 keywords = {ANS:C11}, 16 contributer = {gjditchfield@acm.org}, 17 title = {American National Standard Information Systems -- 18 18 Programming languages -- {C}}, 19 organization = {American National Standards Institute},20 address = {25 West 43rd Street, New York, New York 10036},21 month = may, year= 2012,22 note = {INCITS/ISO/IEC 9899-2011[2012]}19 organization = {American National Standards Institute}, 20 address = {25 West 43rd Street, New York, New York 10036}, 21 month = may, year = 2012, 22 note = {INCITS/ISO/IEC 9899-2011[2012]} 23 23 } 24 24 25 25 @book{c++, 26 keywords = {C++, ANSI},27 author = {Margaret A. Ellis and Bjarne Stroustrup},28 title = {The Annotated {C}{\tt ++} Reference Manual},29 publisher = {Addison Wesley},30 year = 1990,31 edition = {first}26 keywords = {C++, ANSI}, 27 author = {Margaret A. Ellis and Bjarne Stroustrup}, 28 title = {The Annotated {C}{\tt ++} Reference Manual}, 29 publisher = {Addison Wesley}, 30 year = 1990, 31 edition = {first} 32 32 } 33 33 34 34 @Unpublished{Ditchfield96:Overview, 35 author ="Glen Ditchfield",36 title ="An Overview of Cforall",37 note ="in preparation",38 year =199635 author = "Glen Ditchfield", 36 title = "An Overview of Cforall", 37 note = "in preparation", 38 year = 1996 39 39 } 40 40 41 41 @article{Bak:overload, 42 keywords = {compilation},43 contributer = {gjditchfield@msg},44 author = {T. P. Baker},45 title = {A One-Pass Algorithm for Overload Resolution in {Ada}},46 journal = toplas,47 year = 1982,48 month = oct, volume = 4, number = 4, pages= {601--614},49 abstract = {42 keywords = {compilation}, 43 contributer = {gjditchfield@msg}, 44 author = {T. P. Baker}, 45 title = {A One-Pass Algorithm for Overload Resolution in {Ada}}, 46 journal = toplas, 47 year = 1982, 48 month = oct, volume = 4, number = 4, pages = {601--614}, 49 abstract = { 50 50 A simple method is presented for detecting ambiguities and finding 51 51 the correct interpretations of expressions in the programming … … 56 56 approach is demonstrated by a brief formal argument. 57 57 }, 58 comment = {58 comment = { 59 59 See also \cite{D:overload}. 60 60 } … … 77 77 78 78 @book{clu, 79 keywords = {CLU},80 contributer = {gjditchfield@msg},81 author = {Barbara Liskov and Russell Atkinson and Toby Bloom and Eliot79 keywords = {CLU}, 80 contributer = {gjditchfield@msg}, 81 author = {Barbara Liskov and Russell Atkinson and Toby Bloom and Eliot 82 82 Moss and J. Craig Schaffert and Robert Scheifler and Alan Snyder}, 83 title = {CLU Reference Manual},84 publisher = {Springer-Verlag},85 year = 1981,86 volume = 114,87 series = {Lecture Notes in Computer Science}83 title = {CLU Reference Manual}, 84 publisher = {Springer-Verlag}, 85 year = 1981, 86 volume = 114, 87 series = {Lecture Notes in Computer Science} 88 88 } 89 89 90 90 @manual{SIMULA87, 91 keywords = {Simula standard},92 contributer = {gjditchfield@msg},93 title = {Databehandling -- Programspr{\aa}k -- {SIMULA}},94 organization = {Standardiseringskommissionen i Sverige},95 note = {Svensk Standard SS 63 61 14},96 year = 1987,97 abstract = {91 keywords = {Simula standard}, 92 contributer = {gjditchfield@msg}, 93 title = {Databehandling -- Programspr{\aa}k -- {SIMULA}}, 94 organization = {Standardiseringskommissionen i Sverige}, 95 note = {Svensk Standard SS 63 61 14}, 96 year = 1987, 97 abstract = { 98 98 Standard for the programming language SIMULA. Written in English. 99 99 } … … 112 112 113 113 @inproceedings{Thompson90new, 114 title = {A New {C}Compiler},115 author= {Ken Thompson},116 booktitle= {Proceedings of the Summer 1990 UKUUG Conference},117 year= 1990,118 pages= {41--51}114 title = {A New C Compiler}, 115 author = {Ken Thompson}, 116 booktitle = {Proceedings of the Summer 1990 UKUUG Conference}, 117 year = 1990, 118 pages = {41--51} 119 119 } -
doc/refrat/refrat.tex
r2c6c893 r93684eb 11 11 %% Created On : Wed Apr 6 14:52:25 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Jun 2 10:43:14201714 %% Update Count : 8313 %% Last Modified On : Wed Apr 5 23:23:28 2017 14 %% Update Count : 79 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 29 29 \usepackage{epic,eepic} 30 30 \usepackage{upquote} % switch curled `'" to straight 31 \usepackage{calc}32 31 \usepackage{xspace} 33 32 \usepackage{varioref} % extended references … … 63 62 % Names used in the document. 64 63 \newcommand{\Version}{\input{../../version}} 64 65 65 \newcommand{\Textbf}[2][red]{{\color{#1}{\textbf{#2}}}} 66 66 \newcommand{\Emph}[2][red]{{\color{#1}\textbf{\emph{#2}}}} … … 97 97 \renewcommand{\chaptermark}[1]{\markboth{\thechapter\quad #1}{\thechapter\quad #1}} 98 98 \renewcommand{\sectionmark}[1]{\markboth{\thesection\quad #1}{\thesection\quad #1}} 99 \renewcommand{\subsectionmark}[1]{\markboth{\thesubsection\quad #1}{\thesubsection\quad #1}}100 99 \pagenumbering{roman} 101 100 \linenumbers % comment out to turn off line numbering … … 122 121 123 122 This document is a reference manual and rationale for \CFA, a polymorphic extension of the C programming language. 124 It covers low-level syntactic and semantic details of the language to address complex language issues for programmers, and provide language implementers with a precise language description. 125 It makes frequent reference to the \Celeven standard~\cite{C11}, and occasionally compares \CFA to \CC~\cite{C++}. 126 Changes to the syntax and additional features are expected to be included in later revisions. 127 128 The manual deliberately imitates the ordering of the \Celeven standard (although the section numbering differs). 129 Unfortunately, this means the manual contains more ``forward references'' than usual, making it harder to follow if the reader does not have a copy of the \Celeven standard. 123 It makes frequent reference to the {\c11} standard \cite{C11}, and occasionally compares \CFA to {\CC} \cite{C++}. 124 125 The manual deliberately imitates the ordering of the {\c11} standard (although the section numbering differs). 126 Unfortunately, this means the manual contains more ``forward references'' than usual, making it harder to follow if the reader does not have a copy of the {\c11} standard. 130 127 For a simple introduction to \CFA, see the companion document ``An Overview of \CFA'' 131 128 \cite{Ditchfield96:Overview}. … … 142 139 \chapter{Terms, definitions, and symbols} 143 140 144 Terms from the \Celeven standard used in this document have the same meaning as in the \Celevenstandard.141 Terms from the {\c11} standard used in this document have the same meaning as in the {\c11} standard. 145 142 146 143 % No ``Conformance'' or ``Environment'' chapters yet. … … 152 149 153 150 \section{Notation} 154 The syntax notation used in this document is the same as in the \Celeven standard, with one exception: ellipsis in the definition of a nonterminal, as in ``\emph{declaration:} \ldots'', indicates that these rules extend a previous definition, which occurs in this document or in the \Celevenstandard.151 The syntax notation used in this document is the same as in the {\c11} standard, with one exception: ellipsis in the definition of a nonterminal, as in ``\emph{declaration:} \ldots'', indicates that these rules extend a previous definition, which occurs in this document or in the {\c11} standard. 155 152 156 153 … … 165 162 \begin{rationale} 166 163 Hence, a \CFA program can declare an ©int v© and a ©float v© in the same scope; 167 a \CCprogram can not.164 a {\CC} program can not. 168 165 \end{rationale} 169 166 … … 288 285 289 286 \begin{rationale} 290 Note that \Celevendoes not include conversion from \Index{real type}s to \Index{complex type}s in the usual arithmetic conversions, and \CFA does not include them as safe conversions.287 Note that {\c11} does not include conversion from \Index{real type}s to \Index{complex type}s in the usual arithmetic conversions, and \CFA does not include them as safe conversions. 291 288 \end{rationale} 292 289 … … 373 370 \begin{rationale} 374 371 As in C, there is an implicit conversion from ©void *© to any pointer type. 375 This is clearly dangerous, and \CCdoes not have this implicit conversion.372 This is clearly dangerous, and {\CC} does not have this implicit conversion. 376 373 \CFA\index{deficiencies!void * conversion} keeps it, in the interest of remaining as pure a superset of C as possible, but discourages it by making it unsafe. 377 374 \end{rationale} … … 611 608 612 609 There are two notable differences between \CFA's overload resolution rules and the rules for 613 \CCdefined in \cite{C++}.610 {\CC} defined in \cite{C++}. 614 611 First, the result type of a function plays a role. 615 In \CC, a function call must be completely resolved based on the arguments to the call in most circumstances.612 In {\CC}, a function call must be completely resolved based on the arguments to the call in most circumstances. 616 613 In \CFA, a function call may have several interpretations, each with a different result type, and the interpretations of the containing context choose among them. 617 614 Second, safe conversions are used to choose among interpretations of all sorts of functions; 618 in \CC, the ``usual arithmetic conversions'' are a separate set of rules that apply only to the built-in operators.615 in {\CC}, the ``usual arithmetic conversions'' are a separate set of rules that apply only to the built-in operators. 619 616 \end{rationale} 620 617 … … 640 637 641 638 \begin{rationale} 642 Expression syntax is quoted from the \Celevenstandard.639 Expression syntax is quoted from the {\c11} standard. 643 640 The syntax itself defines the precedence and associativity of operators. 644 641 The sections are arranged in decreasing order of precedence, with all operators in a section having the same precedence. … … 668 665 The \Index{valid interpretation} of an \nonterm{identifier} are given by the visible\index{visible} declarations of the identifier. 669 666 670 A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type and value defined by \Celeven.667 A \nonterm{constant} or \nonterm{string-literal} has one valid interpretation, which has the type and value defined by {\c11}. 671 668 The predefined integer identifiers ``©1©'' and ``©0©'' have the integer values 1 and 0, respectively. 672 669 The other two predefined ``©0©'' identifiers are bound to polymorphic pointer values that, when specialized\index{specialization} with a data type or function type respectively, produce a null pointer of that type. … … 1116 1113 forall( otype T ) T restrict * ?++( T restrict *restrict volatile * ); 1117 1114 \end{lstlisting} with ©T© inferred to be ©float *©. 1118 This looks odd, because \Celevencontains a constraint that requires restrict-qualified types to be pointer-to-object types, and ©T© is not syntactically a pointer type. \CFA loosens the constraint.1115 This looks odd, because {\c11} contains a constraint that requires restrict-qualified types to be pointer-to-object types, and ©T© is not syntactically a pointer type. \CFA loosens the constraint. 1119 1116 \end{enumerate} 1120 1117 \end{rationale} … … 1480 1477 1481 1478 \begin{rationale} 1482 \Celevendoes not include conversions from the \Index{real type}s to \Index{complex type}s in the \Index{usual arithmetic conversion}s. Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern.1479 {\c11} does not include conversions from the \Index{real type}s to \Index{complex type}s in the \Index{usual arithmetic conversion}s. Instead it specifies conversion of the result of binary operations on arguments from mixed type domains. \CFA's predefined operators match that pattern. 1483 1480 \end{rationale} 1484 1481 … … 1509 1506 1510 1507 \begin{rationale} 1511 \Celevendefines most arithmetic operations to apply an \Index{integer promotion} to any argument that belongs to a type that has an \Index{integer conversion rank} less than that of ©int©.1508 {\c11} defines most arithmetic operations to apply an \Index{integer promotion} to any argument that belongs to a type that has an \Index{integer conversion rank} less than that of ©int©. 1512 1509 If ©s© is a ©short int©, ``©s *s©'' does not have type ©short int©; 1513 1510 it is treated as ``©( (int)s ) * ( (int)s )©'', and has type ©int©. \CFA matches that pattern; … … 1522 1519 \end{lstlisting} 1523 1520 Since \CFA does not define a multiplication operator for ©short int©, ©square( s )© is treated as ©square( (int)s )©, and the result has type ©int©. 1524 This is mildly surprising, but it follows the \Celevenoperator pattern.1521 This is mildly surprising, but it follows the {\c11} operator pattern. 1525 1522 1526 1523 A more troubling example is … … 1620 1617 ©ptrdiff_t© is an implementation-defined identifier defined in ©<stddef.h>© that is synonymous with a signed integral type that is large enough to hold the difference between two pointers. 1621 1618 It seems reasonable to use it for pointer addition as well. (This is technically a difference between \CFA and C, which only specifies that pointer addition uses an \emph{integral} argument.) Hence it is also used for subscripting, which is defined in terms of pointer addition. 1622 The \Celevenstandard uses ©size_t© in several cases where a library function takes an argument that is used as a subscript, but ©size_t© is unsuitable here because it is an unsigned type.1619 The {\c11} standard uses ©size_t© in several cases where a library function takes an argument that is used as a subscript, but ©size_t© is unsuitable here because it is an unsigned type. 1623 1620 \end{rationale} 1624 1621 … … 1933 1930 \end{lstlisting} 1934 1931 The logical expression calls the ©Rational© inequality operator, passing it ©*rp© and the ©Rational 0©, and getting a 1 or 0 as a result. 1935 In contrast, \CCwould apply a programmer-defined ©Rational©-to-©int© conversion to ©*rp© in the equivalent situation.1932 In contrast, {\CC} would apply a programmer-defined ©Rational©-to-©int© conversion to ©*rp© in the equivalent situation. 1936 1933 The conversion to ©int© would produce a general integer value, which is unfortunate, and possibly dangerous if the conversion was not written with this situation in mind. 1937 1934 \end{rationale} … … 2629 2626 \begin{itemize} 2630 2627 \item a typedef name may be redefined to denote the same type as it currently does, provided that type is not a variably modified type; 2631 \item tags may be redeclared as specified in section 6.7.2.3 of the \Celevenstandard.2628 \item tags may be redeclared as specified in section 6.7.2.3 of the {\c11} standard. 2632 2629 \end{itemize} 2633 2630 \begin{rationale} 2634 This constraint adds the phrase ``with compatible types'' to the \Celevenconstraint, to allow overloading.2631 This constraint adds the phrase ``with compatible types'' to the {\c11} constraint, to allow overloading. 2635 2632 \end{rationale} 2636 2633 2637 2634 An identifier declared by a type declaration shall not be redeclared as a parameter in a function definition whose declarator includes an identifier list. 2638 2635 \begin{rationale} 2639 This restriction echos \Celeven's ban on the redeclaration of typedef names as parameters.2636 This restriction echos {\c11}'s ban on the redeclaration of typedef names as parameters. 2640 2637 This avoids an ambiguity between old-style function declarations and new-style function prototypes: 2641 2638 \begin{lstlisting} … … 2664 2661 2665 2662 \semantics 2666 \CFA extends the \Celeven definition of \define{anonymous structure} to include structure specifiers with tags, and extends the \Celevendefinition of \define{anonymous union} to include union specifiers with tags.2663 \CFA extends the {\c11} definition of \define{anonymous structure} to include structure specifiers with tags, and extends the {\c11} definition of \define{anonymous union} to include union specifiers with tags. 2667 2664 \begin{rationale} 2668 2665 This extension imitates an extension in the Plan 9 C compiler \cite{Thompson90new}. … … 2857 2854 2858 2855 \begin{rationale} 2859 ©lvalue© provides some of the functionality of \CC's ``©T&©'' ( reference to object of type ©T©) type.2860 Reference types have four uses in \CC.2856 ©lvalue© provides some of the functionality of {\CC}'s ``©T&©'' ( reference to object of type ©T©) type. 2857 Reference types have four uses in {\CC}. 2861 2858 \begin{itemize} 2862 2859 \item … … 2865 2862 \item 2866 2863 A reference can be used to define an alias for a complicated lvalue expression, as a way of getting some of the functionality of the Pascal ©with© statement. 2867 The following \CCcode gives an example.2864 The following {\CC} code gives an example. 2868 2865 \begin{lstlisting} 2869 2866 { … … 2877 2874 A reference parameter can be used to allow a function to modify an argument without forcing the caller to pass the address of the argument. 2878 2875 This is most useful for user-defined assignment operators. 2879 In \CC, plain assignment is done by a function called ``©operator=©'', and the two expressions2876 In {\CC}, plain assignment is done by a function called ``©operator=©'', and the two expressions 2880 2877 \begin{lstlisting} 2881 2878 a = b; … … 2890 2887 \item 2891 2888 References to \Index{const-qualified} types can be used instead of value parameters. Given the 2892 \CCfunction call ``©fiddle( a_thing )©'', where the type of ©a_thing© is2889 {\CC} function call ``©fiddle( a_thing )©'', where the type of ©a_thing© is 2893 2890 ©Thing©, the type of ©fiddle© could be either of 2894 2891 \begin{lstlisting} … … 3219 3216 The Simula class \cite{SIMULA87} is essentially a record type. 3220 3217 Since the only operations on a record are member selection and assignment, which can not be overloaded, there is never any ambiguity as to whether the abstraction or the implementation view is being used. 3221 In \CC3218 In {\CC} 3222 3219 \cite{C++}, operations on class instances include assignment and ``©&©'', which can be overloaded. 3223 3220 A ``scope resolution'' operator can be used inside the class to specify whether the abstract or implementation version of the operation should be used. … … 3551 3548 \subsection{Predefined macro names} 3552 3549 3553 The implementation shall define the macro names ©__LINE__©, ©__FILE__©, ©__DATE__©, and ©__TIME__©, as in the \Celevenstandard.3550 The implementation shall define the macro names ©__LINE__©, ©__FILE__©, ©__DATE__©, and ©__TIME__©, as in the {\c11} standard. 3554 3551 It shall not define the macro name ©__STDC__©. 3555 3552 … … 3637 3634 \subsection{Pointer and array types} 3638 3635 3639 Array types can barely be said to exist in \Celeven, since in most cases an array name is treated as a constant pointer to the first element of the array, and the subscript expression ``©a[i]©'' is equivalent to the dereferencing expression ``©(*( a+( i )))©''.3636 Array types can barely be said to exist in {\c11}, since in most cases an array name is treated as a constant pointer to the first element of the array, and the subscript expression ``©a[i]©'' is equivalent to the dereferencing expression ``©(*( a+( i )))©''. 3640 3637 Technically, pointer arithmetic and pointer comparisons other than ``©==©'' and ``©!=©'' are only defined for pointers to array elements, but the type system does not enforce those restrictions. 3641 3638 Consequently, there is no need for a separate ``array type'' specification. … … 3715 3712 Different operators often have related meanings; 3716 3713 for instance, in C, ``©+©'', ``©+=©'', and the two versions of ``©++©'' perform variations of addition. 3717 Languages like \CCand Ada allow programmers to define operators for new types, but do not require that these relationships be preserved, or even that all of the operators be implemented.3714 Languages like {\CC} and Ada allow programmers to define operators for new types, but do not require that these relationships be preserved, or even that all of the operators be implemented. 3718 3715 Completeness and consistency is left to the good taste and discretion of the programmer. 3719 3716 It is possible to encourage these attributes by providing generic operator functions, or member functions of abstract classes, that are defined in terms of other, related operators. … … 3826 3823 \end{theindex} 3827 3824 3828 3829 3825 \end{document} 3830 3826 -
doc/user/user.tex
r2c6c893 r93684eb 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Jun 2 10:07:51201714 %% Update Count : 212 813 %% Last Modified On : Thu Jun 1 22:46:09 2017 14 %% Update Count : 2126 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 185 185 While the \CFA I/O looks similar to the \Index*[C++]{\CC{}} output style, there are important differences, such as automatic spacing between variables as in \Index*{Python} (see~\VRef{s:IOLibrary}). 186 186 187 This document is a programmer reference-manual for the \CFA programming language. 188 The manual covers the core features of the language and runtime-system, with simple examples illustrating syntax and semantics of each feature. 189 The manual does not teach programming, i.e., how to combine the new constructs to build complex programs. 190 A reader should already have an intermediate knowledge of control flow, data structures, and concurrency issues to understand the ideas presented as well as some experience programming in C/\CC. 187 This document is a user manual for the \CFA programming language, targeted at \CFA programmers. 191 188 Implementers may refer to the \CFA Programming Language Specification for details about the language syntax and semantics. 189 In its current state, this document covers the intended core features of the language. 192 190 Changes to the syntax and additional features are expected to be included in later revisions. 193 191 … … 5275 5273 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 5276 5274 // C unsafe allocation 5277 extern "C" { 5278 void * mallac( size_t size );§\indexc{memset}§ 5279 void * calloc( size_t dim, size_t size );§\indexc{calloc}§ 5280 void * realloc( void * ptr, size_t size );§\indexc{realloc}§ 5281 void * memalign( size_t align, size_t size );§\indexc{memalign}§ 5282 int posix_memalign( void ** ptr, size_t align, size_t size );§\indexc{posix_memalign}§ 5283 } 5275 extern "C" { void * mallac( size_t size ); }§\indexc{memset}§ 5276 extern "C" { void * calloc( size_t dim, size_t size ); }§\indexc{calloc}§ 5277 extern "C" { void * realloc( void * ptr, size_t size ); }§\indexc{realloc}§ 5278 extern "C" { void * memalign( size_t align, size_t size ); }§\indexc{memalign}§ 5279 extern "C" { int posix_memalign( void ** ptr, size_t align, size_t size ); }§\indexc{posix_memalign}§ 5284 5280 5285 5281 // §\CFA§ safe equivalents, i.e., implicit size specification … … 5306 5302 5307 5303 // C unsafe initialization/copy 5308 extern "C" { 5309 void * memset( void * dest, int c, size_t size ); 5310 void * memcpy( void * dest, const void * src, size_t size ); 5311 } 5304 extern "C" { void * memset( void * dest, int c, size_t size ); } 5305 extern "C" { void * memcpy( void * dest, const void * src, size_t size ); } 5312 5306 5313 5307 // §\CFA§ safe initialization/copy -
src/libcfa/stdlib
r2c6c893 r93684eb 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 2 15:51:03 201713 // Update Count : 21 812 // Last Modified On : Thu Jun 1 22:46:43 2017 13 // Update Count : 216 14 14 // 15 15 … … 127 127 static inline forall( dtype T | sized(T) ) T * memset( T dest[], size_t dim, char c ) { 128 128 //printf( "X19\n" ); 129 return (void *)memset( dest, c, dim * sizeof(T) ); // C memset129 return memset( dest, c, dim * sizeof(T) ); 130 130 } // memset 131 131 static inline forall( dtype T | sized(T) ) T * memcpy( T dest[], const T src[], size_t dim ) { -
src/tests/.expect/alloc.txt
r2c6c893 r93684eb 13 13 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 14 14 15 C realloc 15 C realloc 40 16 16 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 17 CFA realloc 17 CFA realloc 88 18 18 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 19 19 20 CFA resize alloc 20 CFA resize alloc 40 21 21 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 22 CFA resize array alloc 22 CFA resize array alloc 88 23 23 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 24 CFA resize array alloc 24 CFA resize array alloc 40 25 25 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 26 CFA resize array alloc , fill26 CFA resize array alloc 40, fill 27 27 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 28 CFA resize array alloc , fill28 CFA resize array alloc 88, fill 29 29 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 30 CFA resize array alloc , fill30 CFA resize array alloc 40, fill 31 31 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 32 32 -
src/tests/alloc.c
r2c6c893 r93684eb 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 2 15:13:03201713 // Update Count : 31 612 // Last Modified On : Thu Jun 1 21:33:49 2017 13 // Update Count : 315 14 14 // 15 15 … … 87 87 p = (void *)realloc( p, dim * sizeof(*p) ); // C realloc 88 88 for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; } 89 printf( "C realloc \n");89 printf( "C realloc %ld\n", malloc_usable_size( p ) ); 90 90 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); } 91 91 printf( "\n" ); … … 93 93 p = realloc( p, 2 * dim * sizeof(*p) ); // CFA realloc 94 94 for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; } 95 printf( "CFA realloc \n");95 printf( "CFA realloc %ld\n", malloc_usable_size( p ) ); 96 96 for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); } 97 97 printf( "\n" ); … … 104 104 p = alloc( p, dim ); // CFA resize array alloc 105 105 for ( int i = 0; i < dim; i += 1 ) { p[i] = 0xdeadbeef; } 106 printf( "CFA resize alloc \n");106 printf( "CFA resize alloc %ld\n", malloc_usable_size( p ) ); 107 107 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); } 108 108 printf( "\n" ); … … 110 110 p = alloc( p, 2 * dim ); // CFA resize array alloc 111 111 for ( int i = dim; i < 2 * dim; i += 1 ) { p[i] = 0x1010101; } 112 printf( "CFA resize array alloc \n");112 printf( "CFA resize array alloc %ld\n", malloc_usable_size( p ) ); 113 113 for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); } 114 114 printf( "\n" ); 115 115 116 116 p = alloc( p, dim ); // CFA array alloc 117 printf( "CFA resize array alloc \n");117 printf( "CFA resize array alloc %ld\n", malloc_usable_size( p ) ); 118 118 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); } 119 119 printf( "\n" ); … … 123 123 124 124 p = alloc( p, dim, fill ); // CFA array alloc, fill 125 printf( "CFA resize array alloc , fill\n");125 printf( "CFA resize array alloc %ld, fill\n", malloc_usable_size( p ) ); 126 126 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] ); } 127 127 printf( "\n" ); 128 128 129 129 p = alloc( p, 2 * dim, fill ); // CFA array alloc, fill 130 printf( "CFA resize array alloc , fill\n");130 printf( "CFA resize array alloc %ld, fill\n", malloc_usable_size( p ) ); 131 131 for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); } 132 132 printf( "\n" ); 133 133 134 134 p = alloc( p, dim, fill ); // CFA array alloc, fill 135 printf( "CFA resize array alloc , fill\n");135 printf( "CFA resize array alloc %ld, fill\n", malloc_usable_size( p ) ); 136 136 for ( int i = 0; i < dim; i += 1 ) { printf( "%#x ", p[i] );; } 137 137 printf( "\n" );
Note:
See TracChangeset
for help on using the changeset viewer.