BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions | Variables
system.h File Reference

Prototypes for BSP430 system enhancements to newlib. More...

#include <bsp430/core.h>
#include <unistd.h>

Go to the source code of this file.

Functions

void * sbrk (intptr_t increment)
 
void * _bsp430_sbrk_fatal (ptrdiff_t increment)
 
void * _bsp430_sbrk_dynstack (ptrdiff_t increment)
 
void * _bsp430_sbrk_error (void *brk, ptrdiff_t current, ptrdiff_t increment)
 

Variables

unsigned long ulBSP430newlibNoSysInvoked
 

Detailed Description

Prototypes for BSP430 system enhancements to newlib.

Homepage
http://github.com/pabigot/bsp430

Function Documentation

void* _bsp430_sbrk_dynstack ( ptrdiff_t  increment)

An sbrk() implementation that allows heap (growing up) and stack (growing down) to share a region of memory.

An error is indicated if the new break point would encroach into the current stack space.

void* _bsp430_sbrk_error ( void *  brk,
ptrdiff_t  current,
ptrdiff_t  increment 
)

This function is invoked whenever _sbrk() runs out of memory.

libbsp430.a provides a weak definition is that disables interrupts and enters an infinite loop, allowing diagnosis through a debugger. The application may provide an alternative implementation that is more diagnostic or that returns the responsibility of handling out-of-memory to the application (i.e. requires the application to check allocation return values).

Parameters
brkthe current program break
currenttotal number of bytes allocated by previous successful invocations of _sbrk() (i.e., allocated bytes preceding brk)
incrementthe number of bytes in the request that _sbrk() cannot satisfy
Returns
The weak implementation does not return. If superseded, an implementation that does return must set errno to ENOMEM and return (void*)-1.
void* _bsp430_sbrk_fatal ( ptrdiff_t  increment)

An sbrk() implementation that rejects any attempt to allocate memory dynamically. It immediately invokes _bsp430_brk_error().

void* sbrk ( intptr_t  increment)

The system function used to allocate memory for use by libc heap memory management.

Normally this is an alias for either _bsp430_sbrk_dynstack() (the default) or _bsp430_sbrk_fatal(). An alternative may be specified by defining a function with the same API and adding a alias definition such as:

void * sbrk (ptrdiff_t increment) __attribute__((__alias__("_my_sbrk")));
Note
All BSP430 policies invoke _bsp430_sbrk_error() if allocation fails, allowing an application to control response to the failure.
Parameters
incrementthe number of bytes of additional memory that libc needs in order to perform additional allocations.
Returns
a pointer to the new end-of-memory, or (void*)-1 if no allocation can be performed.

Variable Documentation

unsigned long ulBSP430newlibNoSysInvoked

Variable used by default nosys implementations to record which system calls are invoked.

Stub routines in newlib/nosys set bits in this variable when they are invoked. A non-zero value indicates that some stub system interface was invoked in the course of execution; further analysis can identify the functions and determine why they were invoked and whether supplying a non-stub implementation is worthwhile.

This is a diagnostic aid that may not be worth maintaining.