| | 525 | The CIVL core libraries include: |
| | 526 | |
| | 527 | * `civlc.cvh`: the basic library of CIVL, usually included in a CIVL-C program, defining types and functions that are frequently used; |
| | 528 | |
| | 529 | * `scope.cvh`: providing utility functions related to dynamic scopes; |
| | 530 | |
| | 531 | * `pointer.cvh`: providing utility functions dealing with pointers; |
| | 532 | |
| | 533 | * `seq.cvh`: providing operations on sequences which is realized using arrays; |
| | 534 | |
| | 535 | * `concurrency.cvh`: providing concurrency utilities such as barrier and collective record; |
| | 536 | |
| | 537 | * `bundle.cvh`: defining bundle types and their operations; |
| | 538 | |
| | 539 | * `comm.cvh`: defining communicators and their operations. |
| | 540 | |
| | 541 | === the basic library `civlc` === |
| | 542 | |
| | 543 | * assertion |
| | 544 | |
| | 545 | `void $assert(_Bool expr, ...);` |
| | 546 | |
| | 547 | It takes an boolean type expression and a number of optional expressions which are used to construct an error message. The optional arguments are similar in form to those used in C’s printf statement: a format string, followed by some number of arguments which are evaluated and substituted for successive codes in the format string. |
| | 548 | |
| | 549 | * assumption |
| | 550 | |
| | 551 | `void $assume(_Bool expr);` |
| | 552 | |
| | 553 | During verification, the given expression is assumed to hold. If this leads to a contradiction on some execution, that execution is simply ignored. It never reports a violation, it only restricts the set of possible executions that will be explored by the verification algorithm. |
| | 554 | |
| | 555 | * wait |
| | 556 | |
| | 557 | `void $wait($proc p);` |
| | 558 | |
| | 559 | `void $waitall($proc *procs, int numProcs);` |
| | 560 | |
| | 561 | When invoked, `$wait` will not return until the process referenced by p has terminated. Similarly, `$waitall` will not return until all the `numProcs` processes referenced by the memory specified by `procs` have terminated. |
| | 562 | |
| | 563 | * abruption |
| | 564 | |
| | 565 | `void $exit(void);` |
| | 566 | |
| | 567 | This function takes no arguments. It causes the calling process to terminate immediately, regardless of the state of its call stack. |
| | 568 | |
| | 569 | * non-deterministic choice of integer |
| | 570 | |
| | 571 | `int $choose_int(int n);` |
| | 572 | |
| | 573 | This function takes as input a positive integer `n` and nondeterministicaly returns an integer in the range `[0, n − 1]`. |
| | 574 | |
| | 575 | * is a scope reference defined? |
| | 576 | |
| | 577 | `_Bool $scope_defined($scope s);` |
| | 578 | |
| | 579 | It returns true if the dynamic scope specified by `s` is defined, else it returns false. |
| | 580 | |
| | 581 | * is a process reference defined? |
| | 582 | |
| | 583 | `_Bool $proc_defined($proc p);` |
| | 584 | |
| | 585 | It returns true if and only if the given object of `$proc` type is defined. |
| | 586 | |
| | 587 | * dynamic allocation and deallocation: `$malloc` and `$free` |
| | 588 | |
| | 589 | `void * $malloc($scope scope, int size);` |
| | 590 | |
| | 591 | `void $free(void *p);` |
| | 592 | |
| | 593 | To allocate an object, one first needs a reference to the dynamic scope to be used. The function `$free` is used to deallocate a heap object; it is just like C’s free: An error is generated if the pointer is not one that was returned by $malloc, or if it was already freed. |
| | 594 | |
| | 595 | |
| | 596 | === Scope utilities `scope.cvh` === |
| | 597 | The header `scope.cvh` declares one function: `$scope` parent, which has signature |
| | 598 | |
| | 599 | `$scope $scope_parent($scope s);` |
| | 600 | |
| | 601 | This function returns the parent dynamic scope of the dynamic scope referenced by `s`. If `s` is the root dynamic scope, it returns the undefined value of type `$scope`. |
| | 602 | |
| | 603 | === Pointer utilities `pointer.cvh` === |
| | 604 | The header `pointer.cvh` declares functions taking pointers as the arguments for different purposes, including: |
| | 605 | |
| | 606 | * equality checking: |
| | 607 | `_Bool $equals(void *x, void *y);` |
| | 608 | this function returns true iff the objects pointed to by the pointers `x` and `y` have the same type and value. |
| | 609 | |
| | 610 | * membership testing: |
| | 611 | `_Bool $contains(void *ptr1, void *ptr2);` |
| | 612 | this function returns true iff the object pointed to by `ptr1` contains the object pointed to by `ptr2`. For example, `$contains(&a, &a[1].x)` would return true. |
| | 613 | |
| | 614 | * pointer creation: |
| | 615 | $translate ptr for pointer translation; |
| | 616 | * copy through pointers: |
| | 617 | |