Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: content/gpu/gpu_info_collector_linux.cc

Issue 11343015: Linux: add option to link libpci directly instead of using dlopen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/content_gpu.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/gpu/gpu_info_collector_linux.cc
diff --git a/content/gpu/gpu_info_collector_linux.cc b/content/gpu/gpu_info_collector_linux.cc
index 9afef2380cd28563921db9c30e68ad5b9e6732a9..d0b9e25ff8bda5e529196841a66ccead4dd334e5 100644
--- a/content/gpu/gpu_info_collector_linux.cc
+++ b/content/gpu/gpu_info_collector_linux.cc
@@ -8,6 +8,11 @@
#include <X11/Xlib.h>
#include <vector>
+// TODO(phajdan.jr): Report problem upstream and make pci.h handle this.
+extern "C" {
+#include <pci/pci.h>
+}
+
#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/file_util.h"
@@ -28,51 +33,14 @@
namespace {
-// PciDevice and PciAccess are defined to access libpci functions. Their
-// members match the corresponding structures defined by libpci in size up to
-// fields we may access. For those members we don't use, their names are
-// defined as "fieldX", etc., or, left out if they are declared after the
-// members we care about in libpci.
-
-struct PciDevice {
- PciDevice* next;
-
- uint16 field0;
- uint8 field1;
- uint8 field2;
- uint8 field3;
- int field4;
-
- uint16 vendor_id;
- uint16 device_id;
- uint16 device_class;
-};
-
-struct PciAccess {
- unsigned int field0;
- int field1;
- int field2;
- char* field3;
- int field4;
- int field5;
- unsigned int field6;
- int field7;
-
- void (*function0)();
- void (*function1)();
- void (*function2)();
-
- PciDevice* device_list;
-};
-
// Define function types.
-typedef PciAccess* (*FT_pci_alloc)();
-typedef void (*FT_pci_init)(PciAccess*);
-typedef void (*FT_pci_cleanup)(PciAccess*);
-typedef void (*FT_pci_scan_bus)(PciAccess*);
-typedef void (*FT_pci_scan_bus)(PciAccess*);
-typedef int (*FT_pci_fill_info)(PciDevice*, int);
-typedef char* (*FT_pci_lookup_name)(PciAccess*, char*, int, int, ...);
+typedef pci_access* (*FT_pci_alloc)();
+typedef void (*FT_pci_init)(pci_access*);
+typedef void (*FT_pci_cleanup)(pci_access*);
+typedef void (*FT_pci_scan_bus)(pci_access*);
+typedef void (*FT_pci_scan_bus)(pci_access*);
+typedef int (*FT_pci_fill_info)(pci_dev*, int);
+typedef char* (*FT_pci_lookup_name)(pci_access*, char*, int, int, ...);
// This includes dynamically linked library handle and functions pointers from
// libpci.
@@ -100,6 +68,7 @@ bool IsPciSupported() {
// NULL if library fails to open or any functions can not be located.
// Returned interface (if not NULL) should be deleted in FinalizeLibPci.
PciInterface* InitializeLibPci(const char* lib_name) {
+#if defined(DLOPEN_LIBPCI)
void* handle = dlopen(lib_name, RTLD_LAZY);
if (handle == NULL) {
VLOG(1) << "Failed to dlopen " << lib_name;
@@ -130,13 +99,25 @@ PciInterface* InitializeLibPci(const char* lib_name) {
delete interface;
return NULL;
}
+#else // !defined(DLOPEN_LIBPCI)
+ PciInterface* interface = new struct PciInterface;
+ interface->lib_handle = NULL;
+ interface->pci_alloc = &pci_alloc;
+ interface->pci_init = &pci_init;
+ interface->pci_cleanup = &pci_cleanup;
+ interface->pci_scan_bus = &pci_scan_bus;
+ interface->pci_fill_info = &pci_fill_info;
+ interface->pci_lookup_name = &pci_lookup_name;
+#endif // !defined(DLOPEN_LIBPCI)
return interface;
}
// This close the dynamically opened libpci and delete the interface.
void FinalizeLibPci(PciInterface** interface) {
+#if defined(DLOPEN_LIBPCI)
DCHECK(interface && *interface && (*interface)->lib_handle);
dlclose((*interface)->lib_handle);
+#endif // defined(DLOPEN_LIBPCI)
delete (*interface);
*interface = NULL;
}
@@ -281,12 +262,12 @@ bool CollectVideoCardInfo(content::GPUInfo* gpu_info) {
return false;
}
- PciAccess* access = (interface->pci_alloc)();
+ pci_access* access = (interface->pci_alloc)();
DCHECK(access != NULL);
(interface->pci_init)(access);
(interface->pci_scan_bus)(access);
bool primary_gpu_identified = false;
- for (PciDevice* device = access->device_list;
+ for (pci_dev* device = access->devices;
device != NULL; device = device->next) {
(interface->pci_fill_info)(device, 33); // Fill the IDs and class fields.
// TODO(zmo): there might be other classes that qualify as display devices.
« no previous file with comments | « content/content_gpu.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698