[cairo-commit] 3 commits - util/cairo-sphinx

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 6 16:37:27 UTC 2023


 util/cairo-sphinx/fdr.c       |   92 +++++++++---------------------------------
 util/cairo-sphinx/meson.build |    2 
 2 files changed, 22 insertions(+), 72 deletions(-)

New commits:
commit 7380d3dd7d5128db20f0be063b086519ed555327
Merge: 3c14ef78a 4d274aa25
Author: Emmanuele Bassi <ebassi at gmail.com>
Date:   Wed Sep 6 16:37:25 2023 +0000

    Merge branch 'sphinx-static' into 'master'
    
    Revert "Allow static builds of cairo-sphinx" and always build fdr.c as a shared library
    
    See merge request cairo/cairo!509

commit 4d274aa2592b895dac5b2d02f03801b06195ccdb
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Sep 3 17:28:21 2023 +0200

    Always build fdr.c into a shared library
    
    The code in fdr.c is meant to interpose function calls, e.g. it defines
    a cairo_create() function that records the call and then calls the real
    cairo_create() (via dlsym(RTLD_NEXT)).
    
    This obviously does not work in a static library. This was reported in
    issue #791. This commit fixes that issue by always building this as a
    shared library, even when -Ddefault_library=static is passed to meson.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/util/cairo-sphinx/meson.build b/util/cairo-sphinx/meson.build
index 467ad3b75..01ef64bec 100644
--- a/util/cairo-sphinx/meson.build
+++ b/util/cairo-sphinx/meson.build
@@ -6,7 +6,7 @@ cairo_sphinx_sources = [
   'sphinx.c',
 ]
 
