RCC Local Services

Local services APIs are standard library functions available to RCC workers running in a container. Containers are required to supply them, and portable workers are constrained to use only them, in addition to the worker-to-container methods defined above. The RCC local services are defined as a small subset of the POSIX and ISO-C runtime libraries.

The subset avoids functions that require significant operating system support while providing the author with common, convenient and standard library functions. All I/O is excluded since portable RCC workers should be performing all I/O via the OpenCPI data plane ports and use the OpenCPI log methods rather than printf etc.

These local services APIs represent a minimal environment required of embedded systems. Since RCC workers may execute in a multi-threaded environment, non-reentrant (or thread-unsafe) functions are excluded (e.g. localtime). Similarly, functions that affect the global (process) environment are excluded since they could damage the execution of other workers in the same process (e.g. setenv).

If other APIs are used, there is no guarantee they will be available in all containers. Some containers in fact allow many more functions to be called from a worker, but that makes such workers non-portable. In the future there may be optional explicit error checking for using library functions not in the list below.

In other standards documents, a list of available, standard, functions is sometimes called an Application Environment Profile (AEP).

The actual list of standard functions and global variables usable in portable RCC workers is, in alphabetical order:

abs(), asctime_r(), atof(), atoi(), atol(), atoll(), bsearch(),
calloc(), confstr(), ctime_r(), difftime(), div(), errno,
feclearexcept(), fegetenv(), fegetexceptflag(), fegetround(),
feholdexcept(), feraiseexcept(), fesetenv(), fesetexceptflag(),
fesetround(), fetestexcept(), feupdateenv(), free(), getenv(),
gmtime_r(), imaxabs(), imaxdiv(), isalnum(), isalpha(), isblank(),
iscntrl(), isdigit(), isgraph(), islower(), isprint(), ispunct(),
isspace(), isupper(), isxdigit(), labs(), ldiv(), llabs(), lldiv(),
localeconv(), localtime_r(), longjmp(), malloc(), memchr(),
memcmp(), memcpy(), memmove(), memset(), mktime(), printf(),
qsort(), rand(), rand_r(), realloc(), setjmp(), snprintf(),
sprintf(), srand(), sscanf(), strcat(), strchr(), strcmp(),
strcoll(), strcpy(), strcspn(), strerror(), strerror_r(),
strftime(), strlen(), strncat(), strncmp(), strncpy(), strpbrk(),
strrchr(), strspn(), strstr(), strtod(), strtof(), strtoimax(),
strtok_r(), strtol(), strtold(), strtoll(), strtoul(), strtoull(),
strtoumax(), strxfrm(), sysconf(), time(), tolower(), toupper(),
tzname, tzset(), uname(), va_arg(), va_copy(), va_end(), va_start(),
vsnprintf(), vsprintf(), vsscanf()

The C++ standard library, especially in later versions, has not been analyzed for appropriate restrictions to ensure one worker does not damage the environment for other workers in the same process/container.

Using heap allocation functions (e.g. malloc, calloc, realloc) requires that the worker release any allocated memory in its release method when the allocations persist across methods.

RCC Local Services AEP as a Small Subset of POSIX and ISO-C.

This section explains the rationale for the RCC AEP and its connection to POSIX standards. The POSIX Minimal Realtime System Profile (PSE51) from the IEEE Std 1003.13™‑2003 standard is used as the superset of functionality that is reduced (with subtractions) to the RCC local services available functions. It can be found at https://standards.ieee.org/findstds/standard/1003.13-2003.html.

This subset is defined to require setting the _POSIX_AEP_RT_MINIMAL_C_SOURCE feature test macro to the value 200312L, before including any standard header files. This is not necessary in RCC workers. The PSE51 profile defines POSIX.1 units of functionality in table 6-1 of the IEEE Std 1003.13™‑2003 document. The RCC Local Services AEP removes these units of functionality from that table:

  • POSIX_DEVICE_IO

  • POSIX_FILE_LOCKING

  • POSIX_SIGNALS

  • XSI_THREAD_MUTEX_EXT

  • XSI_THREADS_EXT

  • POSIX_THREADS_BASE

The retained units of functionality, and their defined symbols and functions are:

POSIX_C_LANG_JUMP: longjmp(), setjmp();

POSIX_C_LANG_SUPPORT: abs(), asctime_r(), atof(), atoi(), atol(),
 atoll(), bsearch(), calloc(), ctime_r(), difftime(), div(),
 feclearexcept(), fegetenv(), fegetexceptflag(), fegetround(),
 feholdexcept(), feraiseexcept(), fesetenv(), fesetexceptflag(),
 fesetround(), fetestexcept(), feupdateenv(), free(), gmtime_r(),
 imaxabs(), imaxdiv(), isalnum(), isalpha(), isblank(), iscntrl(),
 isdigit(), isgraph(), islower(), isprint(), ispunct(), isspace(),
 isupper(), isxdigit(), labs(), ldiv(), llabs(), lldiv(),
 localeconv(), localtime_r(), malloc(), memchr(), memcmp(), memcpy(),
 memmove(), memset(), mktime(), qsort(), rand(), rand_r(), realloc(),
 setlocale(), snprintf(), sprintf(), srand(), sscanf(), strcat(),
 strchr(), strcmp(), strcoll(), strcpy(), strcspn(), strerror(),
 strerror_r(), strftime(), strlen(), strncat(), strncmp(), strncpy(),
 strpbrk(), strrchr(), strspn(), strstr(), strtod(), strtof(),
 strtoimax(), strtok(), strtok_r(), strtol(), strtold(), strtoll(),
 strtoul(), strtoull(), strtoumax(), strxfrm(), time(), tolower(),
 toupper(), tzname, tzset(), va_arg(), va_copy(), va_end(),
 va_start(), vsnprintf(), vsprintf(), vsscanf();

POSIX_SINGLE_PROCESS: confstr(), environ, errno, getenv(),
sysconf(), uname();

The philosophy of the base RCC profile AEP subset is to allow functions that are simply libraries (rather than OS services), but remove services that could conflict with the lean container execution model in that profile. This basically leaves the typical ANSI-C (or ISO C99) runtime library (without I/O) – most DSPs have this available, even those environments without multithreading.