Ticket #815: step-thread.patch
| File step-thread.patch, 13.7 KB (added by fperrad, 4 years ago) |
|---|
-
config/auto/thread.pm
1 # Copyright (C) 2009, Parrot Foundation. 2 # $Id$ 3 4 =head1 NAME 5 6 config/auto/thread.pm - Thread support 7 8 =head1 DESCRIPTION 9 10 Determining if the system has a Thread support. 11 12 =cut 13 14 package auto::thread; 15 16 use strict; 17 use warnings; 18 19 use base qw(Parrot::Configure::Step); 20 21 use Parrot::Configure::Utils ':auto'; 22 23 sub _init { 24 my $self = shift; 25 my %data; 26 $data{description} = q{Does your system has thread}; 27 $data{result} = q{}; 28 return \%data; 29 } 30 31 sub runstep { 32 my ( $self, $conf ) = @_; 33 34 my ( $verbose, $without ) = $conf->options->get( 35 qw| 36 verbose 37 without-threads 38 | 39 ); 40 41 if ($without) { 42 $conf->data->set( HAS_THREADS => 0 ); 43 $self->set_result('no'); 44 return 1; 45 } 46 47 if ($conf->data->get_p5('OSNAME') eq 'MSWin32' 48 || $conf->data->get('i_pthread') eq 'define') { 49 $conf->data->set( HAS_THREADS => 1 ); 50 $self->set_result('yes'); 51 } 52 else { 53 $conf->data->set( HAS_THREADS => 0 ); 54 $self->set_result('no'); 55 } 56 57 return 1; 58 } 59 60 1; 61 62 # Local Variables: 63 # mode: cperl 64 # cperl-indent-level: 4 65 # fill-column: 100 66 # End: 67 # vim: expandtab shiftwidth=4: -
config/gen/platform/generic/threads.h
Property changes on: config\auto\thread.pm ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
9 9 * POSIX threading stuff 10 10 */ 11 11 12 #ifdef PARROT_HAS_HEADER_PTHREAD 12 #ifdef PARROT_HAS_THREADS 13 13 14 # include "parrot/thr_pthread.h" 14 #endif15 15 16 # ifdef PARROT_HAS_HEADER_UNISTD17 # include <unistd.h>18 # ifdef _POSIX_PRIORITY_SCHEDULING19 # define YIELD sched_yield()20 # endif21 # endif16 # ifdef PARROT_HAS_HEADER_UNISTD 17 # include <unistd.h> 18 # ifdef _POSIX_PRIORITY_SCHEDULING 19 # define YIELD sched_yield() 20 # endif 21 # endif /* PARROT_HAS_HEADER_UNISTD */ 22 22 23 #endif /* PARROT_HAS_THREADS */ 24 23 25 #endif /* PARROT_PLATFORM_GENERIC_THREADS_H_GUARD */ 24 26 25 27 /* -
config/gen/platform/win32/threads.h
6 6 #ifndef PARROT_PLATFORM_WIN32_THREADS_H_GUARD 7 7 #define PARROT_PLATFORM_WIN32_THREADS_H_GUARD 8 8 9 #include "parrot/thr_windows.h" 9 #undef CONST 10 #include <windows.h> 11 #undef FASTCALL 12 #include <process.h> 13 #include <limits.h> 10 14 15 #ifdef PARROT_HAS_THREADS 16 17 # include "parrot/thr_windows.h" 18 19 #endif /* PARROT_HAS_THREADS */ 20 21 #undef CONST 22 11 23 #endif /* PARROT_PLATFORM_WIN32_THREADS_H_GUARD */ 12 24 13 25 /* -
include/parrot/atomic.h
19 19 20 20 # define PARROT_HAS_NATIVE_ATOMIC 1 /* we'll redefine later if need be */ 21 21 22 #if (PARROT_HAS_THREADS)22 #ifdef PARROT_HAS_THREADS 23 23 # if defined(PARROT_HAS_I386_GCC_CMPXCHG) 24 24 # include "parrot/atomic/gcc_x86.h" 25 25 # elif defined(PARROT_HAS_PPC_GCC_CMPSET) … … 36 36 void *val; 37 37 } Parrot_atomic_pointer; 38 38 39 typedef Parrot_atomic_integer {39 typedef struct Parrot_atomic_integer { 40 40 INTVAL val; 41 41 } Parrot_atomic_integer; 42 42 43 43 # define PARROT_ATOMIC_PTR_INIT(a) 44 # define PARROT_ATOMIC_PTR_GET(result, (a)) (result) = (a).val44 # define PARROT_ATOMIC_PTR_GET(result, a) (result) = (a).val 45 45 # define PARROT_ATOMIC_PTR_SET(a, b) (a).val = (b) 46 46 47 47 /* a is the Parrot_atomic. … … 65 65 # define PARROT_ATOMIC_PTR_DESTROY(a) 66 66 # define PARROT_ATOMIC_INT_INIT(a) 67 67 # define PARROT_ATOMIC_INT_DESTROY(a) 68 # define PARROT_ATOMIC_INT_GET(result, (a)) (result) = (a).val68 # define PARROT_ATOMIC_INT_GET(result, a) (result) = (a).val 69 69 # define PARROT_ATOMIC_INT_SET(a, value) (a).val = (value) 70 70 # define PARROT_ATOMIC_INT_CAS(result, a, expect, update) \ 71 71 do { \ -
include/parrot/thr_pthread.h
18 18 19 19 # include <pthread.h> 20 20 21 # define PARROT_SYNC_PRIMITIVES_DEFINED22 21 # define LOCK(m) pthread_mutex_lock((pthread_mutex_t*)&(m)) 23 22 # define UNLOCK(m) pthread_mutex_unlock((pthread_mutex_t*)&(m)) 24 23 # define COND_WAIT(c, m) pthread_cond_wait(&(c), &(m)) -
include/parrot/thr_windows.h
13 13 #ifndef PARROT_THR_WINDOWS_H_GUARD 14 14 #define PARROT_THR_WINDOWS_H_GUARD 15 15 16 # undef CONST17 # include <windows.h>18 # undef FASTCALL19 # include <process.h>20 # include <limits.h>21 22 # define PARROT_SYNC_PRIMITIVES_DEFINED23 24 16 typedef CRITICAL_SECTION Parrot_mutex; 25 17 typedef struct Windows_cond 26 18 { … … 131 123 }; 132 124 #endif /* HAVE_STRUCT_TIMESPEC */ 133 125 134 # undef CONST135 136 126 #endif /* PARROT_THR_WINDOWS_H_GUARD */ 137 127 138 128 /* -
include/parrot/thread.h
14 14 #define PARROT_THREAD_H_GUARD 15 15 16 16 # include "parrot/parrot.h" 17 18 # define PARROT_HAS_THREADS 119 17 # include "parrot/atomic.h" 20 18 21 #ifndef PARROT_ SYNC_PRIMITIVES_DEFINED19 #ifndef PARROT_HAS_THREADS 22 20 23 # undef PARROT_HAS_THREADS24 # define PARROT_HAS_THREADS 025 26 21 # define LOCK(m) 27 22 # define UNLOCK(m) 28 23 # define COND_WAIT(c, m) … … 59 54 }; 60 55 # endif /* _STRUCT_TIMESPEC */ 61 56 62 #endif /* PARROT_ SYNC_PRIMITIVES_DEFINED*/57 #endif /* PARROT_HAS_THREADS */ 63 58 64 59 #ifndef YIELD 65 60 # define YIELD -
lib/Parrot/Configure/Options/Conf.pm
96 96 --execcapable Use JIT to emit a native executable 97 97 --gc=(type) Determine the type of garbage collection 98 98 type=(gc|libc|malloc|malloc-trace) default is gc 99 --without-threads Build parrot without thread support 99 100 100 101 External Library Options: 101 102 -
lib/Parrot/Configure/Options/Conf/Shared.pm
72 72 without-gdbm 73 73 without-gettext 74 74 without-gmp 75 without-icu 75 76 without-opengl 76 77 without-pcre 77 without- icu78 without-threads 78 79 yacc 79 80 }; 80 81 -
lib/Parrot/Configure/Step/List.pm
52 52 auto::socklen_t 53 53 auto::neg_0 54 54 auto::env 55 auto::thread 55 56 auto::gmp 56 57 auto::readline 57 58 auto::gdbm -
MANIFEST
1 1 # ex: set ro: 2 2 # $Id$ 3 3 # 4 # generated by tools/dev/mk_manifest_and_skip.pl Thu Jul 2 17:10:262009 UT4 # generated by tools/dev/mk_manifest_and_skip.pl Sun Jul 5 10:40:22 2009 UT 5 5 # 6 6 # See below for documentation on the format of this file. 7 7 # … … 289 289 config/auto/snprintf.pm [] 290 290 config/auto/snprintf/test_c.in [] 291 291 config/auto/socklen_t.pm [] 292 config/auto/thread.pm [] 292 293 config/auto/va_ptr.pm [] 293 294 config/auto/va_ptr/test_c.in [] 294 295 config/auto/warnings.pm [] … … 1980 1981 t/steps/auto_sizes-01.t [test] 1981 1982 t/steps/auto_snprintf-01.t [test] 1982 1983 t/steps/auto_socklen_t-01.t [test] 1984 t/steps/auto_thread-01.t [test] 1983 1985 t/steps/auto_va_ptr-01.t [test] 1984 1986 t/steps/auto_warnings-01.t [test] 1985 1987 t/steps/gen_call_list-01.t [test] -
src/events.c
1351 1351 Parrot_sleep_on_event(PARROT_INTERP, FLOATVAL t, ARGIN_NULLOK(opcode_t *next)) 1352 1352 { 1353 1353 ASSERT_ARGS(Parrot_sleep_on_event) 1354 #if PARROT_HAS_THREADS1354 #ifdef PARROT_HAS_THREADS 1355 1355 1356 1356 if (interp->sleeping) 1357 1357 fprintf(stderr, "nested sleep might not work\n"); -
src/scheduler.c
1005 1005 Parrot_cx_schedule_sleep(PARROT_INTERP, FLOATVAL time, ARGIN_NULLOK(opcode_t *next)) 1006 1006 { 1007 1007 ASSERT_ARGS(Parrot_cx_schedule_sleep) 1008 #if PARROT_HAS_THREADS1008 #ifdef PARROT_HAS_THREADS 1009 1009 Parrot_cond condition; 1010 1010 Parrot_mutex lock; 1011 1011 const FLOATVAL timer_end = time + Parrot_floatval_time(); -
t/pmc/threads.t
7 7 use lib qw( . lib ../lib ../../lib ); 8 8 use Test::More; 9 9 use Parrot::Test; 10 use Parrot::Config; 10 11 11 12 =head1 NAME 12 13 … … 23 24 24 25 =cut 25 26 26 my %platforms = map { $_ => 1 } qw/27 aix28 cygwin29 dec_osf30 freebsd31 hpux32 irix33 linux34 netbsd35 openbsd36 solaris37 MSWin3238 darwin39 /;40 41 27 if ( $^O eq "cygwin" ) { 42 28 my @uname = split / /, qx'uname -v'; 43 29 … … 46 32 exit; 47 33 } 48 34 } 49 if ( $ platforms{$^O} ) {35 if ( $PConfig{HAS_THREADS} ) { 50 36 plan tests => 14; 51 37 } 52 38 else { 53 plan skip_all => "No threading yet or test not enabled for '$^O'"; 54 55 # plan skip_all => "Needs COPY for argument passing"; 39 plan skip_all => "No threading enabled for '$^O'"; 56 40 } 57 41 58 42 pasm_output_is( <<'CODE', <<'OUTPUT', "interp identity" ); -
t/pmc/timer.t
7 7 use lib qw( . lib ../lib ../../lib ); 8 8 use Test::More; 9 9 use Parrot::Test tests => 6; 10 use Parrot::Config; 10 11 11 12 =head1 NAME 12 13 … … 24 25 25 26 $ENV{TEST_PROG_ARGS} ||= ''; 26 27 27 my %platforms = map { $_ => 1 } qw/28 aix29 cygwin30 darwin31 dec_osf32 freebsd33 hpux34 irix35 linux36 openbsd37 MSWin3238 /;39 40 28 pasm_output_is( <<'CODE', <<'OUT', "Timer setup" ); 41 29 .include "timer.pasm" 42 30 new P0, ['Timer'] … … 100 88 OUT 101 89 102 90 SKIP: { 103 skip( "No thread config yet", 3 ) unless ( $platforms{$^O} );91 skip( "No thread enabled", 3 ) unless ( $PConfig{HAS_THREADS} ); 104 92 105 93 pasm_output_like( <<'CODE', <<'OUT', "Timer setup - initializer/start" ); 106 94 .include "timer.pasm" -
t/steps/auto_thread-01.t
1 #! perl 2 # Copyright (C) 2009, Parrot Foundation. 3 # $Id$ 4 5 use strict; 6 use warnings; 7 use Test::More tests => 8; 8 use Carp; 9 use lib qw( lib t/configure/testlib ); 10 use_ok('config::auto::thread'); 11 use Parrot::Configure; 12 use Parrot::Configure::Options qw( process_options ); 13 use Parrot::Configure::Test qw( 14 test_step_thru_runstep 15 rerun_defaults_for_testing 16 test_step_constructor_and_description 17 ); 18 use IO::CaptureOutput qw( capture ); 19 20 ########## --without-crypto ########## 21 22 my ($args, $step_list_ref) = process_options( 23 { 24 argv => [ q{--without-threads} ], 25 mode => q{configure}, 26 } 27 ); 28 29 my $conf = Parrot::Configure->new; 30 31 my $pkg = q{auto::thread}; 32 33 $conf->add_steps($pkg); 34 35 my $serialized = $conf->pcfreeze(); 36 37 $conf->options->set( %{$args} ); 38 my $step = test_step_constructor_and_description($conf); 39 my $ret = $step->runstep($conf); 40 ok( $ret, "runstep() returned true value" ); 41 is($conf->data->get('HAS_THREADS'), 0, 42 "Got expected value for 'HAS_THREADS'"); 43 is($step->result(), q{no}, "Expected result was set"); 44 45 $conf->replenish($serialized); 46 47 pass("Completed all tests in $0"); 48 49 ################### DOCUMENTATION ################### 50 51 =head1 NAME 52 53 auto_thread-01.t - test auto::thread 54 55 =head1 SYNOPSIS 56 57 % prove t/steps/auto_thread-01.t 58 59 =head1 DESCRIPTION 60 61 The files in this directory test functionality used by F<Configure.pl>. 62 63 The tests in this file test auto::thread. 64 65 =head1 HISTORY 66 67 Mostly taken from F<t/steps/auto_gdbm-01.t>. 68 69 =head1 AUTHOR 70 71 Francois Perrad 72 73 =head1 SEE ALSO 74 75 config::auto::thread, F<Configure.pl>. 76 77 =cut 78 79 # Local Variables: 80 # mode: cperl 81 # cperl-indent-level: 4 82 # fill-column: 100 83 # End: 84 # vim: expandtab shiftwidth=4:
