Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
66b10200
Commit
66b10200
authored
Feb 29, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace posix_memalign()
parent
cdf21929
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
5 deletions
+62
-5
compat/posix_memalign.c
compat/posix_memalign.c
+55
-0
configure.ac
configure.ac
+1
-1
include/vlc_common.h
include/vlc_common.h
+0
-3
include/vlc_fixups.h
include/vlc_fixups.h
+6
-1
No files found.
compat/posix_memalign.c
0 → 100644
View file @
66b10200
/*****************************************************************************
* posix_memalign.c: POSIX posix_memalign() replacement
*****************************************************************************
* Copyright © 2012 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <errno.h>
#ifndef WIN32
#include <malloc.h>
static
int
check_align
(
size_t
align
)
{
for
(
size_t
i
=
sizeof
(
void
*
);
i
!=
0
;
i
*=
2
)
if
(
align
==
i
)
return
0
;
return
EINVAL
;
}
int
posix_memalign
(
void
**
ptr
,
size_t
align
,
size_t
size
)
{
if
(
check_align
(
align
))
return
EINVAL
;
int
saved_errno
=
errno
;
void
*
p
=
memalign
(
align
,
size
);
if
(
p
==
NULL
)
{
errno
=
saved_errno
;
return
ENOMEM
;
}
*
ptr
=
p
;
return
0
;
}
#endif
configure.ac
View file @
66b10200
...
@@ -491,7 +491,7 @@ need_libc=false
...
@@ -491,7 +491,7 @@ need_libc=false
dnl Check for usual libc functions
dnl Check for usual libc functions
AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r if_nameindex if_nametoindex isatty lstat memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale])
AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r if_nameindex if_nametoindex isatty lstat memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale])
AC_REPLACE_FUNCS([atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r inet_pton lldiv localtime_r nrand48 poll rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
AC_REPLACE_FUNCS([atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r inet_pton lldiv localtime_r nrand48 poll
posix_memalign
rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
AC_CHECK_FUNCS(fdatasync,,
AC_CHECK_FUNCS(fdatasync,,
[AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
[AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
])
])
...
...
include/vlc_common.h
View file @
66b10200
...
@@ -904,9 +904,6 @@ static void vlc_free(void *ptr)
...
@@ -904,9 +904,6 @@ static void vlc_free(void *ptr)
if
(
ptr
)
if
(
ptr
)
free
((
char
*
)
ptr
-
((
char
*
)
ptr
)[
-
1
]);
free
((
char
*
)
ptr
-
((
char
*
)
ptr
)[
-
1
]);
}
}
#elif defined(__ANDROID__)
# define vlc_memalign(align, size) memalign(align, size)
# define vlc_free(base) free(base)
#else
#else
static
inline
void
*
vlc_memalign
(
size_t
align
,
size_t
size
)
static
inline
void
*
vlc_memalign
(
size_t
align
,
size_t
size
)
{
{
...
...
include/vlc_fixups.h
View file @
66b10200
...
@@ -48,7 +48,8 @@ typedef struct
...
@@ -48,7 +48,8 @@ typedef struct
# include <stdio.h>
/* FILE */
# include <stdio.h>
/* FILE */
#endif
#endif
#if !defined (HAVE_STRLCPY) || \
#if !defined (HAVE_POSIX_MEMALIGN) || \
!defined (HAVE_STRLCPY) || \
!defined (HAVE_STRNDUP) || \
!defined (HAVE_STRNDUP) || \
!defined (HAVE_STRNLEN)
!defined (HAVE_STRNLEN)
# include <stddef.h>
/* size_t */
# include <stddef.h>
/* size_t */
...
@@ -212,6 +213,10 @@ int setenv (const char *, const char *, int);
...
@@ -212,6 +213,10 @@ int setenv (const char *, const char *, int);
int
unsetenv
(
const
char
*
);
int
unsetenv
(
const
char
*
);
#endif
#endif
#ifndef HAVE_POSIX_MEMALIGN
int
posix_memalign
(
void
**
,
size_t
,
size_t
);
#endif
/* locale.h */
/* locale.h */
#ifndef HAVE_USELOCALE
#ifndef HAVE_USELOCALE
#define LC_NUMERIC_MASK 0
#define LC_NUMERIC_MASK 0
...
...
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