From dbf53c3e6b992f2043e049ef06b2f600c6edd74d Mon Sep 17 00:00:00 2001 From: niewim19 Date: Fri, 6 Sep 2024 12:01:02 +0200 Subject: [PATCH] x264: reformat `input.patch` with `#ifdef phoenix` JIRA: PP-213 --- x264/patches/input.patch | 54 +++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/x264/patches/input.patch b/x264/patches/input.patch index 7d1ab69..d85cb86 100644 --- a/x264/patches/input.patch +++ b/x264/patches/input.patch @@ -1,10 +1,10 @@ - ---- x264_org/input/input.c 2024-09-05 11:57:22.943594154 +0200 -+++ x264/input/input.c 2024-09-05 11:57:41.344630765 +0200 -@@ -227,6 +227,15 @@ +--- x264_org/input/input.c 2024-09-06 10:29:54.784756723 +0200 ++++ x264/input/input.c 2024-09-06 11:05:56.206158357 +0200 +@@ -227,7 +227,19 @@ } #else size_t padded_size = size + MMAP_PADDING; ++#ifdef phoenix + /** + * PHOENIX-RTOS PATCH + * @@ -13,35 +13,33 @@ + * + * https://github.com/phoenix-rtos/phoenix-rtos-project/issues/1155 + */ -+ padded_size = (1 + padded_size / SIZE_PAGE) * SIZE_PAGE; ++ if( (base = mmap( NULL, ((padded_size + (SIZE_PAGE - 1)) & ~(SIZE_PAGE - 1)), PROT_READ, MAP_PRIVATE, h->fd, offset )) != MAP_FAILED ) ++#else if( (base = mmap( NULL, padded_size, PROT_READ, MAP_PRIVATE, h->fd, offset )) != MAP_FAILED ) ++#endif { /* Ask the OS to readahead pages. This improves performance whereas -@@ -241,9 +250,19 @@ - /* Remap the file mapping of any padding that crosses a page boundary past the end of + * forcing page faults by manually accessing every page does not. +@@ -242,7 +254,22 @@ * the file into a copy of the last valid page to prevent reads from invalid memory. */ size_t aligned_size = (padded_size - 1) & ~h->align_mask; -- if( offset + aligned_size >= h->file_size ) -- mmap( base + aligned_size, padded_size - aligned_size, PROT_READ, MAP_PRIVATE|MAP_FIXED, h->fd, (offset + size - 1) & ~h->align_mask ); -- -+ /** -+ * PHOENIX-RTOS PATCH -+ * -+ * Phoenix implementation of mmap() fails if `size` is not aligned to page size -+ * It is important to remove this patch when this issue is resolved. -+ * -+ * https://github.com/phoenix-rtos/phoenix-rtos-project/issues/1155 -+ */ -+ if( offset + aligned_size >= h->file_size ) { -+ size_t paddedMinusAligned_aligned = (padded_size - aligned_size); -+ paddedMinusAligned_aligned = (1 + paddedMinusAligned_aligned / SIZE_PAGE) * SIZE_PAGE; -+ mmap( base + aligned_size, paddedMinusAligned_aligned, PROT_READ, MAP_PRIVATE|MAP_FIXED, h->fd, (offset + size - 1) & ~h->align_mask ); + if( offset + aligned_size >= h->file_size ) ++#ifdef phoenix ++ { ++ /** ++ * PHOENIX-RTOS PATCH ++ * ++ * Phoenix implementation of mmap() fails if `size` is not aligned to page size ++ * It is important to remove this patch when this issue is resolved. ++ * ++ * https://github.com/phoenix-rtos/phoenix-rtos-project/issues/1155 ++ */ ++ size_t phoenix_paddedMinusAligned = padded_size - aligned_size; ++ mmap( base + aligned_size, ((phoenix_paddedMinusAligned + (SIZE_PAGE - 1)) & ~(SIZE_PAGE - 1)), PROT_READ, MAP_PRIVATE|MAP_FIXED, h->fd, (offset + size - 1) & ~h->align_mask ); + } ++#else + mmap( base + aligned_size, padded_size - aligned_size, PROT_READ, MAP_PRIVATE|MAP_FIXED, h->fd, (offset + size - 1) & ~h->align_mask ); ++#endif + return base + align; } - #endif -@@ -272,3 +291,4 @@ - CloseHandle( h->map_handle ); - #endif - } -+