Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-08 Thread Sebastiaan Couwenberg
Control: fixed -1 2.4.0+dfsg-6
Control: tags -1 pending

Thanks for the advice. I've included both Stevens pthread patch, and an
adaptation of my thr_self patch incorporating the feedback. Updated
packaging is available in the Debian GIS git.

Building an updated package is complicated by the fact that osgearth
fails to build with pbuilder at the moment due to the libav9 transition
[1] which caused libopenscenegraph99 to become uninstallable (#722674,
#720816).

http://release.debian.org/transitions/html/libav9.html

Kind Regards,

Bas

-- 
GnuPG: 0xE88D4AF1 (new) / 0x77A975AD (old)


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-07 Thread Robert Millan
Petr Salinger:
 Is there any lwpid_t which isn't long and defined by kernel headers?
 
 See upstream sources:
 
 http://svnweb.freebsd.org/base/head/sys/sys/_types.h?revision=255219view=markup
 
 
 typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
 
 And compare with
 http://svnweb.freebsd.org/base/head/sys/kern/syscalls.master?revision=255708view=markup
 
 
 432 AUE_NULL STD { int thr_self(long *id); }

Oh, I see. It seems I missunderstood what thr_self() does.

Thanks for clarifying!

-- 
Robert Millan


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-06 Thread Petr Salinger

I think you can avoid this by using the primitive:

lwpid_t tid;
syscall (SYS_thr_self, tid);


There is a mess in kernel interfaces,
the right one is

long  tid;
syscall (SYS_thr_self, tid);

But it holds only for current pthread implementation,
it can be changed anytime.

Petr


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-06 Thread Robert Millan
Petr Salinger:
 I think you can avoid this by using the primitive:

 lwpid_t tid;
 syscall (SYS_thr_self, tid);
 
 There is a mess in kernel interfaces,
 the right one is
 
 long  tid;
 syscall (SYS_thr_self, tid);

Is there any lwpid_t which isn't long and defined by kernel headers?

-- 
Robert Millan


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-06 Thread Petr Salinger

Is there any lwpid_t which isn't long and defined by kernel headers?


See upstream sources:

http://svnweb.freebsd.org/base/head/sys/sys/_types.h?revision=255219view=markup

typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */

And compare with
http://svnweb.freebsd.org/base/head/sys/kern/syscalls.master?revision=255708view=markup

432 AUE_NULL STD { int thr_self(long *id); }


Petr


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-05 Thread Robert Millan
Steven Chamberlain:
 A workaround may be to use pthread_self(), except that the exported
 getCurrentThreadId function has to return 'unsigned int'.  On
 kfreebsd-amd64 a 64-bit pointer to a pthread_t is not absolutely
 guaranteed to be unique if truncated to 32 bits,

I think you can avoid this by using the primitive:

lwpid_t tid;
syscall (SYS_thr_self, tid);

-- 
Robert Millan


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-04 Thread Steven Chamberlain
Source: osgearth
Version: 2.4.0+dfsg-5
Tags: patch
User: debian-...@lists.debian.org
Usertags: kfreebsd
X-Debbugs-Cc: debian-...@lists.debian.org
Severity: serious
Justification: fails to build from source (but built successfully in the
past)

Hi,

osgearth fails to build on kfreebsd-* because it tries to directly use a
Linux-specific syscall:

https://buildd.debian.org/status/package.php?p=osgearthsuite=sid
 cd /«BUILDDIR»/osgearth-2.4.0+dfsg/build/src/osgEarth  /usr/bin/c++   
 -DOSGEARTH_LIBRARY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DTIXML_USE_STL 
 -DosgEarth_EXPORTS -g -O2 -fstack-protector --param=ssp-buffer-size=4 
 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2  -O3 -DNDEBUG -fPIC 
 -isystem /usr/include/qt4 -isystem /usr/include/qt4/QtGui -isystem 
 /usr/include/qt4/QtCore -I/«BUILDDIR»/osgearth-2.4.0+dfsg/src 
 -I/usr/include/gdal -I/usr/include/curl-o 
 CMakeFiles/osgEarth.dir/ThreadingUtils.cpp.o -c 
 /«BUILDDIR»/osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp
 /«BUILDDIR»/osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp: In function 
 'unsigned int osgEarth::Threading::getCurrentThreadId()':
 /«BUILDDIR»/osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp:42:30: error: 
 'SYS_gettid' was not declared in this scope
return (unsigned)::syscall(SYS_gettid);
   ^

osgearth also knows how to use Windows and Mac OS X--specific syscalls
to get a thread ID.  This is not portable and there is nothing directly
equivalent on FreeBSD, see:
http://lists.freebsd.org/pipermail/freebsd-hackers/2010-June/031992.html

A workaround may be to use pthread_self(), except that the exported
getCurrentThreadId function has to return 'unsigned int'.  On
kfreebsd-amd64 a 64-bit pointer to a pthread_t is not absolutely
guaranteed to be unique if truncated to 32 bits, but it is extremely
likely, and certainly better than nothing...

Please refer to attached patch which fixes package build at least.  Thanks!

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 9.0-2-amd64-xenhvm
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Index: osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp
===
--- osgearth-2.4.0+dfsg.orig/src/osgEarth/ThreadingUtils.cpp	2013-04-11 19:07:39.0 +0100
+++ osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp	2013-10-04 22:04:38.898332000 +0100
@@ -20,9 +20,11 @@
 
 #ifdef _WIN32
 extern C unsigned long __stdcall GetCurrentThreadId();
-#else
+#elif defined(__APPLE__) || defined(__LINUX__)
 #   include unistd.h
 #   include sys/syscall.h
+#else
+#   include pthread.h
 #endif
 
 using namespace osgEarth::Threading;
@@ -38,7 +40,10 @@
   return (unsigned)::GetCurrentThreadId();
 #elif __APPLE__
   return ::syscall(SYS_thread_selfid);
-#else
+#elif __LINUX__
   return (unsigned)::syscall(SYS_gettid);
+#else
+  /* :XXX: this truncates to 32 bits, but better than nothing */
+  return (unsigned)pthread_self();
 #endif
 }


Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-04 Thread Sebastiaan Couwenberg
Hi Steven,

