Difference between revisions of "Syscalls/Platform Quirks"

From WikiPrizm
Jump to navigationJump to search
(Created page with "== Syscall Quirks == * realloc is not POSIX-compliant, namely, it appears to not preserve existing memory when asked to expand a previously-allocated chunk. It may also no...")
 
Line 1: Line 1:
 
== Syscall Quirks ==
 
== Syscall Quirks ==
 
* [[realloc]] is not POSIX-compliant, namely, it appears to not preserve existing memory when asked to expand a previously-allocated chunk. It may also not do an in-place resize.
 
* [[realloc]] is not POSIX-compliant, namely, it appears to not preserve existing memory when asked to expand a previously-allocated chunk. It may also not do an in-place resize.
 +
* {{BfileTimersWarning}}
  
 
== Platform Quirks ==
 
== Platform Quirks ==
 
* Your C programs should never explicitly exit(). Users should instead be able to leave your Add-In via the [MENU] key, like native Add-Ins.
 
* Your C programs should never explicitly exit(). Users should instead be able to leave your Add-In via the [MENU] key, like native Add-Ins.
 +
 +
{{HeapFunctionsNote}}

Revision as of 11:05, 31 July 2014

Syscall Quirks

  • realloc is not POSIX-compliant, namely, it appears to not preserve existing memory when asked to expand a previously-allocated chunk. It may also not do an in-place resize.
  • Using Bfile functions while user timers are installed can cause SYSTEM ERRORs and other undefined behavior, especially with functions that change data on the file system. Make sure to stop and uninstall all timers before using Bfile functions (and optionally restore them later). See Incompatibility between Bfile Syscalls and Timers for more information.

Platform Quirks

  • Your C programs should never explicitly exit(). Users should instead be able to leave your Add-In via the [MENU] key, like native Add-Ins.

The heap implementation on the Prizm appears to have some bugs; it also appears to not be able to optimize heap allocation so that fragmentation is avoided. See this forum thread for more information and discussion.

The stack can provide a bigger continuous RAM area than the heap (up to about 500 KiB, depending on static RAM requirements, versus about 128 KiB). This, plus the limitations described above, means that to get the most out of the memory available to add-ins, one has to use non-standard ("incorrect") practices such as preferably using the stack instead of the heap.