\&
\& #include "EXTERN.h"
\& #define PERL_IN_MINIPERLMAIN_C
\& #include "perl.h"
\&
\& static char *me;
\& HMODULE handle;
\&
\& static void
\& die_with(char *msg1, char *msg2, char *msg3, char *msg4)
\& {
\& ULONG c;
\& char *s = " error: ";
\&
\& DosWrite(2, me, strlen(me), &c);
\& DosWrite(2, s, strlen(s), &c);
\& DosWrite(2, msg1, strlen(msg1), &c);
\& DosWrite(2, msg2, strlen(msg2), &c);
\& DosWrite(2, msg3, strlen(msg3), &c);
\& DosWrite(2, msg4, strlen(msg4), &c);
\& DosWrite(2, "\er\en", 2, &c);
\& exit(255);
\& }
\&
\& typedef ULONG (*fill_extLibpath_t)(int type,
\& char *pre,
\& char *post,
\& int replace,
\& char *msg);
\& typedef int (*main_t)(int type, char *argv[], char *env[]);
\& typedef int (*handler_t)(void* data, int which);
\&
\& #ifndef PERL_DLL_BASENAME
\& # define PERL_DLL_BASENAME "perl"
\& #endif
\&
\& static HMODULE
\& load_perl_dll(char *basename)
\& {
\& char buf[300], fail[260];
\& STRLEN l, dirl;
\& fill_extLibpath_t f;
\& ULONG rc_fullname;
\& HMODULE handle, handle1;
\&
\& if (_execname(buf, sizeof(buf) \- 13) != 0)
\& die_with("Can\*(Aqt find full path: ", strerror(errno), "", "");
\& /* XXXX Fill \*(Aqme\*(Aq with new value */
\& l = strlen(buf);
\& while (l && buf[l\-1] != \*(Aq/\*(Aq && buf[l\-1] != \*(Aq\e\e\*(Aq)
\& l\-\-;
\& dirl = l \- 1;
\& strcpy(buf + l, basename);
\& l += strlen(basename);
\& strcpy(buf + l, ".dll");
\& if ( (rc_fullname = DosLoadModule(fail, sizeof fail, buf, &handle))
\& != 0
\& && DosLoadModule(fail, sizeof fail, basename, &handle) != 0 )
\& die_with("Can\*(Aqt load DLL ", buf, "", "");
\& if (rc_fullname)
\& return handle; /* was loaded with short name; all is fine */
\& if (DosQueryProcAddr(handle, 0, "fill_extLibpath", (PFN*)&f))
\& die_with(buf,
\& ": DLL exports no symbol ",
\& "fill_extLibpath",
\& "");
\& buf[dirl] = 0;
\& if (f(0 /*BEGINLIBPATH*/, buf /* prepend */, NULL /* append */,
\& 0 /* keep old value */, me))
\& die_with(me, ": prepending BEGINLIBPATH", "", "");
\& if (DosLoadModule(fail, sizeof fail, basename, &handle1) != 0)
\& die_with(me,
\& ": finding perl DLL again via BEGINLIBPATH",
\& "",
\& "");
\& buf[dirl] = \*(Aq\e\e\*(Aq;
\& if (handle1 != handle) {
\& if (DosQueryModuleName(handle1, sizeof(fail), fail))
\& strcpy(fail, "???");
\& die_with(buf,
\& ":\en\etperl DLL via BEGINLIBPATH is different: \en\et",
\& fail,
\& "\en\etYou may need to manipulate global BEGINLIBPATH"
\& " and LIBPATHSTRICT"
\& "\en\etso that the other copy is loaded via"
\& BEGINLIBPATH.");
\& }
\& return handle;
\& }
\&
\& int
\& main(int argc, char **argv, char **env)
\& {
\& main_t f;
\& handler_t h;
\&
\& me = argv[0];
\& /**/
\& handle = load_perl_dll(PERL_DLL_BASENAME);
\&
\& if (DosQueryProcAddr(handle,
\& 0,
\& "Perl_OS2_handler_install",
\& (PFN*)&h))
\& die_with(PERL_DLL_BASENAME,
\& ": DLL exports no symbol ",
\& "Perl_OS2_handler_install",
\& "");
\& if ( !h((void *)"~installprefix", Perlos2_handler_perllib_from)
\& || !h((void *)"~dll", Perlos2_handler_perllib_to)
\& || !h((void *)"~dll/sh/ksh.exe", Perlos2_handler_perl_sh) )
\& die_with(PERL_DLL_BASENAME,
\& ": Can\*(Aqt install @INC manglers",
\& "",
\& "");
\& if (DosQueryProcAddr(handle, 0, "dll_perlmain", (PFN*)&f))
\& die_with(PERL_DLL_BASENAME,
\& ": DLL exports no symbol ",
\& "dll_perlmain",
\& "");
\& return f(argc, argv, env);
\& }
.Ve
.SH "Build FAQ"
.IX Header "Build FAQ"
.ie n .SS "Some ""/"" became ""\e"" in pdksh."
.el .SS "Some \f(CW/\fP became \f(CW\e\fP in pdksh."
.IX Subsection "Some / became in pdksh."
You have a very old pdksh. See \*(L"Prerequisites\*(R".
.ie n .SS "\*(Aqerrno\*(Aq \- unresolved external"
.el .SS "\f(CW\*(Aqerrno\*(Aq\fP \- unresolved external"
.IX Subsection "errno - unresolved external"
You do not have MT-safe \fIdb.lib\fR. See \*(L"Prerequisites\*(R".
.SS "Problems with tr or sed"
.IX Subsection "Problems with tr or sed"
reported with very old version of tr and sed.
.SS "Some problem (forget which ;\-)"
.IX Subsection "Some problem (forget which ;-)"
You have an older version of \fIperl.dll\fR on your \s-1LIBPATH,\s0 which
broke the build of extensions.
.SS "Library ... not found"
.IX Subsection "Library ... not found"
You did not run \f(CW\*(C`omflibs\*(C'\fR. See \*(L"Prerequisites\*(R".
.SS "Segfault in make"
.IX Subsection "Segfault in make"
You use an old version of \s-1GNU\s0 make. See \*(L"Prerequisites\*(R".
.SS "op/sprintf test failure"
.IX Subsection "op/sprintf test failure"
This can result from a bug in emx sprintf which was fixed in 0.9d fix 03.
.SH "Specific (mis)features of OS/2 port"
.IX Header "Specific (mis)features of OS/2 port"
.ie n .SS """setpriority"", ""getpriority"""
.el .SS "\f(CWsetpriority\fP, \f(CWgetpriority\fP"
.IX Subsection "setpriority, getpriority"
Note that these functions are compatible with *nix, not with the older
ports of '94 \- 95. The priorities are absolute, go from 32 to \-95,
lower is quicker. 0 is the default priority.
.PP
\&\fB\s-1WARNING\s0\fR. Calling \f(CW\*(C`getpriority\*(C'\fR on a non-existing process could lock
the system before Warp3 fixpak22. Starting with Warp3, Perl will use
a workaround: it aborts \fBgetpriority()\fR if the process is not present.
This is not possible on older versions \f(CW\*(C`2.*\*(C'\fR, and has a race
condition anyway.
.ie n .SS """system()"""
.el .SS "\f(CWsystem()\fP"
.IX Subsection "system()"
Multi-argument form of \f(CW\*(C`system()\*(C'\fR allows an additional numeric
argument. The meaning of this argument is described in
OS2::Process.
.PP
When finding a program to run, Perl first asks the \s-1OS\s0 to look for executables
on \f(CW\*(C`PATH\*(C'\fR (\s-1OS/2\s0 adds extension \fI.exe\fR if no extension is present).
If not found, it looks for a script with possible extensions
added in this order: no extension, \fI.cmd\fR, \fI.btm\fR,
\&\fI.bat\fR, \fI.pl\fR. If found, Perl checks the start of the file for magic
strings \f(CW"#!"\fR and \f(CW"extproc "\fR. If found, Perl uses the rest of the
first line as the beginning of the command line to run this script. The
only mangling done to the first line is extraction of arguments (currently
up to 3), and ignoring of the path-part of the \*(L"interpreter\*(R" name if it can't
be found using the full path.
.PP
E.g., \f(CW\*(C`system \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq, \*(Aqbaz\*(Aq\*(C'\fR may lead Perl to finding
\&\fIC:/emx/bin/foo.cmd\fR with the first line being
.PP
.Vb 1
\& extproc /bin/bash \-x \-c
.Ve
.PP
If \fI/bin/bash.exe\fR is not found, then Perl looks for an executable \fIbash.exe\fR on
\&\f(CW\*(C`PATH\*(C'\fR. If found in \fIC:/emx.add/bin/bash.exe\fR, then the above \fBsystem()\fR is
translated to
.PP
.Vb 1
\& system qw(C:/emx.add/bin/bash.exe \-x \-c C:/emx/bin/foo.cmd bar baz)
.Ve
.PP
One additional translation is performed: instead of \fI/bin/sh\fR Perl uses
the hardwired-or-customized shell (see "\f(CW\*(C`PERL_SH_DIR\*(C'\fR").
.PP
The above search for \*(L"interpreter\*(R" is recursive: if \fIbash\fR executable is not
found, but \fIbash.btm\fR is found, Perl will investigate its first line etc.
The only hardwired limit on the recursion depth is implicit: there is a limit
4 on the number of additional arguments inserted before the actual arguments
given to \fBsystem()\fR. In particular, if no additional arguments are specified
on the \*(L"magic\*(R" first lines, then the limit on the depth is 4.
.PP
If Perl finds that the found executable is of \s-1PM\s0 type when the
current session is not, it will start the new process in a separate session of
necessary type. Call via \f(CW\*(C`OS2::Process\*(C'\fR to disable this magic.
.PP
\&\fB\s-1WARNING\s0\fR. Due to the described logic, you need to explicitly
specify \fI.com\fR extension if needed. Moreover, if the executable
\&\fIperl5.6.1\fR is requested, Perl will not look for \fIperl5.6.1.exe\fR.
[This may change in the future.]
.ie n .SS """extproc"" on the first line"
.el .SS "\f(CWextproc\fP on the first line"
.IX Subsection "extproc on the first line"
If the first chars of a Perl script are \f(CW"extproc "\fR, this line is treated
as \f(CW\*(C`#!\*(C'\fR\-line, thus all the switches on this line are processed (twice
if script was started via cmd.exe). See \*(L"\s-1DESCRIPTION\*(R"\s0 in perlrun.
.SS "Additional modules:"
.IX Subsection "Additional modules:"
OS2::Process, \s-1OS2::DLL\s0, \s-1OS2::REXX\s0, OS2::PrfDB, OS2::ExtAttr. These
modules provide access to additional numeric argument for \f(CW\*(C`system\*(C'\fR
and to the information about the running process,
to DLLs having functions with \s-1REXX\s0 signature and to the \s-1REXX\s0 runtime, to
\&\s-1OS/2\s0 databases in the \fI.INI\fR format, and to Extended Attributes.
.PP
Two additional extensions by Andreas Kaiser, \f(CW\*(C`OS2::UPM\*(C'\fR, and
\&\f(CW\*(C`OS2::FTP\*(C'\fR, are included into \f(CW\*(C`ILYAZ\*(C'\fR directory, mirrored on \s-1CPAN.\s0
Other OS/2\-related extensions are available too.
.SS "Prebuilt methods:"
.IX Subsection "Prebuilt methods:"
.ie n .IP """File::Copy::syscopy""" 4
.el .IP "\f(CWFile::Copy::syscopy\fR" 4
.IX Item "File::Copy::syscopy"
used by \f(CW\*(C`File::Copy::copy\*(C'\fR, see File::Copy.
.ie n .IP """DynaLoader::mod2fname""" 4
.el .IP "\f(CWDynaLoader::mod2fname\fR" 4
.IX Item "DynaLoader::mod2fname"
used by \f(CW\*(C`DynaLoader\*(C'\fR for \s-1DLL\s0 name mangling.
.ie n .IP """Cwd::current_drive()""" 4
.el .IP "\f(CWCwd::current_drive()\fR" 4
.IX Item "Cwd::current_drive()"
Self explanatory.
.ie n .IP """Cwd::sys_chdir(name)""" 4
.el .IP "\f(CWCwd::sys_chdir(name)\fR" 4
.IX Item "Cwd::sys_chdir(name)"
leaves drive as it is.
.ie n .IP """Cwd::change_drive(name)""" 4
.el .IP "\f(CWCwd::change_drive(name)\fR" 4
.IX Item "Cwd::change_drive(name)"
changes the \*(L"current\*(R" drive.
.ie n .IP """Cwd::sys_is_absolute(name)""" 4
.el .IP "\f(CWCwd::sys_is_absolute(name)\fR" 4
.IX Item "Cwd::sys_is_absolute(name)"
means has drive letter and is_rooted.
.ie n .IP """Cwd::sys_is_rooted(name)""" 4
.el .IP "\f(CWCwd::sys_is_rooted(name)\fR" 4
.IX Item "Cwd::sys_is_rooted(name)"
means has leading \f(CW\*(C`[/\e\e]\*(C'\fR (maybe after a drive-letter:).
.ie n .IP """Cwd::sys_is_relative(name)""" 4
.el .IP "\f(CWCwd::sys_is_relative(name)\fR" 4
.IX Item "Cwd::sys_is_relative(name)"
means changes with current dir.
.ie n .IP """Cwd::sys_cwd(name)""" 4
.el .IP "\f(CWCwd::sys_cwd(name)\fR" 4
.IX Item "Cwd::sys_cwd(name)"
Interface to cwd from \s-1EMX.\s0 Used by \f(CW\*(C`Cwd::cwd\*(C'\fR.
.ie n .IP """Cwd::sys_abspath(name, dir)""" 4
.el .IP "\f(CWCwd::sys_abspath(name, dir)\fR" 4
.IX Item "Cwd::sys_abspath(name, dir)"
Really really odious function to implement. Returns absolute name of
file which would have \f(CW\*(C`name\*(C'\fR if \s-1CWD\s0 were \f(CW\*(C`dir\*(C'\fR. \f(CW\*(C`Dir\*(C'\fR defaults to the
current dir.
.ie n .IP """Cwd::extLibpath([type])""" 4
.el .IP "\f(CWCwd::extLibpath([type])\fR" 4
.IX Item "Cwd::extLibpath([type])"
Get current value of extended library search path. If \f(CW\*(C`type\*(C'\fR is
present and positive, works with \f(CW\*(C`END_LIBPATH\*(C'\fR, if negative, works
with \f(CW\*(C`LIBPATHSTRICT\*(C'\fR, otherwise with \f(CW\*(C`BEGIN_LIBPATH\*(C'\fR.
.ie n .IP """Cwd::extLibpath_set( path [, type ] )""" 4
.el .IP "\f(CWCwd::extLibpath_set( path [, type ] )\fR" 4
.IX Item "Cwd::extLibpath_set( path [, type ] )"
Set current value of extended library search path. If \f(CW\*(C`type\*(C'\fR is
present and positive, works with <\s-1END_LIBPATH\s0>, if negative, works
with \f(CW\*(C`LIBPATHSTRICT\*(C'\fR, otherwise with \f(CW\*(C`BEGIN_LIBPATH\*(C'\fR.
.ie n .IP """OS2::Error(do_harderror,do_exception)""" 4
.el .IP "\f(CWOS2::Error(do_harderror,do_exception)\fR" 4
.IX Item "OS2::Error(do_harderror,do_exception)"
Returns \f(CW\*(C`undef\*(C'\fR if it was not called yet, otherwise bit 1 is
set if on the previous call do_harderror was enabled, bit
2 is set if on previous call do_exception was enabled.
.Sp
This function enables/disables error popups associated with
hardware errors (Disk not ready etc.) and software exceptions.
.Sp
I know of no way to find out the state of popups \fIbefore\fR the first call
to this function.
.ie n .IP """OS2::Errors2Drive(drive)""" 4
.el .IP "\f(CWOS2::Errors2Drive(drive)\fR" 4
.IX Item "OS2::Errors2Drive(drive)"
Returns \f(CW\*(C`undef\*(C'\fR if it was not called yet, otherwise return false if errors
were not requested to be written to a hard drive, or the drive letter if
this was requested.
.Sp
This function may redirect error popups associated with hardware errors
(Disk not ready etc.) and software exceptions to the file \s-1POPUPLOG.OS2\s0 at
the root directory of the specified drive. Overrides \fBOS2::Error()\fR specified
by individual programs. Given argument undef will disable redirection.
.Sp
Has global effect, persists after the application exits.
.Sp
I know of no way to find out the state of redirection of popups to the disk
\&\fIbefore\fR the first call to this function.
.IP "\fBOS2::SysInfo()\fR" 4
.IX Item "OS2::SysInfo()"
Returns a hash with system information. The keys of the hash are
.Sp
.Vb 8
\& MAX_PATH_LENGTH, MAX_TEXT_SESSIONS, MAX_PM_SESSIONS,
\& MAX_VDM_SESSIONS, BOOT_DRIVE, DYN_PRI_VARIATION,
\& MAX_WAIT, MIN_SLICE, MAX_SLICE, PAGE_SIZE,
\& VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION,
\& MS_COUNT, TIME_LOW, TIME_HIGH, TOTPHYSMEM, TOTRESMEM,
\& TOTAVAILMEM, MAXPRMEM, MAXSHMEM, TIMER_INTERVAL,
\& MAX_COMP_LENGTH, FOREGROUND_FS_SESSION,
\& FOREGROUND_PROCESS
.Ve
.IP "\fBOS2::BootDrive()\fR" 4
.IX Item "OS2::BootDrive()"
Returns a letter without colon.
.ie n .IP """OS2::MorphPM(serve)"", ""OS2::UnMorphPM(serve)""" 4
.el .IP "\f(CWOS2::MorphPM(serve)\fR, \f(CWOS2::UnMorphPM(serve)\fR" 4
.IX Item "OS2::MorphPM(serve), OS2::UnMorphPM(serve)"
Transforms the current application into a \s-1PM\s0 application and back.
The argument true means that a real message loop is going to be served.
\&\fBOS2::MorphPM()\fR returns the \s-1PM\s0 message queue handle as an integer.
.Sp
See \*(L"Centralized management of resources\*(R" for additional details.
.ie n .IP """OS2::Serve_Messages(force)""" 4
.el .IP "\f(CWOS2::Serve_Messages(force)\fR" 4
.IX Item "OS2::Serve_Messages(force)"
Fake on-demand retrieval of outstanding \s-1PM\s0 messages. If \f(CW\*(C`force\*(C'\fR is false,
will not dispatch messages if a real message loop is known to
be present. Returns number of messages retrieved.
.Sp
Dies with \*(L"QUITing...\*(R" if \s-1WM_QUIT\s0 message is obtained.
.ie n .IP """OS2::Process_Messages(force [, cnt])""" 4
.el .IP "\f(CWOS2::Process_Messages(force [, cnt])\fR" 4
.IX Item "OS2::Process_Messages(force [, cnt])"
Retrieval of \s-1PM\s0 messages until window creation/destruction.
If \f(CW\*(C`force\*(C'\fR is false, will not dispatch messages if a real message loop
is known to be present.
.Sp
Returns change in number of windows. If \f(CW\*(C`cnt\*(C'\fR is given,
it is incremented by the number of messages retrieved.
.Sp
Dies with \*(L"QUITing...\*(R" if \s-1WM_QUIT\s0 message is obtained.
.ie n .IP """OS2::_control87(new,mask)""" 4
.el .IP "\f(CWOS2::_control87(new,mask)\fR" 4
.IX Item "OS2::_control87(new,mask)"
the same as \fB_control87\fR\|(3) of \s-1EMX.\s0 Takes integers as arguments, returns
the previous coprocessor control word as an integer. Only bits in \f(CW\*(C`new\*(C'\fR which
are present in \f(CW\*(C`mask\*(C'\fR are changed in the control word.
.IP "\fBOS2::get_control87()\fR" 4
.IX Item "OS2::get_control87()"
gets the coprocessor control word as an integer.
.ie n .IP """OS2::set_control87_em(new=MCW_EM,mask=MCW_EM)""" 4
.el .IP "\f(CWOS2::set_control87_em(new=MCW_EM,mask=MCW_EM)\fR" 4
.IX Item "OS2::set_control87_em(new=MCW_EM,mask=MCW_EM)"
The variant of \fBOS2::_control87()\fR with default values good for
handling exception mask: if no \f(CW\*(C`mask\*(C'\fR, uses exception mask part of \f(CW\*(C`new\*(C'\fR
only. If no \f(CW\*(C`new\*(C'\fR, disables all the floating point exceptions.
.Sp
See \*(L"Misfeatures\*(R" for details.
.ie n .IP """OS2::DLLname([how [, \e&xsub]])""" 4
.el .IP "\f(CWOS2::DLLname([how [, \e&xsub]])\fR" 4
.IX Item "OS2::DLLname([how [, &xsub]])"
Gives the information about the Perl \s-1DLL\s0 or the \s-1DLL\s0 containing the C
function bound to by \f(CW&xsub\fR. The meaning of \f(CW\*(C`how\*(C'\fR is: default (2):
full name; 0: handle; 1: module name.
.PP
(Note that some of these may be moved to different libraries \-
eventually).
.SS "Prebuilt variables:"
.IX Subsection "Prebuilt variables:"
.ie n .IP "$OS2::emx_rev" 4
.el .IP "\f(CW$OS2::emx_rev\fR" 4
.IX Item "$OS2::emx_rev"
numeric value is the same as _emx_rev of \s-1EMX,\s0 a string value the same
as _emx_vprt (similar to \f(CW\*(C`0.9c\*(C'\fR).
.ie n .IP "$OS2::emx_env" 4
.el .IP "\f(CW$OS2::emx_env\fR" 4
.IX Item "$OS2::emx_env"
same as _emx_env of \s-1EMX,\s0 a number similar to 0x8001.
.ie n .IP "$OS2::os_ver" 4
.el .IP "\f(CW$OS2::os_ver\fR" 4
.IX Item "$OS2::os_ver"
a number \f(CW\*(C`OS_MAJOR + 0.001 * OS_MINOR\*(C'\fR.
.ie n .IP "$OS2::is_aout" 4
.el .IP "\f(CW$OS2::is_aout\fR" 4
.IX Item "$OS2::is_aout"
true if the Perl library was compiled in \s-1AOUT\s0 format.
.ie n .IP "$OS2::can_fork" 4
.el .IP "\f(CW$OS2::can_fork\fR" 4
.IX Item "$OS2::can_fork"
true if the current executable is an \s-1AOUT EMX\s0 executable, so Perl can
fork. Do not use this, use the portable check for
\&\f(CW$Config::Config\fR{dfork}.
.ie n .IP "$OS2::nsyserror" 4
.el .IP "\f(CW$OS2::nsyserror\fR" 4
.IX Item "$OS2::nsyserror"
This variable (default is 1) controls whether to enforce the contents
of $^E to start with \f(CW\*(C`SYS0003\*(C'\fR\-like id. If set to 0, then the string
value of $^E is what is available from the \s-1OS/2\s0 message file. (Some
messages in this file have an \f(CW\*(C`SYS0003\*(C'\fR\-like id prepended, some not.)
.SS "Misfeatures"
.IX Subsection "Misfeatures"
.IP "\(bu" 4
Since \fBflock\fR\|(3) is present in \s-1EMX,\s0 but is not functional, it is
emulated by perl. To disable the emulations, set environment variable
\&\f(CW\*(C`USE_PERL_FLOCK=0\*(C'\fR.
.IP "\(bu" 4
Here is the list of things which may be \*(L"broken\*(R" on
\&\s-1EMX\s0 (from \s-1EMX\s0 docs):
.RS 4
.IP "\(bu" 4
The functions \fBrecvmsg\fR\|(3), \fBsendmsg\fR\|(3), and \fBsocketpair\fR\|(3) are not
implemented.
.IP "\(bu" 4
\&\fBsock_init\fR\|(3) is not required and not implemented.
.IP "\(bu" 4
\&\fBflock\fR\|(3) is not yet implemented (dummy function). (Perl has a workaround.)
.IP "\(bu" 4
\&\fBkill\fR\|(3): Special treatment of PID=0, PID=1 and PID=\-1 is not implemented.
.IP "\(bu" 4
\&\fBwaitpid\fR\|(3):
.Sp
.Vb 3
\& WUNTRACED
\& Not implemented.
\& waitpid() is not implemented for negative values of PID.
.Ve
.RE
.RS 4
.Sp
Note that \f(CW\*(C`kill \-9\*(C'\fR does not work with the current version of \s-1EMX.\s0
.RE
.IP "\(bu" 4
See \*(L"Text-mode filehandles\*(R".
.IP "\(bu" 4
Unix-domain sockets on \s-1OS/2\s0 live in a pseudo-file-system \f(CW\*(C`/sockets/...\*(C'\fR.
To avoid a failure to create a socket with a name of a different form,
\&\f(CW"/socket/"\fR is prepended to the socket name (unless it starts with this
already).
.Sp
This may lead to problems later in case the socket is accessed via the
\&\*(L"usual\*(R" file-system calls using the \*(L"initial\*(R" name.
.IP "\(bu" 4
Apparently, \s-1IBM\s0 used a compiler (for some period of time around '95?) which
changes \s-1FP\s0 mask right and left. This is not \fIthat\fR bad for \s-1IBM\s0's
programs, but the same compiler was used for DLLs which are used with
general-purpose applications. When these DLLs are used, the state of
floating-point flags in the application is not predictable.
.Sp
What is much worse, some DLLs change the floating point flags when in
\&\fB_DLLInitTerm()\fR (e.g., \fI\s-1TCP32IP\s0\fR). This means that even if you do not \fIcall\fR
any function in the \s-1DLL,\s0 just the act of loading this \s-1DLL\s0 will reset your
flags. What is worse, the same compiler was used to compile some \s-1HOOK\s0 DLLs.
Given that \s-1HOOK\s0 dlls are executed in the context of \fIall\fR the applications
in the system, this means a complete unpredictability of floating point
flags on systems using such \s-1HOOK\s0 DLLs. E.g., \fI\s-1GAMESRVR.DLL\s0\fR of \fB\s-1DIVE\s0\fR
origin changes the floating point flags on each write to the \s-1TTY\s0 of a \s-1VIO\s0
(windowed text-mode) applications.
.Sp
Some other (not completely debugged) situations when \s-1FP\s0 flags change include
some video drivers (?), and some operations related to creation of the windows.
People who code \fBOpenGL\fR may have more experience on this.
.Sp
Perl is generally used in the situation when all the floating-point
exceptions are ignored, as is the default under \s-1EMX.\s0 If they are not ignored,
some benign Perl programs would get a \f(CW\*(C`SIGFPE\*(C'\fR and would die a horrible death.
.Sp
To circumvent this, Perl uses two hacks. They help against \fIone\fR type of
damage only: \s-1FP\s0 flags changed when loading a \s-1DLL.\s0
.Sp
One of the hacks is to disable floating point exceptions on Perl startup (as
is the default with \s-1EMX\s0). This helps only with compile-time-linked DLLs
changing the flags before \fBmain()\fR had a chance to be called.
.Sp
The other hack is to restore \s-1FP\s0 flags after a call to \fBdlopen()\fR. This helps
against similar damage done by DLLs \fB_DLLInitTerm()\fR at runtime. Currently
no way to switch these hacks off is provided.
.SS "Modifications"
.IX Subsection "Modifications"
Perl modifies some standard C library calls in the following ways:
.ie n .IP """popen""" 9
.el .IP "\f(CWpopen\fR" 9
.IX Item "popen"
\&\f(CW\*(C`my_popen\*(C'\fR uses \fIsh.exe\fR if shell is required, cf. "\f(CW\*(C`PERL_SH_DIR\*(C'\fR".
.ie n .IP """tmpnam""" 9
.el .IP "\f(CWtmpnam\fR" 9
.IX Item "tmpnam"
is created using \f(CW\*(C`TMP\*(C'\fR or \f(CW\*(C`TEMP\*(C'\fR environment variable, via
\&\f(CW\*(C`tempnam\*(C'\fR.
.ie n .IP """tmpfile""" 9
.el .IP "\f(CWtmpfile\fR" 9
.IX Item "tmpfile"
If the current directory is not writable, file is created using modified
\&\f(CW\*(C`tmpnam\*(C'\fR, so there may be a race condition.
.ie n .IP """ctermid""" 9
.el .IP "\f(CWctermid\fR" 9
.IX Item "ctermid"
a dummy implementation.
.ie n .IP """stat""" 9
.el .IP "\f(CWstat\fR" 9
.IX Item "stat"
\&\f(CW\*(C`os2_stat\*(C'\fR special-cases \fI/dev/tty\fR and \fI/dev/con\fR.
.ie n .IP """mkdir"", ""rmdir""" 9
.el .IP "\f(CWmkdir\fR, \f(CWrmdir\fR" 9
.IX Item "mkdir, rmdir"
these \s-1EMX\s0 functions do not work if the path contains a trailing \f(CW\*(C`/\*(C'\fR.
Perl contains a workaround for this.
.ie n .IP """flock""" 9
.el .IP "\f(CWflock\fR" 9
.IX Item "flock"
Since \fBflock\fR\|(3) is present in \s-1EMX,\s0 but is not functional, it is
emulated by perl. To disable the emulations, set environment variable
\&\f(CW\*(C`USE_PERL_FLOCK=0\*(C'\fR.
.SS "Identifying DLLs"
.IX Subsection "Identifying DLLs"
All the DLLs built with the current versions of Perl have \s-1ID\s0 strings
identifying the name of the extension, its version, and the version
of Perl required for this \s-1DLL.\s0 Run \f(CW\*(C`bldlevel DLL\-name\*(C'\fR to find this
info.
.SS "Centralized management of resources"
.IX Subsection "Centralized management of resources"
Since to call certain \s-1OS/2 API\s0 one needs to have a correctly initialized
\&\f(CW\*(C`Win\*(C'\fR subsystem, OS/2\-specific extensions may require getting \f(CW\*(C`HAB\*(C'\fRs and
\&\f(CW\*(C`HMQ\*(C'\fRs. If an extension would do it on its own, another extension could
fail to initialize.
.PP
Perl provides a centralized management of these resources:
.ie n .IP """HAB""" 4
.el .IP "\f(CWHAB\fR" 4
.IX Item "HAB"
To get the \s-1HAB,\s0 the extension should call \f(CW\*(C`hab = perl_hab_GET()\*(C'\fR in C. After
this call is performed, \f(CW\*(C`hab\*(C'\fR may be accessed as \f(CW\*(C`Perl_hab\*(C'\fR. There is
no need to release the \s-1HAB\s0 after it is used.
.Sp
If by some reasons \fIperl.h\fR cannot be included, use
.Sp
.Vb 1
\& extern int Perl_hab_GET(void);
.Ve
.Sp
instead.
.ie n .IP """HMQ""" 4
.el .IP "\f(CWHMQ\fR" 4
.IX Item "HMQ"
There are two cases:
.RS 4
.IP "\(bu" 4
the extension needs an \f(CW\*(C`HMQ\*(C'\fR only because some \s-1API\s0 will not work otherwise.
Use \f(CW\*(C`serve = 0\*(C'\fR below.
.IP "\(bu" 4
the extension needs an \f(CW\*(C`HMQ\*(C'\fR since it wants to engage in a \s-1PM\s0 event loop.
Use \f(CW\*(C`serve = 1\*(C'\fR below.
.RE
.RS 4
.Sp
To get an \f(CW\*(C`HMQ\*(C'\fR, the extension should call \f(CW\*(C`hmq = perl_hmq_GET(serve)\*(C'\fR in C.
After this call is performed, \f(CW\*(C`hmq\*(C'\fR may be accessed as \f(CW\*(C`Perl_hmq\*(C'\fR.
.Sp
To signal to Perl that \s-1HMQ\s0 is not needed any more, call
\&\f(CW\*(C`perl_hmq_UNSET(serve)\*(C'\fR. Perl process will automatically morph/unmorph itself
into/from a \s-1PM\s0 process if \s-1HMQ\s0 is needed/not\-needed. Perl will automatically
enable/disable \f(CW\*(C`WM_QUIT\*(C'\fR message during shutdown if the message queue is
served/not\-served.
.Sp
\&\fB\s-1NOTE\s0\fR. If during a shutdown there is a message queue which did not disable
\&\s-1WM_QUIT,\s0 and which did not process the received \s-1WM_QUIT\s0 message, the
shutdown will be automatically cancelled. Do not call \f(CWperl_hmq_GET(1)\fR
unless you are going to process messages on an orderly basis.
.RE
.IP "Treating errors reported by \s-1OS/2 API\s0" 4
.IX Item "Treating errors reported by OS/2 API"
There are two principal conventions (it is useful to call them \f(CW\*(C`Dos*\*(C'\fR
and \f(CW\*(C`Win*\*(C'\fR \- though this part of the function signature is not always
determined by the name of the \s-1API\s0) of reporting the error conditions
of \s-1OS/2 API.\s0 Most of \f(CW\*(C`Dos*\*(C'\fR APIs report the error code as the result
of the call (so 0 means success, and there are many types of errors).
Most of \f(CW\*(C`Win*\*(C'\fR \s-1API\s0 report success/fail via the result being
\&\f(CW\*(C`TRUE\*(C'\fR/\f(CW\*(C`FALSE\*(C'\fR; to find the reason for the failure one should call
\&\fBWinGetLastError()\fR \s-1API.\s0
.Sp
Some \f(CW\*(C`Win*\*(C'\fR entry points also overload a \*(L"meaningful\*(R" return value
with the error indicator; having a 0 return value indicates an error.
Yet some other \f(CW\*(C`Win*\*(C'\fR entry points overload things even more, and 0
return value may mean a successful call returning a valid value 0, as
well as an error condition; in the case of a 0 return value one should
call \fBWinGetLastError()\fR \s-1API\s0 to distinguish a successful call from a
failing one.
.Sp
By convention, all the calls to \s-1OS/2 API\s0 should indicate their
failures by resetting $^E. All the Perl-accessible functions which
call \s-1OS/2 API\s0 may be broken into two classes: some \fBdie()\fRs when an \s-1API\s0
error is encountered, the other report the error via a false return
value (of course, this does not concern Perl-accessible functions
which \fIexpect\fR a failure of the \s-1OS/2 API\s0 call, having some workarounds
coded).
.Sp
Obviously, in the situation of the last type of the signature of an \s-1OS/2
API,\s0 it is must more convenient for the users if the failure is
indicated by \fBdie()\fRing: one does not need to check $^E to know that
something went wrong. If, however, this solution is not desirable by
some reason, the code in question should reset $^E to 0 before making
this \s-1OS/2 API\s0 call, so that the caller of this Perl-accessible
function has a chance to distinguish a success\-but\-0\-return value from
a failure. (One may return undef as an alternative way of reporting
an error.)
.Sp
The macros to simplify this type of error propagation are
.RS 4
.ie n .IP """CheckOSError(expr)""" 4
.el .IP "\f(CWCheckOSError(expr)\fR" 4
.IX Item "CheckOSError(expr)"
Returns true on error, sets $^E. Expects \fBexpr()\fR be a call of
\&\f(CW\*(C`Dos*\*(C'\fR\-style \s-1API.\s0
.ie n .IP """CheckWinError(expr)""" 4
.el .IP "\f(CWCheckWinError(expr)\fR" 4
.IX Item "CheckWinError(expr)"
Returns true on error, sets $^E. Expects \fBexpr()\fR be a call of
\&\f(CW\*(C`Win*\*(C'\fR\-style \s-1API.\s0
.ie n .IP """SaveWinError(expr)""" 4
.el .IP "\f(CWSaveWinError(expr)\fR" 4
.IX Item "SaveWinError(expr)"
Returns \f(CW\*(C`expr\*(C'\fR, sets $^E from \fBWinGetLastError()\fR if \f(CW\*(C`expr\*(C'\fR is false.
.ie n .IP """SaveCroakWinError(expr,die,name1,name2)""" 4
.el .IP "\f(CWSaveCroakWinError(expr,die,name1,name2)\fR" 4
.IX Item "SaveCroakWinError(expr,die,name1,name2)"
Returns \f(CW\*(C`expr\*(C'\fR, sets $^E from \fBWinGetLastError()\fR if \f(CW\*(C`expr\*(C'\fR is false,
and \fBdie()\fRs if \f(CW\*(C`die\*(C'\fR and $^E are true. The message to die is the
concatenated strings \f(CW\*(C`name1\*(C'\fR and \f(CW\*(C`name2\*(C'\fR, separated by \f(CW": "\fR from
the contents of $^E.
.ie n .IP """WinError_2_Perl_rc""" 4
.el .IP "\f(CWWinError_2_Perl_rc\fR" 4
.IX Item "WinError_2_Perl_rc"
Sets \f(CW\*(C`Perl_rc\*(C'\fR to the return value of \fBWinGetLastError()\fR.
.ie n .IP """FillWinError""" 4
.el .IP "\f(CWFillWinError\fR" 4
.IX Item "FillWinError"
Sets \f(CW\*(C`Perl_rc\*(C'\fR to the return value of \fBWinGetLastError()\fR, and sets $^E
to the corresponding value.
.ie n .IP """FillOSError(rc)""" 4
.el .IP "\f(CWFillOSError(rc)\fR" 4
.IX Item "FillOSError(rc)"
Sets \f(CW\*(C`Perl_rc\*(C'\fR to \f(CW\*(C`rc\*(C'\fR, and sets $^E to the corresponding value.
.RE
.RS 4
.RE
.IP "Loading DLLs and ordinals in DLLs" 4
.IX Item "Loading DLLs and ordinals in DLLs"
Some DLLs are only present in some versions of \s-1OS/2,\s0 or in some
configurations of \s-1OS/2.\s0 Some exported entry points are present only
in DLLs shipped with some versions of \s-1OS/2.\s0 If these DLLs and entry
points were linked directly for a Perl executable/DLL or from a Perl
extensions, this binary would work only with the specified
versions/setups. Even if these entry points were not needed, the
\&\fIload\fR of the executable (or \s-1DLL\s0) would fail.
.Sp
For example, many newer useful APIs are not present in \s-1OS/2\s0 v2; many
PM-related APIs require DLLs not available on floppy-boot setup.
.Sp
To make these calls fail \fIonly when the calls are executed\fR, one
should call these \s-1API\s0 via a dynamic linking \s-1API.\s0 There is a subsystem
in Perl to simplify such type of calls. A large number of entry
points available for such linking is provided (see \f(CW\*(C`entries_ordinals\*(C'\fR
\&\- and also \f(CW\*(C`PMWIN_entries\*(C'\fR \- in \fIos2ish.h\fR). These ordinals can be
accessed via the APIs:
.Sp
.Vb 6
\& CallORD(), DeclFuncByORD(), DeclVoidFuncByORD(),
\& DeclOSFuncByORD(), DeclWinFuncByORD(), AssignFuncPByORD(),
\& DeclWinFuncByORD_CACHE(), DeclWinFuncByORD_CACHE_survive(),
\& DeclWinFuncByORD_CACHE_resetError_survive(),
\& DeclWinFunc_CACHE(), DeclWinFunc_CACHE_resetError(),
\& DeclWinFunc_CACHE_survive(), DeclWinFunc_CACHE_resetError_survive()
.Ve
.Sp
See the header files and the C code in the supplied OS/2\-related
modules for the details on usage of these functions.
.Sp
Some of these functions also combine dynaloading semantic with the
error-propagation semantic discussed above.
.SH "Perl flavors"
.IX Header "Perl flavors"
Because of idiosyncrasies of \s-1OS/2\s0 one cannot have all the eggs in the
same basket (though \s-1EMX\s0 environment tries hard to overcome this
limitations, so the situation may somehow improve). There are 4
executables for Perl provided by the distribution:
.SS "\fIperl.exe\fP"
.IX Subsection "perl.exe"
The main workhorse. This is a chimera executable: it is compiled as an
\&\f(CW\*(C`a.out\*(C'\fR\-style executable, but is linked with \f(CW\*(C`omf\*(C'\fR\-style dynamic
library \fIperl.dll\fR, and with dynamic \s-1CRT DLL.\s0 This executable is a
\&\s-1VIO\s0 application.
.PP
It can load perl dynamic extensions, and it can \fBfork()\fR.
.PP
\&\fBNote.\fR Keep in mind that \fBfork()\fR is needed to open a pipe to yourself.
.SS "\fIperl_.exe\fP"
.IX Subsection "perl_.exe"
This is a statically linked \f(CW\*(C`a.out\*(C'\fR\-style executable. It cannot
load dynamic Perl extensions. The executable supplied in binary
distributions has a lot of extensions prebuilt, thus the above restriction is
important only if you use custom-built extensions. This executable is a \s-1VIO\s0
application.
.PP
\&\fIThis is the only executable with does not require \s-1OS/2.\s0\fR The
friends locked into \f(CW\*(C`M$\*(C'\fR world would appreciate the fact that this
executable runs under \s-1DOS,\s0 Win0.3*, Win0.95 and WinNT with an
appropriate extender. See \*(L"Other OSes\*(R".
.SS "\fIperl_\|_.exe\fP"
.IX Subsection "perl__.exe"
This is the same executable as \fIperl_\|_\|_.exe\fR, but it is a \s-1PM\s0
application.
.PP
\&\fBNote.\fR Usually (unless explicitly redirected during the startup)
\&\s-1STDIN, STDERR,\s0 and \s-1STDOUT\s0 of a \s-1PM\s0
application are redirected to \fInul\fR. However, it is possible to \fIsee\fR
them if you start \f(CW\*(C`perl_\|_.exe\*(C'\fR from a \s-1PM\s0 program which emulates a
console window, like \fIShell mode\fR of Emacs or \s-1EPM.\s0 Thus it \fIis
possible\fR to use Perl debugger (see perldebug) to debug your \s-1PM\s0
application (but beware of the message loop lockups \- this will not
work if you have a message queue to serve, unless you hook the serving
into the \fBgetc()\fR function of the debugger).
.PP
Another way to see the output of a \s-1PM\s0 program is to run it as
.PP
.Vb 1
\& pm_prog args 2>&1 | cat \-
.Ve
.PP
with a shell \fIdifferent\fR from \fIcmd.exe\fR, so that it does not create
a link between a \s-1VIO\s0 session and the session of \f(CW\*(C`pm_porg\*(C'\fR. (Such a link
closes the \s-1VIO\s0 window.) E.g., this works with \fIsh.exe\fR \- or with Perl!
.PP
.Vb 2
\& open P, \*(Aqpm_prog args 2>&1 |\*(Aq or die;
\& print while ;
.Ve
.PP
The flavor \fIperl_\|_.exe\fR is required if you want to start your program without
a \s-1VIO\s0 window present, but not \f(CW\*(C`detach\*(C'\fRed (run \f(CW\*(C`help detach\*(C'\fR for more info).
Very useful for extensions which use \s-1PM,\s0 like \f(CW\*(C`Perl/Tk\*(C'\fR or \f(CW\*(C`OpenGL\*(C'\fR.
.PP
Note also that the differences between \s-1PM\s0 and \s-1VIO\s0 executables are only
in the \fIdefault\fR behaviour. One can start \fIany\fR executable in
\&\fIany\fR kind of session by using the arguments \f(CW\*(C`/fs\*(C'\fR, \f(CW\*(C`/pm\*(C'\fR or
\&\f(CW\*(C`/win\*(C'\fR switches of the command \f(CW\*(C`start\*(C'\fR (of \fI\s-1CMD.EXE\s0\fR or a similar
shell). Alternatively, one can use the numeric first argument of the
\&\f(CW\*(C`system\*(C'\fR Perl function (see OS2::Process).
.SS "\fIperl_\|_\|_.exe\fP"
.IX Subsection "perl___.exe"
This is an \f(CW\*(C`omf\*(C'\fR\-style executable which is dynamically linked to
\&\fIperl.dll\fR and \s-1CRT DLL. I\s0 know no advantages of this executable
over \f(CW\*(C`perl.exe\*(C'\fR, but it cannot \fBfork()\fR at all. Well, one advantage is
that the build process is not so convoluted as with \f(CW\*(C`perl.exe\*(C'\fR.
.PP
It is a \s-1VIO\s0 application.
.SS "Why strange names?"
.IX Subsection "Why strange names?"
Since Perl processes the \f(CW\*(C`#!\*(C'\fR\-line (cf.
\&\*(L"\s-1DESCRIPTION\*(R"\s0 in perlrun, \*(L"Command Switches\*(R" in perlrun,
\&\*(L"No Perl script found in input\*(R" in perldiag), it should know when a
program \fIis a Perl\fR. There is some naming convention which allows
Perl to distinguish correct lines from wrong ones. The above names are
almost the only names allowed by this convention which do not contain
digits (which have absolutely different semantics).
.SS "Why dynamic linking?"
.IX Subsection "Why dynamic linking?"
Well, having several executables dynamically linked to the same huge
library has its advantages, but this would not substantiate the
additional work to make it compile. The reason is the complicated-to-developers
but very quick and convenient-to-users \*(L"hard\*(R" dynamic linking used by \s-1OS/2.\s0
.PP
There are two distinctive features of the dyna-linking model of \s-1OS/2:\s0
first, all the references to external functions are resolved at the compile time;
second, there is no runtime fixup of the DLLs after they are loaded into memory.
The first feature is an enormous advantage over other models: it avoids
conflicts when several DLLs used by an application export entries with
the same name. In such cases \*(L"other\*(R" models of dyna-linking just choose
between these two entry points using some random criterion \- with predictable
disasters as results. But it is the second feature which requires the build
of \fIperl.dll\fR.
.PP
The address tables of DLLs are patched only once, when they are
loaded. The addresses of the entry points into DLLs are guaranteed to be
the same for all the programs which use the same \s-1DLL.\s0 This removes the
runtime fixup \- once \s-1DLL\s0 is loaded, its code is read-only.
.PP
While this allows some (significant?) performance advantages, this makes life
much harder for developers, since the above scheme makes it impossible
for a \s-1DLL\s0 to be \*(L"linked\*(R" to a symbol in the \fI.EXE\fR file. Indeed, this
would need a \s-1DLL\s0 to have different relocations tables for the
(different) executables which use this \s-1DLL.\s0
.PP
However, a dynamically loaded Perl extension is forced to use some symbols
from the perl
executable, e.g., to know how to find the arguments to the functions:
the arguments live on the perl
internal evaluation stack. The solution is to put the main code of
the interpreter into a \s-1DLL,\s0 and make the \fI.EXE\fR file which just loads
this \s-1DLL\s0 into memory and supplies command-arguments. The extension \s-1DLL\s0
cannot link to symbols in \fI.EXE\fR, but it has no problem linking
to symbols in the \fI.DLL\fR.
.PP
This \fIgreatly\fR increases the load time for the application (as well as
complexity of the compilation). Since interpreter is in a \s-1DLL,\s0
the C \s-1RTL\s0 is basically forced to reside in a \s-1DLL\s0 as well (otherwise
extensions would not be able to use \s-1CRT\s0). There are some advantages if
you use different flavors of perl, such as running \fIperl.exe\fR and
\&\fIperl_\|_.exe\fR simultaneously: they share the memory of \fIperl.dll\fR.
.PP
\&\fB\s-1NOTE\s0\fR. There is one additional effect which makes DLLs more wasteful:
DLLs are loaded in the shared memory region, which is a scarse resource
given the 512M barrier of the \*(L"standard\*(R" \s-1OS/2\s0 virtual memory. The code of
\&\fI.EXE\fR files is also shared by all the processes which use the particular
\&\fI.EXE\fR, but they are \*(L"shared in the private address space of the process\*(R";
this is possible because the address at which different sections
of the \fI.EXE\fR file are loaded is decided at compile-time, thus all the
processes have these sections loaded at same addresses, and no fixup
of internal links inside the \fI.EXE\fR is needed.
.PP
Since DLLs may be loaded at run time, to have the same mechanism for DLLs
one needs to have the address range of \fIany of the loaded\fR DLLs in the
system to be available \fIin all the processes\fR which did not load a particular
\&\s-1DLL\s0 yet. This is why the DLLs are mapped to the shared memory region.
.SS "Why chimera build?"
.IX Subsection "Why chimera build?"
Current \s-1EMX\s0 environment does not allow DLLs compiled using Unixish
\&\f(CW\*(C`a.out\*(C'\fR format to export symbols for data (or at least some types of
data). This forces \f(CW\*(C`omf\*(C'\fR\-style compile of \fIperl.dll\fR.
.PP
Current \s-1EMX\s0 environment does not allow \fI.EXE\fR files compiled in
\&\f(CW\*(C`omf\*(C'\fR format to \fBfork()\fR. \fBfork()\fR is needed for exactly three Perl
operations:
.IP "\(bu" 4
explicit \fBfork()\fR in the script,
.IP "\(bu" 4
\&\f(CW\*(C`open FH, "|\-"\*(C'\fR
.IP "\(bu" 4
\&\f(CW\*(C`open FH, "\-|"\*(C'\fR, in other words, opening pipes to itself.
.PP
While these operations are not questions of life and death, they are
needed for a lot of
useful scripts. This forces \f(CW\*(C`a.out\*(C'\fR\-style compile of
\&\fIperl.exe\fR.
.SH "ENVIRONMENT"
.IX Header "ENVIRONMENT"
Here we list environment variables with are either \s-1OS/2\-\s0 and \s-1DOS\-\s0 and
Win*\-specific, or are more important under \s-1OS/2\s0 than under other OSes.
.ie n .SS """PERLLIB_PREFIX"""
.el .SS "\f(CWPERLLIB_PREFIX\fP"
.IX Subsection "PERLLIB_PREFIX"
Specific for \s-1EMX\s0 port. Should have the form
.PP
.Vb 1
\& path1;path2
.Ve
.PP
or
.PP
.Vb 1
\& path1 path2
.Ve
.PP
If the beginning of some prebuilt path matches \fIpath1\fR, it is
substituted with \fIpath2\fR.
.PP
Should be used if the perl library is moved from the default
location in preference to \f(CW\*(C`PERL(5)LIB\*(C'\fR, since this would not leave wrong
entries in \f(CW@INC\fR. For example, if the compiled version of perl looks for \f(CW@INC\fR
in \fIf:/perllib/lib\fR, and you want to install the library in
\&\fIh:/opt/gnu\fR, do
.PP
.Vb 1
\& set PERLLIB_PREFIX=f:/perllib/lib;h:/opt/gnu
.Ve
.PP
This will cause Perl with the prebuilt \f(CW@INC\fR of
.PP
.Vb 5
\& f:/perllib/lib/5.00553/os2
\& f:/perllib/lib/5.00553
\& f:/perllib/lib/site_perl/5.00553/os2
\& f:/perllib/lib/site_perl/5.00553
\& .
.Ve
.PP
to use the following \f(CW@INC:\fR
.PP
.Vb 5
\& h:/opt/gnu/5.00553/os2
\& h:/opt/gnu/5.00553
\& h:/opt/gnu/site_perl/5.00553/os2
\& h:/opt/gnu/site_perl/5.00553
\& .
.Ve
.ie n .SS """PERL_BADLANG"""
.el .SS "\f(CWPERL_BADLANG\fP"
.IX Subsection "PERL_BADLANG"
If 0, perl ignores \fBsetlocale()\fR failing. May be useful with some
strange \fIlocale\fRs.
.ie n .SS """PERL_BADFREE"""
.el .SS "\f(CWPERL_BADFREE\fP"
.IX Subsection "PERL_BADFREE"
If 0, perl would not warn of in case of unwarranted \fBfree()\fR. With older
perls this might be
useful in conjunction with the module DB_File, which was buggy when
dynamically linked and OMF-built.
.PP
Should not be set with newer Perls, since this may hide some \fIreal\fR problems.
.ie n .SS """PERL_SH_DIR"""
.el .SS "\f(CWPERL_SH_DIR\fP"
.IX Subsection "PERL_SH_DIR"
Specific for \s-1EMX\s0 port. Gives the directory part of the location for
\&\fIsh.exe\fR.
.ie n .SS """USE_PERL_FLOCK"""
.el .SS "\f(CWUSE_PERL_FLOCK\fP"
.IX Subsection "USE_PERL_FLOCK"
Specific for \s-1EMX\s0 port. Since \fBflock\fR\|(3) is present in \s-1EMX,\s0 but is not
functional, it is emulated by perl. To disable the emulations, set
environment variable \f(CW\*(C`USE_PERL_FLOCK=0\*(C'\fR.
.ie n .SS """TMP"" or ""TEMP"""
.el .SS "\f(CWTMP\fP or \f(CWTEMP\fP"
.IX Subsection "TMP or TEMP"
Specific for \s-1EMX\s0 port. Used as storage place for temporary files.
.SH "Evolution"
.IX Header "Evolution"
Here we list major changes which could make you by surprise.
.SS "Text-mode filehandles"
.IX Subsection "Text-mode filehandles"
Starting from version 5.8, Perl uses a builtin translation layer for
text-mode files. This replaces the efficient well-tested \s-1EMX\s0 layer by
some code which should be best characterized as a \*(L"quick hack\*(R".
.PP
In addition to possible bugs and an inability to follow changes to the
translation policy with off/on switches of \s-1TERMIO\s0 translation, this
introduces a serious incompatible change: before \fBsysread()\fR on
text-mode filehandles would go through the translation layer, now it
would not.
.SS "Priorities"
.IX Subsection "Priorities"
\&\f(CW\*(C`setpriority\*(C'\fR and \f(CW\*(C`getpriority\*(C'\fR are not compatible with earlier
ports by Andreas Kaiser. See \*(L"setpriority, getpriority\*(R".
.SS "\s-1DLL\s0 name mangling: pre 5.6.2"
.IX Subsection "DLL name mangling: pre 5.6.2"
With the release 5.003_01 the dynamically loadable libraries
should be rebuilt when a different version of Perl is compiled. In particular,
DLLs (including \fIperl.dll\fR) are now created with the names
which contain a checksum, thus allowing workaround for \s-1OS/2\s0 scheme of
caching DLLs.
.PP
It may be possible to code a simple workaround which would
.IP "\(bu" 4
find the old DLLs looking through the old \f(CW@INC\fR;
.IP "\(bu" 4
mangle the names according to the scheme of new perl and copy the DLLs to
these names;
.IP "\(bu" 4
edit the internal \f(CW\*(C`LX\*(C'\fR tables of \s-1DLL\s0 to reflect the change of the name
(probably not needed for Perl extension DLLs, since the internally coded names
are not used for \*(L"specific\*(R" DLLs, they used only for \*(L"global\*(R" DLLs).
.IP "\(bu" 4
edit the internal \f(CW\*(C`IMPORT\*(C'\fR tables and change the name of the \*(L"old\*(R"
\&\fIperl????.dll\fR to the \*(L"new\*(R" \fIperl????.dll\fR.
.SS "\s-1DLL\s0 name mangling: 5.6.2 and beyond"
.IX Subsection "DLL name mangling: 5.6.2 and beyond"
In fact mangling of \fIextension\fR DLLs was done due to misunderstanding
of the \s-1OS/2\s0 dynaloading model. \s-1OS/2\s0 (effectively) maintains two
different tables of loaded \s-1DLL:\s0
.IP "Global DLLs" 4
.IX Item "Global DLLs"
those loaded by the base name from \f(CW\*(C`LIBPATH\*(C'\fR; including those
associated at link time;
.IP "specific DLLs" 4
.IX Item "specific DLLs"
loaded by the full name.
.PP
When resolving a request for a global \s-1DLL,\s0 the table of already-loaded
specific DLLs is (effectively) ignored; moreover, specific DLLs are
\&\fIalways\fR loaded from the prescribed path.
.PP
There is/was a minor twist which makes this scheme fragile: what to do
with DLLs loaded from
.ie n .IP """BEGINLIBPATH"" and ""ENDLIBPATH""" 4
.el .IP "\f(CWBEGINLIBPATH\fR and \f(CWENDLIBPATH\fR" 4
.IX Item "BEGINLIBPATH and ENDLIBPATH"
(which depend on the process)
.ie n .IP "\fI.\fR from ""LIBPATH""" 4
.el .IP "\fI.\fR from \f(CWLIBPATH\fR" 4
.IX Item ". from LIBPATH"
which \fIeffectively\fR depends on the process (although \f(CW\*(C`LIBPATH\*(C'\fR is the
same for all the processes).
.PP
Unless \f(CW\*(C`LIBPATHSTRICT\*(C'\fR is set to \f(CW\*(C`T\*(C'\fR (and the kernel is after
2000/09/01), such DLLs are considered to be global. When loading a
global \s-1DLL\s0 it is first looked in the table of already-loaded global
DLLs. Because of this the fact that one executable loaded a \s-1DLL\s0 from
\&\f(CW\*(C`BEGINLIBPATH\*(C'\fR and \f(CW\*(C`ENDLIBPATH\*(C'\fR, or \fI.\fR from \f(CW\*(C`LIBPATH\*(C'\fR may affect
\&\fIwhich\fR \s-1DLL\s0 is loaded when \fIanother\fR executable requests a \s-1DLL\s0 with
the same name. \fIThis\fR is the reason for version-specific mangling of
the \s-1DLL\s0 name for perl \s-1DLL.\s0
.PP
Since the Perl extension DLLs are always loaded with the full path,
there is no need to mangle their names in a version-specific ways:
their directory already reflects the corresponding version of perl,
and \f(CW@INC\fR takes into account binary compatibility with older version.
Starting from \f(CW5.6.2\fR the name mangling scheme is fixed to be the
same as for Perl 5.005_53 (same as in a popular binary release). Thus
new Perls will be able to \fIresolve the names\fR of old extension DLLs
if \f(CW@INC\fR allows finding their directories.
.PP
However, this still does not guarantee that these \s-1DLL\s0 may be loaded.
The reason is the mangling of the name of the \fIPerl \s-1DLL\s0\fR. And since
the extension DLLs link with the Perl \s-1DLL,\s0 extension DLLs for older
versions would load an older Perl \s-1DLL,\s0 and would most probably
segfault (since the data in this \s-1DLL\s0 is not properly initialized).
.PP
There is a partial workaround (which can be made complete with newer
\&\s-1OS/2\s0 kernels): create a forwarder \s-1DLL\s0 with the same name as the \s-1DLL\s0 of
the older version of Perl, which forwards the entry points to the
newer Perl's \s-1DLL.\s0 Make this \s-1DLL\s0 accessible on (say) the \f(CW\*(C`BEGINLIBPATH\*(C'\fR of
the new Perl executable. When the new executable accesses old Perl's
extension DLLs, they would request the old Perl's \s-1DLL\s0 by name, get the
forwarder instead, so effectively will link with the currently running
(new) Perl \s-1DLL.\s0
.PP
This may break in two ways:
.IP "\(bu" 4
Old perl executable is started when a new executable is running has
loaded an extension compiled for the old executable (ouph!). In this
case the old executable will get a forwarder \s-1DLL\s0 instead of the old
perl \s-1DLL,\s0 so would link with the new perl \s-1DLL.\s0 While not directly
fatal, it will behave the same as new executable. This beats the whole
purpose of explicitly starting an old executable.
.IP "\(bu" 4
A new executable loads an extension compiled for the old executable
when an old perl executable is running. In this case the extension
will not pick up the forwarder \- with fatal results.
.PP
With support for \f(CW\*(C`LIBPATHSTRICT\*(C'\fR this may be circumvented \- unless
one of DLLs is started from \fI.\fR from \f(CW\*(C`LIBPATH\*(C'\fR (I do not know
whether \f(CW\*(C`LIBPATHSTRICT\*(C'\fR affects this case).
.PP
\&\fB\s-1REMARK\s0\fR. Unless newer kernels allow \fI.\fR in \f(CW\*(C`BEGINLIBPATH\*(C'\fR (older
do not), this mess cannot be completely cleaned. (It turns out that
as of the beginning of 2002, \fI.\fR is not allowed, but \fI.\e.\fR is \- and
it has the same effect.)
.PP
\&\fB\s-1REMARK\s0\fR. \f(CW\*(C`LIBPATHSTRICT\*(C'\fR, \f(CW\*(C`BEGINLIBPATH\*(C'\fR and \f(CW\*(C`ENDLIBPATH\*(C'\fR are
not environment variables, although \fIcmd.exe\fR emulates them on \f(CW\*(C`SET
\&...\*(C'\fR lines. From Perl they may be accessed by
Cwd::extLibpath and
Cwd::extLibpath_set.
.SS "\s-1DLL\s0 forwarder generation"
.IX Subsection "DLL forwarder generation"
Assume that the old \s-1DLL\s0 is named \fIperlE0AC.dll\fR (as is one for
5.005_53), and the new version is 5.6.1. Create a file
\&\fIperl5shim.def\-leader\fR with
.PP
.Vb 5
\& LIBRARY \*(AqperlE0AC\*(Aq INITINSTANCE TERMINSTANCE
\& DESCRIPTION \*(Aq@#perl5\-porters@perl.org:5.006001#@ Perl module for 5.00553 \-> Perl 5.6.1 forwarder\*(Aq
\& CODE LOADONCALL
\& DATA LOADONCALL NONSHARED MULTIPLE
\& EXPORTS
.Ve
.PP
modifying the versions/names as needed. Run
.PP
.Vb 2
\& perl \-wnle "next if 0../EXPORTS/; print qq( \e"$1\e")
\& if /\e"(\ew+)\e"/" perl5.def >lst
.Ve
.PP
in the Perl build directory (to make the \s-1DLL\s0 smaller replace perl5.def
with the definition file for the older version of Perl if present).
.PP
.Vb 2
\& cat perl5shim.def\-leader lst >perl5shim.def
\& gcc \-Zomf \-Zdll \-o perlE0AC.dll perl5shim.def \-s \-llibperl
.Ve
.PP
(ignore multiple \f(CW\*(C`warning L4085\*(C'\fR).
.SS "Threading"
.IX Subsection "Threading"
As of release 5.003_01 perl is linked to multithreaded C \s-1RTL
DLL.\s0 If perl itself is not compiled multithread-enabled, so will not be perl's
\&\fBmalloc()\fR. However, extensions may use multiple thread on their own
risk.
.PP
This was needed to compile \f(CW\*(C`Perl/Tk\*(C'\fR for XFree86\-OS/2 out-of-the-box, and
link with DLLs for other useful libraries, which typically are compiled
with \f(CW\*(C`\-Zmt \-Zcrtdll\*(C'\fR.
.SS "Calls to external programs"
.IX Subsection "Calls to external programs"
Due to a popular demand the perl external program calling has been
changed wrt Andreas Kaiser's port. \fIIf\fR perl needs to call an
external program \fIvia shell\fR, the \fIf:/bin/sh.exe\fR will be called, or
whatever is the override, see "\f(CW\*(C`PERL_SH_DIR\*(C'\fR".
.PP
Thus means that you need to get some copy of a \fIsh.exe\fR as well (I
use one from pdksh). The path \fIF:/bin\fR above is set up automatically during
the build to a correct value on the builder machine, but is
overridable at runtime,
.PP
\&\fBReasons:\fR a consensus on \f(CW\*(C`perl5\-porters\*(C'\fR was that perl should use
one non-overridable shell per platform. The obvious choices for \s-1OS/2\s0
are \fIcmd.exe\fR and \fIsh.exe\fR. Having perl build itself would be impossible
with \fIcmd.exe\fR as a shell, thus I picked up \f(CW\*(C`sh.exe\*(C'\fR. This assures almost
100% compatibility with the scripts coming from *nix. As an added benefit
this works as well under \s-1DOS\s0 if you use DOS-enabled port of pdksh
(see \*(L"Prerequisites\*(R").
.PP
\&\fBDisadvantages:\fR currently \fIsh.exe\fR of pdksh calls external programs
via \fBfork()\fR/\fBexec()\fR, and there is \fIno\fR functioning \fBexec()\fR on
\&\s-1OS/2.\s0 \fBexec()\fR is emulated by \s-1EMX\s0 by an asynchronous call while the caller
waits for child completion (to pretend that the \f(CW\*(C`pid\*(C'\fR did not change). This
means that 1 \fIextra\fR copy of \fIsh.exe\fR is made active via \fBfork()\fR/\fBexec()\fR,
which may lead to some resources taken from the system (even if we do
not count extra work needed for \fBfork()\fRing).
.PP
Note that this a lesser issue now when we do not spawn \fIsh.exe\fR
unless needed (metachars found).
.PP
One can always start \fIcmd.exe\fR explicitly via
.PP
.Vb 1
\& system \*(Aqcmd\*(Aq, \*(Aq/c\*(Aq, \*(Aqmycmd\*(Aq, \*(Aqarg1\*(Aq, \*(Aqarg2\*(Aq, ...
.Ve
.PP
If you need to use \fIcmd.exe\fR, and do not want to hand-edit thousands of your
scripts, the long-term solution proposed on p5\-p is to have a directive
.PP
.Vb 1
\& use OS2::Cmd;
.Ve
.PP
which will override \fBsystem()\fR, \fBexec()\fR, \f(CW\*(C`\`\`\*(C'\fR, and
\&\f(CW\*(C`open(,\*(Aq...|\*(Aq)\*(C'\fR. With current perl you may override only \fBsystem()\fR,
\&\fBreadpipe()\fR \- the explicit version of \f(CW\*(C`\`\`\*(C'\fR, and maybe \fBexec()\fR. The code
will substitute the one-argument call to \fBsystem()\fR by
\&\f(CW\*(C`CORE::system(\*(Aqcmd.exe\*(Aq, \*(Aq/c\*(Aq, shift)\*(C'\fR.
.PP
If you have some working code for \f(CW\*(C`OS2::Cmd\*(C'\fR, please send it to me,
I will include it into distribution. I have no need for such a module, so
cannot test it.
.PP
For the details of the current situation with calling external programs,
see \*(L"Starting \s-1OS/2\s0 (and \s-1DOS\s0) programs under Perl\*(R". Set us
mention a couple of features:
.IP "\(bu" 4
External scripts may be called by their basename. Perl will try the same
extensions as when processing \fB\-S\fR command-line switch.
.IP "\(bu" 4
External scripts starting with \f(CW\*(C`#!\*(C'\fR or \f(CW\*(C`extproc \*(C'\fR will be executed directly,
without calling the shell, by calling the program specified on the rest of
the first line.
.SS "Memory allocation"
.IX Subsection "Memory allocation"
Perl uses its own \fBmalloc()\fR under \s-1OS/2\s0 \- interpreters are usually malloc-bound
for speed, but perl is not, since its malloc is lightning-fast.
Perl-memory-usage-tuned benchmarks show that Perl's malloc is 5 times quicker
than \s-1EMX\s0 one. I do not have convincing data about memory footprint, but
a (pretty random) benchmark showed that Perl's one is 5% better.
.PP
Combination of perl's \fBmalloc()\fR and rigid \s-1DLL\s0 name resolution creates
a special problem with library functions which expect their return value to
be \fBfree()\fRd by system's \fBfree()\fR. To facilitate extensions which need to call
such functions, system memory-allocation functions are still available with
the prefix \f(CW\*(C`emx_\*(C'\fR added. (Currently only \s-1DLL\s0 perl has this, it should
propagate to \fIperl_.exe\fR shortly.)
.SS "Threads"
.IX Subsection "Threads"
One can build perl with thread support enabled by providing \f(CW\*(C`\-D usethreads\*(C'\fR
option to \fIConfigure\fR. Currently \s-1OS/2\s0 support of threads is very
preliminary.
.PP
Most notable problems:
.ie n .IP """COND_WAIT""" 4
.el .IP "\f(CWCOND_WAIT\fR" 4
.IX Item "COND_WAIT"
may have a race condition (but probably does not due to edge-triggered
nature of \s-1OS/2\s0 Event semaphores). (Needs a reimplementation (in terms of chaining
waiting threads, with the linked list stored in per-thread structure?)?)
.IP "\fIos2.c\fR" 4
.IX Item "os2.c"
has a couple of static variables used in OS/2\-specific functions. (Need to be
moved to per-thread structure, or serialized?)
.PP
Note that these problems should not discourage experimenting, since they
have a low probability of affecting small programs.
.SH "BUGS"
.IX Header "BUGS"
This description is not updated often (since 5.6.1?), see \fI./os2/Changes\fR
for more info.
.SH "AUTHOR"
.IX Header "AUTHOR"
Ilya Zakharevich, cpan@ilyaz.org
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBperl\fR\|(1).