On 10/04/2013 11:33 PM, Steven Chamberlain wrote:
 Hi,
 
 osgearth fails to build on kfreebsd-* because it tries to directly use a
 Linux-specific syscall:
 
 https://buildd.debian.org/status/package.php?p=osgearthsuite=sid
 cd /«BUILDDIR»/osgearth-2.4.0+dfsg/build/src/osgEarth  /usr/bin/c++   
 -DOSGEARTH_LIBRARY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DTIXML_USE_STL 
 -DosgEarth_EXPORTS -g -O2 -fstack-protector --param=ssp-buffer-size=4 
 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2  -O3 -DNDEBUG -fPIC 
 -isystem /usr/include/qt4 -isystem /usr/include/qt4/QtGui -isystem 
 /usr/include/qt4/QtCore -I/«BUILDDIR»/osgearth-2.4.0+dfsg/src 
 -I/usr/include/gdal -I/usr/include/curl-o 
 CMakeFiles/osgEarth.dir/ThreadingUtils.cpp.o -c 
 /«BUILDDIR»/osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp
 /«BUILDDIR»/osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp: In function 
 'unsigned int osgEarth::Threading::getCurrentThreadId()':
 /«BUILDDIR»/osgearth-2.4.0+dfsg/src/osgEarth/ThreadingUtils.cpp:42:30: 
 error: 'SYS_gettid' was not declared in this scope
return (unsigned)::syscall(SYS_gettid);
   ^
 
 osgearth also knows how to use Windows and Mac OS X--specific syscalls
 to get a thread ID.  This is not portable and there is nothing directly
 equivalent on FreeBSD, see:
 http://lists.freebsd.org/pipermail/freebsd-hackers/2010-June/031992.html
 
 A workaround may be to use pthread_self(), except that the exported
 getCurrentThreadId function has to return 'unsigned int'.  On
 kfreebsd-amd64 a 64-bit pointer to a pthread_t is not absolutely
 guaranteed to be unique if truncated to 32 bits, but it is extremely
 likely, and certainly better than nothing...
 
 Please refer to attached patch which fixes package build at least.  Thanks!

