diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-12-01 02:54:29 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-12-01 02:54:29 +0000 |
commit | 22239a37ce131e4f5341aee571f08aced283e16a (patch) | |
tree | 8f7f8e19354cc72b2f70b0f4bee40968a002c92b /win32 | |
parent | 36c15d3fd87bb94724027176c49a6c0afbc14dc9 (diff) | |
download | perl-22239a37ce131e4f5341aee571f08aced283e16a.tar.gz |
Create a struct for all perls globals (as an option)
Mainly for Mingw32 which cannot import data.
Now only Opcode tests fail (op_desc/op_name not
handled yet stuff)
p4raw-id: //depot/ansiperl@341
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile | 11 | ||||
-rw-r--r-- | win32/makedef.pl | 186 | ||||
-rw-r--r-- | win32/makegcc.mk | 4 | ||||
-rw-r--r-- | win32/perllib.c | 8 | ||||
-rw-r--r-- | win32/win32.c | 13 | ||||
-rw-r--r-- | win32/win32.h | 24 | ||||
-rw-r--r-- | win32/win32iop.h | 159 | ||||
-rw-r--r-- | win32/win32thread.c | 5 |
8 files changed, 243 insertions, 167 deletions
diff --git a/win32/Makefile b/win32/Makefile index 901a9f4978..2411ff42c5 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -11,9 +11,10 @@ # newly built perl. INST_DRV=c: INST_TOP=$(INST_DRV)\perl5004.5x -BUILDOPT=-DUSE_THREADS +#BUILDOPT=-DUSE_THREADS #BUILDOPT=-DMULTIPLICITY #BUILDOPT=-DMULTIPLICITY -DUSE_THREADS +BUILDOPT=-DPERL_GLOBAL_STRUCT -DMULTIPLICITY CORECCOPT= # @@ -54,7 +55,7 @@ RUNTIME = -MD INCLUDES = -I.\include -I. -I.. #PCHFLAGS = -Fp"$(INTDIR)/modules.pch" -YX DEFINES = -DWIN32 -D_CONSOLE $(BUILDOPT) -LOCDEFS = -DPERLDLL -DPERL_CORE $(CORECCOPT) +LOCDEFS = -DPERLDLL $(CORECCOPT) SUBSYS = console !IF "$(RUNTIME)" == "-MD" @@ -376,13 +377,13 @@ perl95.c : runperl.c copy runperl.c perl95.c perl95.obj : perl95.c - $(CC) $(CFLAGS) -MT -UPERLDLL -c perl95.c + $(CC) $(CFLAGS) -MT -UPERLDLL -DWIN95FIX -c perl95.c win32sckmt.obj : win32sck.c - $(CC) $(CFLAGS) -MT -UPERLDLL -c $(OBJOUT_FLAG)win32sckmt.obj win32sck.c + $(CC) $(CFLAGS) -MT -UPERLDLL -DWIN95FIX -c $(OBJOUT_FLAG)win32sckmt.obj win32sck.c win32mt.obj : win32.c - $(CC) $(CFLAGS) -MT -UPERLDLL -c $(OBJOUT_FLAG)win32mt.obj win32.c + $(CC) $(CFLAGS) -MT -UPERLDLL -DWIN95FIX -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/makedef.pl b/win32/makedef.pl index 91630d991d..9b6cfe308d 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -38,9 +38,37 @@ if ($CCTYPE ne 'GCC') print "CODE LOADONCALL\n"; print "DATA LOADONCALL NONSHARED MULTIPLE\n"; } +else + { + $define{'PERL_GLOBAL_STRUCT'} = 1; + $define{'MULTIPLICITY'} = 1; + } + print "EXPORTS\n"; -$skip_sym=<<'!END!OF!SKIP!'; +my %skip; +my %export; + +sub skip_symbols +{ + my $list = shift; + foreach my $symbol (@$list) + { + $skip{$symbol} = 1; + } +} + +sub emit_symbols +{ + my $list = shift; + foreach my $symbol (@$list) + { + emit_symbol($symbol) unless exists $skip{$symbol}; + } +} + +skip_symbols [qw( +Perl_statusvalue_vms Perl_block_type Perl_additem Perl_cast_ulong @@ -157,30 +185,26 @@ Perl_my_memset Perl_cshlen Perl_cshname Perl_opsave -!END!OF!SKIP! +)]; -if ($CCTYPE eq 'GCC') - { - $skip_sym .= "Perl_na\n"; - } 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'); + skip_symbols [qw( + Perl_safefree + Perl_safemalloc + Perl_saferealloc + Perl_safecalloc)]; + emit_symbols [qw( + Perl_malloc + Perl_free + Perl_realloc + Perl_calloc)]; } unless ($define{'USE_THREADS'}) { - $skip_sym .= <<'!END!OF!SKIP!'; + skip_symbols [qw( Perl_condpair_magic Perl_thr_key Perl_sv_mutex @@ -205,56 +229,63 @@ Perl_sv_nv Perl_sv_true Perl_sv_uv Perl_sv_pvn -Perl_newRV_noinc -!END!OF!SKIP! +Perl_newRV_noinc)]; } +sub readvar +{ + my $file = shift; + open(VARS,$file) || die "Cannot open $file:$!"; + my @syms; + while (<VARS>) + { + # All symbols have a Perl_ prefix because that's what embed.h + # sticks in front of them. + push(@syms,"Perl_".$1) if (/\bPERLVARI?\([IGT](\w+)/); + } + close(VARS); + return \@syms; +} + if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'}) { - open(THREAD,"<../thrdvar.h") || die "Cannot open ../thrdvar.h:$!"; - while (<THREAD>) - { - if (/\bPERLVARI?\(T(\w+)/) - { - $skip_sym .= "Perl_".$1."\n"; - } - } - close(THREAD); + my $thrd = readvar("../thrdvar.h"); + skip_symbols $thrd; } if ($define{'MULTIPLICITY'}) { - open(THREAD,"<../intrpvar.h") || die "Cannot open ../intrpvar.h:$!"; - while (<THREAD>) - { - if (/\bPERLVARI?\(I(\w+)/) - { - $skip_sym .= "Perl_".$1."\n"; - } - } - close(THREAD); + my $interp = readvar("../intrpvar.h"); + skip_symbols $interp; + } + +if ($define{'PERL_GLOBAL_STRUCT'}) + { + my $global = readvar("../perlvars.h"); + skip_symbols $global; } unless ($define{'DEBUGGING'}) { - $skip_sym .= "Perl_runops_debug\n"; - $skip_sym .= "Perl_sv_peek\n"; + skip_symbols [qw( + Perl_runops_debug + Perl_sv_peek + Perl_watchaddr + Perl_watchok)]; } -# All symbols have a Perl_ prefix because that's what embed.h -# sticks in front of them. - - open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!; -while (<GLOBAL>) { - my $symbol; - next if (!/^[A-Za-z]/); - next if (/_amg[ \t]*$/); - $symbol = "Perl_$_"; - next if ($skip_sym =~ m/$symbol/m); - emit_symbol($symbol); -} +while (<GLOBAL>) + { + next if (!/^[A-Za-z]/); + next if (/_amg[ \t]*$/); + # All symbols have a Perl_ prefix because that's what embed.h + # sticks in front of them. + chomp($_); + my $symbol = "Perl_$_"; + emit_symbol($symbol) unless exists $skip{$symbol}; + } close(GLOBAL); # also add symbols from interp.sym @@ -262,34 +293,41 @@ close(GLOBAL); # doesn't hurt to include them anyway. # these don't have Perl prefix -open (INTERP, "<../interp.sym") || die "failed to open interp.sym" . $!; -while (<INTERP>) { - my $symbol; - next if (!/^[A-Za-z]/); - next if (/_amg[ \t]*$/); - $symbol = $_; - next if ($skip_sym =~ m/$symbol/m); - #print "\t$symbol"; - emit_symbol("Perl_" . $symbol); -} +if ($define{'PERL_GLOBAL_STRUCT'}) + { + emit_symbol( ($CCTYPE eq 'GCC') ? 'Perl_GetVars' : 'Perl_VarsPtr') + } +else + { + my $glob = readvar("../perlvars.h"); + emit_symbols $glob; + } + +unless ($define{'MULTIPLICITY'}) + { + my $glob = readvar("../intrpvar.h"); + emit_symbols $glob; + } -#close(INTERP); +unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) + { + my $glob = readvar("../thrdvar.h"); + emit_symbols $glob; + } while (<DATA>) { my $symbol; next if (!/^[A-Za-z]/); next if (/^#/); s/\r//g; + chomp($_); $symbol = $_; - next if ($skip_sym =~ m/^$symbol/m); - $symbol = "Perl_".$symbol if ($define{'USE_THISPTR'} - && $symbol =~ /^perl/); + next if exists $skip{$symbol}; emit_symbol($symbol); } -sub emit_symbol { - my $symbol = shift; - chomp $symbol; +foreach my $symbol (sort keys %export) + { if ($CCTYPE eq "BORLAND") { # workaround Borland quirk by exporting both the straight # name and a name with leading underscore. Note the @@ -298,12 +336,23 @@ sub emit_symbol { print "\t_$symbol\n"; print "\t$symbol = _$symbol\n"; } + elsif ($CCTYPE eq 'GCC') { + # Symbols have leading _ whole process is $%£"% slow + # so skip aliases for now + print "\t$symbol\n"; + } else { # for binary coexistence, export both the symbol and # alias with leading underscore print "\t$symbol\n"; print "\t_$symbol = $symbol\n"; } + } + +sub emit_symbol { + my $symbol = shift; + chomp($symbol); + $export{$symbol} = 1; } 1; @@ -453,3 +502,4 @@ Perl_init_os_extras Perl_getTHR Perl_setTHR RunPerl + diff --git a/win32/makegcc.mk b/win32/makegcc.mk index dfe372c935..56daeca918 100644 --- a/win32/makegcc.mk +++ b/win32/makegcc.mk @@ -11,7 +11,7 @@ # newly built perl. INST_DRV=c: INST_TOP=$(INST_DRV)\perl5004.5x -BUILDOPT=-DUSE_THREADS +BUILDOPT= # @@ -49,7 +49,7 @@ CCLIBDIR = $(CCHOME)\lib .USESHELL : -CC = gcc +CC = gcc -pipe LINK32 = gcc LIB32 = ar IMPLIB = dlltool diff --git a/win32/perllib.c b/win32/perllib.c index 848360698b..b1002ebb16 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -15,6 +15,14 @@ RunPerl(int argc, char **argv, char **env, void *iosubsystem) int exitstatus; PerlInterpreter *my_perl; +#ifdef PERL_GLOBAL_STRUCT +#define PERLVAR(var,type) /**/ +#define PERLVARI(var,type,init) Perl_Vars.var = init; +#include "perlvars.h" +#undef PERLVAR +#undef PERLVARI +#endif + PERL_SYS_INIT(&argc,&argv); perl_init_i18nl10n(1); diff --git a/win32/win32.c b/win32/win32.c index c4b8c3bb7c..dcdda533d6 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -545,15 +545,15 @@ getegid(void) } int -setuid(uid_t uid) +setuid(uid_t auid) { - return (uid == ROOT_UID ? 0 : -1); + return (auid == ROOT_UID ? 0 : -1); } int -setgid(gid_t gid) +setgid(gid_t agid) { - return (gid == ROOT_GID ? 0 : -1); + return (agid == ROOT_GID ? 0 : -1); } /* @@ -1131,9 +1131,9 @@ win32_abort(void) } DllExport int -win32_fstat(int fd,struct stat *bufptr) +win32_fstat(int fd,struct stat *sbufptr) { - return fstat(fd,bufptr); + return fstat(fd,sbufptr); } DllExport int @@ -1779,3 +1779,4 @@ win32_strip_return(SV *sv) + diff --git a/win32/win32.h b/win32/win32.h index db87a6dca8..9b53a9a4b5 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -10,11 +10,27 @@ #define _INC_WIN32_PERL5 #ifdef __GNUC__ -#define __declspec(x) typedef long long __int64; #define Win32_Winsock +/* GCC does not do __declspec() - render it a nop + * and turn on options to avoid importing data + */ +#define __declspec(x) +#define PERL_GLOBAL_STRUCT +#define MULTIPLICITY #endif +/* Define DllExport akin to perl's EXT, + * If we are in the DLL or mimicing the DLL for Win95 work round + * then Export the symbol, + * otherwise import it. + */ + +#if defined(PERLDLL) || defined(WIN95FIX) +#define DllExport __declspec(dllexport) +#else +#define DllExport __declspec(dllimport) +#endif #define WIN32_LEAN_AND_MEAN #include <windows.h> @@ -56,8 +72,6 @@ struct tms { #define STANDARD_C 1 #define DOSISH 1 /* no escaping our roots */ #define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */ -#define DllExport __declspec(dllexport) -#define DllImport __declspec(dllimport) /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as * real filehandles. XXX Should always be defined (the other version is untested) */ @@ -133,8 +147,8 @@ extern void *sbrk(int need); #undef init_os_extras #define init_os_extras Perl_init_os_extras -EXT void Perl_win32_init(int *argcp, char ***argvp); -EXT void Perl_init_os_extras(void); +DllExport void Perl_win32_init(int *argcp, char ***argvp); +DllExport void Perl_init_os_extras(void); #ifndef USE_SOCKETS_AS_HANDLES extern FILE * my_fdopen(int, char *); diff --git a/win32/win32iop.h b/win32/win32iop.h index a2b318a558..78c90e1696 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -30,90 +30,90 @@ */ START_EXTERN_C -EXT int * win32_errno(void); -EXT char *** win32_environ(void); -EXT FILE* win32_stdin(void); -EXT FILE* win32_stdout(void); -EXT FILE* win32_stderr(void); -EXT int win32_ferror(FILE *fp); -EXT int win32_feof(FILE *fp); -EXT char* win32_strerror(int e); - -EXT int win32_fprintf(FILE *pf, const char *format, ...); -EXT int win32_printf(const char *format, ...); -EXT int win32_vfprintf(FILE *pf, const char *format, va_list arg); -EXT int win32_vprintf(const char *format, va_list arg); -EXT size_t win32_fread(void *buf, size_t size, size_t count, FILE *pf); -EXT size_t win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf); -EXT FILE* win32_fopen(const char *path, const char *mode); -EXT FILE* win32_fdopen(int fh, const char *mode); -EXT FILE* win32_freopen(const char *path, const char *mode, FILE *pf); -EXT int win32_fclose(FILE *pf); -EXT int win32_fputs(const char *s,FILE *pf); -EXT int win32_fputc(int c,FILE *pf); -EXT int win32_ungetc(int c,FILE *pf); -EXT int win32_getc(FILE *pf); -EXT int win32_fileno(FILE *pf); -EXT void win32_clearerr(FILE *pf); -EXT int win32_fflush(FILE *pf); -EXT long win32_ftell(FILE *pf); -EXT int win32_fseek(FILE *pf,long offset,int origin); -EXT int win32_fgetpos(FILE *pf,fpos_t *p); -EXT int win32_fsetpos(FILE *pf,const fpos_t *p); -EXT void win32_rewind(FILE *pf); -EXT FILE* win32_tmpfile(void); -EXT void win32_abort(void); -EXT int win32_fstat(int fd,struct stat *bufptr); -EXT int win32_stat(const char *name,struct stat *bufptr); -EXT int win32_pipe( int *phandles, unsigned int psize, int textmode ); -EXT FILE* win32_popen( const char *command, const char *mode ); -EXT int win32_pclose( FILE *pf); -EXT int win32_setmode( int fd, int mode); -EXT long win32_lseek( int fd, long offset, int origin); -EXT long win32_tell( int fd); -EXT int win32_dup( int fd); -EXT int win32_dup2(int h1, int h2); -EXT int win32_open(const char *path, int oflag,...); -EXT int win32_close(int fd); -EXT int win32_eof(int fd); -EXT int win32_read(int fd, void *buf, unsigned int cnt); -EXT int win32_write(int fd, const void *buf, unsigned int cnt); -EXT int win32_spawnvp(int mode, const char *cmdname, +DllExport int * win32_errno(void); +DllExport char *** win32_environ(void); +DllExport FILE* win32_stdin(void); +DllExport FILE* win32_stdout(void); +DllExport FILE* win32_stderr(void); +DllExport int win32_ferror(FILE *fp); +DllExport int win32_feof(FILE *fp); +DllExport char* win32_strerror(int e); + +DllExport int win32_fprintf(FILE *pf, const char *format, ...); +DllExport int win32_printf(const char *format, ...); +DllExport int win32_vfprintf(FILE *pf, const char *format, va_list arg); +DllExport int win32_vprintf(const char *format, va_list arg); +DllExport size_t win32_fread(void *buf, size_t size, size_t count, FILE *pf); +DllExport size_t win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf); +DllExport FILE* win32_fopen(const char *path, const char *mode); +DllExport FILE* win32_fdopen(int fh, const char *mode); +DllExport FILE* win32_freopen(const char *path, const char *mode, FILE *pf); +DllExport int win32_fclose(FILE *pf); +DllExport int win32_fputs(const char *s,FILE *pf); +DllExport int win32_fputc(int c,FILE *pf); +DllExport int win32_ungetc(int c,FILE *pf); +DllExport int win32_getc(FILE *pf); +DllExport int win32_fileno(FILE *pf); +DllExport void win32_clearerr(FILE *pf); +DllExport int win32_fflush(FILE *pf); +DllExport long win32_ftell(FILE *pf); +DllExport int win32_fseek(FILE *pf,long offset,int origin); +DllExport int win32_fgetpos(FILE *pf,fpos_t *p); +DllExport int win32_fsetpos(FILE *pf,const fpos_t *p); +DllExport void win32_rewind(FILE *pf); +DllExport FILE* win32_tmpfile(void); +DllExport void win32_abort(void); +DllExport int win32_fstat(int fd,struct stat *sbufptr); +DllExport int win32_stat(const char *name,struct stat *sbufptr); +DllExport int win32_pipe( int *phandles, unsigned int psize, int textmode ); +DllExport FILE* win32_popen( const char *command, const char *mode ); +DllExport int win32_pclose( FILE *pf); +DllExport int win32_setmode( int fd, int mode); +DllExport long win32_lseek( int fd, long offset, int origin); +DllExport long win32_tell( int fd); +DllExport int win32_dup( int fd); +DllExport int win32_dup2(int h1, int h2); +DllExport int win32_open(const char *path, int oflag,...); +DllExport int win32_close(int fd); +DllExport int win32_eof(int fd); +DllExport int win32_read(int fd, void *buf, unsigned int cnt); +DllExport int win32_write(int fd, const void *buf, unsigned int cnt); +DllExport int win32_spawnvp(int mode, const char *cmdname, const char *const *argv); -EXT int win32_mkdir(const char *dir, int mode); -EXT int win32_rmdir(const char *dir); -EXT int win32_chdir(const char *dir); -EXT int win32_flock(int fd, int oper); -EXT int win32_execvp(const char *cmdname, const char *const *argv); -EXT void win32_perror(const char *str); -EXT void win32_setbuf(FILE *pf, char *buf); -EXT int win32_setvbuf(FILE *pf, char *buf, int type, size_t size); -EXT int win32_flushall(void); -EXT int win32_fcloseall(void); -EXT char* win32_fgets(char *s, int n, FILE *pf); -EXT char* win32_gets(char *s); -EXT int win32_fgetc(FILE *pf); -EXT int win32_putc(int c, FILE *pf); -EXT int win32_puts(const char *s); -EXT int win32_getchar(void); -EXT int win32_putchar(int c); -EXT void* win32_malloc(size_t size); -EXT void* win32_calloc(size_t numitems, size_t size); -EXT void* win32_realloc(void *block, size_t size); -EXT void win32_free(void *block); - -EXT int win32_open_osfhandle(long handle, int flags); -EXT long win32_get_osfhandle(int fd); +DllExport int win32_mkdir(const char *dir, int mode); +DllExport int win32_rmdir(const char *dir); +DllExport int win32_chdir(const char *dir); +DllExport int win32_flock(int fd, int oper); +DllExport int win32_execvp(const char *cmdname, const char *const *argv); +DllExport void win32_perror(const char *str); +DllExport void win32_setbuf(FILE *pf, char *buf); +DllExport int win32_setvbuf(FILE *pf, char *buf, int type, size_t size); +DllExport int win32_flushall(void); +DllExport int win32_fcloseall(void); +DllExport char* win32_fgets(char *s, int n, FILE *pf); +DllExport char* win32_gets(char *s); +DllExport int win32_fgetc(FILE *pf); +DllExport int win32_putc(int c, FILE *pf); +DllExport int win32_puts(const char *s); +DllExport int win32_getchar(void); +DllExport int win32_putchar(int c); +DllExport void* win32_malloc(size_t size); +DllExport void* win32_calloc(size_t numitems, size_t size); +DllExport void* win32_realloc(void *block, size_t size); +DllExport void win32_free(void *block); + +DllExport int win32_open_osfhandle(long handle, int flags); +DllExport long win32_get_osfhandle(int fd); #ifndef USE_WIN32_RTL_ENV -EXT char* win32_getenv(const char *name); +DllExport char* win32_getenv(const char *name); #endif -EXT unsigned int win32_sleep(unsigned int); -EXT int win32_times(struct tms *timebuf); -EXT unsigned int win32_alarm(unsigned int sec); -EXT int win32_flock(int fd, int oper); -EXT int win32_stat(const char *path, struct stat *buf); +DllExport unsigned int win32_sleep(unsigned int); +DllExport int win32_times(struct tms *timebuf); +DllExport unsigned int win32_alarm(unsigned int sec); +DllExport int win32_flock(int fd, int oper); +DllExport int win32_stat(const char *path, struct stat *buf); END_EXTERN_C @@ -240,3 +240,4 @@ END_EXTERN_C #endif /* WIN32IO_IS_STDIO */ #endif /* WIN32IOP_H */ + diff --git a/win32/win32thread.c b/win32/win32thread.c index d3783f6857..3ea73c32a5 100644 --- a/win32/win32thread.c +++ b/win32/win32thread.c @@ -45,7 +45,7 @@ Perl_alloc_thread_key(void) } void -Perl_init_thread_intern(struct perl_thread *thr) +Perl_init_thread_intern(struct perl_thread *athr) { #ifdef USE_THREADS #ifndef USE_DECLSPEC_THREAD @@ -56,7 +56,7 @@ Perl_init_thread_intern(struct perl_thread *thr) * return values we don't _need_ to do anything but * this is good practice: */ - memset(&thr->i,0,sizeof(thr->i)); + memset(&athr->i,0,sizeof(athr->i)); #endif #endif @@ -95,3 +95,4 @@ Perl_thread_create(struct perl_thread *thr, thread_func_t *fn) return thr->self ? 0 : -1; } #endif + |