VxWorks Reference Manual : Libraries

cplusLib

NAME

cplusLib - basic run-time support for C++

ROUTINES

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++)

DESCRIPTION

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:

Shell utilities are provided for:

The usage of cplusLib is more fully described in the VxWorks Programmer's Guide: C++ Development.

SEE ALSO

cplusLib, VxWorks Programmer's Guide: C++ Development


Libraries : Routines

cplusCallNewHandler( )

NAME

cplusCallNewHandler( ) - call the allocation failure handler (C++)

SYNOPSIS


extern void cplusCallNewHandler ()

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

cplusLib


Libraries : Routines

cplusCtors( )

NAME

cplusCtors( ) - call static constructors (C++)

SYNOPSIS

extern "C" void cplusCtors
    (
    const char * moduleName /* name of loaded module */
    )

DESCRIPTION

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.

EXAMPLES

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 = 0x0
The following example shows how to initialize all the static objects that are currently loaded, with a single invocation of cplusCtors( ):

    -> cplusCtors
    value = 0 = 0x0

RETURNS

N/A

SEE ALSO

cplusLib, cplusXtorSet( )


Libraries : Routines

cplusCtorsLink( )

NAME

cplusCtorsLink( ) - call all linked static constructors (C++)

SYNOPSIS


extern "C" void cplusCtorsLink ()

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

cplusLib


Libraries : Routines

cplusDemanglerSet( )

NAME

cplusDemanglerSet( ) - change C++ demangling mode (C++)

SYNOPSIS

extern "C" void cplusDemanglerSet
    (
    int mode
    )

DESCRIPTION

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:

Mode Code

off 0
terse 1
complete 2
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.

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.

EXAMPLES

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*))

RETURNS

N/A

SEE ALSO

cplusLib


Libraries : Routines

cplusDtors( )

NAME

cplusDtors( ) - call static destructors (C++)

SYNOPSIS

extern "C" void cplusDtors
    (
    const char * moduleName
    )

DESCRIPTION

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.

EXAMPLES

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 = 0x0
The following example shows how to destroy all the static objects that are currently loaded, with a single invocation of cplusDtors( ):

    -> cplusDtors
    value = 0 = 0x0

RETURNS

N/A

SEE ALSO

cplusLib, cplusXtorSet( )


Libraries : Routines

cplusDtorsLink( )

NAME

cplusDtorsLink( ) - call all linked static destructors (C++)

SYNOPSIS


extern "C" void cplusDtorsLink ()

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

cplusLib


Libraries : Routines

cplusLibInit( )

NAME

cplusLibInit( ) - initialize the C++ library (C++)

SYNOPSIS


extern "C" STATUS cplusLibInit (void)

DESCRIPTION

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.

RETURNS

OK or ERROR.

SEE ALSO

cplusLib


Libraries : Routines

cplusXtorSet( )

NAME

cplusXtorSet( ) - change C++ static constructor calling strategy (C++)

SYNOPSIS

extern "C" void cplusXtorSet
    (
    int strategy
    )

DESCRIPTION

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:

Strategy Code

manual 0
automatic 1
Under the manual strategy, a module's static constructors and destructors are called by cplusCtors( ) and cplusDtors( ), which are themselves invoked manually.

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.

NOTE

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( ).

RETURNS

N/A

SEE ALSO

cplusLib


Libraries : Routines

operator delete( )

NAME

operator delete( ) - default run-time support for memory deallocation (C++)

SYNOPSIS

extern void operator delete
    (
    void * pMem /* pointer to dynamically-allocated object */
    )

DESCRIPTION

This function provides the default implementation of operator delete. It returns the memory, previously allocated by operator new, to the VxWorks system memory partition.

RETURNS

N/A

SEE ALSO

cplusLib


Libraries : Routines

operator new( )

NAME

operator new( ) - default run-time support for operator new (C++)

SYNOPSIS

extern void * operator new
    (
    size_t n /* size of object to allocate */
    ) throw (std::bad_alloc)

DESCRIPTION

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.

RETURNS

Pointer to new object.

THROWS

std::bad_alloc if allocation failed.

SEE ALSO

cplusLib


Libraries : Routines

operator new( )

NAME

operator new( ) - default run-time support for operator new (nothrow) (C++)

SYNOPSIS

extern void * operator new
    (
    size_t          n, /* size of object to allocate */
    const nothrow_t &  /* supply argument of "nothrow" here */
    ) throw ()

DESCRIPTION

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.

RETURNS

Pointer to new object or 0 if allocation fails.

INCLUDE FILES

new

SEE ALSO

cplusLib


Libraries : Routines

operator new( )

NAME

operator new( ) - run-time support for operator new with placement (C++)

SYNOPSIS

extern void * operator new
    (
    size_t n,   /* size of object to allocate (unused) */
    void * pMem /* pointer to allocated memory */
    )

DESCRIPTION

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.

RETURNS

pMem

INCLUDE FILES

new

SEE ALSO

cplusLib


Libraries : Routines

set_new_handler( )

NAME

set_new_handler( ) - set new_handler to user-defined function (C++)

SYNOPSIS


extern void (*set_new_handler (void(* pNewNewHandler)()))  ()
    

DESCRIPTION

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.

RETURNS

A pointer to the previous value of new_handler.

INCLUDE FILES

new

SEE ALSO

cplusLib


Libraries : Routines

set_terminate( )

NAME

set_terminate( ) - set terminate to user-defined function (C++)

SYNOPSIS


extern void (*set_terminate (void(* terminate_handler)()))  ()
    

DESCRIPTION

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.

RETURNS

The previous terminate_handler.

INCLUDE FILES

exception

SEE ALSO

cplusLib