Introduction to Library Replacement Routines

The µTasker code contains a few routines which are used instead of typical library calls. For example uMemcpy() is used instead of the standard memcpy() to copy a block of memory to another location.

This allows many projects to be linked without using any specific libraries being available (like stdlib). This makes the project independent of libraries and also allows some common routines to be optimised for a particular processor. An example of this is the use of (optional) DMA suppport in the uMemcpy() realisation.

Generally the interface to these routines is identical to the standard library routines. These calls can also be typically replaced by standard library equivalents if required. One notable exception in the µTasker demo project is the use of uStrcpy() which returns a pointer to the next memory address which would have been written after a string copy - this allows more efficient string concatonations without requiring other routines and string searches. Code which doesn't make use of this additional property is however fully compatible.

Also included in this section are the µTasker heap routines which can often be used in many embedded projects instead of malloc() since it allows very high heap memory efficiency by not using any heap free calls. Projects can also use standard malloc()/free() library code either instead of, or alongside these.

Individual routines (or all) can be globally replaced by their library equivalents if this is preferred by adding defines in the project's config.h file as follows. This example shows how uMemcpy() is selectively replaced by memcpy() in the entire project:

#include "types.h"                 // project specific type settings
#include "..\..\uTasker\driver.h"  // driver and general formatting routines
#define uMemcpy memcpy             // global redefinition of the memcpy() routine to be taken from stdlib


Note that the position for the define is important. It should follow the include for driver.h!
Generally however there is no need to replace any of these in typical embedded projects using the devices that the µTasker concentrates on.

This section includes more detailed descriptions of each of the routines which are considered as 'library replacement routines'. Some of the descriptions refer to hardware specific implementations where appropriate.