VxWorks Reference Manual : Libraries
cplusLib - basic run-time support for C++
cplusCallNewHandler( ) - call the allocation failure handler (C++)
cplusCtors( ) - call static constructors (C++)
cplusCtorsLink( ) - call all linked static constructors (C++)
cplusDemanglerSet( ) - change C++ demangling mode (C++)
cplusDtors( ) - call static destructors (C++)
cplusDtorsLink( ) - call all linked static destructors (C++)
cplusLibInit( ) - initialize the C++ library (C++)
cplusXtorSet( ) - change C++ static constructor calling strategy (C++)
operator delete( ) - default run-time support for memory deallocation (C++)
operator new( ) - default run-time support for operator new (C++)
operator new( ) - default run-time support for operator new (nothrow) (C++)
operator new( ) - run-time support for operator new with placement (C++)
set_new_handler( ) - set new_handler to user-defined function (C++)
set_terminate( ) - set terminate to user-defined function (C++)
This library provides run-time support and shell utilities that support the development of VxWorks applications in C++. The run-time support can be broken into three categories:
- Support for C++ new and delete operators.
- Support for initialization and cleanup of static objects.
Shell utilities are provided for:
- Resolving overloaded C++ function names.
- Hiding C++ name mangling, with support for terse or complete name demangling.
- Manual or automatic invocation of static constructors and destructors.
The usage of cplusLib is more fully described in the VxWorks Programmer's Guide: C++ Development.
cplusLib, VxWorks Programmer's Guide: C++ Development
cplusCallNewHandler( ) - call the allocation failure handler (C++)
extern void cplusCallNewHandler ()
This function provides a procedural-interface to the new-handler. It can be used by user-defined new operators to call the current new-handler. This function is specific to VxWorks and may not be available in other C++ environments.
N/A
cplusCtors( ) - call static constructors (C++)
extern "C" void cplusCtors ( const char * moduleName /* name of loaded module */ )
This function is used to call static constructors under the manual strategy (see cplusXtorSet( )). moduleName is the name of an object module that was "munched" before loading. If moduleName is 0, then all static constructors, in all modules loaded by the VxWorks module loader, are called.
The following example shows how to initialize the static objects in modules called "applx.out" and "apply.out".
-> cplusCtors "applx.out" value = 0 = 0x0 -> cplusCtors "apply.out" value = 0 = 0x0The following example shows how to initialize all the static objects that are currently loaded, with a single invocation of cplusCtors( ):
-> cplusCtors value = 0 = 0x0
N/A
cplusLib, cplusXtorSet( )
cplusCtorsLink( ) - call all linked static constructors (C++)
extern "C" void cplusCtorsLink ()
This function calls constructors for all of the static objects linked with a VxWorks bootable image. When creating bootable applications, this function should be called from usrRoot( ) to initialize all static objects. Correct operation depends on correctly munching the C++ modules that are linked with VxWorks.
N/A
cplusDemanglerSet( ) - change C++ demangling mode (C++)
extern "C" void cplusDemanglerSet ( int mode )
This command sets the C++ demangling mode to mode. The default mode is 2.
There are three demangling modes, complete, terse, and off. These modes are represented by numeric codes:
In complete mode, when C++ function names are printed, the class name (if any) is prefixed and the function's parameter type list is appended.
Mode Code off 0 terse 1 complete 2 In terse mode, only the function name is printed. The class name and parameter type list are omitted.
In off mode, the function name is not demangled.
The following example shows how one function name would be printed under each demangling mode:
Mode Printed symbol off _member__5classFPFl_PvPFPv_v terse _member complete foo::_member(void* (*)(long),void (*)(void*))
N/A
cplusDtors( ) - call static destructors (C++)
extern "C" void cplusDtors ( const char * moduleName )
This function is used to call static destructors under the manual strategy (see cplusXtorSet( )). moduleName is the name of an object module that was "munched" before loading. If moduleName is 0, then all static destructors, in all modules loaded by the VxWorks module loader, are called.
The following example shows how to destroy the static objects in modules called "applx.out" and "apply.out":
-> cplusDtors "applx.out" value = 0 = 0x0 -> cplusDtors "apply.out" value = 0 = 0x0The following example shows how to destroy all the static objects that are currently loaded, with a single invocation of cplusDtors( ):
-> cplusDtors value = 0 = 0x0
N/A
cplusLib, cplusXtorSet( )
cplusDtorsLink( ) - call all linked static destructors (C++)
extern "C" void cplusDtorsLink ()
This function calls destructors for all of the static objects linked with a VxWorks bootable image. When creating bootable applications, this function should be called during system shutdown to decommission all static objects. Correct operation depends on correctly munching the C++ modules that are linked with VxWorks.
N/A
cplusLibInit( ) - initialize the C++ library (C++)
extern "C" STATUS cplusLibInit (void)
This routine initializes the C++ library and forces all C++ run-time support to be linked with the bootable VxWorks image. If the configuration macro INCLUDE_CPLUS is defined, cplusLibInit( ) is called automatically from the root task, usrRoot( ), in usrConfig.c.
OK or ERROR.
cplusXtorSet( ) - change C++ static constructor calling strategy (C++)
extern "C" void cplusXtorSet ( int strategy )
This command sets the C++ static constructor calling strategy to strategy. The default strategy is 0.
There are two static constructor calling strategies: automatic and manual. These modes are represented by numeric codes:
Under the manual strategy, a module's static constructors and destructors are called by cplusCtors( ) and cplusDtors( ), which are themselves invoked manually.
Strategy Code manual 0 automatic 1 Under the automatic strategy, a module's static constructors are called as a side-effect of loading the module using the VxWorks module loader. A module's static destructors are called as a side-effect of unloading the module.
The manual strategy is applicable only to modules that are loaded by the VxWorks module loader. Static constructors and destructors contained by modules linked with the VxWorks image are called using cplusCtorsLink( ) and cplusDtorsLink( ).
N/A
operator delete( ) - default run-time support for memory deallocation (C++)
extern void operator delete ( void * pMem /* pointer to dynamically-allocated object */ )
This function provides the default implementation of operator delete. It returns the memory, previously allocated by operator new, to the VxWorks system memory partition.
N/A
operator new( ) - default run-time support for operator new (C++)
extern void * operator new ( size_t n /* size of object to allocate */ ) throw (std::bad_alloc)
This function provides the default implementation of operator new. It allocates memory from the system memory partition for the requested object. The value, when evaluated, is a pointer of the type pointer-to-T where T is the type of the new object.
If allocation fails a new-handler, if one is defined, is called. If the new-handler returns, presumably after attempting to recover from the memory allocation failure, allocation is retried. If there is no new-handler an exception of type "bad_alloc" is thrown.
Pointer to new object.
std::bad_alloc if allocation failed.
operator new( ) - default run-time support for operator new (nothrow) (C++)
extern void * operator new ( size_t n, /* size of object to allocate */ const nothrow_t & /* supply argument of "nothrow" here */ ) throw ()
This function provides the default implementation of operator new (nothrow). It allocates memory from the system memory partition for the requested object. The value, when evaluated, is a pointer of the type pointer-to-T where T is the type of the new object.
If allocation fails, a new-handler, if one is defined, is called. If the new-handler returns, presumably after attempting to recover from the memory allocation failure, allocation is retried. If the new_handler throws a bad_alloc exception, the exception is caught and 0 is returned. If allocation fails and there is no new_handler 0 is returned.
Pointer to new object or 0 if allocation fails.
new
operator new( ) - run-time support for operator new with placement (C++)
extern void * operator new ( size_t n, /* size of object to allocate (unused) */ void * pMem /* pointer to allocated memory */ )
This function provides the default implementation of the global new operator, with support for the placement syntax. New-with-placement is used to initialize objects for which memory has already been allocated. pMem points to the previously allocated memory. memory.
pMem
new
set_new_handler( ) - set new_handler to user-defined function (C++)
extern void (*set_new_handler (void(* pNewNewHandler)())) ()
This function is used to define the function that will be called when operator new cannot allocate memory.
The new_handler acts for all threads in the system; you cannot set a different handler for different tasks.
A pointer to the previous value of new_handler.
new
set_terminate( ) - set terminate to user-defined function (C++)
extern void (*set_terminate (void(* terminate_handler)())) ()
This function is used to define the terminate_handler which will be called when an uncaught exception is raised.
The terminate_handler acts for all threads in the system; you cannot set a different handler for different tasks.
The previous terminate_handler.
exception