Author: marvin
Date: Sun Jan 1 22:39:24 2012
New Revision: 1226311
URL: http://svn.apache.org/viewvc?rev=1226311&view=rev
Log:
LUCY-195 Avoid pthreads if possible on OpenBSD.
Linking with the -lpthread flag on single-threaded Perls built on OpenBSD
causes strange test failures where some tests fail to produce output. On such
systems, avoid pthreads entirely.
Modified:
incubator/lucy/branches/0.3/ (props changed)
incubator/lucy/branches/0.3/core/Lucy/Util/Atomic.cfh
incubator/lucy/branches/0.3/perl/buildlib/Lucy/Build.pm
Propchange: incubator/lucy/branches/0.3/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan 1 22:39:24 2012
@@ -1 +1 @@
-/incubator/lucy/trunk:1225600-1225601,1226190-1226191,1226199
+/incubator/lucy/trunk:1225600-1225601,1226190-1226191,1226199,1226310
Modified: incubator/lucy/branches/0.3/core/Lucy/Util/Atomic.cfh
URL:
http://svn.apache.org/viewvc/incubator/lucy/branches/0.3/core/Lucy/Util/Atomic.cfh?rev=1226311&r1=1226310&r2=1226311&view=diff
==============================================================================
--- incubator/lucy/branches/0.3/core/Lucy/Util/Atomic.cfh (original)
+++ incubator/lucy/branches/0.3/core/Lucy/Util/Atomic.cfh Sun Jan 1 22:39:24
2012
@@ -29,8 +29,22 @@ __C__
static CHY_INLINE chy_bool_t
lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value);
+/************************** Single threaded *******************************/
+#ifdef LUCY_NOTHREADS
+
+static CHY_INLINE chy_bool_t
+lucy_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
+ if (*target == old_value) {
+ *target = new_value;
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
/************************** Mac OS X 10.4 and later ***********************/
-#ifdef CHY_HAS_OSATOMIC_CAS_PTR
+#elif defined(CHY_HAS_OSATOMIC_CAS_PTR)
#include <libkern/OSAtomic.h>
static CHY_INLINE chy_bool_t
Modified: incubator/lucy/branches/0.3/perl/buildlib/Lucy/Build.pm
URL:
http://svn.apache.org/viewvc/incubator/lucy/branches/0.3/perl/buildlib/Lucy/Build.pm?rev=1226311&r1=1226310&r2=1226311&view=diff
==============================================================================
--- incubator/lucy/branches/0.3/perl/buildlib/Lucy/Build.pm (original)
+++ incubator/lucy/branches/0.3/perl/buildlib/Lucy/Build.pm Sun Jan 1 22:39:24
2012
@@ -81,6 +81,9 @@ BEGIN { unshift @PATH, rel2abs( getcwd()
sub extra_ccflags {
my $self = shift;
my $gcc_flags = '-std=gnu99 -D_GNU_SOURCE ';
+ if ( $Config{osname} =~ /openbsd/i && !$Config{usethreads} ) {
+ $gcc_flags .= '-DLUCY_NOTHREADS ';
+ }
if ( defined $ENV{LUCY_VALGRIND} ) {
return "$gcc_flags -DLUCY_VALGRIND -fno-inline-functions ";
}
@@ -621,7 +624,10 @@ sub ACTION_compile_custom_xs {
my $lib_file = catfile( $archdir, "Lucy.$Config{dlext}" );
if ( !$self->up_to_date( [ @objects, $AUTOGEN_DIR ], $lib_file ) ) {
# TODO: use Charmonizer to determine whether pthreads are userland.
- my $link_flags = $Config{osname} =~ /openbsd/i ? '-lpthread ' : '';
+ my $link_flags = '';
+ if ( $Config{osname} =~ /openbsd/i && $Config{usethreads} ) {
+ $link_flags = '-lpthread ';
+ }
$cbuilder->link(
module_name => 'Lucy',
objects => \@objects,