-libcairosphinx = library('cairo-sphinx', libcairo_sphinx_sources,
+libcairosphinx = shared_library('cairo-sphinx', libcairo_sphinx_sources,
   include_directories: [incbase, incsrc],
   dependencies: deps,
   install: true,
commit e45396298157473b26d0186c881bffabc80ea87e
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Sep 3 17:25:00 2023 +0200

    Revert "Allow static builds of cairo-sphinx"
    
    This reverts commit dfc15dd2e5e39492e9ecf9ea79f12716b0aee070.
    
    The code in fdr.c is supposed to interpose function calls into cairo.
    I.e., instead of calling cairo_create(), the application would call into
    fdr.c, this call would be recorded, and then the call is forwarded to
    the real cairo_create().
    
    The commit that is being reverted here just completely broke this by
    renaming the functions. Thus, no more interposition would happen.

diff --git a/util/cairo-sphinx/fdr.c b/util/cairo-sphinx/fdr.c
index d72f0ce5c..a28251650 100644
--- a/util/cairo-sphinx/fdr.c
+++ b/util/cairo-sphinx/fdr.c
@@ -31,16 +31,16 @@
 
 static void *_dlhandle = RTLD_NEXT;
 #define DLCALL(name, args...) ({ \
-    static typeof (&name) fdr_##name##_real; \
-    if (fdr_##name##_real == NULL) { \
-	fdr_##name##_real = dlsym (_dlhandle, #name); \
-	if (fdr_##name##_real == NULL && _dlhandle == RTLD_NEXT) { \
+    static typeof (&name) name##_real; \
+    if (name##_real == NULL) { \
+	name##_real = dlsym (_dlhandle, #name); \
+	if (name##_real == NULL && _dlhandle == RTLD_NEXT) { \
 	    _dlhandle = dlopen ("libcairo.so", RTLD_LAZY); \
-	    fdr_##name##_real = dlsym (_dlhandle, #name); \
-	    assert (fdr_##name##_real != NULL); \
+	    name##_real = dlsym (_dlhandle, #name); \
+	    assert (name##_real != NULL); \
 	} \
     } \
-    (* fdr_##name##_real) (args);  \
+    (*name##_real) (args);  \
 })
 
 static cairo_device_t *fdr_context;
@@ -109,13 +109,8 @@ fdr_write (void *closure, const unsigned char *data, unsigned int len)
     return CAIRO_STATUS_SUCCESS;
 }
 
-#define cairo_create(s) fdr_cairo_create(s)
-
-cairo_t *
-fdr_cairo_create (cairo_surface_t *surface);
-
 cairo_t *
-fdr_cairo_create (cairo_surface_t *surface)
+cairo_create (cairo_surface_t *surface)
 {
     cairo_surface_t *tee;
 
@@ -155,13 +150,8 @@ fdr_remove_tee (cairo_surface_t *surface)
     fdr_surface_destroy (surface);
 }
 
-#define cairo_destroy(cr) fdr_cairo_destroy(cr)
-
 void
-fdr_cairo_destroy (cairo_t *cr);
-
-void
-fdr_cairo_destroy (cairo_t *cr)
+cairo_destroy (cairo_t *cr)
 {
     cairo_surface_t *tee;
 
@@ -172,13 +162,8 @@ fdr_cairo_destroy (cairo_t *cr)
 	fdr_remove_tee (fdr_tee_surface_index (tee, 0));
 }
 
-#define cairo_pattern_destroy(p) fdr_cairo_pattern_destroy(p)
-
 void
-fdr_cairo_pattern_destroy (cairo_pattern_t *pattern);
-
-void
-fdr_cairo_pattern_destroy (cairo_pattern_t *pattern)
+cairo_pattern_destroy (cairo_pattern_t *pattern)
 {
     if (DLCALL (cairo_pattern_get_type, pattern) == CAIRO_PATTERN_TYPE_SURFACE) {
 	cairo_surface_t *surface;
@@ -194,13 +179,8 @@ fdr_cairo_pattern_destroy (cairo_pattern_t *pattern)
     DLCALL (cairo_pattern_destroy, pattern);
 }
 
-#define cairo_get_target(cr) fdr_cairo_get_target(cr)
-
 cairo_surface_t *
-fdr_cairo_get_target (cairo_t *cr);
-
-cairo_surface_t *
-fdr_cairo_get_target (cairo_t *cr)
+cairo_get_target (cairo_t *cr)
 {
     cairo_surface_t *tee;
 
@@ -208,13 +188,8 @@ fdr_cairo_get_target (cairo_t *cr)
     return fdr_tee_surface_index (tee, 0);
 }
 
-#define cairo_get_group_target(cr) fdr_cairo_get_group_target(cr)
-
 cairo_surface_t *
-fdr_cairo_get_group_target (cairo_t *cr);
-
-cairo_surface_t *
-fdr_cairo_get_group_target (cairo_t *cr)
+cairo_get_group_target (cairo_t *cr)
 {
     cairo_surface_t *tee;
 
@@ -222,13 +197,8 @@ fdr_cairo_get_group_target (cairo_t *cr)
     return fdr_tee_surface_index (tee, 0);
 }
 
-#define cairo_pattern_create_for_surface(s) fdr_cairo_pattern_create_for_surface(s)
-
-cairo_pattern_t *
-fdr_cairo_pattern_create_for_surface (cairo_surface_t *surface);
-
 cairo_pattern_t *
-fdr_cairo_pattern_create_for_surface (cairo_surface_t *surface)
+cairo_pattern_create_for_surface (cairo_surface_t *surface)
 {
     cairo_surface_t *tee;
 
@@ -239,15 +209,9 @@ fdr_cairo_pattern_create_for_surface (cairo_surface_t *surface)
     return DLCALL (cairo_pattern_create_for_surface, surface);
 }
 
-#define cairo_pattern_get_surface(p,s) fdr_cairo_pattern_get_surface(p,s)
-
-cairo_status_t
-fdr_cairo_pattern_get_surface (cairo_pattern_t *pattern,
-                               cairo_surface_t **surface);
-
 cairo_status_t
-fdr_cairo_pattern_get_surface (cairo_pattern_t *pattern,
-                               cairo_surface_t **surface)
+cairo_pattern_get_surface (cairo_pattern_t *pattern,
+			   cairo_surface_t **surface)
 {
     cairo_status_t status;
     cairo_surface_t *tee;
@@ -263,17 +227,10 @@ fdr_cairo_pattern_get_surface (cairo_pattern_t *pattern,
     return CAIRO_STATUS_SUCCESS;
 }
 
-#define cairo_set_source_surface(cr,s,x,y) fdr_cairo_set_source_surface(cr,s,x,y)
-
-void
-fdr_cairo_set_source_surface (cairo_t *cr,
-                              cairo_surface_t *surface,
-                              double x, double y);
-
 void
-fdr_cairo_set_source_surface (cairo_t *cr,
-                              cairo_surface_t *surface,
-                              double x, double y)
+cairo_set_source_surface (cairo_t *cr,
+			  cairo_surface_t *surface,
+			  double x, double y)
 {
     cairo_surface_t *tee;
 
@@ -284,17 +241,10 @@ fdr_cairo_set_source_surface (cairo_t *cr,
     DLCALL (cairo_set_source_surface, cr, surface, x, y);
 }
 
-#define cairo_surface_create_similar(s,c,w,h) fdr_cairo_surface_create_similar(s,c,w,h)
-
-cairo_surface_t *
-fdr_cairo_surface_create_similar (cairo_surface_t *surface,
-                                  cairo_content_t content,
-                                  int width, int height);
-
 cairo_surface_t *
-fdr_cairo_surface_create_similar (cairo_surface_t *surface,
-                                  cairo_content_t content,
-                                  int width, int height)
+cairo_surface_create_similar (cairo_surface_t *surface,
+			      cairo_content_t content,
+			      int width, int height)
 {
     cairo_surface_t *tee;
 


More information about the cairo-commit mailing list