diff options
author | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-11-25 15:42:07 +0000 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-11-25 15:42:07 +0000 |
commit | 48bfcc53740a66ec5a66616b846e1db9955c1c69 (patch) | |
tree | 2de7728957d83a013605f4f68638b4bbef4565a2 /win32 | |
parent | fd206186f8bcdcb1b41bbddfb851c60acb937fcd (diff) | |
parent | d40103885dfef00fdafa10024e6e4d5e414d1403 (diff) | |
download | perl-48bfcc53740a66ec5a66616b846e1db9955c1c69.tar.gz |
Integrate from ansi branch to mainline.
p4raw-id: //depot/perl@296
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile | 14 | ||||
-rw-r--r-- | win32/config.bc | 11 | ||||
-rw-r--r-- | win32/config.vc | 5 | ||||
-rw-r--r-- | win32/config_H.bc | 62 | ||||
-rw-r--r-- | win32/config_H.vc | 62 | ||||
-rw-r--r-- | win32/config_h.PL | 15 | ||||
-rw-r--r-- | win32/config_sh.PL | 11 | ||||
-rw-r--r-- | win32/makedef.pl | 36 | ||||
-rw-r--r-- | win32/makefile.mk | 6 | ||||
-rw-r--r-- | win32/perlglob.c | 4 | ||||
-rw-r--r-- | win32/perllib.c | 4 | ||||
-rw-r--r-- | win32/win32.c | 127 | ||||
-rw-r--r-- | win32/win32.h | 22 | ||||
-rw-r--r-- | win32/win32iop.h | 7 | ||||
-rw-r--r-- | win32/win32thread.c | 14 | ||||
-rw-r--r-- | win32/win32thread.h | 22 |
16 files changed, 351 insertions, 71 deletions
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 922bef4a5c..3e63327638 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 d2dfe4225c..0d92ffc96f 100644 --- a/win32/win32thread.h +++ b/win32/win32thread.h @@ -105,14 +105,27 @@ 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 perl_thread *thr, thread_func_t *fn)); void Perl_set_thread_self _((struct perl_thread *thr)); +struct perl_thread *Perl_getTHR _((void)); +void Perl_setTHR _((struct perl_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 +135,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 */ + |