perl 4.0.00: (no release announcement available)
[p5sagit/p5-mst-13.2.git] / os2 / README.OS2
CommitLineData
87250799 1 Notes on the OS/2 Perl port
2
3 Raymond Chen
b6ccd89c 4 (rjc@math.princeton.edu)
5
6 Kai Uwe Rommel
7 (rommel@lan.informatik.tu-muenchen.dbp.de)
87250799 8
9-1. Background.
10
11This port was based on the MS-DOS port by Diomidis Spinellis.
12
130. Set-up.
14
15First copy the files in the os2 directory into the parent
16directory. Also install the file msdos/dir.h in your include
17directory.
18
191. Compiling.
20
b6ccd89c 21Perl has been compiled under MS-DOS using the Microsoft C compiler
22version 6.0. Before compiling install dir.h as <sys/dir.h>. You will
23need a Unix-like make program and something like yacc (e.g. bison). I
24just ran yacc on my UNIX box and downloaded the resulting y.tab.[ch]
87250799 25files. Compilation takes 45 minutes on a 16MHz 386 machine running
b6ccd89c 26no jobs other than the compiler, so you will probably need something to
87250799 27do in the meantime. Like, say, lunch. (Compilation time does not
b6ccd89c 28include formatting the manual.) If you compile with optimization
87250799 29turned off, it takes about half as long.
30
31The executable is 270k (perlsym.exe is 473k; if you compile
b6ccd89c 32without optimization, the sizes are 329K/531K), and the top level
33directory needs 800K for sources, 550K for object code, and 800K for the
87250799 34executables, assuming you want to build both perl.exe and perlsym.exe
35with full optimization.
36
b6ccd89c 37The makefile will compile glob for you which you will need to place
38somewhere in your path so that perl globbing will work correctly. All
39the tests were run, although some modifications were necessary because
40OS/2 isn't UNIX. The tests that failed failed because of limitations of
41the operating system and aren't the fault of the compiler. a2p and s2p
42were not tested.
87250799 43
44In the eg directory you will find the syscalls.pl header file,
45and a sample program that demonstrates some of the improvements
46of the OS/2 version over the MS-DOS version and some of the
47system calls.
48
492. Using OS/2 Perl
50
b6ccd89c 51The OS/2 version of perl has much of the functionality of the Unix
52version. Here are some things that don't work: sockets, password
53functions, [gs]et[eug]id, dbm functions, fork.
87250799 54
55One thing that doesn't work is "split" with no arguments. Somehow,
56yylval.arg is empty ... [[ Wait, sorry, I fixed that. --rjc ]]
57
58Care has been taken to implement the rest, although the implementation
b6ccd89c 59might not be the best possible. Here are short notes on the tricky
60bits:
87250799 61
622.1. In-place editing.
63
b6ccd89c 64Files currently can be edited in-place provided you are creating a
87250799 65backup. Considerable effort is made to ensure that a reasonable
66name for the backup is selected, while still remaining within
67the 8.3 contraints of the FAT filesystem. (HPFS users have nothing
68to worry about, since HPFS doesn't have the stupid 8.3 rule.)
69
70The rules for how OS/2 perl combines your filename with the suffix
71(the thing passed to "-i") are rather complicated, but the basic
72idea is that the "obvious" name is chosen.
73
74Here are the rules:
75
76Style 0: Append the suffix exactly as UNIX perl would do it.
77 If the filesystem likes it, use it. (HPFS will always
78 swallow it. FAT will rarely accept it.)
79
80Style 1: If the suffix begins with a '.', change the file extension
b6ccd89c 81 to whatever you supplied. If the name matches the original
87250799 82 name, use the fallback method.
83
b6ccd89c 84Style 2: If the suffix is a single character, not a '.', try to add the
87250799 85 suffix to the following places, using the first one that works.
b6ccd89c 86 [1] Append to extension.
87 [2] Append to filename,
88 [3] Replace end of extension,
87250799 89 [4] Replace end of filename.
90 If the name matches the original name, use the fallback method.
91
92Style 3: Any other case: Ignore the suffix completely and use the
93 fallback method.
94
95Fallback method: Change the extension to ".$$$". If that matches the
96 original name, then change the extension to ".~~~".
97
98If filename is more than 1000 characters long, we die a horrible
99death. Sorry.
100
101Examples, assuming style 0 failed.
102
103suffix = ".bak" (style 1)
104 foo.bar => foo.bak
105 foo.bak => foo.$$$ (fallback)
106 foo.$$$ => foo.~~~ (fallback)
107 makefile => makefile.bak
108
109suffix = "~" (style 2)
110 foo.c => foo.c~
111 foo.c~ => foo.c~~
112 foo.c~~ => foo~.c~~
113 foo~.c~~ => foo~~.c~~
114 foo~~~~~.c~~ => foo~~~~~.$$$ (fallback)
115
116 foo.pas => foo~.pas
117 makefile => makefile.~
118 longname.fil => longname.fi~
119 longname.fi~ => longnam~.fi~
120 longnam~.fi~ => longnam~.$$$
b6ccd89c 121
87250799 1222.2. Directory access.
123
124Are implemented, but in order to support telldir() and seekdir(),
125they operate by reading in the entire directory at opendir(),
126then handing out pieces of it each time you do a readdir().
127
1282.3. Pipes and redirection.
129
b6ccd89c 130Pipes and redirection are supported. Although OS/2 does not
87250799 131terminate programs which try to write to closed pipes, perl will
132kill them for you if you do it like this:
133
134 open(I, "long-running-program|");
135 ... process a few lines ...
136 close(I); # discard the rest ...
137
138The killing works like this: We wait until the child program either
139closes its stdout or tries to write to it. If it writes to its stdout,
140we kill it. Otherwise, we cwait for it. This is pretty much what UNIX
141does by default.
142
143All pipe commands are given to cmd.exe (or your COMSPEC) for execution as
144
145 CMD /c your-command-line
146
147so you can go ahead and load it up with any goofy things you want,
148like 2>1 redirection, more pipes, && || etc.
149
150The pipe() function is also supported, so you can go ahead and
151make your own funky file descriptor connections before piping off
152a process. However, you have to mark the descriptor you are
153retaining as NOINHERIT before spawning, else you are in deadlock city.
154Unfortunately, there's no way to mark the handle as NOINHERIT yet.
155It's on my wish list.
156
1572.4. Syscall and Ioctl
158
159IOCtl is not supported because the API is very different from the
160UNIX API. Instead, IOCtl is supported as a syscall. Here are
161the syscalls I've written so far:
162
163 $OS2_GetVersion = 0;
164 $OS2_Shutdown = 1;
165 $OS2_Beep = 2;
166 $OS2_PhysicalDisk = 3;
167 $OS2_Config = 4;
168 $OS2_IOCtl = 5;
169 $OS2_QCurDisk = 6;
170 $OS2_SelectDisk = 7;
171 $OS2_SetMaxFH = 8;
172 $OS2_Sleep = 9;
173 $OS2_StartSession = 10;
174 $OS2_StopSession = 11;
175 $OS2_SelectSession = 12;
176
177The arguments you pass are handed off to OS/2 without interpretation,
178and the return value is returned straight to you. However, you don't
b6ccd89c 179have to supply arguments for the ones whose descriptions are "must be
87250799 180zero"; perl will supply the mandatory zeros for you.
181
1822.5. Binary file access
183
b6ccd89c 184Files are opened in text mode by default. This means that CR LF pairs
185are translated to LF. If binary access is needed the `binarymode'
186function should be used. There is currently no way to reverse the
187effect of the binary function. If that is needed close and reopen the
188file.
87250799 189
1902.6. Priority
191
b6ccd89c 192The getpriority and setpriority functions are implemented, but since
193OS/2 priorities are different from UNIX priorities, the arguments aren't
194the same. Basically, the arguments you pass are handed directly to
195OS/2. The only exception is the last argument to setpriority. To make
196it easier to make delta priorities, if the priority class is 0xff, it
87250799 197is changed to 0. That way, you can write
198
199 setpriority(0,0,-2)
200
201instead of
202
203 setpriority(0,0,0xfe)
204
205to decrease the delta by 2.
206
2072.7. Interpreter startup.
208
b6ccd89c 209The effect of the Unix #!/bin/perl interpreter startup can be obtained
210under OS/2 by giving the script a .cmd extension and beginning the script
87250799 211with the line
212
213 extproc C:\binp\perl.exe -S
214
215You should provide the appropriate path to your executable, and
216the -S option is necessary so that perl can find your script.
217
2182.8. The kill function.
219
220UNIX and OS/2 have different ideas about the kill function. I've
221done a pretty feeble job of taking perl's UNIXish approach and
222trying to jam it into the OS/2 way. No doubt you'll find that
223your kill()s aren't working. My apologies in advance.
224
2253. Bug reports.
226
227I don't normally have access to an OS/2 machine, so if you find
228a bug, you can go ahead and tell me about it, but the odds that
229I'd be able to fix it are slim.
230
2314. Wish list.
232
2334.1. OS/2.
234
235Make ENOPIPE a fatal error.
236
237Permit linking of files. (Allegedly, they're working on this.)
238
239Get a fork.
240
241Make CMD.EXE pass through the return code of its child.
242
2434.2 perl.
244
245Provide a nice way to add new functions to perl without having
246to understand the innards of perl. Not being fluent in perl
247innards hacking, I added my extra functions via syscall.
248
2494.3. My port.
250
2514.3.1. In-place editing.
252
253Make more idiot-proof.
254
255Allow in-place editing without backup. (How?)
256
2574.3.2. Spawning and piping.
258
259Make popen() cleverer. Currently, it blindly hands everything
260off to CMD.EXE. This wastes an exec if the command line didn't
261have any shell metacharacters and if the program being run
262is not a batch file.
263
264Clever spawning is carried out by do_spawn. We should try
265to make popen() do much of the same sort of preprocessing
266as do_spawn does (which means, of course, that we probably
267should yank out code to be dished off into a subroutine).
268
b6ccd89c 269In do_spawn(), use DosExecPgm instead of spawnl in order to get more
87250799 270precise reasons why the child terminated (RESULTCODES).
271
272
273 July 1990
274
275 Raymond Chen <rjc@math.princeton.edu>
276 1817 Oxford St. Apt 6
277 Berkeley, CA 94709-1828 USA
b6ccd89c 278
279-----------------------
280I picked up the OS/2 port with patches 19-28. When compiling, I found
281out that os2.c and director.c were missing. I had to rewrite them because
282even the original author of the port (Raymond Chen) did no longer have them.
283
284I had directory routines laying around, this was no big deal.
285I rewrote os2.c, but did not implement the syscall() as described above.
286I had not the time and did not really need it. Feel free ...
287
288Changes to above described port:
289
290- the small program GLOB is now named PERLGLOB for better ordering in
291 my /bin directory
292
293- added help page (well, a graphical user interface would be overkill
294 but a simple help page should be in every program :-)
295
296- several cosmetic changes in standard distribution files because of
297 naming conventions etc., #ifdef'd OS2
298
299- syscall() not supported as noted above
300
301- chdir now recognizes also drive letters and changes also the drive
302
303- new mypopen(), mypclose() functions and simulation routines for DOS mode,
304 they are selected automatically in real mode
305- the new pclose() does not kill the child, my experience is that this is
306 not needed.
307
308- setpriority is now: setpriority(class, pid, val)
309 see description of DosSetPrty() for class and val meanings
310- getpriority is now: getpriority(dummy, pid)
311 see description of DosGetPrty()
312
313- kill is now: kill(pid, sig)
314 where sig can be 0 (kill process)
315 1-3 (send process flags A-C, see DosFlagProcess())
316 if pid is less than zero, the signal is sent to the whole
317 process tree originating at -pid.
318
319The following files are now new with patch >=29:
320
321readme.os2 this file
322
323dir.h sys/dir.h
324director.c directory routines
325os2.c kernel of OS/2 port (see below)
326popen.c new popen.c
327mktemp.c enhanced mktemp(), uses TMP env. variable, used by popen.c
fe14fcc3 328alarm.c PD implementation for alarm()
329alarm.h header for alarm.c
b6ccd89c 330
331perl.cs Compiler Shell script for perl itself
332perl.def linker definition file for perl
333perl.bad names of protect-only API calls for BIND
334perlglob.cs Compiler Shell script for perl globbing program
335perlglob.def linker definition file for perlglob
336a2p.cs Compiler Shell script for a2p (see below)
337a2p.def linker definition file for a2p
338makefile Makefile, not tested
339
340perlsh.cmd the converted perlsh
5303340c 341perldb.dif changes required for perldb.pl (change for your needs)
b6ccd89c 342selfrun.cmd sample selfrunning perl script for OS/2
343selfrun.bat sample selfrunning perl script for DOS mode
344
345Note: I don't use make but my own utility, the Compiler Shell CS.
346It was posted in comp.binaries.os2 or you can ask me for the newest
347version. The .CS files are the "makefiles" for it.
348
349Note: MS C 6.00 is required. C 5.1 is not capable of compiling perl,
350especially not with -DDEBUGGING
351
352
353 August 1990
354
355 Kai Uwe Rommel
356 rommel@lan.informatik.tu-muenchen.dbp.de
fe14fcc3 357 Zennerstr. 1
358 D-8000 Muenchen 70
359
360
5303340c 361+ I have verified with patchlevel 37, that the OS/2 port compiles,
362 after doing two minor changes. HPFS filenames support was also added.
363 Some bugs were fixed.
364+ To compile,
365 - you need the bison parser generator
366 - copy config.h from os2 into the main perl directory (important !)
367 - copy perl.cs and perlglob.cs from the os2 subdir to the main dir
368 - copy a2p.cs from os2 to x2p
369 - say "bison -d perl.y"
370 "ren perl_tab.c perl.c" and
371 "ren perl_tab.h perly.h" in the main directory
372 - say "cs perl" and
373 "cs perlglob" in the main directory
374 - say "cs a2p" in the x2p subdir
375+ If you don't have CS or don't want to use it, you have to
376 construct a makefile ...
377+ If you have GNU gdbm, you can define NDBM in config.h and link with a
378 large model library of gdbm.
379+ I am not shure if I can verify the OS/2 port with each release
380 from Larry Wall. Therefore, in future releases there may be
381 changes required to compile perl for OS/2.
382 October 1990
383 Kai Uwe Rommel
384 rommel@lan.informatik.tu-muenchen.dbp.de
fe14fcc3 385
386
387Verified patchlevel 40.
388Some bugs were fixed. Added alarm() support (using PD implementation).
389
390
391 November 1990
392
393 Kai Uwe Rommel
394 rommel@lan.informatik.tu-muenchen.dbp.de
395
396
397Verified patchlevel 44.
398Only two #ifdefs added to eval.c. Stack size for A2P had to be corrected.
399PERLGLOB separated from DOS version because of HPFS support.
400
401[Note: instead of #ifdef'ing eval.c I fixed it in perl.h--lwall]
402
403 January 1991
404
405 Kai Uwe Rommel
406 rommel@lan.informatik.tu-muenchen.dbp.de