summaryrefslogtreecommitdiff
path: root/perf
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2011-08-30 16:16:04 +0200
committerAndrea Canciani <ranma42@gmail.com>2011-09-02 12:27:13 +0200
commit6d6bfbd641bbb4de62df704e724e507a7e55b883 (patch)
tree9a1b624ce3c02b59c67865f6743caf37b86ed2cb /perf
parent0101a545793291d0fe76b765ba8392ade5faa1a1 (diff)
Introduce the cairo-missing library
The cairo-missing library provides the functions which are needed in order to correctly compile cairo (or its utilities) and which were not found during configuration. Fixes the build on MacOS X Lion, which failed because of collisons between the cairo internal getline and strndup and those in libc: cairo-analyse-trace.c:282: error: static declaration of ‘getline’ follows non-static declaration /usr/include/stdio.h:449: error: previous declaration of ‘getline’ was here cairo-analyse-trace.c:307: error: static declaration of ‘strndup’ follows non-static declaration ...
Diffstat (limited to 'perf')
-rw-r--r--perf/Makefile.am5
-rw-r--r--perf/cairo-analyse-trace.c52
-rw-r--r--perf/cairo-perf-report.c67
-rw-r--r--perf/cairo-perf-trace.c52
4 files changed, 8 insertions, 168 deletions
diff --git a/perf/Makefile.am b/perf/Makefile.am
index 4344b98c..88f691fc 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -6,6 +6,7 @@ AM_CPPFLAGS = \
-I$(srcdir) \
-I$(top_srcdir)/boilerplate \
-I$(top_srcdir)/src \
+ -I$(top_srcdir)/util/cairo-missing \
-I$(top_srcdir)/util/cairo-script \
-I$(top_builddir)/src \
$(CAIRO_CFLAGS)
@@ -54,9 +55,11 @@ cairo_analyse_trace_SOURCES = \
$(cairo_analyse_trace_external_sources)
cairo_analyse_trace_LDADD = \
$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/util/cairo-missing/libcairo-missing.la \
$(LDADD)
cairo_analyse_trace_DEPENDENCIES = \
$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/util/cairo-missing/libcairo-missing.la \
$(LDADD)
cairo_perf_trace_SOURCES = \
@@ -64,9 +67,11 @@ cairo_perf_trace_SOURCES = \
$(cairo_perf_trace_external_sources)
cairo_perf_trace_LDADD = \
$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/util/cairo-missing/libcairo-missing.la \
$(LDADD)
cairo_perf_trace_DEPENDENCIES = \
$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
+ $(top_builddir)/util/cairo-missing/libcairo-missing.la \
$(LDADD)
cairo_perf_diff_files_SOURCES = $(cairo_perf_diff_files_sources)
diff --git a/perf/cairo-analyse-trace.c b/perf/cairo-analyse-trace.c
index 1fee3cfd..96229074 100644
--- a/perf/cairo-analyse-trace.c
+++ b/perf/cairo-analyse-trace.c
@@ -38,6 +38,7 @@
#include "cairo-boilerplate-getopt.h"
#include <cairo-script-interpreter.h>
+#include "cairo-missing.h"
/* rudely reuse bits of the library... */
#include "../src/cairo-error-private.h"
@@ -273,57 +274,6 @@ usage (const char *argv0)
argv0, argv0);
}
-#ifndef __USE_GNU
-#define POORMANS_GETLINE_BUFFER_SIZE (65536)
-static ssize_t
-getline (char **lineptr,
- size_t *n,
- FILE *stream)
-{
- if (!*lineptr)
- {
- *n = POORMANS_GETLINE_BUFFER_SIZE;
- *lineptr = (char *) malloc (*n);
- }
-
- if (!fgets (*lineptr, *n, stream))
- return -1;
-
- if (!feof (stream) && !strchr (*lineptr, '\n'))
- {
- fprintf (stderr, "The poor man's implementation of getline in "
- __FILE__ " needs a bigger buffer. Perhaps it's "
- "time for a complete implementation of getline.\n");
- exit (0);
- }
-
- return strlen (*lineptr);
-}
-#undef POORMANS_GETLINE_BUFFER_SIZE
-
-static char *
-strndup (const char *s,
- size_t n)
-{
- size_t len;
- char *sdup;
-
- if (!s)
- return NULL;
-
- len = strlen (s);
- len = (n < len ? n : len);
- sdup = (char *) malloc (len + 1);
- if (sdup)
- {
- memcpy (sdup, s, len);
- sdup[len] = '\0';
- }
-
- return sdup;
-}
-#endif /* ifndef __USE_GNU */
-
static cairo_bool_t
read_excludes (cairo_perf_t *perf,
const char *filename)
diff --git a/perf/cairo-perf-report.c b/perf/cairo-perf-report.c
index a04db6bc..01ddeb1c 100644
--- a/perf/cairo-perf-report.c
+++ b/perf/cairo-perf-report.c
@@ -25,6 +25,7 @@
* Authors: Carl Worth <cworth@cworth.org>
*/
+#include "cairo-missing.h"
#include "cairo-perf.h"
#include "cairo-stats.h"
@@ -49,17 +50,6 @@
typedef ptrdiff_t ssize_t;
#endif
-#if !defined (__USE_GNU) && !defined(__USE_XOPEN2K8)
-static ssize_t
-getline (char **lineptr,
- size_t *n,
- FILE *stream);
-
-static char *
-strndup (const char *s,
- size_t n);
-#endif
-
#ifdef _MSC_VER
static long long
strtoll (const char *nptr,
@@ -230,61 +220,6 @@ test_report_parse (test_report_t *report,
return TEST_REPORT_STATUS_SUCCESS;
}
-/* We conditionally provide a custom implementation of getline and strndup
- * as needed. These aren't necessary full-fledged general purpose
- * implementations. They just get the job done for our purposes.
- */
-#if !defined (__USE_GNU) && !defined(__USE_XOPEN2K8)
-#define POORMANS_GETLINE_BUFFER_SIZE (65536)
-static ssize_t
-getline (char **lineptr,
- size_t *n,
- FILE *stream)
-{
- if (!*lineptr)
- {
- *n = POORMANS_GETLINE_BUFFER_SIZE;
- *lineptr = (char *) malloc (*n);
- }
-
- if (!fgets (*lineptr, *n, stream))
- return -1;
-
- if (!feof (stream) && !strchr (*lineptr, '\n'))
- {
- fprintf (stderr, "The poor man's implementation of getline in "
- __FILE__ " needs a bigger buffer. Perhaps it's "
- "time for a complete implementation of getline.\n");
- exit (0);
- }
-
- return strlen (*lineptr);
-}
-#undef POORMANS_GETLINE_BUFFER_SIZE
-
-static char *
-strndup (const char *s,
- size_t n)
-{
- size_t len;
- char *sdup;
-
- if (!s)
- return NULL;
-
- len = strlen (s);
- len = (n < len ? n : len);
- sdup = (char *) malloc (len + 1);
- if (sdup)
- {
- memcpy (sdup, s, len);
- sdup[len] = '\0';
- }
-
- return sdup;
-}
-#endif /* ifndef __USE_GNU */
-
/* We provide hereafter a win32 implementation of the basename
* and strtoll functions which are not available otherwise.
* The basename function is fully compliant to its GNU specs.
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index 25a98f34..3319917f 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -32,6 +32,7 @@
#include "../cairo-version.h" /* for the real version */
+#include "cairo-missing.h"
#include "cairo-perf.h"
#include "cairo-stats.h"
@@ -373,57 +374,6 @@ usage (const char *argv0)
argv0, argv0);
}
-#ifndef __USE_GNU
-#define POORMANS_GETLINE_BUFFER_SIZE (65536)
-static ssize_t
-getline (char **lineptr,
- size_t *n,
- FILE *stream)
-{
- if (!*lineptr)
- {
- *n = POORMANS_GETLINE_BUFFER_SIZE;
- *lineptr = (char *) malloc (*n);
- }
-
- if (!fgets (*lineptr, *n, stream))
- return -1;
-
- if (!feof (stream) && !strchr (*lineptr, '\n'))
- {
- fprintf (stderr, "The poor man's implementation of getline in "
- __FILE__ " needs a bigger buffer. Perhaps it's "
- "time for a complete implementation of getline.\n");
- exit (0);
- }
-
- return strlen (*lineptr);
-}
-#undef POORMANS_GETLINE_BUFFER_SIZE
-
-static char *
-strndup (const char *s,
- size_t n)
-{
- size_t len;
- char *sdup;
-
- if (!s)
- return NULL;
-
- len = strlen (s);
- len = (n < len ? n : len);
- sdup = (char *) malloc (len + 1);
- if (sdup)
- {
- memcpy (sdup, s, len);
- sdup[len] = '\0';
- }
-
- return sdup;
-}
-#endif /* ifndef __USE_GNU */
-
static cairo_bool_t
read_excludes (cairo_perf_t *perf,
const char *filename)