From bd2a53fc4ece82321f139cdf3276a7ceb871f895 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 24 Mar 2008 14:51:09 -0700 Subject: [PATCH] Add pixman_version function and related macros The complete new API here makes available compile-tim version checks: PIXMAN_VERSION PIXMAN_VERSION_STRING PIXMAN_VERSION_ENCODE as well as run-time version checks: pixman_version() pixman_version_string() --- .gitignore | 1 + configure.ac | 9 ++++-- pixman/Makefile.am | 5 ++-- pixman/pixman-version.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ pixman/pixman-version.h.in | 46 +++++++++++++++++++++++++++++ pixman/pixman.h | 8 +++++ 6 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 pixman/pixman-version.c create mode 100644 pixman/pixman-version.h.in diff --git a/.gitignore b/.gitignore index 2c736c1..70b7b64 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ stamp-h? config.h config.h.in .*.swp +pixman/pixman-version.h test/composite-test test/fetch-test test/gradient-test diff --git a/configure.ac b/configure.ac index 63ee2c5..e39f4c0 100644 --- a/configure.ac +++ b/configure.ac @@ -72,8 +72,12 @@ m4_define([lt_age], [pixman_minor]) LT_VERSION_INFO="lt_current:lt_revision:lt_age" -PIXMAN_MAJOR=pixman_major -AC_SUBST(PIXMAN_MAJOR) +PIXMAN_VERSION_MAJOR=pixman_major() +AC_SUBST(PIXMAN_VERSION_MAJOR) +PIXMAN_VERSION_MINOR=pixman_minor() +AC_SUBST(PIXMAN_VERSION_MINOR) +PIXMAN_VERSION_MICRO=pixman_micro() +AC_SUBST(PIXMAN_VERSION_MICRO) AC_SUBST(LT_VERSION_INFO) @@ -212,4 +216,5 @@ AC_SUBST(DEP_LIBS) AC_OUTPUT([pixman-1.pc Makefile pixman/Makefile + pixman/pixman-version.h test/Makefile]) diff --git a/pixman/Makefile.am b/pixman/Makefile.am index 37d892b..ff3997b 100644 --- a/pixman/Makefile.am +++ b/pixman/Makefile.am @@ -21,10 +21,11 @@ libpixman_1_la_SOURCES = \ pixman-edge-imp.h \ pixman-trap.c \ pixman-compute-region.c \ - pixman-timer.c + pixman-timer.c \ + pixman-version.c libpixmanincludedir = $(includedir)/pixman-1/ -libpixmaninclude_HEADERS = pixman.h +libpixmaninclude_HEADERS = pixman.h pixman-version.h # mmx code if USE_MMX diff --git a/pixman/pixman-version.c b/pixman/pixman-version.c new file mode 100644 index 0000000..58ac057 --- /dev/null +++ b/pixman/pixman-version.c @@ -0,0 +1,73 @@ +/* + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Author: Carl D. Worth + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "pixman-private.h" + +/** + * pixman_version: + * + * Returns the version of the pixman library encoded in a single + * integer as per %PIXMAN_VERSION_ENCODE. The encoding ensures that + * later versions compare greater than earlier versions. + * + * A run-time comparison to check that pixman's version is greater than + * or equal to version X.Y.Z could be performed as follows: + * + * + * if (pixman_version() >= PIXMAN_VERSION_ENCODE(X,Y,Z)) {...} + * + * + * See also pixman_version_string() as well as the compile-time + * equivalents %PIXMAN_VERSION and %PIXMAN_VERSION_STRING. + * + * Return value: the encoded version. + **/ +int +pixman_version (void) +{ + return PIXMAN_VERSION; +} + +/** + * pixman_version_string: + * + * Returns the version of the pixman library as a human-readable string + * of the form "X.Y.Z". + * + * See also pixman_version() as well as the compile-time equivalents + * %PIXMAN_VERSION_STRING and %PIXMAN_VERSION. + * + * Return value: a string containing the version. + **/ +const char* +pixman_version_string (void) +{ + return PIXMAN_VERSION_STRING; +} diff --git a/pixman/pixman-version.h.in b/pixman/pixman-version.h.in new file mode 100644 index 0000000..ce86312 --- /dev/null +++ b/pixman/pixman-version.h.in @@ -0,0 +1,46 @@ +/* + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Author: Carl D. Worth + */ + +#ifndef PIXMAN_VERSION_H__ +#define PIXMAN_VERSION_H__ + +#define PIXMAN_VERSION_MAJOR @PIXMAN_VERSION_MAJOR@ +#define PIXMAN_VERSION_MINOR @PIXMAN_VERSION_MINOR@ +#define PIXMAN_VERSION_MICRO @PIXMAN_VERSION_MICRO@ + +#define PIXMAN_VERSION_STRING "@PIXMAN_VERSION_MAJOR@.@PIXMAN_VERSION_MINOR@.@PIXMAN_VERSION_MICRO@" + +#define PIXMAN_VERSION_ENCODE(major, minor, micro) ( \ + ((major) * 10000) \ + + ((minor) * 100) \ + + ((micro) * 1)) + +#define PIXMAN_VERSION PIXMAN_VERSION_ENCODE( \ + PIXMAN_VERSION_MAJOR, \ + PIXMAN_VERSION_MINOR, \ + PIXMAN_VERSION_MICRO) + +#endif /* PIXMAN_VERSION_H__ */ diff --git a/pixman/pixman.h b/pixman/pixman.h index 2965acd..c4c5c3b 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -69,6 +69,8 @@ SOFTWARE. #ifndef PIXMAN_H__ #define PIXMAN_H__ +#include + /* * Standard integers */ @@ -272,6 +274,12 @@ typedef enum PIXMAN_REGION_PART } pixman_region_overlap_t; +PIXMAN_EXPORT +int pixman_version (void); + +PIXMAN_EXPORT +const char* pixman_version_string (void); + /* This function exists only to make it possible to preserve the X ABI - it should * go away at first opportunity. */ -- 2.7.4