summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1997-11-23 08:26:00 +0000
committerGurusamy Sarathy <gsar@cpan.org>1997-11-23 08:26:00 +0000
commitd8b5173a253b0e32501b412922cc7aba3e1c7072 (patch)
tree8699dca6bf61de6029ae5179ad0d0e44a266817a
parent977336f534851e24a2161d3011e030ea4043a2ae (diff)
parentd7de06700e5c5216cde5bae1cd5b7fed260b4270 (diff)
downloadperl-d8b5173a253b0e32501b412922cc7aba3e1c7072.tar.gz
[win32] Initial reverse integration of winansi branch.
p4raw-id: //depot/win32/perl@285
-rw-r--r--global.sym1
-rw-r--r--miniperlmain.c4
-rw-r--r--op.c9
-rw-r--r--perl.c7
-rw-r--r--perl.h4
-rw-r--r--pp_ctl.c7
-rw-r--r--regcomp.c7
-rw-r--r--regcomp.h4
-rw-r--r--regexec.c16
-rw-r--r--sv.c4
-rw-r--r--toke.c32
-rw-r--r--util.c5
-rw-r--r--win32/Makefile14
-rw-r--r--win32/config.bc11
-rw-r--r--win32/config.vc5
-rw-r--r--win32/config_H.bc62
-rw-r--r--win32/config_H.vc62
-rw-r--r--win32/config_h.PL15
-rw-r--r--win32/config_sh.PL11
-rw-r--r--win32/makedef.pl36
-rw-r--r--win32/makefile.mk6
-rw-r--r--win32/perlglob.c4
-rw-r--r--win32/perllib.c4
-rw-r--r--win32/win32.c127
-rw-r--r--win32/win32.h22
-rw-r--r--win32/win32iop.h7
-rw-r--r--win32/win32thread.c14
-rw-r--r--win32/win32thread.h25
28 files changed, 424 insertions, 101 deletions
diff --git a/global.sym b/global.sym
index ebd6d7e3f5..d7f78306f7 100644
--- a/global.sym
+++ b/global.sym
@@ -461,7 +461,6 @@ gv_stashpv
gv_stashpvn
gv_stashsv
he_root
-hoistmust
hv_clear
hv_delayfree_ent
hv_delete
diff --git a/miniperlmain.c b/miniperlmain.c
index 27ad541fb4..81e649344d 100644
--- a/miniperlmain.c
+++ b/miniperlmain.c
@@ -25,6 +25,10 @@ char **env;
{
int exitstatus;
+#ifdef USE_THREADS
+ MUTEX_INIT(&malloc_mutex);
+#endif
+
PERL_SYS_INIT(&argc,&argv);
perl_init_i18nl10n(1);
diff --git a/op.c b/op.c
index d7a6fe4e16..2d9706bb08 100644
--- a/op.c
+++ b/op.c
@@ -531,8 +531,7 @@ find_threadsv(char *name)
case '\'':
sawampersand = TRUE;
SvREADONLY_on(sv);
- sv_magic(sv, 0, 0, name, 1);
- break;
+ /* FALL THROUGH */
default:
sv_magic(sv, 0, 0, name, 1);
}
@@ -3438,9 +3437,9 @@ newSUB(I32 floor, OP *o, OP *proto, OP *block)
CV *cv;
HV *hv;
- sv_setpvf(sv, "%_:%ld-%ld",
- GvSV(curcop->cop_filegv),
- (long)subline, (long)curcop->cop_line);
+ sv_setpvf(sv, "%_:%ld-%ld", GvSV(curcop->cop_filegv),
+ (long)(subline < 0 ? -subline : subline),
+ (long)curcop->cop_line);
gv_efullname3(tmpstr, gv, Nullch);
hv_store(GvHV(DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
if (!db_postponed) {
diff --git a/perl.c b/perl.c
index 0ff9f4e990..3608f0dd34 100644
--- a/perl.c
+++ b/perl.c
@@ -1686,6 +1686,9 @@ GNU General Public License, which may be found in the Perl 5.0 source kit.\n\n")
break;
case '-':
case 0:
+#ifdef WIN32
+ case '\r':
+#endif
case '\n':
case '\t':
break;
@@ -1987,7 +1990,7 @@ SV *sv;
if (strEQ(origfilename,"-"))
scriptname = "";
if (fdscript >= 0) {
- rsfp = PerlIO_fdopen(fdscript,"r");
+ rsfp = PerlIO_fdopen(fdscript,PERL_SCRIPT_MODE);
#if defined(HAS_FCNTL) && defined(F_SETFD)
if (rsfp)
fcntl(PerlIO_fileno(rsfp),F_SETFD,1); /* ensure close-on-exec */
@@ -2071,7 +2074,7 @@ sed %s -e \"/^[^#]/b\" \
rsfp = PerlIO_stdin();
}
else {
- rsfp = PerlIO_open(scriptname,"r");
+ rsfp = PerlIO_open(scriptname,PERL_SCRIPT_MODE);
#if defined(HAS_FCNTL) && defined(F_SETFD)
if (rsfp)
fcntl(PerlIO_fileno(rsfp),F_SETFD,1); /* ensure close-on-exec */
diff --git a/perl.h b/perl.h
index b4e886552b..724384f9e9 100644
--- a/perl.h
+++ b/perl.h
@@ -2297,6 +2297,10 @@ EXT bool numeric_local INIT(TRUE); /* Assume local numerics */
#define printf PerlIO_stdoutf
#endif
+#ifndef PERL_SCRIPT_MODE
+#define PERL_SCRIPT_MODE "r"
+#endif
+
/*
* nice_chunk and nice_chunk size need to be set
* and queried under the protection of sv_mutex
diff --git a/pp_ctl.c b/pp_ctl.c
index f5454ec3ed..d79145c719 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2119,7 +2119,7 @@ sv_compile_2op(SV *sv, OP** startop, char *code, AV** avp)
dSP; /* Make POPBLOCK work. */
PERL_CONTEXT *cx;
SV **newsp;
- I32 gimme;
+ I32 gimme = 0; /* SUSPECT - INITIALZE TO WHAT? NI-S */
I32 optype;
OP dummy;
OP *oop = op, *rop;
@@ -2378,7 +2378,7 @@ PP(pp_require)
)
{
tryname = name;
- tryrsfp = PerlIO_open(name,"r");
+ tryrsfp = PerlIO_open(name,PERL_SCRIPT_MODE);
}
else {
AV *ar = GvAVn(incgv);
@@ -2401,7 +2401,7 @@ PP(pp_require)
sv_setpvf(namesv, "%s/%s", dir, name);
#endif
tryname = SvPVX(namesv);
- tryrsfp = PerlIO_open(tryname, "r");
+ tryrsfp = PerlIO_open(tryname, PERL_SCRIPT_MODE);
if (tryrsfp) {
if (tryname[0] == '.' && tryname[1] == '/')
tryname += 2;
@@ -2881,3 +2881,4 @@ doparseform(SV *sv)
SvCOMPILED_on(sv);
}
+
diff --git a/regcomp.c b/regcomp.c
index 603a421bd0..adda2aa8f9 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -372,7 +372,7 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32
data->last_start_max = is_inf
? I32_MAX : data->pos_min + data->pos_delta;
}
- sv_catpvn(data->last_found, OPERAND(scan)+1, l);
+ sv_catpvn(data->last_found, (char *)(OPERAND(scan)+1), l);
data->last_end = data->pos_min + l;
data->pos_min += l; /* As in the first entry. */
data->flags &= ~SF_BEFORE_EOL;
@@ -1673,7 +1673,7 @@ tryagain:
ret = reg_node((regflags & PMf_FOLD)
? ((regflags & PMf_LOCALE) ? EXACTFL : EXACTF)
: EXACT);
- s = OPERAND(ret);
+ s = (char *) OPERAND(ret);
regc(0, s++); /* save spot for len */
for (len = 0, p = regparse - 1;
len < 127 && p < regxend;
@@ -1841,7 +1841,7 @@ regclass(void)
register I32 def;
I32 numlen;
- s = opnd = OPERAND(regcode);
+ s = opnd = (char *) OPERAND(regcode);
ret = reg_node(ANYOF);
for (Class = 0; Class < 33; Class++)
regc(0, s++);
@@ -2662,3 +2662,4 @@ re_croak2(const char* pat1,const char* pat2, va_alist)
croak("%s", buf);
}
+
diff --git a/regcomp.h b/regcomp.h
index dec5ac361b..2a00d40b6f 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -144,9 +144,9 @@ typedef OP OP_4tree; /* Will be redefined later. */
*/
#ifndef DOINIT
-EXT const U8 regkind[];
+EXTCONST U8 regkind[];
#else
-EXT const U8 regkind[] = {
+EXTCONST U8 regkind[] = {
END,
BOL,
BOL,
diff --git a/regexec.c b/regexec.c
index fb811d2330..7285bea112 100644
--- a/regexec.c
+++ b/regexec.c
@@ -411,7 +411,7 @@ regexec_flags(register regexp *prog, char *stringarg, register char *strend, cha
goto phooey;
} else if (c = prog->regstclass) {
I32 doevery = (prog->reganch & ROPT_SKIP) == 0;
- char *class;
+ char *Class;
if (minlen)
dontbother = minlen - 1;
@@ -420,9 +420,9 @@ regexec_flags(register regexp *prog, char *stringarg, register char *strend, cha
/* We know what class it must start with. */
switch (OP(c)) {
case ANYOF:
- class = OPERAND(c);
+ Class = (char *) OPERAND(c);
while (s < strend) {
- if (reginclass(class, *s)) {
+ if (reginclass(Class, *s)) {
if (tmp && regtry(prog, s))
goto got_it;
else
@@ -854,7 +854,7 @@ regmatch(regnode *prog)
nextchar = UCHARAT(++locinput);
break;
case EXACT:
- s = OPERAND(scan);
+ s = (char *) OPERAND(scan);
ln = UCHARAT(s++);
/* Inline the first character, for speed. */
if (UCHARAT(s) != nextchar)
@@ -870,7 +870,7 @@ regmatch(regnode *prog)
reg_flags |= RF_tainted;
/* FALL THROUGH */
case EXACTF:
- s = OPERAND(scan);
+ s = (char *) OPERAND(scan);
ln = UCHARAT(s++);
/* Inline the first character, for speed. */
if (UCHARAT(s) != nextchar &&
@@ -887,7 +887,7 @@ regmatch(regnode *prog)
nextchar = UCHARAT(locinput);
break;
case ANYOF:
- s = OPERAND(scan);
+ s = (char *) OPERAND(scan);
if (nextchar < 0)
nextchar = UCHARAT(locinput);
if (!reginclass(s, nextchar))
@@ -1633,7 +1633,7 @@ regrepeat(regnode *p, I32 max)
scan = reginput;
if (max != REG_INFTY && max < loceol - scan)
loceol = scan + max;
- opnd = OPERAND(p);
+ opnd = (char *) OPERAND(p);
switch (OP(p)) {
case ANY:
while (scan < loceol && *scan != '\n')
@@ -1801,3 +1801,5 @@ reginclass(register char *p, register I32 c)
return match ^ ((flags & ANYOF_INVERT) != 0);
}
+
+
diff --git a/sv.c b/sv.c
index 408cc77587..9a7f075beb 100644
--- a/sv.c
+++ b/sv.c
@@ -3219,6 +3219,10 @@ screamer2:
}
}
+#ifdef WIN32
+ win32_strip_return(sv);
+#endif
+
return (SvCUR(sv) - append) ? SvPVX(sv) : Nullch;
}
diff --git a/toke.c b/toke.c
index 28ea26dd38..95be7df498 100644
--- a/toke.c
+++ b/toke.c
@@ -187,7 +187,7 @@ missingterm(char *s)
char q;
if (s) {
char *nl = strrchr(s,'\n');
- if (nl)
+ if (nl)
*nl = '\0';
}
else if (multi_close < 32 || multi_close == 127) {
@@ -219,6 +219,19 @@ depcom(void)
deprecate("comma-less variable list");
}
+#ifdef WIN32
+
+static I32
+win32_textfilter(int idx, SV *sv, int maxlen)
+{
+ I32 count = FILTER_READ(idx+1, sv, maxlen);
+ if (count > 0 && !maxlen)
+ win32_strip_return(sv);
+ return count;
+}
+#endif
+
+
void
lex_start(SV *line)
{
@@ -1158,6 +1171,7 @@ filter_read(int idx, SV *buf_sv, int maxlen)
else
return 0 ; /* end of file */
}
+
}
return SvCUR(buf_sv);
}
@@ -1178,9 +1192,15 @@ filter_read(int idx, SV *buf_sv, int maxlen)
return (*funcp)(idx, buf_sv, maxlen);
}
+
static char *
filter_gets(register SV *sv, register FILE *fp, STRLEN append)
{
+#ifdef WIN32FILTER
+ if (!rsfp_filters) {
+ filter_add(win32_textfilter,NULL);
+ }
+#endif
if (rsfp_filters) {
if (!append)
@@ -1192,7 +1212,6 @@ filter_gets(register SV *sv, register FILE *fp, STRLEN append)
}
else
return (sv_gets(sv, fp, append));
-
}
@@ -1211,6 +1230,8 @@ yylex(void)
register char *d;
register I32 tmp;
STRLEN len;
+ GV *gv = Nullgv;
+ GV **gvp = 0;
if (pending_ident) {
char pit = pending_ident;
@@ -1723,9 +1744,11 @@ yylex(void)
}
goto retry;
case '\r':
+#ifndef WIN32CHEAT
warn("Illegal character \\%03o (carriage return)", '\r');
croak(
"(Maybe you didn't strip carriage returns after a network transfer?)\n");
+#endif
case ' ': case '\t': case '\f': case 013:
s++;
goto retry;
@@ -2524,8 +2547,8 @@ yylex(void)
case 'z': case 'Z':
keylookup: {
- GV *gv = Nullgv;
- GV **gvp = 0;
+ gv = Nullgv;
+ gvp = 0;
bufptr = s;
s = scan_word(s, tokenbuf, sizeof tokenbuf, FALSE, &len);
@@ -5360,3 +5383,4 @@ yyerror(char *s)
return 0;
}
+
diff --git a/util.c b/util.c
index e771cbc28d..ab6ddd7d61 100644
--- a/util.c
+++ b/util.c
@@ -867,9 +867,9 @@ fbm_instr(unsigned char *big, register unsigned char *bigend, SV *littlestr)
if (!len) {
if (SvTAIL(littlestr)) {
if (bigend > big && bigend[-1] == '\n')
- return bigend - 1;
+ return (char *)(bigend - 1);
else
- return bigend;
+ return (char *) bigend;
}
return (char*)big;
}
@@ -2547,3 +2547,4 @@ Perl_huge(void)
}
#endif
+
diff --git a/win32/Makefile b/win32/Makefile
index d2e464145a..91a417da2f 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -20,7 +20,7 @@ CORECCOPT=
#
# uncomment next line if you want debug version of perl (big,slow)
-#CFG=Debug
+CFG=Debug
#
# set the install locations of the compiler include/libraries
@@ -166,7 +166,8 @@ CORE_C= ..\av.c \
..\taint.c \
..\toke.c \
..\universal.c \
- ..\util.c
+ ..\util.c \
+ ..\malloc.c
CORE_OBJ= ..\av.obj \
..\deb.obj \
@@ -193,7 +194,8 @@ CORE_OBJ= ..\av.obj \
..\taint.obj \
..\toke.obj \
..\universal.obj\
- ..\util.obj
+ ..\util.obj \
+ ..\malloc.obj
WIN32_C = perllib.c \
win32.c \
@@ -335,7 +337,7 @@ $(WIN32_OBJ) : $(CORE_H)
$(CORE_OBJ) : $(CORE_H)
$(DLL_OBJ) : $(CORE_H)
-perldll.def : $(MINIPERL) $(CONFIGPM)
+perldll.def : $(MINIPERL) $(CONFIGPM) makedef.pl ..\global.sym
$(MINIPERL) -w makedef.pl $(DEFINES) $(CCTYPE) > perldll.def
$(PERLDLL): perldll.def $(CORE_OBJ) $(WIN32_OBJ) $(DLL_OBJ)
@@ -371,10 +373,10 @@ perl95.obj : perl95.c
$(CC) $(CFLAGS) -MT -UPERLDLL -c perl95.c
win32sckmt.obj : win32sck.c
- $(CC) $(CFLAGS) -MT -c $(OBJOUT_FLAG)win32sckmt.obj win32sck.c
+ $(CC) $(CFLAGS) -MT -UPERLDLL -c $(OBJOUT_FLAG)win32sckmt.obj win32sck.c
win32mt.obj : win32.c
- $(CC) $(CFLAGS) -MT -c $(OBJOUT_FLAG)win32mt.obj win32.c
+ $(CC) $(CFLAGS) -MT -UPERLDLL -c $(OBJOUT_FLAG)win32mt.obj win32.c
$(PERL95EXE): $(PERLDLL) $(CONFIGPM) $(PERL95_OBJ)
$(LINK32) -subsystem:console -out:perl95.exe $(LINK_FLAGS) $(LIBFILES) \
diff --git a/win32/config.bc b/win32/config.bc
index e3559a041a..c5340214b8 100644
--- a/win32/config.bc
+++ b/win32/config.bc
@@ -5,7 +5,7 @@
## Target system: WIN32
#
-archlibexp='~INST_TOP~\lib'
+archlibexp='~INST_TOP~\lib\~archname~'
archname='MSWin32'
cc='bcc32'
ccflags='-DWIN32'
@@ -13,7 +13,7 @@ cppflags='-DWIN32'
dlsrc='dl_win32.xs'
dynamic_ext='Socket IO Fcntl Opcode SDBM_File attrs Thread'
extensions='~static_ext~ ~dynamic_ext~'
-installarchlib='~INST_TOP~\lib'
+installarchlib='~INST_TOP~\lib\~archname~'
installprivlib='~INST_TOP~\lib'
libpth=''
libs=''
@@ -46,7 +46,7 @@ afs='false'
alignbytes='8'
aphostname=''
ar='tlib /P128'
-archlib='~INST_TOP~\lib'
+archlib='~INST_TOP~\lib\~archname~'
archobjs=''
awk='awk'
baserev='5.0'
@@ -162,7 +162,7 @@ d_msgctl='define'
d_msgget='define'
d_msgrcv='define'
d_msgsnd='define'
-d_mymalloc='undef'
+d_mymalloc='define'
d_nice='undef'
d_oldarchlib='undef'
d_oldsock='undef'
@@ -286,6 +286,9 @@ full_csh=''
full_sed=''
gcc=''
gccversion=''
+gethbadd_addr_type='char *'
+gethbadd_alen_type='int'
+getnbadd_net_type='long'
gidtype='gid_t'
glibpth='/usr/shlib /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/ucblib /usr/shlib '
grep='grep'
diff --git a/win32/config.vc b/win32/config.vc
index c117689b0b..3e7f9aa523 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -162,7 +162,7 @@ d_msgctl='define'
d_msgget='define'
d_msgrcv='define'
d_msgsnd='define'
-d_mymalloc='undef'
+d_mymalloc='define'
d_nice='undef'
d_oldarchlib='undef'
d_oldsock='undef'
@@ -286,6 +286,9 @@ full_csh=''
full_sed=''
gcc=''
gccversion=''
+gethbadd_addr_type='char *'
+gethbadd_alen_type='int'
+getnbadd_net_type='long'
gidtype='gid_t'
glibpth='/usr/shlib /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/ucblib /usr/shlib '
grep='grep'
diff --git a/win32/config_H.bc b/win32/config_H.bc
index 3ba2481a0f..cea8b4e9c3 100644
--- a/win32/config_H.bc
+++ b/win32/config_H.bc
@@ -10,8 +10,8 @@
* $Id: Config_h.U,v 3.0.1.4 1995/09/25 09:10:49 ram Exp $
*/
-/* Configuration time: Thu Apr 11 06:20:49 PDT 1996
- * Configured by: garyng
+/* Configuration time: undef
+ * Configured by: nick
* Target system:
*/
@@ -47,11 +47,7 @@
* where library files may be held under a private library, for
* instance.
*/
-#ifdef _ALPHA_
-#define ARCHNAME "alpha-mswin32" /**/
-#else
-#define ARCHNAME "x86-mswin32" /**/
-#endif
+#define ARCHNAME "MSWin32-x86-thread" /**/
/* BIN:
* This symbol holds the path of the bin directory where the package will
@@ -315,6 +311,36 @@
*/
/*#define HAS_GETHOSTENT /**/
+/* HAS_GETHBADD:
+ * This symbol, if defined, indicates that the gethostbyaddr routine is
+ * available to lookup host names by their IP addresses.
+ */
+/*#define HAS_GETHBADD /**/
+
+/* Gethbadd_addr_t:
+ * This symbol holds the type used for the 1st argument
+ * to gethostbyaddr().
+ */
+#define Gethbadd_addr_t char *
+
+/* Gethbadd_alen_t:
+ * This symbol holds the type used for the 2nd argument
+ * to gethostbyaddr().
+ */
+#define Gethbadd_alen_t int
+
+/* HAS_GETNBADD:
+ * This symbol, if defined, indicates that the getnetbyaddr routine is
+ * available to lookup networks by their IP addresses.
+ */
+/*#define HAS_GETNBADD /**/
+
+/* Gethbadd_net_t:
+ * This symbol holds the type used for the 1st argument
+ * to getnetbyaddr().
+ */
+#define Getnbadd_net_t long
+
/* HAS_UNAME:
* This symbol, if defined, indicates that the C program may use the
* uname() routine to derive the host name. See also HAS_GETHOSTNAME
@@ -1103,6 +1129,12 @@
*/
/*#define I_NETINET_IN /**/
+/* I_NETDB:
+ * This symbol, if defined, indicates that <netdb.h> exists and
+ * should be included.
+ */
+/*#define I_NETDB /**/
+
/* I_PWD:
* This symbol, if defined, indicates to the C program that it should
* include <pwd.h>.
@@ -1434,8 +1466,8 @@
* This symbol contains the ~name expanded version of ARCHLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define ARCHLIB "c:\\perl\\lib" /**/
-#define ARCHLIB_EXP (win32PerlLibPath()) /**/
+#define ARCHLIB "c:\\perl\\lib\\MSWin32-x86-thread" /**/
+#define ARCHLIB_EXP (win32PerlLibPath(ARCHNAME,NULL)) /**/
/* BINCOMPAT3:
* This symbol, if defined, indicates that Perl 5.004 should be
@@ -1654,7 +1686,7 @@
/* MYMALLOC:
* This symbol, if defined, indicates that we're using our own malloc.
*/
-/*#define MYMALLOC /**/
+#define MYMALLOC /**/
/* OLDARCHLIB:
* This variable, if defined, holds the name of the directory in
@@ -1682,7 +1714,7 @@
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#define PRIVLIB "c:\\perl\\lib" /**/
-#define PRIVLIB_EXP "c:\\perl\\lib" /**/
+#define PRIVLIB_EXP (win32PerlLibPath(NULL)) /**/
/* SH_PATH:
* This symbol contains the full pathname to the shell used on this
@@ -1691,7 +1723,7 @@
* /bin/pdksh, /bin/ash, /bin/bash, or even something such as
* D:/bin/sh.exe.
*/
-#define SH_PATH "cmd.exe" /**/
+#define SH_PATH "cmd /x /c" /**/
/* SIG_NAME:
* This symbol contains a list of signal names in order of
@@ -1738,7 +1770,7 @@
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#define SITEARCH "c:\\perl\\lib\\site" /**/
-#define SITEARCH_EXP "c:\\perl\\lib\\site" /**/
+#define SITEARCH_EXP (win32PerlLibPath("site",ARCHNAME,NULL)) /**/
/* SITELIB:
* This symbol contains the name of the private library for this package.
@@ -1754,14 +1786,14 @@
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#define SITELIB "c:\\perl\\lib\\site" /**/
-#define SITELIB_EXP "c:\\perl\\lib\\site" /**/
+#define SITELIB_EXP (win32PerlLibPath("site",NULL)) /**/
/* STARTPERL:
* This variable contains the string to put in front of a perl
* script to make sure (one hopes) that it runs with perl and not
* some shell.
*/
-#define STARTPERL "#perl" /**/
+#define STARTPERL "#!perl" /**/
/* USE_PERLIO:
* This symbol, if defined, indicates that the PerlIO abstraction should
diff --git a/win32/config_H.vc b/win32/config_H.vc
index d2c6d47afb..87ecab8221 100644
--- a/win32/config_H.vc
+++ b/win32/config_H.vc
@@ -10,8 +10,8 @@
* $Id: Config_h.U,v 3.0.1.4 1995/09/25 09:10:49 ram Exp $
*/
-/* Configuration time: Thu Apr 11 06:20:49 PDT 1996
- * Configured by: garyng
+/* Configuration time: undef
+ * Configured by: nick
* Target system:
*/
@@ -47,11 +47,7 @@
* where library files may be held under a private library, for
* instance.
*/
-#ifdef _ALPHA_
-#define ARCHNAME "alpha-mswin32" /**/
-#else
-#define ARCHNAME "x86-mswin32" /**/
-#endif
+#define ARCHNAME "MSWin32-x86-thread" /**/
/* BIN:
* This symbol holds the path of the bin directory where the package will
@@ -315,6 +311,36 @@
*/
/*#define HAS_GETHOSTENT /**/
+/* HAS_GETHBADD:
+ * This symbol, if defined, indicates that the gethostbyaddr routine is
+ * available to lookup host names by their IP addresses.
+ */
+/*#define HAS_GETHBADD /**/
+
+/* Gethbadd_addr_t:
+ * This symbol holds the type used for the 1st argument
+ * to gethostbyaddr().
+ */
+#define Gethbadd_addr_t char *
+
+/* Gethbadd_alen_t:
+ * This symbol holds the type used for the 2nd argument
+ * to gethostbyaddr().
+ */
+#define Gethbadd_alen_t int
+
+/* HAS_GETNBADD:
+ * This symbol, if defined, indicates that the getnetbyaddr routine is
+ * available to lookup networks by their IP addresses.
+ */
+/*#define HAS_GETNBADD /**/
+
+/* Gethbadd_net_t:
+ * This symbol holds the type used for the 1st argument
+ * to getnetbyaddr().
+ */
+#define Getnbadd_net_t long
+
/* HAS_UNAME:
* This symbol, if defined, indicates that the C program may use the
* uname() routine to derive the host name. See also HAS_GETHOSTNAME
@@ -1103,6 +1129,12 @@
*/
/*#define I_NETINET_IN /**/
+/* I_NETDB:
+ * This symbol, if defined, indicates that <netdb.h> exists and
+ * should be included.
+ */
+/*#define I_NETDB /**/
+
/* I_PWD:
* This symbol, if defined, indicates to the C program that it should
* include <pwd.h>.
@@ -1434,8 +1466,8 @@
* This symbol contains the ~name expanded version of ARCHLIB, to be used
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
-#define ARCHLIB "c:\\perl\\lib" /**/
-#define ARCHLIB_EXP (win32PerlLibPath()) /**/
+#define ARCHLIB "c:\\perl\\lib\\MSWin32-x86-thread" /**/
+#define ARCHLIB_EXP (win32PerlLibPath(ARCHNAME,NULL)) /**/
/* BINCOMPAT3:
* This symbol, if defined, indicates that Perl 5.004 should be
@@ -1654,7 +1686,7 @@
/* MYMALLOC:
* This symbol, if defined, indicates that we're using our own malloc.
*/
-/*#define MYMALLOC /**/
+#define MYMALLOC /**/
/* OLDARCHLIB:
* This variable, if defined, holds the name of the directory in
@@ -1682,7 +1714,7 @@
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#define PRIVLIB "c:\\perl\\lib" /**/
-#define PRIVLIB_EXP "c:\\perl\\lib" /**/
+#define PRIVLIB_EXP (win32PerlLibPath(NULL)) /**/
/* SH_PATH:
* This symbol contains the full pathname to the shell used on this
@@ -1691,7 +1723,7 @@
* /bin/pdksh, /bin/ash, /bin/bash, or even something such as
* D:/bin/sh.exe.
*/
-#define SH_PATH "cmd.exe" /**/
+#define SH_PATH "cmd /x /c" /**/
/* SIG_NAME:
* This symbol contains a list of signal names in order of
@@ -1738,7 +1770,7 @@
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#define SITEARCH "c:\\perl\\lib\\site" /**/
-#define SITEARCH_EXP "c:\\perl\\lib\\site" /**/
+#define SITEARCH_EXP (win32PerlLibPath("site",ARCHNAME,NULL)) /**/
/* SITELIB:
* This symbol contains the name of the private library for this package.
@@ -1754,14 +1786,14 @@
* in programs that are not prepared to deal with ~ expansion at run-time.
*/
#define SITELIB "c:\\perl\\lib\\site" /**/
-#define SITELIB_EXP "c:\\perl\\lib\\site" /**/
+#define SITELIB_EXP (win32PerlLibPath("site",NULL)) /**/
/* STARTPERL:
* This variable contains the string to put in front of a perl
* script to make sure (one hopes) that it runs with perl and not
* some shell.
*/
-#define STARTPERL "#perl" /**/
+#define STARTPERL "#!perl" /**/
/* USE_PERLIO:
* This symbol, if defined, indicates that the PerlIO abstraction should
diff --git a/win32/config_h.PL b/win32/config_h.PL
index 5d47016dc9..679ba99112 100644
--- a/win32/config_h.PL
+++ b/win32/config_h.PL
@@ -37,8 +37,19 @@ while (<SH>)
s#/[ *\*]*\*/#/**/#;
if (/^\s*#define\s+ARCHLIB_EXP/)
{
- $_ = "#define ARCHLIB_EXP (win32PerlLibPath())\t/**/\n"
- . "#define APPLLIB_EXP (win32SiteLibPath())\t/**/\n";
+ $_ = "#define ARCHLIB_EXP (win32PerlLibPath(ARCHNAME,NULL))\t/**/\n";
+ }
+ if (/^\s*#define\s+PRIVLIB_EXP/)
+ {
+ $_ = "#define PRIVLIB_EXP (win32PerlLibPath(NULL))\t/**/\n"
+ }
+ if (/^\s*#define\s+SITEARCH_EXP/)
+ {
+ $_ = "#define SITEARCH_EXP (win32PerlLibPath(\"site\",ARCHNAME,NULL))\t/**/\n";
+ }
+ if (/^\s*#define\s+SITELIB_EXP/)
+ {
+ $_ = "#define SITELIB_EXP (win32PerlLibPath(\"site\",NULL))\t/**/\n";
}
print H;
}
diff --git a/win32/config_sh.PL b/win32/config_sh.PL
index 0c3713cb2e..5f3f157a0c 100644
--- a/win32/config_sh.PL
+++ b/win32/config_sh.PL
@@ -5,6 +5,17 @@ while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
shift(@ARGV);
}
+$opt{'archname'} = 'MSWin32';
+if (defined $ENV{'PROCESSOR_ARCHITECTURE'})
+ {
+ $opt{'archname'} .= '-'.$ENV{'PROCESSOR_ARCHITECTURE'};
+ }
+
+if ($opt{'ccflags'} =~ /USE_THREADS/)
+ {
+ $opt{'archname'} .= '-thread';
+ }
+
if ($] =~ /\.(\d\d\d)?(\d\d)?$/) { # should always be true
$opt{PATCHLEVEL} = int($1 || 0);
$opt{SUBVERSION} = $2 || '00';
diff --git a/win32/makedef.pl b/win32/makedef.pl
index abc89d848a..55b3e29bcd 100644
--- a/win32/makedef.pl
+++ b/win32/makedef.pl
@@ -20,10 +20,23 @@ while (@ARGV && $ARGV[0] =~ /^-/)
$define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
}
+open(CFG,'config.h') || die "Cannot open config.h:$!";
+while (<CFG>)
+ {
+ $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
+ }
+close(CFG);
+
warn join(' ',keys %define)."\n";
my $CCTYPE = shift || "MSVC";
+print "LIBRARY Perl\n";
+print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
+print "CODE LOADONCALL\n";
+print "DATA LOADONCALL NONSHARED MULTIPLE\n";
+print "EXPORTS\n";
+
$skip_sym=<<'!END!OF!SKIP!';
Perl_block_type
Perl_additem
@@ -143,6 +156,20 @@ Perl_cshname
Perl_opsave
!END!OF!SKIP!
+if ($define{'MYMALLOC'})
+ {
+ $skip_sym .= <<'!END!OF!SKIP!';
+Perl_safefree
+Perl_safemalloc
+Perl_saferealloc
+Perl_safecalloc
+!END!OF!SKIP!
+ emit_symbol('Perl_malloc');
+ emit_symbol('Perl_free');
+ emit_symbol('Perl_realloc');
+ emit_symbol('Perl_calloc');
+ }
+
unless ($define{'USE_THREADS'})
{
$skip_sym .= <<'!END!OF!SKIP!';
@@ -193,12 +220,6 @@ unless ($define{'USE_THREADS'})
# sticks in front of them.
-print "LIBRARY Perl\n";
-print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
-print "CODE LOADONCALL\n";
-print "DATA LOADONCALL NONSHARED MULTIPLE\n";
-print "EXPORTS\n";
-
open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!;
while (<GLOBAL>) {
my $symbol;
@@ -232,6 +253,7 @@ while (<DATA>) {
my $symbol;
next if (!/^[A-Za-z]/);
next if (/^#/);
+ s/\r//g;
$symbol = $_;
next if ($skip_sym =~ m/^$symbol/m);
$symbol = "Perl_".$symbol if ($define{'USE_THISPTR'}
@@ -402,4 +424,6 @@ win32_open_osfhandle
win32_get_osfhandle
Perl_win32_init
Perl_init_os_extras
+Perl_getTHR
+Perl_setTHR
RunPerl
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 2b7dc8ccbe..03788c731e 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -234,7 +234,8 @@ CORE_C= ..\av.c \
..\taint.c \
..\toke.c \
..\universal.c \
- ..\util.c
+ ..\util.c \
+ ..\malloc.c
CORE_OBJ= ..\av.obj \
..\deb.obj \
@@ -261,7 +262,8 @@ CORE_OBJ= ..\av.obj \
..\taint.obj \
..\toke.obj \
..\universal.obj\
- ..\util.obj
+ ..\util.obj \
+ ..\malloc.obj
WIN32_C = perllib.c \
win32.c \
diff --git a/win32/perlglob.c b/win32/perlglob.c
index b2fdca2f71..be9d55052c 100644
--- a/win32/perlglob.c
+++ b/win32/perlglob.c
@@ -22,7 +22,8 @@ main(int argc, char *argv[])
/* check out the file system characteristics */
if (GetFullPathName(".", MAX_PATH, root, &dummy)) {
- if (dummy = strchr(root, '\\'))
+ dummy = strchr(root,'\\');
+ if (dummy)
*++dummy = '\0';
if (GetVolumeInformation(root, volname, MAX_PATH,
&serial, &maxname, &flags, 0, 0)) {
@@ -40,3 +41,4 @@ main(int argc, char *argv[])
}
return 0;
}
+
diff --git a/win32/perllib.c b/win32/perllib.c
index 848360698b..c24941f111 100644
--- a/win32/perllib.c
+++ b/win32/perllib.c
@@ -15,6 +15,10 @@ RunPerl(int argc, char **argv, char **env, void *iosubsystem)
int exitstatus;
PerlInterpreter *my_perl;
+#ifdef USE_THREADS
+ MUTEX_INIT(&malloc_mutex);
+#endif
+
PERL_SYS_INIT(&argc,&argv);
perl_init_i18nl10n(1);
diff --git a/win32/win32.c b/win32/win32.c
index 4551679f58..74be770ff1 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -55,30 +55,30 @@ IsWinNT(void) {
}
char *
-win32PerlLibPath(void)
+win32PerlLibPath(char *sfx,...)
{
+ va_list ap;
char *end;
+ va_start(ap,sfx);
GetModuleFileName((PerlDllHandle == INVALID_HANDLE_VALUE)
? GetModuleHandle(NULL)
: PerlDllHandle,
szPerlLibRoot,
sizeof(szPerlLibRoot));
-
*(end = strrchr(szPerlLibRoot, '\\')) = '\0';
if (stricmp(end-4,"\\bin") == 0)
end -= 4;
strcpy(end,"\\lib");
+ while (sfx)
+ {
+ strcat(end,"\\");
+ strcat(end,sfx);
+ sfx = va_arg(ap,char *);
+ }
+ va_end(ap);
return (szPerlLibRoot);
}
-char *
-win32SiteLibPath(void)
-{
- static char szPerlSiteLib[MAX_PATH+1];
- strcpy(szPerlSiteLib, win32PerlLibPath());
- strcat(szPerlSiteLib, "\\site");
- return (szPerlSiteLib);
-}
BOOL
HasRedirection(char *ptr)
@@ -1303,6 +1303,85 @@ win32_putchar(int c)
return putchar(c);
}
+#ifdef MYMALLOC
+
+#ifndef USE_PERL_SBRK
+
+static char *committed = NULL;
+static char *base = NULL;
+static char *reserved = NULL;
+static char *brk = NULL;
+static DWORD pagesize = 0;
+static DWORD allocsize = 0;
+
+void *
+sbrk(int need)
+{
+ void *result;
+ if (!pagesize)
+ {SYSTEM_INFO info;
+ GetSystemInfo(&info);
+ /* Pretend page size is larger so we don't perpetually
+ * call the OS to commit just one page ...
+ */
+ pagesize = info.dwPageSize << 3;
+ allocsize = info.dwAllocationGranularity;
+ }
+ /* This scheme fails eventually if request for contiguous
+ * block is denied so reserve big blocks - this is only
+ * address space not memory ...
+ */
+ if (brk+need >= reserved)
+ {
+ DWORD size = 64*1024*1024;
+ char *addr;
+ if (committed && reserved && committed < reserved)
+ {
+ /* Commit last of previous chunk cannot span allocations */
+ addr = (char *) VirtualAlloc(committed,reserved-committed,MEM_COMMIT,PAGE_READWRITE);
+ if (addr)
+ committed = reserved;
+ }
+ /* Reserve some (more) space
+ * Note this is a little sneaky, 1st call passes NULL as reserved
+ * so lets system choose where we start, subsequent calls pass
+ * the old end address so ask for a contiguous block
+ */
+ addr = (char *) VirtualAlloc(reserved,size,MEM_RESERVE,PAGE_NOACCESS);
+ if (addr)
+ {
+ reserved = addr+size;
+ if (!base)
+ base = addr;
+ if (!committed)
+ committed = base;
+ if (!brk)
+ brk = committed;
+ }
+ else
+ {
+ return (void *) -1;
+ }
+ }
+ result = brk;
+ brk += need;
+ if (brk > committed)
+ {
+ DWORD size = ((brk-committed + pagesize -1)/pagesize) * pagesize;
+ char *addr = (char *) VirtualAlloc(committed,size,MEM_COMMIT,PAGE_READWRITE);
+ if (addr)
+ {
+ committed += size;
+ }
+ else
+ return (void *) -1;
+ }
+ return result;
+}
+
+#endif
+#endif
+
DllExport void*
win32_malloc(size_t size)
{
@@ -1327,6 +1406,7 @@ win32_free(void *block)
free(block);
}
+
int
win32_open_osfhandle(long handle, int flags)
{
@@ -1645,6 +1725,33 @@ Perl_win32_init(int *argcp, char ***argvp)
#endif
}
+#ifdef USE_BINMODE_SCRIPTS
+
+void
+win32_strip_return(SV *sv)
+{
+ char *s = SvPVX(sv);
+ char *e = s+SvCUR(sv);
+ char *d = s;
+ while (s < e)
+ {
+ if (*s == '\r' && s[1] == '\n')
+ {
+ *d++ = '\n';
+ s += 2;
+ }
+ else
+ {
+ *d++ = *s++;
+ }
+ }
+ SvCUR_set(sv,d-SvPVX(sv));
+}
+
+#endif
+
+
+
diff --git a/win32/win32.h b/win32/win32.h
index 18bf8a2e96..2e31d0e3ba 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -111,6 +111,7 @@ extern gid_t getegid(void);
extern int setuid(uid_t uid);
extern int setgid(gid_t gid);
extern int kill(int pid, int sig);
+extern void *sbrk(int need);
#undef Stat
#define Stat win32_stat
@@ -128,8 +129,7 @@ extern int my_fclose(FILE *);
extern int do_aspawn(void* really, void ** mark, void ** arglast);
extern int do_spawn(char *cmd);
extern char do_exec(char *cmd);
-extern char * win32PerlLibPath(void);
-extern char * win32SiteLibPath(void);
+extern char * win32PerlLibPath(char *sfx,...);
extern int IsWin95(void);
extern int IsWinNT(void);
@@ -145,4 +145,22 @@ typedef char * caddr_t; /* In malloc.c (core address). */
#include <sys/socket.h>
#include <netdb.h>
+#ifdef MYMALLOC
+#define EMBEDMYMALLOC /**/
+/* #define USE_PERL_SBRK /**/
+/* #define PERL_SBRK_VIA_MALLOC /**/
+#endif
+
+#ifdef PERLDLL
+#define PERL_CORE
+#endif
+
+#ifdef USE_BINMODE_SCRIPTS
+#define PERL_SCRIPT_MODE "rb"
+EXT void win32_strip_return(struct sv *sv);
+#else
+#define PERL_SCRIPT_MODE "r"
+#define win32_strip_return(sv) NOOP
+#endif
+
#endif /* _INC_WIN32_PERL5 */
diff --git a/win32/win32iop.h b/win32/win32iop.h
index a60194d0f0..bd70def18e 100644
--- a/win32/win32iop.h
+++ b/win32/win32iop.h
@@ -219,10 +219,17 @@ END_EXTERN_C
#define puts win32_puts
#define getchar win32_getchar
#define putchar win32_putchar
+
+#if !defined(MYMALLOC) || !defined(PERLDLL)
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
#define malloc win32_malloc
#define calloc win32_calloc
#define realloc win32_realloc
#define free win32_free
+#endif
#define pipe(fd) win32_pipe((fd), 512, O_BINARY)
#define pause() win32_sleep((32767L << 16) + 32767)
diff --git a/win32/win32thread.c b/win32/win32thread.c
index 4dbc750b05..c0c3c60239 100644
--- a/win32/win32thread.c
+++ b/win32/win32thread.c
@@ -1,6 +1,20 @@
#include "EXTERN.h"
#include "perl.h"
+__declspec(thread) struct thread *Perl_current_thread = NULL;
+
+void
+Perl_setTHR(struct thread *t)
+{
+ Perl_current_thread = t;
+}
+
+struct thread *
+Perl_getTHR(void)
+{
+ return Perl_current_thread;
+}
+
void
Perl_alloc_thread_key(void)
{
diff --git a/win32/win32thread.h b/win32/win32thread.h
index 0c6bb55b69..38e66e9fc9 100644
--- a/win32/win32thread.h
+++ b/win32/win32thread.h
@@ -97,7 +97,7 @@ typedef HANDLE perl_mutex;
} \
} STMT_END
-#define THR ((struct thread *) TlsGetValue(thr_key))
+
#define THREAD_CREATE(t, f) Perl_thread_create(t, f)
#define THREAD_POST_CREATE(t) NOOP
#define THREAD_RET_TYPE DWORD WINAPI
@@ -105,14 +105,28 @@ typedef HANDLE perl_mutex;
typedef THREAD_RET_TYPE thread_func_t(void *);
+
START_EXTERN_C
+
+#if defined(PERLDLL) && (!defined(__BORLANDC__) || defined(_DLL))
+extern __declspec(thread) struct thread *Perl_current_thread;
+#define SET_THR(t) (Perl_current_thread = t)
+#define THR Perl_current_thread
+#else
+#define THR Perl_getTHR()
+#define SET_THR(t) Perl_setTHR(t)
+#endif
+
void Perl_alloc_thread_key _((void));
int Perl_thread_create _((struct thread *thr, thread_func_t *fn));
void Perl_set_thread_self _((struct thread *thr));
+struct thread *Perl_getTHR _((void));
+void Perl_setTHR _((struct thread *t));
+
END_EXTERN_C
#define INIT_THREADS NOOP
-#define ALLOC_THREAD_KEY Perl_alloc_thread_key()
+#define ALLOC_THREAD_KEY NOOP
#define SET_THREAD_SELF(thr) Perl_set_thread_self(thr)
#define JOIN(t, avp) \
@@ -122,12 +136,7 @@ END_EXTERN_C
croak("panic: JOIN"); \
} STMT_END
-#define SET_THR(t) \
- STMT_START { \
- if (TlsSetValue(thr_key, (void *) (t)) == 0) \
- croak("panic: TlsSetValue"); \
- } STMT_END
-
#define YIELD Sleep(0)
#endif /* _WIN32THREAD_H */
+