Index: config/auto/thread.pm =================================================================== --- config/auto/thread.pm (revision 0) +++ config/auto/thread.pm (revision 0) @@ -0,0 +1,67 @@ +# Copyright (C) 2009, Parrot Foundation. +# $Id$ + +=head1 NAME + +config/auto/thread.pm - Thread support + +=head1 DESCRIPTION + +Determining if the system has a Thread support. + +=cut + +package auto::thread; + +use strict; +use warnings; + +use base qw(Parrot::Configure::Step); + +use Parrot::Configure::Utils ':auto'; + +sub _init { + my $self = shift; + my %data; + $data{description} = q{Does your system has thread}; + $data{result} = q{}; + return \%data; +} + +sub runstep { + my ( $self, $conf ) = @_; + + my ( $verbose, $without ) = $conf->options->get( + qw| + verbose + without-threads + | + ); + + if ($without) { + $conf->data->set( HAS_THREADS => 0 ); + $self->set_result('no'); + return 1; + } + + if ($conf->data->get_p5('OSNAME') eq 'MSWin32' + || $conf->data->get('i_pthread') eq 'define') { + $conf->data->set( HAS_THREADS => 1 ); + $self->set_result('yes'); + } + else { + $conf->data->set( HAS_THREADS => 0 ); + $self->set_result('no'); + } + + return 1; +} + +1; + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Property changes on: config\auto\thread.pm ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Index: config/gen/platform/generic/threads.h =================================================================== --- config/gen/platform/generic/threads.h (revision 39897) +++ config/gen/platform/generic/threads.h (working copy) @@ -9,17 +9,19 @@ * POSIX threading stuff */ -#ifdef PARROT_HAS_HEADER_PTHREAD +#ifdef PARROT_HAS_THREADS + # include "parrot/thr_pthread.h" -#endif -#ifdef PARROT_HAS_HEADER_UNISTD -# include -# ifdef _POSIX_PRIORITY_SCHEDULING -# define YIELD sched_yield() -# endif -#endif +# ifdef PARROT_HAS_HEADER_UNISTD +# include +# ifdef _POSIX_PRIORITY_SCHEDULING +# define YIELD sched_yield() +# endif +# endif /* PARROT_HAS_HEADER_UNISTD */ +#endif /* PARROT_HAS_THREADS */ + #endif /* PARROT_PLATFORM_GENERIC_THREADS_H_GUARD */ /* Index: config/gen/platform/win32/threads.h =================================================================== --- config/gen/platform/win32/threads.h (revision 39897) +++ config/gen/platform/win32/threads.h (working copy) @@ -6,8 +6,20 @@ #ifndef PARROT_PLATFORM_WIN32_THREADS_H_GUARD #define PARROT_PLATFORM_WIN32_THREADS_H_GUARD -#include "parrot/thr_windows.h" +#undef CONST +#include +#undef FASTCALL +#include +#include +#ifdef PARROT_HAS_THREADS + +# include "parrot/thr_windows.h" + +#endif /* PARROT_HAS_THREADS */ + +#undef CONST + #endif /* PARROT_PLATFORM_WIN32_THREADS_H_GUARD */ /* Index: include/parrot/atomic.h =================================================================== --- include/parrot/atomic.h (revision 39897) +++ include/parrot/atomic.h (working copy) @@ -19,7 +19,7 @@ # define PARROT_HAS_NATIVE_ATOMIC 1 /* we'll redefine later if need be */ -#if (PARROT_HAS_THREADS) +#ifdef PARROT_HAS_THREADS # if defined(PARROT_HAS_I386_GCC_CMPXCHG) # include "parrot/atomic/gcc_x86.h" # elif defined(PARROT_HAS_PPC_GCC_CMPSET) @@ -36,12 +36,12 @@ void *val; } Parrot_atomic_pointer; -typedef Parrot_atomic_integer { +typedef struct Parrot_atomic_integer { INTVAL val; } Parrot_atomic_integer; # define PARROT_ATOMIC_PTR_INIT(a) -# define PARROT_ATOMIC_PTR_GET(result, (a)) (result) = (a).val +# define PARROT_ATOMIC_PTR_GET(result, a) (result) = (a).val # define PARROT_ATOMIC_PTR_SET(a, b) (a).val = (b) /* a is the Parrot_atomic. @@ -65,7 +65,7 @@ # define PARROT_ATOMIC_PTR_DESTROY(a) # define PARROT_ATOMIC_INT_INIT(a) # define PARROT_ATOMIC_INT_DESTROY(a) -# define PARROT_ATOMIC_INT_GET(result, (a)) (result) = (a).val +# define PARROT_ATOMIC_INT_GET(result, a) (result) = (a).val # define PARROT_ATOMIC_INT_SET(a, value) (a).val = (value) # define PARROT_ATOMIC_INT_CAS(result, a, expect, update) \ do { \ Index: include/parrot/thr_pthread.h =================================================================== --- include/parrot/thr_pthread.h (revision 39897) +++ include/parrot/thr_pthread.h (working copy) @@ -18,7 +18,6 @@ # include -# define PARROT_SYNC_PRIMITIVES_DEFINED # define LOCK(m) pthread_mutex_lock((pthread_mutex_t*)&(m)) # define UNLOCK(m) pthread_mutex_unlock((pthread_mutex_t*)&(m)) # define COND_WAIT(c, m) pthread_cond_wait(&(c), &(m)) Index: include/parrot/thr_windows.h =================================================================== --- include/parrot/thr_windows.h (revision 39897) +++ include/parrot/thr_windows.h (working copy) @@ -13,14 +13,6 @@ #ifndef PARROT_THR_WINDOWS_H_GUARD #define PARROT_THR_WINDOWS_H_GUARD -# undef CONST -# include -# undef FASTCALL -# include -# include - -# define PARROT_SYNC_PRIMITIVES_DEFINED - typedef CRITICAL_SECTION Parrot_mutex; typedef struct Windows_cond { @@ -131,8 +123,6 @@ }; #endif /* HAVE_STRUCT_TIMESPEC */ -# undef CONST - #endif /* PARROT_THR_WINDOWS_H_GUARD */ /* Index: include/parrot/thread.h =================================================================== --- include/parrot/thread.h (revision 39897) +++ include/parrot/thread.h (working copy) @@ -14,15 +14,10 @@ #define PARROT_THREAD_H_GUARD # include "parrot/parrot.h" - -# define PARROT_HAS_THREADS 1 # include "parrot/atomic.h" -#ifndef PARROT_SYNC_PRIMITIVES_DEFINED +#ifndef PARROT_HAS_THREADS -# undef PARROT_HAS_THREADS -# define PARROT_HAS_THREADS 0 - # define LOCK(m) # define UNLOCK(m) # define COND_WAIT(c, m) @@ -59,7 +54,7 @@ }; # endif /* _STRUCT_TIMESPEC */ -#endif /* PARROT_SYNC_PRIMITIVES_DEFINED */ +#endif /* PARROT_HAS_THREADS */ #ifndef YIELD # define YIELD Index: lib/Parrot/Configure/Options/Conf.pm =================================================================== --- lib/Parrot/Configure/Options/Conf.pm (revision 39897) +++ lib/Parrot/Configure/Options/Conf.pm (working copy) @@ -96,6 +96,7 @@ --execcapable Use JIT to emit a native executable --gc=(type) Determine the type of garbage collection type=(gc|libc|malloc|malloc-trace) default is gc + --without-threads Build parrot without thread support External Library Options: Index: lib/Parrot/Configure/Options/Conf/Shared.pm =================================================================== --- lib/Parrot/Configure/Options/Conf/Shared.pm (revision 39897) +++ lib/Parrot/Configure/Options/Conf/Shared.pm (working copy) @@ -72,9 +72,10 @@ without-gdbm without-gettext without-gmp + without-icu without-opengl without-pcre - without-icu + without-threads yacc }; Index: lib/Parrot/Configure/Step/List.pm =================================================================== --- lib/Parrot/Configure/Step/List.pm (revision 39897) +++ lib/Parrot/Configure/Step/List.pm (working copy) @@ -52,6 +52,7 @@ auto::socklen_t auto::neg_0 auto::env + auto::thread auto::gmp auto::readline auto::gdbm Index: MANIFEST =================================================================== --- MANIFEST (revision 39897) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Thu Jul 2 17:10:26 2009 UT +# generated by tools/dev/mk_manifest_and_skip.pl Sun Jul 5 10:40:22 2009 UT # # See below for documentation on the format of this file. # @@ -289,6 +289,7 @@ config/auto/snprintf.pm [] config/auto/snprintf/test_c.in [] config/auto/socklen_t.pm [] +config/auto/thread.pm [] config/auto/va_ptr.pm [] config/auto/va_ptr/test_c.in [] config/auto/warnings.pm [] @@ -1980,6 +1981,7 @@ t/steps/auto_sizes-01.t [test] t/steps/auto_snprintf-01.t [test] t/steps/auto_socklen_t-01.t [test] +t/steps/auto_thread-01.t [test] t/steps/auto_va_ptr-01.t [test] t/steps/auto_warnings-01.t [test] t/steps/gen_call_list-01.t [test] Index: src/events.c =================================================================== --- src/events.c (revision 39897) +++ src/events.c (working copy) @@ -1351,7 +1351,7 @@ Parrot_sleep_on_event(PARROT_INTERP, FLOATVAL t, ARGIN_NULLOK(opcode_t *next)) { ASSERT_ARGS(Parrot_sleep_on_event) -#if PARROT_HAS_THREADS +#ifdef PARROT_HAS_THREADS if (interp->sleeping) fprintf(stderr, "nested sleep might not work\n"); Index: src/scheduler.c =================================================================== --- src/scheduler.c (revision 39897) +++ src/scheduler.c (working copy) @@ -1005,7 +1005,7 @@ Parrot_cx_schedule_sleep(PARROT_INTERP, FLOATVAL time, ARGIN_NULLOK(opcode_t *next)) { ASSERT_ARGS(Parrot_cx_schedule_sleep) -#if PARROT_HAS_THREADS +#ifdef PARROT_HAS_THREADS Parrot_cond condition; Parrot_mutex lock; const FLOATVAL timer_end = time + Parrot_floatval_time(); Index: t/pmc/threads.t =================================================================== --- t/pmc/threads.t (revision 39897) +++ t/pmc/threads.t (working copy) @@ -7,6 +7,7 @@ use lib qw( . lib ../lib ../../lib ); use Test::More; use Parrot::Test; +use Parrot::Config; =head1 NAME @@ -23,21 +24,6 @@ =cut -my %platforms = map { $_ => 1 } qw/ - aix - cygwin - dec_osf - freebsd - hpux - irix - linux - netbsd - openbsd - solaris - MSWin32 - darwin - /; - if ( $^O eq "cygwin" ) { my @uname = split / /, qx'uname -v'; @@ -46,13 +32,11 @@ exit; } } -if ( $platforms{$^O} ) { +if ( $PConfig{HAS_THREADS} ) { plan tests => 14; } else { - plan skip_all => "No threading yet or test not enabled for '$^O'"; - - # plan skip_all => "Needs COPY for argument passing"; + plan skip_all => "No threading enabled for '$^O'"; } pasm_output_is( <<'CODE', <<'OUTPUT', "interp identity" ); Index: t/pmc/timer.t =================================================================== --- t/pmc/timer.t (revision 39897) +++ t/pmc/timer.t (working copy) @@ -7,6 +7,7 @@ use lib qw( . lib ../lib ../../lib ); use Test::More; use Parrot::Test tests => 6; +use Parrot::Config; =head1 NAME @@ -24,19 +25,6 @@ $ENV{TEST_PROG_ARGS} ||= ''; -my %platforms = map { $_ => 1 } qw/ - aix - cygwin - darwin - dec_osf - freebsd - hpux - irix - linux - openbsd - MSWin32 -/; - pasm_output_is( <<'CODE', <<'OUT', "Timer setup" ); .include "timer.pasm" new P0, ['Timer'] @@ -100,7 +88,7 @@ OUT SKIP: { - skip( "No thread config yet", 3 ) unless ( $platforms{$^O} ); + skip( "No thread enabled", 3 ) unless ( $PConfig{HAS_THREADS} ); pasm_output_like( <<'CODE', <<'OUT', "Timer setup - initializer/start" ); .include "timer.pasm" Index: t/steps/auto_thread-01.t =================================================================== --- t/steps/auto_thread-01.t (revision 0) +++ t/steps/auto_thread-01.t (revision 0) @@ -0,0 +1,84 @@ +#! perl +# Copyright (C) 2009, Parrot Foundation. +# $Id$ + +use strict; +use warnings; +use Test::More tests => 8; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::auto::thread'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( + test_step_thru_runstep + rerun_defaults_for_testing + test_step_constructor_and_description +); +use IO::CaptureOutput qw( capture ); + +########## --without-crypto ########## + +my ($args, $step_list_ref) = process_options( + { + argv => [ q{--without-threads} ], + mode => q{configure}, + } +); + +my $conf = Parrot::Configure->new; + +my $pkg = q{auto::thread}; + +$conf->add_steps($pkg); + +my $serialized = $conf->pcfreeze(); + +$conf->options->set( %{$args} ); +my $step = test_step_constructor_and_description($conf); +my $ret = $step->runstep($conf); +ok( $ret, "runstep() returned true value" ); +is($conf->data->get('HAS_THREADS'), 0, + "Got expected value for 'HAS_THREADS'"); +is($step->result(), q{no}, "Expected result was set"); + +$conf->replenish($serialized); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +auto_thread-01.t - test auto::thread + +=head1 SYNOPSIS + + % prove t/steps/auto_thread-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F. + +The tests in this file test auto::thread. + +=head1 HISTORY + +Mostly taken from F. + +=head1 AUTHOR + +Francois Perrad + +=head1 SEE ALSO + +config::auto::thread, F. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Property changes on: t\steps\auto_thread-01.t ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native