[2/7] pci/vfio: improve musl compatibility

Message ID 4694d02efdd764a45e84d2da00f1dff284694963.1535543250.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Improve core EAL musl compatibility |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly Aug. 29, 2018, 11:56 a.m. UTC
  Musl already has PAGE_SIZE defined, and our define clashed with it.
Rename our define to SYS_PAGE_SIZE.

Bugzilla ID: 36

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/bus/pci/linux/pci_vfio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Bruce Richardson Aug. 29, 2018, 12:35 p.m. UTC | #1
On Wed, Aug 29, 2018 at 12:56:16PM +0100, Anatoly Burakov wrote:
> Musl already has PAGE_SIZE defined, and our define clashed with it.
> Rename our define to SYS_PAGE_SIZE.
> 
> Bugzilla ID: 36
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---

Would it not be easier to just do?

#ifndef PAGE_SIZE
#define PAGE_SIZE ...
#endif
>  drivers/bus/pci/linux/pci_vfio.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
> index 686386d6a..88bcfb88b 100644
> --- a/drivers/bus/pci/linux/pci_vfio.c
> +++ b/drivers/bus/pci/linux/pci_vfio.c
> @@ -35,8 +35,8 @@
>  
>  #ifdef VFIO_PRESENT
>  
> -#define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
> -#define PAGE_MASK   (~(PAGE_SIZE - 1))
> +#define SYS_PAGE_SIZE   (sysconf(_SC_PAGESIZE))
> +#define SYS_PAGE_MASK   (~(SYS_PAGE_SIZE - 1))
>  
>  static struct rte_tailq_elem rte_vfio_tailq = {
>  	.name = "VFIO_RESOURCE_LIST",
> @@ -344,8 +344,8 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,
>  		 */
>  		uint32_t table_start = msix_table->offset;
>  		uint32_t table_end = table_start + msix_table->size;
> -		table_end = (table_end + ~PAGE_MASK) & PAGE_MASK;
> -		table_start &= PAGE_MASK;
> +		table_end = (table_end + ~SYS_PAGE_MASK) & SYS_PAGE_MASK;
> +		table_start &= SYS_PAGE_MASK;
>  
>  		if (table_start == 0 && table_end >= bar->size) {
>  			/* Cannot map this BAR */
> -- 
> 2.17.1
  
Burakov, Anatoly Aug. 29, 2018, 2:08 p.m. UTC | #2
On 29-Aug-18 1:35 PM, Bruce Richardson wrote:
> On Wed, Aug 29, 2018 at 12:56:16PM +0100, Anatoly Burakov wrote:
>> Musl already has PAGE_SIZE defined, and our define clashed with it.
>> Rename our define to SYS_PAGE_SIZE.
>>
>> Bugzilla ID: 36
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
> 
> Would it not be easier to just do?
> 
> #ifndef PAGE_SIZE
> #define PAGE_SIZE ...
> #endif

Sure, that can work.
  

Patch

diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index 686386d6a..88bcfb88b 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -35,8 +35,8 @@ 
 
 #ifdef VFIO_PRESENT
 
-#define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
-#define PAGE_MASK   (~(PAGE_SIZE - 1))
+#define SYS_PAGE_SIZE   (sysconf(_SC_PAGESIZE))
+#define SYS_PAGE_MASK   (~(SYS_PAGE_SIZE - 1))
 
 static struct rte_tailq_elem rte_vfio_tailq = {
 	.name = "VFIO_RESOURCE_LIST",
@@ -344,8 +344,8 @@  pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,
 		 */
 		uint32_t table_start = msix_table->offset;
 		uint32_t table_end = table_start + msix_table->size;
-		table_end = (table_end + ~PAGE_MASK) & PAGE_MASK;
-		table_start &= PAGE_MASK;
+		table_end = (table_end + ~SYS_PAGE_MASK) & SYS_PAGE_MASK;
+		table_start &= SYS_PAGE_MASK;
 
 		if (table_start == 0 && table_end >= bar->size) {
 			/* Cannot map this BAR */