Very optimized set of memory manipulation functions for the Sega Dreamcast.
libfastmem is a tiny library for KallistiOS
that provides set of functions dedicated to memory manipulation, that are very
optimized in terms of speed and/or memory. These functions can be used in
remplacement of standard functions provided by Newlib,
but keep in mind that all functions provided in that library are suffixed
with the _fast
prefix.
This library is intended to be used as a KallistiOS Port (kos-ports
) but it
can be used as a KallistiOS add-on as well.
You need to include <fastmem/fastmem.h>
in your project.
This library ship 3 functions:
memset_fast
memcpy_fast
memmove_fast
Set an area of memory.
void *memset_fast(void *s, int c, size_t n);
This function converts the argument c
into an unsigned char and fills the
first n
characters of the array pointed to by s
to the value.
Copy memory regions.
void *memcpy_fast(void *dst, const void *src, size_t n);
This function copies n
bytes from the memory region pointed to by src
to the
memory region pointed to by dst
. It is assumed that there is no overlap
between src
and dst
. If there is an overlap, then the results are undefined.
Copy memory area.
void *memmove_fast(void *dst, const void *src, size_t n);
This function copies n
bytes from memory area src
to memory area dst
.
The memory areas may overlap: copying takes place as though the bytes in src
are first copied into a temporary array that does not overlap src
or dst
,
and the bytes are then copied from the temporary array to dst
.
This library can be installed using 2 ways:
- Using the
libfastmem
KallistiOS Ports (inkos-ports
) - Cloning this repository directly in your
${KOS_BASE}/addons
directory. In that case you just have to enter this directory and build the library withmake
.
Copyright (C) 1999 Niibe Yutaka
Copyright (c) 2009 STMicroelectronics Ltd
Optimized using 64bit data transfer (via FPU) and the
movca.l
inst, by Giuseppe Cavallaro
Copyright (C) 1999 Niibe Yutaka
Copyright (c) 2002 STMicroelectronics Ltd
Modified from
memcpy.S
and micro-optimized for SH4, by Stuart Menefy
Copyright (c) 2009 STMicroelectronics Ltd
Optimized using prefetching and 64bit data transfer via FPU, by Giuseppe Cavallaro
Copyright (C) 1999 Niibe Yutaka
These functions were intended to be directly merged in KallistiOS patches but unfortunately, this couldn't be done due to licensing issue. These functions remain very interesting for Sega Dreamcast programming, that's why these were published in that library.