Adds patch generated from mhillenibm's PR (see https://github.com/thjaeger/easystroke/pull/14)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 686b7778767f1f94cf9f6d5c2acd401d76bb3d4a Mon Sep 17 00:00:00 2001 | |
From: Marius Hillenbrand <mhillen@linux.ibm.com> | |
Date: Tue, 14 Apr 2020 16:00:36 +0200 | |
Subject: [PATCH] Move Stroke::save() and load() into header | |
The template member functions Stroke::save and Stroke::load get called | |
via the serialize() function generated by boost's macro | |
BOOST_SERIALIZATION_SPLIT_MEMBER() in gesture.h. Since the definitions | |
of save()/load() are only available in gesture.cc, the compiler may | |
produce two versions of Stroke::serialize() -- one with save()/load() | |
inlined in gesture.o and one with calls to save()/load() in all other | |
referencing translation units. Since the compiler inlined Stroke::save() | |
and Stroke::load(), it will not export them in gesture.o (which is | |
legitimate, since the code only requests an export of | |
Stroke::serialize). As a result, some orders of object files can fail to | |
link, when the linker picks the version of Stroke::serialize() that | |
would call save()/load() (which are not available separately) instead of | |
the version with these functions inlined. | |
Avoid relying on this compiler- and optimization-level dependent | |
behavior by moving the definition of template member functions | |
Stroke::save() and Stroke::load() into gesture.h. As a side-effect, that | |
change unifies code style, since all other classes have their ::save() | |
and ::load() definitions in header files, too. | |
These link failures surfaced when building on s390x with -march=zEC12 or | |
later, and can be reproduced on x86_64 with gcc parameters | |
--param max-inline-insns-auto=80 --param inline-min-speedup=2 | |
Signed-off-by: Marius Hillenbrand <mhillen@linux.ibm.com> | |
--- | |
gesture.cc | 36 ------------------------------------ | |
gesture.h | 37 +++++++++++++++++++++++++++++++++++-- | |
2 files changed, 35 insertions(+), 38 deletions(-) | |
diff --git a/gesture.cc b/gesture.cc | |
index 8531c08..f97bce3 100644 | |
--- a/gesture.cc | |
+++ b/gesture.cc | |
@@ -14,7 +14,6 @@ | |
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
*/ | |
#include "gesture.h" | |
-#include "prefdb.h" | |
#include <boost/archive/text_oarchive.hpp> | |
#include <boost/archive/text_iarchive.hpp> | |
@@ -35,41 +34,6 @@ RTriple create_triple(float x, float y, Time t) { | |
return e; | |
} | |
-template<class Archive> void Stroke::save(Archive & ar, const unsigned int version) const { | |
- std::vector<Point> ps; | |
- for (unsigned int i = 0; i < size(); i++) | |
- ps.push_back(points(i)); | |
- ar & ps; | |
- ar & button; | |
- ar & trigger; | |
- ar & timeout; | |
- ar & modifiers; | |
-} | |
- | |
-template<class Archive> void Stroke::load(Archive & ar, const unsigned int version) { | |
- std::vector<Point> ps; | |
- ar & ps; | |
- if (ps.size()) { | |
- stroke_t *s = stroke_alloc(ps.size()); | |
- for (std::vector<Point>::iterator i = ps.begin(); i != ps.end(); ++i) | |
- stroke_add_point(s, i->x, i->y); | |
- stroke_finish(s); | |
- stroke.reset(s, &stroke_free); | |
- } | |
- if (version == 0) return; | |
- ar & button; | |
- if (version >= 2) | |
- ar & trigger; | |
- if (version < 4 && (!button || trigger == (int)prefs.button.get().button)) | |
- trigger = 0; | |
- if (version < 3) | |
- return; | |
- ar & timeout; | |
- if (version < 5) | |
- return; | |
- ar & modifiers; | |
-} | |
- | |
Stroke::Stroke(PreStroke &ps, int trigger_, int button_, unsigned int modifiers_, bool timeout_) : trigger(trigger_), button(button_), modifiers(modifiers_), timeout(timeout_) { | |
if (ps.valid()) { | |
stroke_t *s = stroke_alloc(ps.size()); | |
diff --git a/gesture.h b/gesture.h | |
index accecdf..1c31887 100644 | |
--- a/gesture.h | |
+++ b/gesture.h | |
@@ -16,6 +16,7 @@ | |
#ifndef __GESTURE_H__ | |
#define __GESTURE_H__ | |
+#include "prefdb.h" | |
#include "stroke.h" | |
#include <gdkmm.h> | |
#include <vector> | |
@@ -83,8 +84,40 @@ private: | |
static Glib::RefPtr<Gdk::Pixbuf> pbEmpty; | |
BOOST_SERIALIZATION_SPLIT_MEMBER() | |
- template<class Archive> void load(Archive & ar, const unsigned int version); | |
- template<class Archive> void save(Archive & ar, const unsigned int version) const; | |
+ template<class Archive> void load(Archive & ar, const unsigned int version) { | |
+ std::vector<Point> ps; | |
+ ar & ps; | |
+ if (ps.size()) { | |
+ stroke_t *s = stroke_alloc(ps.size()); | |
+ for (std::vector<Point>::iterator i = ps.begin(); i != ps.end(); ++i) | |
+ stroke_add_point(s, i->x, i->y); | |
+ stroke_finish(s); | |
+ stroke.reset(s, &stroke_free); | |
+ } | |
+ if (version == 0) return; | |
+ ar & button; | |
+ if (version >= 2) | |
+ ar & trigger; | |
+ if (version < 4 && (!button || trigger == (int)prefs.button.get().button)) | |
+ trigger = 0; | |
+ if (version < 3) | |
+ return; | |
+ ar & timeout; | |
+ if (version < 5) | |
+ return; | |
+ ar & modifiers; | |
+ | |
+ } | |
+ template<class Archive> void save(Archive & ar, const unsigned int version) const { | |
+ std::vector<Point> ps; | |
+ for (unsigned int i = 0; i < size(); i++) | |
+ ps.push_back(points(i)); | |
+ ar & ps; | |
+ ar & button; | |
+ ar & trigger; | |
+ ar & timeout; | |
+ ar & modifiers; | |
+ } | |
public: | |
int trigger; | |
int button; | |
-- | |
2.27.0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maintainer: AppleBloom <rat.o.drat@gmail.com> | |
_pkgname="easystroke" | |
pkgname="$_pkgname-git" | |
pkgver=0.6.0.r9.gf7c1614 | |
pkgrel=3 | |
pkgdesc="Gesture-recognition application for X11." | |
arch=("i686" "x86_64") | |
url="https://github.com/thjaeger/easystroke/wiki" | |
license=("custom") | |
depends=("gtkmm3" "boost-libs" "libxtst" "dbus-glib" "xorg-server") | |
makedepends=("boost" "xorgproto" "intltool" "gettext" "xorg-server-devel" "help2man" "git") | |
provides=("$_pkgname") | |
conflicts=("$_pkgname") | |
install="$_pkgname.install" | |
source=("git+https://github.com/thjaeger/easystroke.git" | |
"sigc.patch" | |
"dont-ignore-xshape-when-saving.patch" | |
"add-toggle-option.patch" | |
"abs.patch" | |
"Move-Stroke-save-and-load-into-header.patch") | |
md5sums=("SKIP" | |
"25fb4b21e36501276285caa788e1acd0" | |
"b9cd799d59ec868371e8e6c538d43bf6" | |
"39013c97c368735967a2f6897c96d614" | |
"cf43fd18e370a37d9e780df97f1cbf92" | |
"a89cda1b52869b448855f7ea796d0e7b") | |
pkgver() { | |
cd "$_pkgname" | |
git describe --long | sed "s/\([^-]*-g\)/r\1/;s/-/./g" | |
} | |
prepare() { | |
cd "$_pkgname" | |
for patch in ../*.patch | |
do | |
patch -i "$patch" | |
done | |
} | |
build() { | |
cd "$_pkgname" | |
make | |
make man | |
} | |
package() { | |
cd "$_pkgname" | |
make PREFIX="/usr" DESTDIR="$pkgdir" install | |
install -Dm644 "$_pkgname.1" "$pkgdir/usr/share/man/man1/$_pkgname.1" | |
install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$_pkgname/LICENSE" | |
} | |
# vim:set ts=2 sw=2 et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mhillenibm's PR made sense to me so I tried it out and it seems to work fine so far. Here's my modified PKGBUILD & patch in case you would like to add it to the
easystroke-git
AUR package. HTH