Library Reference
This module provides operations that determine the storage requirement
of a composition of two objects, each of which has its own storage
requirement. The storage requirement of an object is determined by the
number of memory units it occupies, the number by which its address
should be divisible, and whether its address is the address of its first
memory unit or the address of the first memory unit above it. Two
distinct composition strategies, concatenation and overlaying, are
supported by this module. (When two objects are concatenated they are
allocated adjacent areas of memory; when they are overlaid they share
memory.)
#include "Storage.h"
StorageRequired NewStorage(/* int size, align, top; */);
StorageRequired CopyStorage(/* StorageRequired a; */);
StorageRequired ArrayStorage(/* int n; StorageRequired a; */);
int StorageSize(/* StorageRequired a; */);
int StorageAlignment(/* StorageRequired a; */);
int Concatenate(/* StorageRequired a, b; */);
int Overlay(/* StorageRequired a, b; */);
The type StorageRequired is a pointer to the data structure
representing a storage requirement.
There is one predefined value, NoStorage , of type
StorageRequired .
NoStorage is a null pointer, and represents "no storage requirement".
NewStorage creates a new description of a storage area requiring
size memory units, whose address must be divisible by
align , and returns a reference to that description. If
top is TRUE then the address of the storage area is the
address of the first memory unit above the area; otherwise the address
is the address of the first memory unit of the area itself.
CopyStorage creates a new description of a storage area whose
requirements are identical to those of a and returns a reference
to that description.
ArrayStorage creates a new description of a storage area for an
array of n elements, each described by a and returns a
reference to that description.
StorageSize returns the number of memory units required by
storage area a . The function StorageAlignment returns the
number by which the address of storage area a must be divisible.
Concatenate determines the requirements of the storage area
resulting when storage area b is concatenated to storage area
a . Area b is placed above area a if the address of
area a is the address of its first memory unit. If the address
of area a is the address of the first memory unit above that
area, then area b is placed below area a . In either case,
area b is placed as close to area a as possible, without
overlapping it. The description referenced by a is changed to
describe the result of the concatenation, and Concatenate returns
the relative address of area b within that resultant area.
Overlay determines the requirements of the storage area resulting
when storage area b is overlaid onto storage area a . The
description referenced by a is changed to describe the result of
the overlay, and Overlay returns the relative address of area
b within that resultant area.
This module should be made available to the Eli specification by including
the following line in a type-specs file:
$/Tech/Storage.specs
|