Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libc / machine / powerpc / vec_malloc.c
blobb62fe0762c4d0c11e868040e22fbec348c342522
1 /*
2 FUNCTION
3 <<vec_malloc>>, <<vec_realloc>>, <<vec_free>>---manage vector memory
5 INDEX
6 vec_malloc
7 INDEX
8 vec_realloc
9 INDEX
10 vec_free
11 INDEX
12 _vec_malloc_r
13 INDEX
14 _vec_realloc_r
15 INDEX
16 _vec_free_r
18 SYNOPSIS
19 #include <stdlib.h>
20 void *vec_malloc(size_t <[nbytes]>);
21 void *vec_realloc(void *<[aptr]>, size_t <[nbytes]>);
22 void vec_free(void *<[aptr]>);
25 void *_vec_malloc_r(void *<[reent]>, size_t <[nbytes]>);
26 void *_vec_realloc_r(void *<[reent]>,
27 void *<[aptr]>, size_t <[nbytes]>);
28 void _vec_free_r(void *<[reent]>, void *<[aptr]>);
30 DESCRIPTION
31 These functions manage a pool of system memory that is 16-byte aligned..
33 Use <<vec_malloc>> to request allocation of an object with at least
34 <[nbytes]> bytes of storage available and is 16-byte aligned. If the space is
35 available, <<vec_malloc>> returns a pointer to a newly allocated block as its result.
37 If you already have a block of storage allocated by <<vec_malloc>>, but
38 you no longer need all the space allocated to it, you can make it
39 smaller by calling <<vec_realloc>> with both the object pointer and the
40 new desired size as arguments. <<vec_realloc>> guarantees that the
41 contents of the smaller object match the beginning of the original object.
43 Similarly, if you need more space for an object, use <<vec_realloc>> to
44 request the larger size; again, <<vec_realloc>> guarantees that the
45 beginning of the new, larger object matches the contents of the
46 original object.
48 When you no longer need an object originally allocated by <<vec_malloc>>
49 or <<vec_realloc>> (or the related function <<vec_calloc>>), return it to the
50 memory storage pool by calling <<vec_free>> with the address of the object
51 as the argument. You can also use <<vec_realloc>> for this purpose by
52 calling it with <<0>> as the <[nbytes]> argument.
54 The alternate functions <<_vec_malloc_r>>, <<_vec_realloc_r>>, <<_vec_free_r>>,
55 are reentrant versions. The extra argument <[reent]> is a pointer to a reentrancy
56 structure.
58 If you have multiple threads of execution which may call any of these
59 routines, or if any of these routines may be called reentrantly, then
60 you must provide implementations of the <<__vec_malloc_lock>> and
61 <<__vec_malloc_unlock>> functions for your system. See the documentation
62 for those functions.
64 These functions operate by calling the function <<_sbrk_r>> or
65 <<sbrk>>, which allocates space. You may need to provide one of these
66 functions for your system. <<_sbrk_r>> is called with a positive
67 value to allocate more space, and with a negative value to release
68 previously allocated space if it is no longer required.
69 @xref{Stubs}.
71 RETURNS
72 <<vec_malloc>> returns a pointer to the newly allocated space, if
73 successful; otherwise it returns <<NULL>>. If your application needs
74 to generate empty objects, you may use <<vec_malloc(0)>> for this purpose.
76 <<vec_realloc>> returns a pointer to the new block of memory, or <<NULL>>
77 if a new block could not be allocated. <<NULL>> is also the result
78 when you use `<<vec_realloc(<[aptr]>,0)>>' (which has the same effect as
79 `<<vec_free(<[aptr]>)>>'). You should always check the result of
80 <<vec_realloc>>; successful vec_reallocation is not guaranteed even when
81 you request a smaller object.
83 <<vec_free>> does not return a result.
85 PORTABILITY
86 <<vec_malloc>>, <<vec_realloc>>, and <<vec_free>> are all extensions
87 specified in the AltiVec Programming Interface Manual.
89 Supporting OS subroutines required: <<sbrk>>. */
91 #include <_ansi.h>
92 #include <reent.h>
93 #include <stdlib.h>
94 #include <malloc.h>
96 #ifndef _REENT_ONLY
98 void *
99 vec_malloc (size_t nbytes) /* get a block */
101 return _memalign_r (_REENT, 16, nbytes);
104 #endif