Thanks for the patch.

Another option I've looked at is to use the undocumented thr_self(2)
syscall, this was recommended over pthread_self() on freebsd-hackers@:
http://lists.freebsd.org/pipermail/freebsd-hackers/2010-June/031991.html

The attached patch is what I was working on, but it breaks the build
even worse than without it.

I'll have another go at making my patch work, otherwise I'll apply your
patch to at least get the package to build. I had changed the package to
linux-any since upstream doesn't support FreeBSD, but that's not really
a fix for the problem.

Kind Regards,

Bas

-- 
GnuPG: 0xE88D4AF1 (new) / 0x77A975AD (old)
Index: osgearth/src/osgEarth/ThreadingUtils.cpp
===
--- osgearth.orig/src/osgEarth/ThreadingUtils.cpp	2013-10-05 00:21:18.0 +0200
+++ osgearth/src/osgEarth/ThreadingUtils.cpp	2013-10-05 01:02:46.0 +0200
@@ -23,6 +23,9 @@
 #else
 #   include unistd.h
 #   include sys/syscall.h
+#   if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#   include sys/thr.h
+#   endif
 #endif
 
 using namespace osgEarth::Threading;
@@ -39,6 +42,12 @@
 #elif __APPLE__
   return ::syscall(SYS_thread_selfid);
 #else
-  return (unsigned)::syscall(SYS_gettid);
+  if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+long lwpid;
+thr_self( lwpid );
+return (unsigned) lwpid;
+  else
+return (unsigned)::syscall(SYS_gettid);
+  endif
 #endif
 }
Index: osgearth/CMakeModules/FindFREEBSD_THR.cmake
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ osgearth/CMakeModules/FindFREEBSD_THR.cmake	2013-10-05 00:21:18.0 +0200
@@ -0,0 +1,14 @@
+execute_process(COMMAND uname -r OUTPUT_VARIABLE FREEBSD_KERNEL_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+set(FREEBSD_KERNEL_HEADERS_DIR /usr/src/kfreebsd-headers-${FREEBSD_KERNEL_RELEASE}/)
+
+FIND_PATH(FREEBSD_THR_INCLUDE_DIR
+  NAMES sys/thr.h
+  PATH_SUFFIXES sys
+  PATHS ${FREEBSD_KERNEL_HEADERS_DIR}
+)
+
+set(FREEBSD_THR_INCLUDE_DIRS ${FREEBSD_THR_INCLUDE_DIR})
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(FREEBSD_THR DEFAULT_MSG FREEBSD_THR_INCLUDE_DIR)
+mark_as_advanced(FREEBSD_THR_INCLUDE_DIR)
Index: osgearth/CMakeLists.txt
===
--- osgearth.orig/CMakeLists.txt	2013-10-05 00:21:18.0 +0200
+++ osgearth/CMakeLists.txt	2013-10-05 00:22:50.0 +0200
@@ -196,6 +196,12 @@
 
 #FIND_PACKAGE(GDAL)
 
+FIND_PACKAGE(FREEBSD_THR)
+
+if(NOT FREEBSD_THR_FOUND)
+message(FATAL_ERROR FreeBSD kernel header sys/thr.h could not be found and is a mandatory dependency)
+endif(NOT FREEBSD_THR_FOUND)
+
 
 # Create bin and lib directories if required
 
Index: osgearth/src/osgEarth/CMakeLists.txt
===
--- osgearth.orig/src/osgEarth/CMakeLists.txt	2013-10-05 00:21:18.0 +0200
+++ osgearth/src/osgEarth/CMakeLists.txt	2013-10-05 02:01:12.0 +0200

Bug#725383: FTBFS on kfreebsd-*: SYS_gettid is Linux-specific

2013-10-04 Thread Ed Maste
 osgearth also knows how to use Windows and Mac OS X--specific syscalls
 to get a thread ID.  This is not portable and there is nothing directly
 equivalent on FreeBSD, see:
 http://lists.freebsd.org/pipermail/freebsd-hackers/2010-June/031992.html

The FreeBSD equivalent is:
int pthread_getthreadid_np(void);


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org