Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3d204385
Commit
3d204385
authored
Sep 13, 2001
by
Nick Kurshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
memalign autodetection
Originally committed as revision 115 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
544286b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
19 deletions
+65
-19
configure
configure
+60
-0
utils.c
libavcodec/utils.c
+5
-19
No files found.
configure
View file @
3d204385
#!/bin/sh
TMPC
=
"ffmpeg-conf-
${
RANDOM
}
-
$$
-
${
RANDOM
}
.c"
TMPO
=
"ffmpeg-conf-
${
RANDOM
}
-
$$
-
${
RANDOM
}
.o"
TMPS
=
"ffmpeg-conf-
${
RANDOM
}
-
$$
-
${
RANDOM
}
.S"
if
[
!
-z
"
$TMPDIR
"
]
;
then
TMPC
=
"
${
TMPDIR
}
/
${
TMPC
}
"
TMPCPP
=
"
${
TMPDIR
}
/
${
TMPCPP
}
"
TMPO
=
"
${
TMPDIR
}
/
${
TMPO
}
"
TMPS
=
"
${
TMPDIR
}
/
${
TMPS
}
"
elif
[
!
-z
"
$TEMPDIR
"
]
;
then
TMPC
=
"
${
TEMPDIR
}
/
${
TMPC
}
"
TMPCPP
=
"
${
TEMPDIR
}
/
${
TMPCPP
}
"
TMPO
=
"
${
TEMPDIR
}
/
${
TMPO
}
"
TMPS
=
"
${
TEMPDIR
}
/
${
TMPS
}
"
else
TMPC
=
"/tmp/
${
TMPC
}
"
TMPCPP
=
"/tmp/
${
TMPCPP
}
"
TMPO
=
"/tmp/
${
TMPO
}
"
TMPS
=
"/tmp/
${
TMPS
}
"
fi
# default parameters
prefix
=
"/usr/local"
cc
=
"gcc"
...
...
@@ -75,6 +96,31 @@ if [ "$win32" = "yes" ] ; then
grab
=
"no"
fi
# ---
# check availability of some header files
cat
>
$TMPC
<<
EOF
#include <malloc.h>
int main( void ) { return 0; }
EOF
_memalign
=
no
_malloc_h
=
no
if
$cc
-o
$TMPO
$TMPC
2> /dev/null
;
then
_malloc_h
=
yes
_memalign
=
yes
# check for memalign - atmos
cat
>
$TMPC
<<
EOF
#include <malloc.h>
int main ( void ) {
char *string = NULL;
string = memalign(64, sizeof(char));
return 0;
}
EOF
$cc
-o
$TMPO
$TMPC
2> /dev/null
||
_memalign
=
no
fi
echo
"Install prefix
$prefix
"
echo
"C compiler
$cc
"
echo
"CPU
$cpu
"
...
...
@@ -136,3 +182,17 @@ if [ "$win32" = "yes" ] ; then
echo
"#define CONFIG_WIN32 1"
>>
config.h
echo
"CONFIG_WIN32=yes"
>>
config.mak
fi
if
[
"
$_malloc_h
"
=
"yes"
]
;
then
echo
"#define HAVE_MALLOC_H 1"
>>
config.h
else
echo
"#undef HAVE_MALLOC_H"
>>
config.h
fi
if
[
"
$_memalign
"
=
"yes"
]
;
then
echo
"#define HAVE_MEMALIGN 1"
>>
config.h
else
echo
"#undef HAVE_MEMALIGN"
>>
config.h
fi
rm
-f
$TMPO
$TMPC
$TMPS
libavcodec/utils.c
View file @
3d204385
...
...
@@ -16,37 +16,23 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
/* __GLIBC__ and __GLIBC_MINOR__ are defined here */
#if __GLIBC__ >=2 && __GLIBC_MINOR__ >= 1
/* Fixme about glibc-2.0 */
#define HAVE_MEMALIGN 1
#include <malloc.h>
#endif
#include "common.h"
#include "dsputil.h"
#include "avcodec.h"
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
/* memory alloc */
void
*
av_mallocz
(
int
size
)
{
void
*
ptr
;
#if defined ( ARCH_X86 ) && defined ( HAVE_MEMALIGN )
/*
From glibc-2.1.x manuals:
-------------------------
The address of a block returned by `malloc' or `realloc' in the GNU
system is always a multiple of eight (or sixteen on 64-bit systems).
If you need a block whose address is a multiple of a higher power of
two than that, use `memalign' or `valloc'. These functions are
declared in `stdlib.h'.
With the GNU library, you can use `free' to free the blocks that
`memalign' and `valloc' return. That does not work in BSD,
however--BSD does not provide any way to free such blocks.
*/
ptr
=
memalign
(
64
,
size
);
/* Why 64?
Indeed, we should align it:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment