From: David Mitchell Date: Thu, 2 Apr 2009 22:09:01 +0000 (+0100) Subject: document PERL_SYS_INIT, PERL_SYS_TERM and that they should only be used once X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eb53357261107ec40e8c517666330fc71276b6fb;p=p5sagit%2Fp5-mst-13.2.git document PERL_SYS_INIT, PERL_SYS_TERM and that they should only be used once --- diff --git a/perl.h b/perl.h index c890e1f..fb0c8b6 100644 --- a/perl.h +++ b/perl.h @@ -2680,6 +2680,25 @@ typedef struct clone_params CLONE_PARAMS; # define PERL_SYS_INIT3_BODY(argvp,argcp,envp) PERL_SYS_INIT_BODY(argvp,argcp) #endif +/* +=for apidoc Am|void|PERL_SYS_INIT|int argc|char** argv +Provides system-specific tune up of the C runtime environment necessary to +run Perl interpreters. This should be called only once, before creating +any Perl interpreters. + +=for apidoc Am|void|PERL_SYS_INIT3|int argc|char** argv|char** env +Provides system-specific tune up of the C runtime environment necessary to +run Perl interpreters. This should be called only once, before creating +any Perl interpreters. + +=for apidoc Am|void|PERL_SYS_TERM| +Provides system-specific clean up of the C runtime environment after +running Perl interpreters. This should be called only once, after +freeing any remaining Perl interpreters. + +=cut + */ + #define PERL_SYS_INIT(argc, argv) Perl_sys_init(argc, argv) #define PERL_SYS_INIT3(argc, argv, env) Perl_sys_init3(argc, argv, env) #define PERL_SYS_TERM() Perl_sys_term() diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 0687604..7498939 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -1207,6 +1207,50 @@ Found in file mathoms.c =back +=head1 Functions in file perl.h + + +=over 8 + +=item PERL_SYS_INIT +X + +Provides system-specific tune up of the C runtime environment necessary to +run Perl interpreters. This should be called only once, before creating +any Perl interpreters. + + void PERL_SYS_INIT(int argc, char** argv) + +=for hackers +Found in file perl.h + +=item PERL_SYS_INIT3 +X + +Provides system-specific tune up of the C runtime environment necessary to +run Perl interpreters. This should be called only once, before creating +any Perl interpreters. + + void PERL_SYS_INIT3(int argc, char** argv, char** env) + +=for hackers +Found in file perl.h + +=item PERL_SYS_TERM +X + +Provides system-specific clean up of the C runtime environment after +running Perl interpreters. This should be called only once, after +freeing any remaining Perl interpreters. + + void PERL_SYS_TERM() + +=for hackers +Found in file perl.h + + +=back + =head1 Functions in file pp_ctl.c diff --git a/pod/perlembed.pod b/pod/perlembed.pod index 39364eb..161e1ce 100644 --- a/pod/perlembed.pod +++ b/pod/perlembed.pod @@ -196,11 +196,16 @@ version of I containing the essentials of embedding: Notice that we don't use the C pointer. Normally handed to C as its final argument, C here is replaced by -C, which means that the current environment will be used. The macros -PERL_SYS_INIT3() and PERL_SYS_TERM() provide system-specific tune up -of the C runtime environment necessary to run Perl interpreters; since -PERL_SYS_INIT3() may change C, it may be more appropriate to provide -C as an argument to perl_parse(). +C, which means that the current environment will be used. + +The macros PERL_SYS_INIT3() and PERL_SYS_TERM() provide system-specific +tune up of the C runtime environment necessary to run Perl interpreters; +they should only be called once regardless of how many interpreters you +create or destroy. Call PERL_SYS_INIT3() before you create your first +interpreter, and PERL_SYS_TERM() after you free your last interpreter. + +Since PERL_SYS_INIT3() may change C, it may be more appropriate to +provide C as an argument to perl_parse(). Now compile this program (I'll call it I) into an executable: