# $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
#
-# Generated on Wed Apr 17 02:10:04 EET DST 2002 [metaconfig 3.0 PL70]
+# Generated on Wed Apr 17 17:49:13 EET DST 2002 [metaconfig 3.0 PL70]
# (with additional metaconfig patches by perlbug@perl.org)
cat >c1$$ <<EOF
esac
;;
threads|threads/shared)
- case "$usethreads" in
- true|$define|y)
- case "$useithreads" in
- $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
- esac
- esac
+ # threads and threads::shared are special cases.
+ # To stop people from asking "Perl 5.8.0 was supposed
+ # to have this new fancy threads implementation but my
+ # perl doesn't have it" and from people trying to
+ # (re)install the threads module using CPAN.pm and
+ # CPAN.pm then offering to reinstall Perl 5.8.0,
+ # the threads.pm and threads/shared.pm will always be
+ # there, croaking informatively ("you need to rebuild
+ # all of Perl with threads, sorry") when threads haven't
+ # been compiled in.
+ # --jhi
+ avail_ext="$avail_ext $xxx"
;;
IPC/SysV|ipc/sysv)
: XXX Do we need a useipcsysv variable here
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
-use Config;
-
-
-unless($Config{'useithreads'} eq 'define') {
- die "We need a perl that is built with USEITHREADS!\n";
-}
-
-
WriteMakefile(
'NAME' => 'threads',
'VERSION_FROM' => 'threads.pm', # finds $VERSION
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
-use Config;
-
-
-unless($Config{'useithreads'} eq 'define') {
- die "We need a perl that is built with USEITHREAD!\n";
-}
-
WriteMakefile(
'NAME' => 'threads::shared',
'VERSION_FROM' => 'shared.pm', # finds $VERSION
package threads::shared;
+
+use 5.007_003;
use strict;
use warnings;
use Config;
+BEGIN {
+ unless ($Config{useithreads}) {
+ my @caller = caller(2);
+ die <<EOF;
+$caller[1] line $caller[2]:
+
+This Perl hasn't been configured and built properly for the threads
+module to work. (The 'useithreads' configuration option hasn't been used.)
+
+Having threads support requires all of Perl and all of the modules in
+the Perl installation to be rebuilt, it is not just a question of adding
+the threads module. (In other words, threaded and non-threaded Perls
+are binary incompatible.)
+
+If you want to the use the threads module, please contact the people
+who built your Perl.
+
+Cannot continue, aborting.
+EOF
+ }
+}
+
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(share cond_wait cond_broadcast cond_signal _refcnt _id _thrcnt);
=head1 SYNOPSIS
+ use threads;
use threads::shared;
my($foo, @foo, %foo);
#include "perl.h"
#include "XSUB.h"
+#ifdef USE_ITHREADS
+
#define SHAREDSvPTR(a) ((a)->sv)
/*
PL_sharehook = &Perl_sharedsv_share;
}
+#endif /* USE_ITHREADS */
+
MODULE = threads::shared PACKAGE = threads::shared::tie
PROTOTYPES: DISABLE
+#ifdef USE_ITHREADS
void
PUSH(shared_sv *shared, ...)
croak("cond_broadcast can only be used on shared values");
COND_BROADCAST(&shared->user_cond);
+#endif /* USE_ITHREADS */
+
BOOT:
{
+#ifdef USE_ITHREADS
Perl_sharedsv_init(aTHX);
+#endif /* USE_ITHREADS */
}
+
+
+
package threads;
-use 5.007_002;
+use 5.007_003;
use strict;
use warnings;
+use Config;
+
+BEGIN {
+ unless ($Config{useithreads}) {
+ my @caller = caller(2);
+ die <<EOF;
+$caller[1] line $caller[2]:
+
+This Perl hasn't been configured and built properly for the threads
+module to work. (The 'useithreads' configuration option hasn't been used.)
+
+Having threads support requires all of Perl and all of the modules in
+the Perl installation to be rebuilt, it is not just a question of adding
+the threads module. (In other words, threaded and non-threaded Perls
+are binary incompatible.)
+
+If you want to the use the threads module, please contact the people
+who built your Perl.
+
+Cannot continue, aborting.
+EOF
+ }
+}
use overload
'==' => \&equal,
#include "perl.h"
#include "XSUB.h"
+#ifdef USE_ITHREADS
+
#ifdef WIN32
#include <windows.h>
#include <win32thread.h>
sv_unmagic(SvRV(sv),PERL_MAGIC_shared_scalar);
}
-
+#endif /* USE_ITHREADS */
MODULE = threads PACKAGE = threads PREFIX = ithread_
PROTOTYPES: DISABLE
+#ifdef USE_ITHREADS
+
void
ithread_new (classname, function_to_call, ...)
char * classname
void
ithread_DESTROY(SV *thread)
+#endif /* USE_ITHREADS */
+
BOOT:
{
+#ifdef USE_ITHREADS
ithread* thread;
PL_perl_destruct_level = 2;
PERL_THREAD_ALLOC_SPECIFIC(self_key);
PERL_THREAD_SETSPECIFIC(self_key,thread);
MUTEX_UNLOCK(&create_destruct_mutex);
+#endif /* USE_ITHREADS */
}