From 73c4f7a1d0b3ac27682d86c953e22cbc7dc810e6 Mon Sep 17 00:00:00 2001 From: Gurusamy Sarathy Date: Sat, 12 Jun 1999 06:43:03 +0000 Subject: [PATCH] EXTERN_C declarations for global arrays in various headers, so perl can be built even in C++ mode; win32 build fixups; regen headers p4raw-id: //depot/perl@3537 --- XSUB.h | 2 +- embedvar.h | 54 ++++++++++++++++++++++++++---------------------------- ext/B/B.xs | 1 - objXSUB.h | 2 -- opcode.h | 9 +++++++++ opcode.pl | 9 +++++++++ perl.h | 33 ++++++++++++++++----------------- regcomp.h | 3 +++ regexec.c | 3 ++- utf8.h | 4 ++++ win32/win32.c | 13 ++++++++++++- win32/win32.h | 4 ++-- 12 files changed, 84 insertions(+), 53 deletions(-) diff --git a/XSUB.h b/XSUB.h index 44e2f7d..74e8f02 100644 --- a/XSUB.h +++ b/XSUB.h @@ -25,7 +25,7 @@ # define XSINTERFACE_CVT(ret,name) ret (*name)() #endif #define dXSFUNCTION(ret) XSINTERFACE_CVT(ret,XSFUNCTION) -#define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT(ret,))(f)) +#define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT(ret,cv))(f)) #define XSINTERFACE_FUNC_SET(cv,f) \ CvXSUBANY(cv).any_dptr = (void (*) (pTHX_ void*))(f) diff --git a/embedvar.h b/embedvar.h index 7f4ea6a..1312258 100644 --- a/embedvar.h +++ b/embedvar.h @@ -305,11 +305,13 @@ #define PL_comppad_name_floor (PL_curinterp->Icomppad_name_floor) #define PL_cop_seqmax (PL_curinterp->Icop_seqmax) #define PL_copline (PL_curinterp->Icopline) +#define PL_cred_mutex (PL_curinterp->Icred_mutex) #define PL_cryptseen (PL_curinterp->Icryptseen) #define PL_cshlen (PL_curinterp->Icshlen) #define PL_cshname (PL_curinterp->Icshname) #define PL_curcopdb (PL_curinterp->Icurcopdb) #define PL_curstname (PL_curinterp->Icurstname) +#define PL_curthr (PL_curinterp->Icurthr) #define PL_dbargs (PL_curinterp->Idbargs) #define PL_debdelim (PL_curinterp->Idebdelim) #define PL_debname (PL_curinterp->Idebname) @@ -331,6 +333,9 @@ #define PL_errgv (PL_curinterp->Ierrgv) #define PL_error_count (PL_curinterp->Ierror_count) #define PL_euid (PL_curinterp->Ieuid) +#define PL_eval_cond (PL_curinterp->Ieval_cond) +#define PL_eval_mutex (PL_curinterp->Ieval_mutex) +#define PL_eval_owner (PL_curinterp->Ieval_owner) #define PL_eval_root (PL_curinterp->Ieval_root) #define PL_eval_start (PL_curinterp->Ieval_start) #define PL_evalseq (PL_curinterp->Ievalseq) @@ -394,6 +399,7 @@ #define PL_main_cv (PL_curinterp->Imain_cv) #define PL_main_root (PL_curinterp->Imain_root) #define PL_main_start (PL_curinterp->Imain_start) +#define PL_malloc_mutex (PL_curinterp->Imalloc_mutex) #define PL_max_intro_pending (PL_curinterp->Imax_intro_pending) #define PL_maxo (PL_curinterp->Imaxo) #define PL_maxsysfd (PL_curinterp->Imaxsysfd) @@ -418,6 +424,8 @@ #define PL_nice_chunk (PL_curinterp->Inice_chunk) #define PL_nice_chunk_size (PL_curinterp->Inice_chunk_size) #define PL_nomemok (PL_curinterp->Inomemok) +#define PL_nthreads (PL_curinterp->Inthreads) +#define PL_nthreads_cond (PL_curinterp->Inthreads_cond) #define PL_numeric_local (PL_curinterp->Inumeric_local) #define PL_numeric_name (PL_curinterp->Inumeric_name) #define PL_numeric_standard (PL_curinterp->Inumeric_standard) @@ -474,15 +482,20 @@ #define PL_subname (PL_curinterp->Isubname) #define PL_sv_arenaroot (PL_curinterp->Isv_arenaroot) #define PL_sv_count (PL_curinterp->Isv_count) +#define PL_sv_mutex (PL_curinterp->Isv_mutex) #define PL_sv_no (PL_curinterp->Isv_no) #define PL_sv_objcount (PL_curinterp->Isv_objcount) #define PL_sv_root (PL_curinterp->Isv_root) #define PL_sv_undef (PL_curinterp->Isv_undef) #define PL_sv_yes (PL_curinterp->Isv_yes) +#define PL_svref_mutex (PL_curinterp->Isvref_mutex) #define PL_sys_intern (PL_curinterp->Isys_intern) #define PL_tainting (PL_curinterp->Itainting) #define PL_thisexpr (PL_curinterp->Ithisexpr) +#define PL_thr_key (PL_curinterp->Ithr_key) #define PL_threadnum (PL_curinterp->Ithreadnum) +#define PL_threads_mutex (PL_curinterp->Ithreads_mutex) +#define PL_threadsv_names (PL_curinterp->Ithreadsv_names) #define PL_thrsv (PL_curinterp->Ithrsv) #define PL_tokenbuf (PL_curinterp->Itokenbuf) #define PL_uid (PL_curinterp->Iuid) @@ -548,11 +561,13 @@ #define PL_Icomppad_name_floor PL_comppad_name_floor #define PL_Icop_seqmax PL_cop_seqmax #define PL_Icopline PL_copline +#define PL_Icred_mutex PL_cred_mutex #define PL_Icryptseen PL_cryptseen #define PL_Icshlen PL_cshlen #define PL_Icshname PL_cshname #define PL_Icurcopdb PL_curcopdb #define PL_Icurstname PL_curstname +#define PL_Icurthr PL_curthr #define PL_Idbargs PL_dbargs #define PL_Idebdelim PL_debdelim #define PL_Idebname PL_debname @@ -574,6 +589,9 @@ #define PL_Ierrgv PL_errgv #define PL_Ierror_count PL_error_count #define PL_Ieuid PL_euid +#define PL_Ieval_cond PL_eval_cond +#define PL_Ieval_mutex PL_eval_mutex +#define PL_Ieval_owner PL_eval_owner #define PL_Ieval_root PL_eval_root #define PL_Ieval_start PL_eval_start #define PL_Ievalseq PL_evalseq @@ -637,6 +655,7 @@ #define PL_Imain_cv PL_main_cv #define PL_Imain_root PL_main_root #define PL_Imain_start PL_main_start +#define PL_Imalloc_mutex PL_malloc_mutex #define PL_Imax_intro_pending PL_max_intro_pending #define PL_Imaxo PL_maxo #define PL_Imaxsysfd PL_maxsysfd @@ -661,6 +680,8 @@ #define PL_Inice_chunk PL_nice_chunk #define PL_Inice_chunk_size PL_nice_chunk_size #define PL_Inomemok PL_nomemok +#define PL_Inthreads PL_nthreads +#define PL_Inthreads_cond PL_nthreads_cond #define PL_Inumeric_local PL_numeric_local #define PL_Inumeric_name PL_numeric_name #define PL_Inumeric_standard PL_numeric_standard @@ -717,15 +738,20 @@ #define PL_Isubname PL_subname #define PL_Isv_arenaroot PL_sv_arenaroot #define PL_Isv_count PL_sv_count +#define PL_Isv_mutex PL_sv_mutex #define PL_Isv_no PL_sv_no #define PL_Isv_objcount PL_sv_objcount #define PL_Isv_root PL_sv_root #define PL_Isv_undef PL_sv_undef #define PL_Isv_yes PL_sv_yes +#define PL_Isvref_mutex PL_svref_mutex #define PL_Isys_intern PL_sys_intern #define PL_Itainting PL_tainting #define PL_Ithisexpr PL_thisexpr +#define PL_Ithr_key PL_thr_key #define PL_Ithreadnum PL_threadnum +#define PL_Ithreads_mutex PL_threads_mutex +#define PL_Ithreadsv_names PL_threadsv_names #define PL_Ithrsv PL_thrsv #define PL_Itokenbuf PL_tokenbuf #define PL_Iuid PL_uid @@ -1024,47 +1050,19 @@ #define PL_No (PL_Vars.GNo) #define PL_Yes (PL_Vars.GYes) -#define PL_cred_mutex (PL_Vars.Gcred_mutex) #define PL_curinterp (PL_Vars.Gcurinterp) -#define PL_curthr (PL_Vars.Gcurthr) #define PL_do_undump (PL_Vars.Gdo_undump) -#define PL_eval_cond (PL_Vars.Geval_cond) -#define PL_eval_mutex (PL_Vars.Geval_mutex) -#define PL_eval_owner (PL_Vars.Geval_owner) #define PL_hexdigit (PL_Vars.Ghexdigit) -#define PL_malloc_mutex (PL_Vars.Gmalloc_mutex) -#define PL_ninterps (PL_Vars.Gninterps) -#define PL_nthreads (PL_Vars.Gnthreads) -#define PL_nthreads_cond (PL_Vars.Gnthreads_cond) #define PL_patleave (PL_Vars.Gpatleave) -#define PL_sv_mutex (PL_Vars.Gsv_mutex) -#define PL_svref_mutex (PL_Vars.Gsvref_mutex) -#define PL_thr_key (PL_Vars.Gthr_key) -#define PL_threads_mutex (PL_Vars.Gthreads_mutex) -#define PL_threadsv_names (PL_Vars.Gthreadsv_names) #else /* !PERL_GLOBAL_STRUCT */ #define PL_GNo PL_No #define PL_GYes PL_Yes -#define PL_Gcred_mutex PL_cred_mutex #define PL_Gcurinterp PL_curinterp -#define PL_Gcurthr PL_curthr #define PL_Gdo_undump PL_do_undump -#define PL_Geval_cond PL_eval_cond -#define PL_Geval_mutex PL_eval_mutex -#define PL_Geval_owner PL_eval_owner #define PL_Ghexdigit PL_hexdigit -#define PL_Gmalloc_mutex PL_malloc_mutex -#define PL_Gninterps PL_ninterps -#define PL_Gnthreads PL_nthreads -#define PL_Gnthreads_cond PL_nthreads_cond #define PL_Gpatleave PL_patleave -#define PL_Gsv_mutex PL_sv_mutex -#define PL_Gsvref_mutex PL_svref_mutex -#define PL_Gthr_key PL_thr_key -#define PL_Gthreads_mutex PL_threads_mutex -#define PL_Gthreadsv_names PL_threadsv_names #endif /* PERL_GLOBAL_STRUCT */ diff --git a/ext/B/B.xs b/ext/B/B.xs index 6413a24..90ec6c1 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -10,7 +10,6 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" -#include "INTERN.h" #ifdef PERL_OBJECT #undef PL_op_name diff --git a/objXSUB.h b/objXSUB.h index 08356c0..579b916 100644 --- a/objXSUB.h +++ b/objXSUB.h @@ -394,8 +394,6 @@ #define PL_nice_chunk pPerl->PL_nice_chunk #undef PL_nice_chunk_size #define PL_nice_chunk_size pPerl->PL_nice_chunk_size -#undef PL_ninterps -#define PL_ninterps pPerl->PL_ninterps #undef PL_nomemok #define PL_nomemok pPerl->PL_nomemok #undef PL_nrs diff --git a/opcode.h b/opcode.h index 370fb6a..20ec044 100644 --- a/opcode.h +++ b/opcode.h @@ -357,6 +357,9 @@ typedef enum { #define MAXO 348 + +START_EXTERN_C + #ifndef DOINIT EXT char *PL_op_name[]; #else @@ -1067,6 +1070,8 @@ EXT char *PL_op_desc[] = { }; #endif +END_EXTERN_C + #ifndef PERL_OBJECT START_EXTERN_C @@ -1081,6 +1086,8 @@ START_EXTERN_C END_EXTERN_C #endif /* PERL_OBJECT */ +START_EXTERN_C + #ifndef DOINIT EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX); #else @@ -2145,3 +2152,5 @@ EXT U32 PL_opargs[] = { 0x00000044, /* threadsv */ }; #endif + +END_EXTERN_C diff --git a/opcode.pl b/opcode.pl index 98e18da..1afc2f6 100755 --- a/opcode.pl +++ b/opcode.pl @@ -46,6 +46,9 @@ print "\n#define MAXO ", scalar @ops, "\n\n"; # Emit op names and descriptions. print < isn't - * included until after runops is initialised. - */ - -#ifndef PERL_OBJECT +#ifdef PERL_OBJECT +typedef int (CPerlObj::*runops_proc_t) (void); +#else typedef int (*runops_proc_t) (pTHX); -int Perl_runops_standard (pTHX); -#ifdef DEBUGGING -int Perl_runops_debug (pTHX); -#endif #endif /* _ (for $_) must be first in the following list (DEFSV requires it) */ @@ -1973,6 +1966,8 @@ extern char ** environ; /* environment variables supplied via exec */ # endif #endif +START_EXTERN_C + /* handy constants */ EXTCONST char PL_warn_uninit[] INIT("Use of uninitialized value"); @@ -2231,6 +2226,8 @@ EXTCONST char* PL_block_type[]; #endif #endif +END_EXTERN_C + /*****************************************************************************/ /* This lexer/parser stuff is currently global since yacc is hard to reenter */ /*****************************************************************************/ @@ -2350,10 +2347,6 @@ typedef struct exitlistentry { #ifdef PERL_OBJECT extern "C" CPerlObj* perl_alloc (IPerlMem*, IPerlEnv*, IPerlStdIO*, IPerlLIO*, IPerlDir*, IPerlSock*, IPerlProc*); -#ifdef PERL_OBJECT -typedef int (CPerlObj::*runops_proc_t) (void); -#endif /* PERL_OBJECT */ - #undef EXT #define EXT #undef EXTCONST @@ -2482,7 +2475,9 @@ END_EXTERN_C #define PERLVARIC(var,type,init) EXTCONST type PL_##var INIT(init); #ifndef PERL_GLOBAL_STRUCT +START_EXTERN_C #include "perlvars.h" +END_EXTERN_C #endif #ifndef MULTIPLICITY @@ -2523,6 +2518,8 @@ PERLVAR(object_compatibility[30], char) #undef PERLVARI #undef PERLVARIC +START_EXTERN_C + #ifdef DOINIT EXT MGVTBL PL_vtbl_sv = {Perl_magic_get, @@ -2727,6 +2724,8 @@ EXTCONST char * PL_AMG_names[NofAMmeth] = { EXTCONST char * PL_AMG_names[NofAMmeth]; #endif /* def INITAMAGIC */ +END_EXTERN_C + struct am_table { long was_ok_sub; long was_ok_am; diff --git a/regcomp.h b/regcomp.h index 5097d97..7c5c13a 100644 --- a/regcomp.h +++ b/regcomp.h @@ -207,6 +207,8 @@ struct regnode_2 { #define REG_SEEN_GPOS 4 #define REG_SEEN_EVAL 8 +START_EXTERN_C + #include "regnodes.h" /* The following have no fixed length. char* since we do strchr on it. */ @@ -234,3 +236,4 @@ EXTCONST char PL_simple[] = { }; #endif +END_EXTERN_C diff --git a/regexec.c b/regexec.c index 833e4bd..7dbf6dc 100644 --- a/regexec.c +++ b/regexec.c @@ -485,7 +485,8 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char * prog->anchored_substr ? prog->anchored_offset : prog->float_min_offset; I32 delta = back_max - back_min; char *last = HOPc(strend, /* Cannot start after this */ - -(CHR_SVLEN(must) - (SvTAIL(must) != 0) + back_min)); + -(I32)(CHR_SVLEN(must) + - (SvTAIL(must) != 0) + back_min)); char *last1; /* Last position checked before */ if (s > PL_bostr) diff --git a/utf8.h b/utf8.h index 31e208b..698c687 100644 --- a/utf8.h +++ b/utf8.h @@ -7,6 +7,8 @@ * */ +START_EXTERN_C + #ifdef DOINIT EXTCONST unsigned char PL_utf8skip[] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ascii */ @@ -22,6 +24,8 @@ EXTCONST unsigned char PL_utf8skip[] = { EXTCONST unsigned char PL_utf8skip[]; #endif +END_EXTERN_C + #define IN_UTF8 (PL_curcop->op_private & HINT_UTF8) #define UTF8SKIP(s) PL_utf8skip[*(U8*)s] diff --git a/win32/win32.c b/win32/win32.c index 694f48a..1882108 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -666,6 +666,7 @@ Perl_do_exec(pTHX_ char *cmd) DIR * win32_opendir(char *filename) { + dTHX; DIR *p; long len; long idx; @@ -978,6 +979,7 @@ win32_stat(const char *path, struct stat *buffer) } } if (USING_WIDE()) { + dTHX; A2WHELPER(path, wbuffer, sizeof(wbuffer), GETINTERPMODE()); res = _wstat(wbuffer, (struct _stat *)buffer); } @@ -1122,11 +1124,13 @@ win32_longpath(char *path) DllExport char * win32_getenv(const char *name) { + dTHX; static char *curitem = Nullch; /* XXX threadead */ static WCHAR *wCuritem = (WCHAR*)Nullch; /* XXX threadead */ static DWORD curlen = 0, wCurlen = 0;/* XXX threadead */ WCHAR wBuffer[MAX_PATH]; DWORD needlen; + if (USING_WIDE()) { if (!wCuritem) { wCurlen = 512; @@ -1194,8 +1198,9 @@ win32_putenv(const char *name) WCHAR* wCuritem; WCHAR* wVal; int length, relval = -1; - if(name) { + if (name) { if (USING_WIDE()) { + dTHX; length = strlen(name)+1; New(1309,wCuritem,length,WCHAR); A2WHELPER(name, wCuritem, length*2, GETINTERPMODE()); @@ -1307,6 +1312,7 @@ win32_utime(const char *filename, struct utimbuf *times) int rc; if (USING_WIDE()) { + dTHX; A2WHELPER(filename, wbuffer, sizeof(wbuffer), GETINTERPMODE()); rc = _wutime(wbuffer, (struct _utimbuf*)times); } @@ -1878,6 +1884,7 @@ win32_fopen(const char *filename, const char *mode) filename = "NUL"; if (USING_WIDE()) { + dTHX; A2WHELPER(mode, wMode, sizeof(wMode), GETINTERPMODE()); A2WHELPER(filename, wBuffer, sizeof(wBuffer), GETINTERPMODE()); return _wfopen(wBuffer, wMode); @@ -1895,6 +1902,7 @@ win32_fdopen(int handle, const char *mode) { WCHAR wMode[MODE_SIZE]; if (USING_WIDE()) { + dTHX; A2WHELPER(mode, wMode, sizeof(wMode), GETINTERPMODE()); return _wfdopen(handle, wMode); } @@ -1909,6 +1917,7 @@ win32_freopen(const char *path, const char *mode, FILE *stream) path = "NUL"; if (USING_WIDE()) { + dTHX; A2WHELPER(mode, wMode, sizeof(wMode), GETINTERPMODE()); A2WHELPER(path, wBuffer, sizeof(wBuffer), GETINTERPMODE()); return _wfreopen(wBuffer, wMode, stream); @@ -2156,6 +2165,7 @@ win32_rename(const char *oname, const char *newname) */ if (IsWinNT()) { if (USING_WIDE()) { + dTHX; A2WHELPER(oname, wOldName, sizeof(wOldName), GETINTERPMODE()); A2WHELPER(newname, wNewName, sizeof(wNewName), GETINTERPMODE()); bResult = MoveFileExW(wOldName,wNewName, @@ -2291,6 +2301,7 @@ win32_open(const char *path, int flag, ...) path = "NUL"; if (USING_WIDE()) { + dTHX; A2WHELPER(path, wBuffer, sizeof(wBuffer), GETINTERPMODE()); return _wopen(wBuffer, flag, pmode); } diff --git a/win32/win32.h b/win32/win32.h index 61aa223..c688ee9 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -402,8 +402,8 @@ struct thread_intern { lpa[0] = '\0', WideCharToMultiByte(acp, 0, lpw, -1, lpa, nChars, NULL, NULL) /* place holders for now */ -#define USING_WIDE() 0 -#define GETINTERPMODE() CP_ACP +#define USING_WIDE() (IsWinNT()) +#define GETINTERPMODE() (IN_UTF8) /* * This provides a layer of functions and macros to ensure extensions will -- 1.8.3.1