Mercurial > libavcodec.hg
comparison utils.c @ 80:f2d17413c4e3 libavcodec
memalign autodetection
| author | nickols_k |
|---|---|
| date | Thu, 13 Sep 2001 07:16:59 +0000 |
| parents | 9e8ae8222ddc |
| children | db55e2d3b380 |
comparison
equal
deleted
inserted
replaced
| 79:82e579c37bc3 | 80:f2d17413c4e3 |
|---|---|
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU General Public License | 15 * You should have received a copy of the GNU General Public License |
| 16 * along with this program; if not, write to the Free Software | 16 * along with this program; if not, write to the Free Software |
| 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 */ | 18 */ |
| 19 #include <stdlib.h> | |
| 20 #include <stdio.h> | 19 #include <stdio.h> |
| 21 #include <string.h> | 20 #include <string.h> |
| 22 #include <errno.h> | 21 #include <errno.h> |
| 23 #include <limits.h> /* __GLIBC__ and __GLIBC_MINOR__ are defined here */ | |
| 24 #if __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1 /* Fixme about glibc-2.0 */ | |
| 25 #define HAVE_MEMALIGN 1 | |
| 26 #include <malloc.h> | |
| 27 #endif | |
| 28 #include "common.h" | 22 #include "common.h" |
| 29 #include "dsputil.h" | 23 #include "dsputil.h" |
| 30 #include "avcodec.h" | 24 #include "avcodec.h" |
| 25 #ifdef HAVE_MALLOC_H | |
| 26 #include <malloc.h> | |
| 27 #else | |
| 28 #include <stdlib.h> | |
| 29 #endif | |
| 31 | 30 |
| 32 /* memory alloc */ | 31 /* memory alloc */ |
| 33 void *av_mallocz(int size) | 32 void *av_mallocz(int size) |
| 34 { | 33 { |
| 35 void *ptr; | 34 void *ptr; |
| 36 #if defined ( ARCH_X86 ) && defined ( HAVE_MEMALIGN ) | 35 #if defined ( ARCH_X86 ) && defined ( HAVE_MEMALIGN ) |
| 37 /* | |
| 38 From glibc-2.1.x manuals: | |
| 39 ------------------------- | |
| 40 The address of a block returned by `malloc' or `realloc' in the GNU | |
| 41 system is always a multiple of eight (or sixteen on 64-bit systems). | |
| 42 If you need a block whose address is a multiple of a higher power of | |
| 43 two than that, use `memalign' or `valloc'. These functions are | |
| 44 declared in `stdlib.h'. | |
| 45 | |
| 46 With the GNU library, you can use `free' to free the blocks that | |
| 47 `memalign' and `valloc' return. That does not work in BSD, | |
| 48 however--BSD does not provide any way to free such blocks. | |
| 49 */ | |
| 50 ptr = memalign(64,size); | 36 ptr = memalign(64,size); |
| 51 /* Why 64? | 37 /* Why 64? |
| 52 Indeed, we should align it: | 38 Indeed, we should align it: |
| 53 on 4 for 386 | 39 on 4 for 386 |
| 54 on 16 for 486 | 40 on 16 for 486 |
