On Wed, 1 Feb 2012, Daniel Verkamp wrote:
Add av_page_alloc, av_page_free, and av_page_protect to allocate pages and mark them executable, and use them to replace the equivalent open-coded functionality in libswscale. --- libavutil/Makefile | 2 + libavutil/page.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libavutil/page.h | 82 ++++++++++++++++++++++++++++++++++++ libswscale/utils.c | 45 +++----------------- 4 files changed, 208 insertions(+), 38 deletions(-) create mode 100644 libavutil/page.c create mode 100644 libavutil/page.hdiff --git a/libavutil/Makefile b/libavutil/Makefile index 626b60a..a193acd 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -28,6 +28,7 @@ HEADERS = adler32.h \ mem.h \ dict.h \ opt.h \ + page.h \ parseutils.h \ pixdesc.h \ pixfmt.h \ @@ -62,6 +63,7 @@ OBJS = adler32.o \ mem.o \ dict.o \ opt.o \ + page.o \ parseutils.o \ pixdesc.o \ random_seed.o \
diff --git a/libavutil/page.h b/libavutil/page.h new file mode 100644 index 0000000..0786ca6 --- /dev/null +++ b/libavutil/page.h @@ -0,0 +1,82 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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. + */ + +/** + * @file + * Memory page handling functions + */ + +#ifndef AVUTIL_PAGE_H +#define AVUTIL_PAGE_H + +#include "avutil.h" +#include "config.h" + +#if HAVE_SYS_MMAN_H +# include <sys/mman.h> +#endif + +#ifdef PROT_NONE +# define AV_PROT_NONE PROT_NONE +# define AV_PROT_READ PROT_READ +# define AV_PROT_WRITE PROT_WRITE +# define AV_PROT_EXEC PROT_EXEC +#else +# define AV_PROT_NONE 0 ///< No access allowed +# define AV_PROT_READ 1 ///< Memory can be read +# define AV_PROT_WRITE 2 ///< Memory can be written +# define AV_PROT_EXEC 4 ///< Memory can be executed +#endif
You can't include config.h in an installed header. But if you unconditionally define these constants here, and add similar mapping to mprotect call as for the windows one, it should work.
// Martin _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
