After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 795510 - SYS_gettid is not available on non-Linux system
SYS_gettid is not available on non-Linux system
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other FreeBSD
: Normal normal
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2018-04-24 15:08 UTC by Ting-Wei Lan
Modified: 2018-04-28 15:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libgimpbase: Find thread ID on FreeBSD with thr_self (2.51 KB, patch)
2018-04-28 13:03 UTC, Ting-Wei Lan
none Details | Review

Description Ting-Wei Lan 2018-04-24 15:08:12 UTC
The man page of gettid says gettid is a Linux-specific system call and it is not portable to other operating systems. GIMP git master cannot be compiled on FreeBSD because gettid is not available:

gmake[2]: Entering directory '/home/lantw44/gnome/build/gimp/libgimpbase'
  CC       gimputils.lo
/home/lantw44/gnome/source/gimp/libgimpbase/gimputils.c:1182:27: error: use of undeclared identifier 'SYS_gettid'
  long     tid = syscall (SYS_gettid);
                          ^
1 error generated.
Comment 1 Jehan 2018-04-24 22:32:23 UTC
Thanks for the report. I searched the web and could not find a good replacement. Anyway that's a bit redundant information, so let's just skip this on FreeBSD. This should be fixed now. Could you check?

commit 106fc9309f2884bb91f2c9c6a17a9aa3e67c359b (HEAD -> master, origin/master, origin/HEAD)
Author: Jehan <jehan@girinstud.io>
Date:   Wed Apr 25 00:19:37 2018 +0200

    Bug 795510 - SYS_gettid is not available on non-Linux system.
    
    I could not find for sure what to use on FreeBSD instead, so let's just
    not get this information there. It is quite useful information to know
    where thread traces were asked from, but it is more important to make
    sure the program can be compiled everywhere. Also we can just check
    which thread has gimp_stack_trace*() calls. Thus it can be seen as
    redundant information in any case.
    
    SYS_gettid is apparently defined as a macro, so let's simply check for
    it being defined.

 libgimpbase/gimputils.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Comment 2 Ting-Wei Lan 2018-04-25 16:40:42 UTC
Thanks, GIMP can be compiled on FreeBSD now. By the way, I just found that there is a system call 'thr_self' which can return current thread ID on FreeBSD.

https://www.freebsd.org/cgi/man.cgi?query=thr_self
Comment 3 Jehan 2018-04-25 16:53:11 UTC
(In reply to Ting-Wei Lan from comment #2)
> Thanks, GIMP can be compiled on FreeBSD now. By the way, I just found that
> there is a system call 'thr_self' which can return current thread ID on
> FreeBSD.
> 
> https://www.freebsd.org/cgi/man.cgi?query=thr_self

We are going to release 2.10, so I'd prefer not to push a commit for BSD blindly (since I won't be actually able to test the patch) because I'd prefer not to break BSD compilation.

But if you can provide a patch with some #if which works on BSD, I'll happily push it. :-)
Comment 4 Ting-Wei Lan 2018-04-28 13:03:49 UTC
Created attachment 371494 [details] [review]
libgimpbase: Find thread ID on FreeBSD with thr_self

This only works on FreeBSD. It seems that each BSD implements pthread
differently so there is no generic solution.
Comment 5 Jehan 2018-04-28 15:21:01 UTC
Thanks. I pushed it.

A small advice for the future: reopen the bug report when you add a patch (or even just if you think the bug fix is still not right yet).
Otherwise we may forget about these later if we don't process them right away. Obviously none wants this. :-D

commit 077036273cefd0206c73dc2df03c7d93b860c1a0 (HEAD -> master, origin/master, origin/HEAD)
Author: Ting-Wei Lan <lantw@src.gnome.org>
Date:   Sat Apr 28 20:57:46 2018 +0800

    libgimpbase: Find thread ID on FreeBSD with thr_self
    
    https://bugzilla.gnome.org/show_bug.cgi?id=795510

 configure.ac            |  3 ++-
 libgimpbase/gimputils.c | 11 +++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)