OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [powerpc/] [vec_malloc.c] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
<<vec_malloc>>, <<vec_realloc>>, <<vec_free>>---manage vector memory
4
 
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
17
 
18
ANSI_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]>);
23
 
24
 
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]>);
29
 
30
 
31
TRAD_SYNOPSIS
32
        #include <stdlib.h>
33
        char *vec_malloc(<[nbytes]>)
34
        size_t <[nbytes]>;
35
 
36
        char *vec_realloc(<[aptr]>, <[nbytes]>)
37
        char *<[aptr]>;
38
        size_t <[nbytes]>;
39
 
40
        void vec_free(<[aptr]>)
41
        char *<[aptr]>;
42
 
43
        char *_vec_malloc_r(<[reent]>,<[nbytes]>)
44
        char *<[reent]>;
45
        size_t <[nbytes]>;
46
 
47
        char *_vec_realloc_r(<[reent]>, <[aptr]>, <[nbytes]>)
48
        char *<[reent]>;
49
        char *<[aptr]>;
50
        size_t <[nbytes]>;
51
 
52
        void _vec_free_r(<[reent]>, <[aptr]>)
53
        char *<[reent]>;
54
        char *<[aptr]>;
55
 
56
DESCRIPTION
57
These functions manage a pool of system memory that is 16-byte aligned..
58
 
59
Use <<vec_malloc>> to request allocation of an object with at least
60
<[nbytes]> bytes of storage available and is 16-byte aligned.  If the space is
61
available, <<vec_malloc>> returns a pointer to a newly allocated block as its result.
62
 
63
If you already have a block of storage allocated by <<vec_malloc>>, but
64
you no longer need all the space allocated to it, you can make it
65
smaller by calling <<vec_realloc>> with both the object pointer and the
66
new desired size as arguments.  <<vec_realloc>> guarantees that the
67
contents of the smaller object match the beginning of the original object.
68
 
69
Similarly, if you need more space for an object, use <<vec_realloc>> to
70
request the larger size; again, <<vec_realloc>> guarantees that the
71
beginning of the new, larger object matches the contents of the
72
original object.
73
 
74
When you no longer need an object originally allocated by <<vec_malloc>>
75
or <<vec_realloc>> (or the related function <<vec_calloc>>), return it to the
76
memory storage pool by calling <<vec_free>> with the address of the object
77
as the argument.  You can also use <<vec_realloc>> for this purpose by
78
calling it with <<0>> as the <[nbytes]> argument.
79
 
80
The alternate functions <<_vec_malloc_r>>, <<_vec_realloc_r>>, <<_vec_free_r>>,
81
are reentrant versions.  The extra argument <[reent]> is a pointer to a reentrancy
82
structure.
83
 
84
If you have multiple threads of execution which may call any of these
85
routines, or if any of these routines may be called reentrantly, then
86
you must provide implementations of the <<__vec_malloc_lock>> and
87
<<__vec_malloc_unlock>> functions for your system.  See the documentation
88
for those functions.
89
 
90
These functions operate by calling the function <<_sbrk_r>> or
91
<<sbrk>>, which allocates space.  You may need to provide one of these
92
functions for your system.  <<_sbrk_r>> is called with a positive
93
value to allocate more space, and with a negative value to release
94
previously allocated space if it is no longer required.
95
@xref{Stubs}.
96
 
97
RETURNS
98
<<vec_malloc>> returns a pointer to the newly allocated space, if
99
successful; otherwise it returns <<NULL>>.  If your application needs
100
to generate empty objects, you may use <<vec_malloc(0)>> for this purpose.
101
 
102
<<vec_realloc>> returns a pointer to the new block of memory, or <<NULL>>
103
if a new block could not be allocated.  <<NULL>> is also the result
104
when you use `<<vec_realloc(<[aptr]>,0)>>' (which has the same effect as
105
`<<vec_free(<[aptr]>)>>').  You should always check the result of
106
<<vec_realloc>>; successful vec_reallocation is not guaranteed even when
107
you request a smaller object.
108
 
109
<<vec_free>> does not return a result.
110
 
111
PORTABILITY
112
<<vec_malloc>>, <<vec_realloc>>, and <<vec_free>> are all extensions
113
specified in the AltiVec Programming Interface Manual.
114
 
115
Supporting OS subroutines required: <<sbrk>>.  */
116
 
117
#include <_ansi.h>
118
#include <reent.h>
119
#include <stdlib.h>
120
#include <malloc.h>
121
 
122
#ifndef _REENT_ONLY
123
 
124
_PTR
125
_DEFUN (vec_malloc, (nbytes),
126
        size_t nbytes)          /* get a block */
127
{
128
  return _memalign_r (_REENT, 16, nbytes);
129
}
130
 
131
#endif
132
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.