跳到內容

clibrary

本頁內容尚未翻譯。

data VariadicArguments

What a library function takes after its parameters: nothing, arguments as printf’s (sprintf), or targets as scanf’s (sscanf).

record LibraryFunction (L : Constructs)

A library function: name, parameter types, result type (none is void), the effects of a call, the parameters it writes through when they are the only ones (a call whose arguments there are all null pointer constants writes nothing: strtol with no end pointer), and what it takes after its parameters.

def LibraryFunction.reading : Effects

What reading through its arguments’ pointers does: reads elsewhere.

def LibraryFunction.writing : Effects

What writing through its arguments’ pointers does: writes and reads elsewhere.

def LibraryFunction.reads : Effects

What reading input into its arguments’ pointers does.

def LibraryFunction.prints : Effects

What printing to the console does (%s reads through a pointer).

def LibraryFunction.of {L : Constructs} (name : String) (parameters : List (Ty L)) (result : Ty L) (effects : Effects) : LibraryFunction L

A library function returning a value.

def LibraryFunction.writingThrough {L : Constructs} (name : String) (parameters : List (Ty L)) (result : Ty L) (indices : List Nat) : LibraryFunction L

A library function returning a value that writes only through the parameters at the indices.

def LibraryFunction.variadic {L : Constructs} (name : String) (parameters : List (Ty L)) (result : Ty L) (rest : VariadicArguments) : LibraryFunction L

A library function returning int that takes more arguments after its parameters.

cfamily.LibraryFunction.variadicWritingThrough

Section titled “cfamily.LibraryFunction.variadicWritingThrough”
def LibraryFunction.variadicWritingThrough {L : Constructs} (name : String) (parameters : List (Ty L)) (result : Ty L) (rest : VariadicArguments) (indices : List Nat) : LibraryFunction L

The library function name returning result that takes more arguments after its parameters (as rest says) and writes only through the parameters at the indices (sprintf’s buffer).

record LibraryTypes (L : Constructs)

The types the library’s signatures use, on a target.

def LibraryTypes.of {L : Constructs} (tgt : Target) : LibraryTypes L

The signatures’ types on a target: size_t as the platform’s ABI has it, FILE is opaque, wchar_t is int.

def LibraryFunction.input {L : Constructs} (t : LibraryTypes L) : List (LibraryFunction L)

<stdio.h>’s functions: the console, the files, formatted input and output.

def LibraryFunction.strings {L : Constructs} (t : LibraryTypes L) : List (LibraryFunction L)

<string.h>’s functions.

def LibraryFunction.characters {L : Constructs} (t : LibraryTypes L) : List (LibraryFunction L)

<ctype.h>’s functions.

def LibraryFunction.mathematics {L : Constructs} (t : LibraryTypes L) : List (LibraryFunction L)

<math.h>’s functions.

def LibraryFunction.utilities {L : Constructs} (t : LibraryTypes L) : List (LibraryFunction L)

<stdlib.h>’s functions (malloc, calloc, realloc and free are checked by their own rules).

def LibraryFunction.randomAndTime {L : Constructs} (tgt : Target) (t : LibraryTypes L) : List (LibraryFunction L)

<stdlib.h>’s random numbers and <time.h>’s clock (time_t is long): checked by their own rules when called.

def LibraryFunction.wide {L : Constructs} (t : LibraryTypes L) : List (LibraryFunction L)

<wchar.h>’s functions (wchar_t is int).

def LibraryFunction.sortChecks {L : Constructs} (t : LibraryTypes L) : List (LibraryFunction L)

The checks qsort and bsearch make.

def LibraryFunction.standard {L : Constructs} (tgt : Target) : List (LibraryFunction L)

The C library functions on a target.

def LibraryFunction.isMath (tgt : Target) (f : String) : Bool

Whether f names one of <math.h>’s functions (LibraryFunction.mathematics), on the target tgt.

def LibraryFunction.named {L : Constructs} (fs : List (LibraryFunction L)) (f : String) : Option (LibraryFunction L)

The library function with the name, if any.

def LibraryFunction.writesThroughOf {L : Constructs} (fs : List (LibraryFunction L)) (f : String) : List Nat

The arguments (by position) the function named f of the library fs writes through when those are all it writes elsewhere (snprintf’s buffer, memcpy’s destination); none for a function the library does not have.

record LibraryConstant

A macro constant of the standard headers (C11 5.2.4.2.1 <limits.h>, 7.21.1 <stdio.h>’s EOF, 7.22 <stdlib.h>’s RAND_MAX and EXIT_*): its name, the headers that declare it (C’s and C++’s spelling), its type and its value on a platform. A program writes it as eConst.

def LibraryConstant.promoted (p : Platform) (t : IntegerType) : IntegerType

The type a limit of t has: t after the integer promotions (C11 5.2.4.2.1p1: UCHAR_MAX is an int).

def LibraryConstant.maximumIn (headers : List String) (name : String) (t : Platform -> IntegerType) : LibraryConstant

The largest value of a type, as a limit some headers declare.

def LibraryConstant.minimumIn (headers : List String) (name : String) (t : Platform -> IntegerType) : LibraryConstant

The smallest value of a type, as a limit some headers declare.

def LibraryConstant.maximumOf (name : String) (t : Platform -> IntegerType) : LibraryConstant

The largest value of a type, as a limit of <limits.h>.

def LibraryConstant.minimumOf (name : String) (t : Platform -> IntegerType) : LibraryConstant

The smallest value of a type, as a limit of <limits.h>.

def LibraryConstant.fixed (name : String) (headers : List String) (v : Int) : LibraryConstant

An int constant a header declares, the same on every platform.

def LibraryConstant.standard : List LibraryConstant

The macro constants of the standard headers. RAND_MAX is INT_MAX on the platforms modeled (glibc, Apple’s libc, AVR libc and newlib all define it so; the standard only asks for at least 32767). C++’s std::string::npos (size_type(-1), [basic.string]) is here too, written with or without std::: only C++ names have ::.

def LibraryConstant.limitsOf (start : String) (signed : Platform -> IntegerType) (unsigned : Platform -> IntegerType) : List LibraryConstant

The limits of <stdint.h> for one of its types: INTN_MIN, INTN_MAX, UINTN_MAX and so on (C11 7.20.2).

def LibraryConstant.integerLimits : List LibraryConstant

The limits of <stdint.h> (C11 7.20.2, 7.20.3): each one’s type is its type’s after the integer promotions.

def LibraryConstant.named (name : String) : Option LibraryConstant

The macro constant of that name, if a standard header declares one.

def LibraryConstant.included {L : Constructs} (g : Globals L) (c : LibraryConstant) : Bool

Whether the program includes one of the headers that declare a constant.

def LibraryFunction.allocation : List String

The allocation functions: the checker models them by its own rules rather than a signature.

def LibraryFunction.specialEffects : List (String * Effects)

The effects of the library functions checked by their own rules rather than a signature: allocation, variadic formatting, the random numbers and the clock.

def LibraryFunction.isNull {L : Constructs} (e : Option (TypedExpr L)) : Bool

Whether an argument is there and a null pointer constant.

def LibraryFunction.effectsWith {L : Constructs} (f : LibraryFunction L) (args : List (TypedExpr L)) : Effects

The effects of a call with its arguments: none of the writes when every argument it writes through is a null pointer constant.

def LibraryFunction.effectsOf {L : Constructs} (fs : List (LibraryFunction L)) (f : String) (args : List (TypedExpr L)) : Effects

The effects of calling a function by name that the program does not define: the library’s, or (for a function the library does not have) reading elsewhere.