targets: Use a macro to reduce cut and paste in driver setup.
authorEric Anholt <eric@anholt.net>
Fri, 3 Feb 2017 18:54:12 +0000 (10:54 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 6 Feb 2017 20:44:06 +0000 (12:44 -0800)
All the replicated prototypes/function bodies obfuscated the interesting
logic of the file: the mapping from driver enable macros to entrypoints we
expose, and the way that the swrast entrypoints are special compared to
the DRM entrypoints.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/targets/dri/target.c

index dba18cce65cc63f24b7c939a0a0e4129463d6060..df93c94ea832837fb5be7826459c9195cbaaebf7 100644 (file)
@@ -3,6 +3,14 @@
 
 #include "dri_screen.h"
 
+#define DEFINE_LOADER_DRM_ENTRYPOINT(drivername)                          \
+const __DRIextension **__driDriverGetExtensions_##drivername(void);       \
+PUBLIC const __DRIextension **__driDriverGetExtensions_##drivername(void) \
+{                                                                         \
+   globalDriverAPI = &galliumdrm_driver_api;                              \
+   return galliumdrm_driver_extensions;                                   \
+}
+
 #if defined(GALLIUM_SOFTPIPE)
 
 const __DRIextension **__driDriverGetExtensions_swrast(void);
@@ -27,154 +35,57 @@ PUBLIC const __DRIextension **__driDriverGetExtensions_kms_swrast(void)
 #endif
 
 #if defined(GALLIUM_I915)
-
-const __DRIextension **__driDriverGetExtensions_i915(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_i915(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(i915)
 #endif
 
 #if defined(GALLIUM_ILO)
-
-const __DRIextension **__driDriverGetExtensions_i965(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_i965(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(i965)
 #endif
 
 #if defined(GALLIUM_NOUVEAU)
-
-const __DRIextension **__driDriverGetExtensions_nouveau(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_nouveau(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(nouveau)
 #endif
 
 #if defined(GALLIUM_R300)
-
-const __DRIextension **__driDriverGetExtensions_r300(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_r300(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(r300)
 #endif
 
 #if defined(GALLIUM_R600)
-
-const __DRIextension **__driDriverGetExtensions_r600(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_r600(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(r600)
 #endif
 
 #if defined(GALLIUM_RADEONSI)
-
-const __DRIextension **__driDriverGetExtensions_radeonsi(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_radeonsi(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(radeonsi)
 #endif
 
 #if defined(GALLIUM_VMWGFX)
-
-const __DRIextension **__driDriverGetExtensions_vmwgfx(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_vmwgfx(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(vmwgfx)
 #endif
 
 #if defined(GALLIUM_FREEDRENO)
-
-const __DRIextension **__driDriverGetExtensions_msm(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_msm(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-
-const __DRIextension **__driDriverGetExtensions_kgsl(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_kgsl(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(msm)
+DEFINE_LOADER_DRM_ENTRYPOINT(kgsl)
 #endif
 
 #if defined(GALLIUM_VIRGL)
-
-const __DRIextension **__driDriverGetExtensions_virtio_gpu(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_virtio_gpu(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(virtio_gpu)
 #endif
 
 #if defined(GALLIUM_VC4)
-
-const __DRIextension **__driDriverGetExtensions_vc4(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_vc4(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(vc4)
 
 #if defined(USE_VC4_SIMULATOR)
-const __DRIextension **__driDriverGetExtensions_i965(void);
-
 /**
  * When building using the simulator (on x86), we advertise ourselves as the
  * i965 driver so that you can just make a directory with a link from
  * i965_dri.so to the built vc4_dri.so, and point LIBGL_DRIVERS_PATH to that
  * on your i965-using host to run the driver under simulation.
  */
-PUBLIC const __DRIextension **__driDriverGetExtensions_i965(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(i965)
 #endif
 #endif
 
 #if defined(GALLIUM_ETNAVIV)
-
-const __DRIextension **__driDriverGetExtensions_imx_drm(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_imx_drm(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-
-const __DRIextension **__driDriverGetExtensions_etnaviv(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_etnaviv(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
+DEFINE_LOADER_DRM_ENTRYPOINT(imx_drm)
+DEFINE_LOADER_DRM_ENTRYPOINT(etnaviv)
 #endif