<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>On Tue, Jun 20, 2017, at 11:53, <a href="mailto:remi@remlab.net">remi@remlab.net</a> wrote:<br></div>
<blockquote type="cite"><div>Repeating myself but this patch does not change the fallback logic, so it can't break anything.<br></div>
</blockquote><div><br></div>
<div>You're right, this patch doesn't change the fallback logic.<br></div>
<div><br></div>
<div>The ones that break windows are:<br></div>
<div> "Win32: fix mismatched alloc/free"<br></div>
<div> "Remove vlc_free()"<br></div>
<div> "picture_pool: fix potentially invalid allocation size"<br></div>
<div><br></div>
<div>Can we add back vlc_memalign and vlc_free ?<br></div>
<div><br></div>
<blockquote type="cite"><div> <br></div>
<div> And to paraphrase other devs "I don't care" about non-ISO toolchains.<br></div>
<div><br></div>
<div defang_data-gmailquote="yes"><div>Le 20 juin 2017 12:40:41 GMT+03:00, Steve Lhomme <robux4@gmail.com> a écrit :<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:0pt;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;"><pre><div>On Tue, Jun 20, 2017 at 11:35 AM, Steve Lhomme <robux4@gmail.com> wrote:<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(114, 159, 207);padding-left:1ex;"><div> On Tue, Jun 20, 2017 at 11:28 AM, <remi@remlab.net> wrote:<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(173, 127, 168);padding-left:1ex;"><div> The goal is to use aligned_alloc() instead of posix_memalign() since the<br></div>
<div> earlier is required by ISO C and C++ (and slightly simpler to use).<br></div>
<div><br></div>
<div> This patch only changes the behaviour on supported non-POSIX toolchains by<br></div>
<div> removing the need for POSIX emulation code. If the toolchain is broken, then<br></div>
<div> the fallback logic is unchanged: posix_memalign(), else memalign() else<br></div>
<div> screw-you.<br></div>
</blockquote><div><br></div>
<div> There is no posix_memalign() or memalign() on Windows. So right now<br></div>
<div> VLC and libvlc cannot be used at all.<br></div>
<div><br></div>
<div> Proper support requires using __mingw_aligned_malloc() or<br></div>
<div> _aligned_malloc(). But that means using __mingw_aligned_free() and<br></div>
<div> _aligned_free() as well.<br></div>
</blockquote><div><br></div>
<div>For the record, calling free() instead of these aligned free functions<br></div>
<div>results in a crash.<br></div>
<div><br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(114, 159, 207);padding-left:1ex;"><div> Next time you may break the core, please submit patches for review first.<br></div>
<div><br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(173, 127, 168);padding-left:1ex;"><div> Le 20 juin 2017 12:07:38 GMT+03:00, Steve Lhomme <robux4@gmail.com> a écrit<br></div>
<div> :<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(138, 226, 52);padding-left:1ex;"><div><br></div>
<div> On Sat, Jun 17, 2017 at 2:35 PM, Rémi Denis-Courmont <git@videolan.org><br></div>
<div> wrote:<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(252, 175, 62);padding-left:1ex;"><div><br></div>
<div> vlc | branch: master | Rémi Denis-Courmont <remi@remlab.net> | Sat Jun<br></div>
<div> 17 15:27:16 2017 +0300| [34cd965645cb0246f3d74515bbd5e55367f7d884] |<br></div>
<div> committer: Rémi Denis-Courmont<br></div>
<div><br></div>
<div> compat: replace aligned_alloc() rather than posix_memalign()<br></div>
<div><br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(233, 185, 110);padding-left:1ex;"><div><br></div>
<div> <a href="http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=34cd965645cb0246f3d74515bbd5e55367f7d884">http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=34cd965645cb0246f3d74515bbd5e55367f7d884</a><br></div>
</blockquote><div><br></div>
<div> ---<br></div>
<div><br></div>
<div> compat/{posix_memalign.c => aligned_alloc.c} | 62<br></div>
<div> ++++++++++++++--------------<br></div>
<div> <a href="http://configure.ac">configure.ac</a> | 4 +-<br></div>
<div> include/vlc_common.h | 8 +---<br></div>
<div> include/vlc_fixups.h | 6 +--<br></div>
<div> 4 files changed, 36 insertions(+), 44 deletions(-)<br></div>
<div><br></div>
<div> diff --git a/compat/posix_memalign.c b/compat/aligned_alloc.c<br></div>
<div> similarity index 55%<br></div>
<div> rename from compat/posix_memalign.c<br></div>
<div> rename to compat/aligned_alloc.c<br></div>
<div> index 3c6ffdfe28..9a61c0010f 100644<br></div>
<div> --- a/compat/posix_memalign.c<br></div>
<div> +++ b/compat/aligned_alloc.c<br></div>
<div> @@ -1,7 +1,7 @@<br></div>
<div><br></div>
<div> /*****************************************************************************<br></div>
<div> - * posix_memalign.c: POSIX posix_memalign() replacement<br></div>
<div> + * aligned_alloc.c: C11 aligned_alloc() replacement<br></div>
<div><br></div>
<div> *****************************************************************************<br></div>
<div> - * Copyright © 2012 Rémi Denis-Courmont<br></div>
<div> + * Copyright © 2012, 2017 Rémi Denis-Courmont<br></div>
<div> *<br></div>
<div> * This program is free software; you can redistribute it and/or modify<br></div>
<div> it<br></div>
<div> * under the terms of the GNU Lesser General Public License as<br></div>
<div> published by<br></div>
<div> @@ -22,46 +22,44 @@<br></div>
<div> # include <config.h><br></div>
<div> #endif<br></div>
<div><br></div>
<div> +#include <assert.h><br></div>
<div> #include <stdlib.h><br></div>
<div> #include <errno.h><br></div>
<div> +#if !defined (HAVE_POSIX_MEMALIGN) && !defined (_WIN32) && !defined<br></div>
<div> (__APPLE__)<br></div>
<div> +# include <malloc.h><br></div>
<div> +#endif<br></div>
<div><br></div>
<div> -static int check_align (size_t align)<br></div>
<div> +void *aligned_alloc(size_t align, size_t size)<br></div>
<div> {<br></div>
<div> - for (size_t i = sizeof (void *); i != 0; i *= 2)<br></div>
<div> - if (align == i)<br></div>
<div> - return 0;<br></div>
<div> - return EINVAL;<br></div>
<div> -}<br></div>
<div> -<br></div>
<div> -#if !defined (_WIN32) && !defined (__APPLE__)<br></div>
<div> -#include <malloc.h><br></div>
<div> + /* align must be a power of 2 */<br></div>
<div> + /* size must be a multiple of align */<br></div>
<div> + if ((align & (align - 1)) || (size & (align - 1)))<br></div>
<div> + {<br></div>
<div> + errno = EINVAL;<br></div>
<div> + return NULL;<br></div>
<div> + }<br></div>
<div><br></div>
<div> -int posix_memalign (void **ptr, size_t align, size_t size)<br></div>
<div> -{<br></div>
<div> - if (check_align (align))<br></div>
<div> - return EINVAL;<br></div>
<div> +#ifdef HAVE_POSIX_MEMALIGN<br></div>
<div> + if (align < sizeof (void *)) /* POSIX does not allow small<br></div>
<div> alignment */<br></div>
<div> + align = sizeof (void *);<br></div>
<div><br></div>
<div> - int saved_errno = errno;<br></div>
<div> - void *p = memalign (align, size);<br></div>
<div> - if (p == NULL)<br></div>
<div> + void *ptr;<br></div>
<div> + int err = posix_memalign(&ptr, align, size);<br></div>
<div> + if (err)<br></div>
<div> {<br></div>
<div> - errno = saved_errno;<br></div>
<div> - return ENOMEM;<br></div>
<div> + errno = err;<br></div>
<div> + ptr = NULL;<br></div>
<div> }<br></div>
<div> + return ptr;<br></div>
<div><br></div>
<div> - *ptr = p;<br></div>
<div> - return 0;<br></div>
<div> -}<br></div>
<div> +#elif !defined (_WIN32) && !defined (__APPLE__)<br></div>
<div><br></div>
<div> -#else<br></div>
<div> -<br></div>
<div> -int posix_memalign (void **ptr, size_t align, size_t size)<br></div>
<div> -{<br></div>
<div> - if (check_align (align))<br></div>
<div> - return EINVAL;<br></div>
<div> + return memalign(align, size);<br></div>
</blockquote><div><br></div>
<div><br></div>
<div> Is the goal that this code is never called for Windows and Apple OSes<br></div>
<div> ? Because it worked and this function always return NULL.<br></div>
<div><br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(252, 175, 62);padding-left:1ex;"><div> - *ptr = NULL;<br></div>
<div> - return size ? ENOMEM : 0;<br></div>
<div> -}<br></div>
<div> +#else<br></div>
<div><br></div>
<div> + if (size > 0)<br></div>
<div> + errno = ENOMEM;<br></div>
<div> + return NULL;<br></div>
<div> #endif<br></div>
<div> +}<br></div>
<div> diff --git a/<a href="http://configure.ac">configure.ac</a> b/<a href="http://configure.ac">configure.ac</a><br></div>
<div> index b1883a18b7..67fc7deb1a 100644<br></div>
<div> --- a/<a href="http://configure.ac">configure.ac</a><br></div>
<div> +++ b/<a href="http://configure.ac">configure.ac</a><br></div>
<div> @@ -597,8 +597,8 @@ dnl Check for system libs needed<br></div>
<div> need_libc=false<br></div>
<div><br></div>
<div> dnl Check for usual libc functions<br></div>
<div> -AC_CHECK_FUNCS([daemon fcntl flock fstatvfs fork getenv getpwuid_r<br></div>
<div> isatty lstat memalign mkostemp mmap open_memstream openat pread<br></div>
<div> posix_fadvise posix_madvise setlocale stricmp strnicmp strptime tdestroy<br></div>
<div> uselocale])<br></div>
<div> -AC_REPLACE_FUNCS([atof atoll dirfd fdopendir ffsll flockfile fsync<br></div>
<div> getdelim getpid lldiv memrchr nrand48 poll posix_memalign recvmsg rewind<br></div>
<div> sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr<br></div>
<div> strsep strtof strtok_r strtoll swab tfind timegm timespec_get strverscmp<br></div>
<div> pathconf])<br></div>
<div> +AC_CHECK_FUNCS([daemon fcntl flock fstatvfs fork getenv getpwuid_r<br></div>
<div> isatty lstat memalign mkostemp mmap open_memstream openat pread<br></div>
<div> posix_fadvise posix_madvise posix_memalign setlocale stricmp strnicmp<br></div>
<div> strptime tdestroy uselocale])<br></div>
<div> +AC_REPLACE_FUNCS([aligned_alloc atof atoll dirfd fdopendir ffsll<br></div>
<div> flockfile fsync getdelim getpid lldiv memrchr nrand48 poll recvmsg rewind<br></div>
<div> sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr<br></div>
<div> strsep strtof strtok_r strtoll swab tfind timegm timespec_get strverscmp<br></div>
<div> pathconf])<br></div>
<div> AC_REPLACE_FUNCS([gettimeofday])<br></div>
<div> AC_CHECK_FUNC(fdatasync,,<br></div>
<div> [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if<br></div>
<div> missing.])<br></div>
<div> diff --git a/include/vlc_common.h b/include/vlc_common.h<br></div>
<div> index e1cf885379..0bfb1b9b04 100644<br></div>
<div> --- a/include/vlc_common.h<br></div>
<div> +++ b/include/vlc_common.h<br></div>
<div> @@ -854,13 +854,7 @@ VLC_API bool vlc_ureduce( unsigned *, unsigned *,<br></div>
<div> uint64_t, uint64_t, uint64_t )<br></div>
<div> # define vlc_memalign(align, size) (_aligned_malloc(size, align))<br></div>
<div> # define vlc_free(base) (_aligned_free(base))<br></div>
<div> #else<br></div>
<div> -static inline void *vlc_memalign(size_t align, size_t size)<br></div>
<div> -{<br></div>
<div> - void *base;<br></div>
<div> - if (unlikely(posix_memalign(&base, align, size)))<br></div>
<div> - base = NULL;<br></div>
<div> - return base;<br></div>
<div> -}<br></div>
<div> +# define vlc_memalign(align, size) aligned_alloc(align, size)<br></div>
<div> # define vlc_free(base) free(base)<br></div>
<div> #endif<br></div>
<div><br></div>
<div> diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h<br></div>
<div> index 8bfb76888f..44b8426f2c 100644<br></div>
<div> --- a/include/vlc_fixups.h<br></div>
<div> +++ b/include/vlc_fixups.h<br></div>
<div> @@ -88,7 +88,7 @@ typedef struct<br></div>
<div> # include <stdio.h> /* FILE */<br></div>
<div> #endif<br></div>
<div><br></div>
<div> -#if !defined (HAVE_POSIX_MEMALIGN) || \<br></div>
<div> +#if !defined (HAVE_ALIGNED_ALLOC) || \<br></div>
<div> !defined (HAVE_MEMRCHR) || \<br></div>
<div> !defined (HAVE_STRLCPY) || \<br></div>
<div> !defined (HAVE_STRNDUP) || \<br></div>
<div> @@ -302,8 +302,8 @@ int setenv (const char *, const char *, int);<br></div>
<div> int unsetenv (const char *);<br></div>
<div> #endif<br></div>
<div><br></div>
<div> -#ifndef HAVE_POSIX_MEMALIGN<br></div>
<div> -int posix_memalign (void **, size_t, size_t);<br></div>
<div> +#ifndef HAVE_ALIGNED_ALLOC<br></div>
<div> +void *aligned_alloc(size_t, size_t);<br></div>
<div> #endif<br></div>
<div><br></div>
<div> #if defined(__native_client__) && defined(__cplusplus)<br></div>
<div><br></div>
<div><hr><br></div>
<div><br></div>
<div> vlc-commits mailing list<br></div>
<div> vlc-commits@videolan.org<br></div>
<div> <a href="https://mailman.videolan.org/listinfo/vlc-commits">https://mailman.videolan.org/listinfo/vlc-commits</a><br></div>
</blockquote><div><br></div>
<div><hr><br></div>
<div><br></div>
<div> vlc-devel mailing list<br></div>
<div> To unsubscribe or modify your subscription options:<br></div>
<div> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div>
</blockquote><div><br></div>
<div><br></div>
<div> --<br></div>
<div> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma<br></div>
<div> brièveté.<br></div>
<div><br></div>
<div><hr><br></div>
<div> vlc-devel mailing list<br></div>
<div> To unsubscribe or modify your subscription options:<br></div>
<div> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div>
</blockquote></blockquote><div><hr><br></div>
<div>vlc-devel mailing list<br></div>
<div>To unsubscribe or modify your subscription options:<br></div>
<div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div>
</pre></blockquote></div>
<div><br></div>
<div>--<br></div>
<div> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. <br></div>
<div><u>_______________________________________________</u><br></div>
<div>vlc-devel mailing list<br></div>
<div>To unsubscribe or modify your subscription options:<br></div>
<div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div>
</blockquote><div><br></div>
</body>
</html>