summaryrefslogtreecommitdiff
path: root/os2
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.ohio-state.edu>1997-06-09 16:52:06 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit367f3c247e808d76465803ec861b19fd55ffd90d (patch)
tree4ca58250b62dedd5b9ff9bae8d8a993b3debb769 /os2
parent17fd57d4d5d145d80aa9549b4fb89625b31a4148 (diff)
downloadperl-367f3c247e808d76465803ec861b19fd55ffd90d.tar.gz
Assorted OS/2 fixes
In article <9706131709.AA05526@toad.ig.co.uk>, Tim Bunce <Tim.Bunce@ig.co.uk> wrote: > It give me great pleasure to announce the arrival of perl5.004_01. Thank you for a great job! You even corrected os2/diff.configure! Unfortunately, several sections of os2/diff.configure were erroneously removed, so it will not create a valid config.sh any more (ar used instead of $ar, and one extra method to extract symbols is not tried). Unfortunately, I was away from my development machine, so could not try it earlier. A patch to correct this problem, and some other ones, follows. a) Missing sections restored; os2/diff.configure b) my_flock added to os2/os2.c (libc contains a dummy implementation only) (switchable off in case CRT DLL is fixed in this respect); os2/os2ish.h os2/Makefile.SHs os2/os2.c c) depending on architecture, waitpid may be implemented or not. New define HAS_WAITPID_RUNTIME is added and wait4pid corrected correspondingly; os2/os2ish.h util.c d) if -S was given and the file name contained \ , it was nevertheless searched on path; perl.c e) updated: os2/Changes README.os2 f) by default use better gcc optimization options (as mbeattie advices): hints/os2.sh [editor's note: this was applied in the reverse order to one a couple of commits ago] p5p-msgid: 1997Jun16.163234.2091727@hmivax.humgen.upenn.edu
Diffstat (limited to 'os2')
-rw-r--r--os2/Changes6
-rw-r--r--os2/Makefile.SHs1
-rw-r--r--os2/diff.configure37
-rw-r--r--os2/os2.c113
-rw-r--r--os2/os2ish.h2
5 files changed, 157 insertions, 2 deletions
diff --git a/os2/Changes b/os2/Changes
index 9678ea66e1..c69fb73205 100644
--- a/os2/Changes
+++ b/os2/Changes
@@ -144,6 +144,12 @@ after 5.003_27:
returns immediately, thus Perl cannot wait for completion of
started programs.
+after 5.004_01:
+ flock emulation added (disable by setting env PERL_USE_FLOCK=0),
+ thanks to Rocco Caputo;
+ RSX bug with missing waitpid circomvented;
+ -S bug with full path with \ corrected.
+
before 5.004_02:
-S switch to perl enables a search with additional extensions
.cmd, .btm, .bat, .pl as well. This means that if you have
diff --git a/os2/Makefile.SHs b/os2/Makefile.SHs
index 6b07e72dba..32af9ccffe 100644
--- a/os2/Makefile.SHs
+++ b/os2/Makefile.SHs
@@ -54,6 +54,7 @@ perl5.def: perl.linkexp
echo ' "dlerror"' >>$@
echo ' "my_tmpfile"' >>$@
echo ' "my_tmpnam"' >>$@
+ echo ' "my_flock"' >>$@
!NO!SUBS!
if [ ! -z "$myttyname" ] ; then
diff --git a/os2/diff.configure b/os2/diff.configure
index 6d108c7d0d..a649869d2a 100644
--- a/os2/diff.configure
+++ b/os2/diff.configure
@@ -51,7 +51,16 @@
case "$libs" in
'') ;;
*) for thislib in $libs; do
-@@ -4136,6 +4144,10 @@
+@@ -3968,6 +3976,8 @@
+ :
+ elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
+ :
++ elif try=`./loc $thislib$lib_ext X $libpth`; $test -f "$try"; then
++ :
+ elif try=`./loc Slib$thislib$lib_ext X $xlibpth`; $test -f "$try"; then
+ :
+ else
+@@ -4152,6 +4162,10 @@
eval $xscan;\
$contains '^fprintf$' libc.list >/dev/null 2>&1; then
eval $xrun
@@ -194,7 +203,31 @@
dflt=`./try`
case "$dflt" in
[1-4][1-4][1-4][1-4]|12345678|87654321)
-@@ -8692,7 +8714,7 @@
+@@ -8707,18 +8731,18 @@
+ $cc $ccflags -c bar1.c >/dev/null 2>&1
+ $cc $ccflags -c bar2.c >/dev/null 2>&1
+ $cc $ccflags -c foo.c >/dev/null 2>&1
+-ar rc bar$lib_ext bar2.o bar1.o >/dev/null 2>&1
++$ar rc bar$lib_ext bar2.o bar1.o >/dev/null 2>&1
+ if $cc $ccflags $ldflags -o foobar foo.o bar$lib_ext $libs > /dev/null 2>&1 &&
+ ./foobar >/dev/null 2>&1; then
+- echo "ar appears to generate random libraries itself."
++ echo "$ar appears to generate random libraries itself."
+ orderlib=false
+ ranlib=":"
+-elif ar ts bar$lib_ext >/dev/null 2>&1 &&
++elif $ar ts bar$lib_ext >/dev/null 2>&1 &&
+ $cc $ccflags $ldflags -o foobar foo.o bar$lib_ext $libs > /dev/null 2>&1 &&
+ ./foobar >/dev/null 2>&1; then
+- echo "a table of contents needs to be added with 'ar ts'."
++ echo "a table of contents needs to be added with '$ar ts'."
+ orderlib=false
+- ranlib="ar ts"
++ ranlib="$ar ts"
+ else
+ case "$ranlib" in
+ :) ranlib='';;
+@@ -8790,7 +8814,7 @@
'') $echo $n ".$c"
if $cc $ccflags \
$i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone \
diff --git a/os2/os2.c b/os2/os2.c
index c45dfecd1e..80742429be 100644
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -1196,3 +1196,116 @@ my_tmpfile ()
return fopen(my_tmpnam(NULL), "w+b"); /* Race condition, but
grants TMP. */
}
+
+#undef flock
+
+/* This code was contributed by Rocco Caputo. */
+int
+my_flock(int handle, int op)
+{
+ FILELOCK rNull, rFull;
+ ULONG timeout, handle_type, flag_word;
+ APIRET rc;
+ int blocking, shared;
+ static int use_my = -1;
+
+ if (use_my == -1) {
+ char *s = getenv("USE_PERL_FLOCK");
+ if (s)
+ use_my = atoi(s);
+ else
+ use_my = 1;
+ }
+ if (!(_emx_env & 0x200) || !use_my)
+ return flock(handle, op); /* Delegate to EMX. */
+
+ // is this a file?
+ if ((DosQueryHType(handle, &handle_type, &flag_word) != 0) ||
+ (handle_type & 0xFF))
+ {
+ errno = EBADF;
+ return -1;
+ }
+ // set lock/unlock ranges
+ rNull.lOffset = rNull.lRange = rFull.lOffset = 0;
+ rFull.lRange = 0x7FFFFFFF;
+ // set timeout for blocking
+ timeout = ((blocking = !(op & LOCK_NB))) ? 100 : 1;
+ // shared or exclusive?
+ shared = (op & LOCK_SH) ? 1 : 0;
+ // do not block the unlock
+ if (op & (LOCK_UN | LOCK_SH | LOCK_EX)) {
+ rc = DosSetFileLocks(handle, &rFull, &rNull, timeout, shared);
+ switch (rc) {
+ case 0:
+ errno = 0;
+ return 0;
+ case ERROR_INVALID_HANDLE:
+ errno = EBADF;
+ return -1;
+ case ERROR_SHARING_BUFFER_EXCEEDED:
+ errno = ENOLCK;
+ return -1;
+ case ERROR_LOCK_VIOLATION:
+ break; // not an error
+ case ERROR_INVALID_PARAMETER:
+ case ERROR_ATOMIC_LOCK_NOT_SUPPORTED:
+ case ERROR_READ_LOCKS_NOT_SUPPORTED:
+ errno = EINVAL;
+ return -1;
+ case ERROR_INTERRUPT:
+ errno = EINTR;
+ return -1;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ }
+ // lock may block
+ if (op & (LOCK_SH | LOCK_EX)) {
+ // for blocking operations
+ for (;;) {
+ rc =
+ DosSetFileLocks(
+ handle,
+ &rNull,
+ &rFull,
+ timeout,
+ shared
+ );
+ switch (rc) {
+ case 0:
+ errno = 0;
+ return 0;
+ case ERROR_INVALID_HANDLE:
+ errno = EBADF;
+ return -1;
+ case ERROR_SHARING_BUFFER_EXCEEDED:
+ errno = ENOLCK;
+ return -1;
+ case ERROR_LOCK_VIOLATION:
+ if (!blocking) {
+ errno = EWOULDBLOCK;
+ return -1;
+ }
+ break;
+ case ERROR_INVALID_PARAMETER:
+ case ERROR_ATOMIC_LOCK_NOT_SUPPORTED:
+ case ERROR_READ_LOCKS_NOT_SUPPORTED:
+ errno = EINVAL;
+ return -1;
+ case ERROR_INTERRUPT:
+ errno = EINTR;
+ return -1;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ // give away timeslice
+ DosSleep(1);
+ }
+ }
+
+ errno = 0;
+ return 0;
+}
diff --git a/os2/os2ish.h b/os2/os2ish.h
index a1b6db9d68..b62e3d04d4 100644
--- a/os2/os2ish.h
+++ b/os2/os2ish.h
@@ -15,6 +15,7 @@
#define HAS_KILL
#define HAS_WAIT
#define HAS_DLERROR
+#define HAS_WAITPID_RUNTIME (_emx_env & 0x200)
/* USEMYBINMODE
* This symbol, if defined, indicates that the program should
@@ -125,6 +126,7 @@ char *my_tmpnam (char *);
#define fwrite1 fwrite
#define my_getenv(var) getenv(var)
+#define flock my_flock
void *emx_calloc (size_t, size_t);
void emx_free (void *);