From: Ilya Zakharevich Date: Thu, 9 Jan 1997 22:02:16 +0000 (-0500) Subject: Perl 5.003_20: OS/2 patches X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a3e71f668bd84b1cf53dd3ea10f588d59ecfebb;p=p5sagit%2Fp5-mst-13.2.git Perl 5.003_20: OS/2 patches Chip Salzenberg writes: > > It's all become so routine: > > file: $CPAN/authors/id/CHIPS/perl5.003_20.pat.gz Below are latest os/2-related patches. **** Note the first chunk **** It shows that under OS/2 4-argument select was writing over memory (256 bites = 32 bytes) over what is typically 1-char malloc area. Since an exception of the general rule is needed on linux and OS/2, can we trust this rule at all? There may be zillions of obscure little-endian systems where select sets all the bytes it cares about instead of just the passed number. If one wants a Configure test for this, here is the skeleton: #include #include char buffer[81] = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"; char buffer1[81] = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"; int main (int argc, char* argv[], char* envp[]) { int i = 80; buffer[0] = 2; /* stdout */ select(8, NULL, (fd_set *)buffer, NULL, NULL); while (i > 0 && buffer1[i] == buffer[i]) i--; printf("%i bytes overwritten.\n", i+1); exit(0); } Enjoy, Ilya This patch does the following: a) substitutes BSD (s)random instead of broken EMX's one; b) removes rsignal from os2/os2.c since it it exported now; c) defines `register' to none if better debugging is deemed necessary. d) fixes broken pp_sselect. p5p-msgid: <199701101102.GAA19051@monk.mps.ohio-state.edu> --- diff --git a/hints/os2.sh b/hints/os2.sh index 59087e3..9bce2a5 100644 --- a/hints/os2.sh +++ b/hints/os2.sh @@ -129,7 +129,9 @@ fi # [Maybe we should just remove c from $libswanted ?] -libs='-lsocket -lm' +# Test would pick up wrong rand, so we hardwire the value for random() +libs='-lsocket -lm -lbsd' +randbits=31 archobjs="os2$obj_ext dl_os2$obj_ext" # Run files without extension with sh: diff --git a/os2/Changes b/os2/Changes index 83af2d8..9027832 100644 --- a/os2/Changes +++ b/os2/Changes @@ -122,3 +122,8 @@ after 5.003_08: after 5.003_11: Functions emx_{malloc,realloc,calloc,free} are exported from DLL. get_sysinfo() bugs corrected (flags were not used and wrongly defined). + +after 5.003_20: + _isterm is substituted instead of isatty, s?random instead of srand. + `register' disabled if -DDEBUGGING and not AOUT build: stupid SD386. + 3-argument select() was stomping over memory. diff --git a/os2/os2.c b/os2/os2.c index c9d1e55..701bb52 100644 --- a/os2/os2.c +++ b/os2/os2.c @@ -158,22 +158,6 @@ getpriority(int which /* ignored */, int pid) /* spawn */ typedef void (*Sigfunc) _((int)); -static -Sigfunc rsignal(signo,handler) -int signo; -Sigfunc handler; -{ - struct sigaction act,oact; - - act.sa_handler = handler; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sigaction(signo, &act, &oact) < 0) - return(SIG_ERR); - else - return(oact.sa_handler); -} - static int result(int flag, int pid) { diff --git a/os2/os2ish.h b/os2/os2ish.h index b2e1f66..44aee84 100644 --- a/os2/os2ish.h +++ b/os2/os2ish.h @@ -99,6 +99,8 @@ char *my_tmpnam (char *); #define tmpfile my_tmpfile #define tmpnam my_tmpnam #define isatty _isterm +#define rand random +#define srand srandom /* * fwrite1() should be a routine with the same calling sequence as fwrite(), @@ -155,6 +157,11 @@ void *emx_realloc (void *, size_t); #endif +/* With SD386 it is impossible to debug register variables. */ +#if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register) +# define register +#endif + /* Our private OS/2 specific data. */ typedef struct OS2_Perl_data { diff --git a/pp_sys.c b/pp_sys.c index f24c8ab..13e11b5 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -675,7 +675,7 @@ PP(pp_sselect) } #if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678 -#ifdef __linux__ +#if defined(__linux__) || defined(OS2) growsize = sizeof(fd_set); #else growsize = maxlen; /* little endians can use vecs directly */