fix FTBS on XSERVER_LIBPCIACCESS

Not all Xserver versions define that symbol with a numeric value
(1 or 0), some just might not define it at all when disabled.

Using #if instead of #ifdef (as most sites do) will lead to compile break:

    ../../src/vmware.c:1102:25: error: expected value in expression
    #if XSERVER_LIBPCIACCESS
                        ^

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2024-06-06 11:09:18 +02:00
parent 4f854bb179
commit 7d7aa65d64
3 changed files with 16 additions and 18 deletions

View File

@@ -341,7 +341,7 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
SVGA_LEGACY_BASE_PORT + SVGA_VALUE_PORT*sizeof(uint32);
} else {
/* Note: This setting of valueReg causes unaligned I/O */
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
pVMWARE->portIOBase = pVMWARE->PciInfo->regions[0].base_addr;
#else
pVMWARE->portIOBase = pVMWARE->PciInfo->ioBase[0];
@@ -383,7 +383,7 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
}
pVMWARE->suspensionSavedRegId = id;
#if !XSERVER_LIBPCIACCESS
#ifndef XSERVER_LIBPCIACCESS
pVMWARE->PciTag = pciTag(pVMWARE->PciInfo->bus, pVMWARE->PciInfo->device,
pVMWARE->PciInfo->func);
#endif
@@ -727,13 +727,11 @@ static Bool
VMWAREMapMem(ScrnInfoPtr pScrn)
{
VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
int err;
struct pci_device *const device = pVMWARE->PciInfo;
void *fbBase;
#endif
#if XSERVER_LIBPCIACCESS
err = pci_device_map_range(device,
pVMWARE->memPhysBase,
pVMWARE->videoRam,
@@ -770,7 +768,7 @@ VMWAREUnmapMem(ScrnInfoPtr pScrn)
VmwareLog(("Unmapped: %p/%u\n", pVMWARE->FbBase, pVMWARE->videoRam));
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
pci_device_unmap_range(pVMWARE->PciInfo, pVMWARE->FbBase, pVMWARE->videoRam);
#else
xf86UnMapVidMem(pScrn->scrnIndex, pVMWARE->FbBase, pVMWARE->videoRam);
@@ -1045,7 +1043,7 @@ static void
VMWAREInitFIFO(ScrnInfoPtr pScrn)
{
VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
struct pci_device *const device = pVMWARE->PciInfo;
int err;
void *mmioVirtBase;
@@ -1058,7 +1056,7 @@ VMWAREInitFIFO(ScrnInfoPtr pScrn)
pVMWARE->mmioPhysBase = vmwareReadReg(pVMWARE, SVGA_REG_MEM_START);
pVMWARE->mmioSize = vmwareReadReg(pVMWARE, SVGA_REG_MEM_SIZE) & ~3;
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
err = pci_device_map_range(device, pVMWARE->mmioPhysBase,
pVMWARE->mmioSize,
PCI_DEV_MAP_FLAG_WRITABLE,
@@ -1099,7 +1097,7 @@ VMWAREStopFIFO(ScrnInfoPtr pScrn)
TRACEPOINT
vmwareWriteReg(pVMWARE, SVGA_REG_CONFIG_DONE, 0);
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
pci_device_unmap_range(pVMWARE->PciInfo, pVMWARE->mmioVirtBase, pVMWARE->mmioSize);
#else
xf86UnMapVidMem(pScrn->scrnIndex, pVMWARE->mmioVirtBase, pVMWARE->mmioSize);

View File

@@ -83,7 +83,7 @@ typedef xXineramaScreenInfo VMWAREXineramaRec, *VMWAREXineramaPtr;
typedef struct {
EntityInfoPtr pEnt;
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
struct pci_device *PciInfo;
#else
pciVideoPtr PciInfo;
@@ -207,7 +207,7 @@ typedef struct {
/* Undefine this to kill all acceleration */
#define ACCELERATE_OPS
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
#define VENDOR_ID(p) (p)->vendor_id
#define DEVICE_ID(p) (p)->device_id
#define SUBVENDOR_ID(p) (p)->subvendor_id

View File

@@ -85,7 +85,7 @@ static char vmware_driver_name[] = VMWARE_DRIVER_NAME;
VMW_STRING(PACKAGE_VERSION_MAJOR) "." VMW_STRING(PACKAGE_VERSION_MINOR) \
"." VMW_STRING(PACKAGE_VERSION_PATCHLEVEL)
#if !XSERVER_LIBPCIACCESS
#ifndef XSERVER_LIBPCIACCESS
static const char VMWAREBuildStr[] = "VMware Guest X Server "
VMWARE_DRIVER_VERSION_STRING " - build=$Name$\n";
#else
@@ -121,7 +121,7 @@ static resRange vmwareLegacyRes[] = {
#define vmwareLegacyRes NULL
#endif
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
#define VENDOR_ID(p) (p)->vendor_id
#define DEVICE_ID(p) (p)->device_id
#define SUBVENDOR_ID(p) (p)->subvendor_id
@@ -135,7 +135,7 @@ static resRange vmwareLegacyRes[] = {
#define CHIP_REVISION(p) (p)->chipRev
#endif
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
#define VMWARE_DEVICE_MATCH(d, i) \
{PCI_VENDOR_ID_VMWARE, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
@@ -214,7 +214,7 @@ vmwgfx_hosted_detect(void);
static Bool
VMwarePreinitStub(ScrnInfoPtr pScrn, int flags)
{
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
struct pci_device *pciInfo;
#else
pciVideoPtr pciInfo;
@@ -264,7 +264,7 @@ VMwarePreinitStub(ScrnInfoPtr pScrn, int flags)
return (*pScrn->PreInit)(pScrn, flags);
};
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
static Bool
VMwarePciProbe (DriverPtr drv,
int entity_num,
@@ -514,7 +514,7 @@ _X_EXPORT DriverRec vmware = {
VMWARE_DRIVER_VERSION,
vmware_driver_name,
VMWAREIdentify,
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
NULL,
#else
VMWAREProbe,
@@ -526,7 +526,7 @@ _X_EXPORT DriverRec vmware = {
VMWareDriverFunc,
#endif
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 4
#if XSERVER_LIBPCIACCESS
#ifdef XSERVER_LIBPCIACCESS
VMwareDeviceMatch,
VMwarePciProbe,
#else