From 0d844014bfbcab4e48718b787c268d052f773197 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 19 Apr 2002 19:16:22 +0000 Subject: 2002-04-19 Jeff Johnston * configure.host: Add support for powerpc-eabialtivec*. * libc/include/malloc.h: Add include of . * libc/include/stdlib.h: Add include of . * libc/include/machine/malloc.h: New file. * libc/include/machine/stdlib.h: Ditto. * libc/include/machine/setjmp.h: Add support for powerpc altivec. * libc/machine/powerpc/Makefile.am: Add conditional objects and sources based on configuration. * libc/machine/powerpc/Makefile.in: Regenerated. * libc/machine/powerpc/configure: Ditto. * libc/machine/powerpc/configure.in: Add check for powerpc-eabialtivec* in which case add in additional source files. * libc/machine/powerpc/setjmp.S: Add altivec support. * libc/machine/powerpc/vec_calloc.c: New file. * libc/machine/powerpc/vec_free.c: Ditto. * libc/machine/powerpc/vec_malloc.c: Ditto. * libc/machine/powerpc/vec_mallocr.c: Ditto. * libc/machine/powerpc/vec_realloc.c: Ditto. * libc/machine/powerpc/machine/malloc.h: Ditto. * libc/machine/powerpc/machine/stdlib.h: Ditto. * libc/machine/powerpc/vfprintf.c: New file that is vfprintf.c with added altivec format specifiers. * libc/machine/powerpc/vfscanf.c: New file that is vfscanf.c with added altivec format specifiers. --- newlib/libc/machine/powerpc/vec_malloc.c | 132 +++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 newlib/libc/machine/powerpc/vec_malloc.c (limited to 'newlib/libc/machine/powerpc/vec_malloc.c') diff --git a/newlib/libc/machine/powerpc/vec_malloc.c b/newlib/libc/machine/powerpc/vec_malloc.c new file mode 100644 index 000000000..6bcad59b6 --- /dev/null +++ b/newlib/libc/machine/powerpc/vec_malloc.c @@ -0,0 +1,132 @@ +/* +FUNCTION +<>, <>, <>---manage vector memory + +INDEX + vec_malloc +INDEX + vec_realloc +INDEX + vec_free +INDEX + _vec_malloc_r +INDEX + _vec_realloc_r +INDEX + _vec_free_r + +ANSI_SYNOPSIS + #include + void *vec_malloc(size_t <[nbytes]>); + void *vec_realloc(void *<[aptr]>, size_t <[nbytes]>); + void vec_free(void *<[aptr]>); + + + void *_vec_malloc_r(void *<[reent]>, size_t <[nbytes]>); + void *_vec_realloc_r(void *<[reent]>, + void *<[aptr]>, size_t <[nbytes]>); + void _vec_free_r(void *<[reent]>, void *<[aptr]>); + + +TRAD_SYNOPSIS + #include + char *vec_malloc(<[nbytes]>) + size_t <[nbytes]>; + + char *vec_realloc(<[aptr]>, <[nbytes]>) + char *<[aptr]>; + size_t <[nbytes]>; + + void vec_free(<[aptr]>) + char *<[aptr]>; + + char *_vec_malloc_r(<[reent]>,<[nbytes]>) + char *<[reent]>; + size_t <[nbytes]>; + + char *_vec_realloc_r(<[reent]>, <[aptr]>, <[nbytes]>) + char *<[reent]>; + char *<[aptr]>; + size_t <[nbytes]>; + + void _vec_free_r(<[reent]>, <[aptr]>) + char *<[reent]>; + char *<[aptr]>; + +DESCRIPTION +These functions manage a pool of system memory that is 16-byte aligned.. + +Use <> to request allocation of an object with at least +<[nbytes]> bytes of storage available and is 16-byte aligned. If the space is +available, <> returns a pointer to a newly allocated block as its result. + +If you already have a block of storage allocated by <>, but +you no longer need all the space allocated to it, you can make it +smaller by calling <> with both the object pointer and the +new desired size as arguments. <> guarantees that the +contents of the smaller object match the beginning of the original object. + +Similarly, if you need more space for an object, use <> to +request the larger size; again, <> guarantees that the +beginning of the new, larger object matches the contents of the +original object. + +When you no longer need an object originally allocated by <> +or <> (or the related function <>), return it to the +memory storage pool by calling <> with the address of the object +as the argument. You can also use <> for this purpose by +calling it with <<0>> as the <[nbytes]> argument. + +The alternate functions <<_vec_malloc_r>>, <<_vec_realloc_r>>, <<_vec_free_r>>, +are reentrant versions. The extra argument <[reent]> is a pointer to a reentrancy +structure. + +If you have multiple threads of execution which may call any of these +routines, or if any of these routines may be called reentrantly, then +you must provide implementations of the <<__vec_malloc_lock>> and +<<__vec_malloc_unlock>> functions for your system. See the documentation +for those functions. + +These functions operate by calling the function <<_sbrk_r>> or +<>, which allocates space. You may need to provide one of these +functions for your system. <<_sbrk_r>> is called with a positive +value to allocate more space, and with a negative value to release +previously allocated space if it is no longer required. +@xref{Stubs}. + +RETURNS +<> returns a pointer to the newly allocated space, if +successful; otherwise it returns <>. If your application needs +to generate empty objects, you may use <> for this purpose. + +<> returns a pointer to the new block of memory, or <> +if a new block could not be allocated. <> is also the result +when you use `<,0)>>' (which has the same effect as +`<)>>'). You should always check the result of +<>; successful vec_reallocation is not guaranteed even when +you request a smaller object. + +<> does not return a result. + +PORTABILITY +<>, <>, and <> are all extensions +specified in the AltiVec Programming Interface Manual. + +Supporting OS subroutines required: <>. */ + +#include <_ansi.h> +#include +#include +#include + +#ifndef _REENT_ONLY + +_PTR +_DEFUN (vec_malloc, (nbytes), + size_t nbytes) /* get a block */ +{ + return _memalign_r (_REENT, 16, nbytes); +} + +#endif + -- cgit v1.2.3