From: Jarkko Hietaniemi Date: Sat, 9 Sep 2006 15:29:12 +0000 (+0300) Subject: C++: Solaris CC now compiles "perl" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ccb7c8d11bf6f3b795893f8ec88106e161747d5;p=p5sagit%2Fp5-mst-13.2.git C++: Solaris CC now compiles "perl" Message-ID: <4502B398.6060505@iki.fi> p4raw-id: //depot/perl@28814 --- diff --git a/hints/solaris_2.sh b/hints/solaris_2.sh index 4668edd..d4549e3 100644 --- a/hints/solaris_2.sh +++ b/hints/solaris_2.sh @@ -638,13 +638,26 @@ EOOVER rm -f try.c try.o try a.out -# If using g++, the Configure scan for dlopen() will fail in Solaris +# If using C++, the Configure scan for dlopen() will fail in Solaris # because one of the two (1) an extern "C" linkage definition is needed # (2) #include is needed, *and* a cast to (void*(*)()) # is needed for the &dlopen. Adding any of these would require changing # a delicate spot in Configure, so easier just to force our guess here # for Solaris. case "$cc" in -*g++*) d_dlopen='define' ;; +*g++*|/opt/SUNWspro/bin/CC) d_dlopen='define' ;; +esac + +# The Sun C++ doesn't define the global environ array. +case "$cc" in +/opt/SUNWspro/bin/CC) + for o in NO_ENVIRON_ARRAY PERL_USE_SAFE_PUTENV + do + case "$ccflags" in + *$o*) ;; + *) ccflags="$ccflags $o" ;; + esac + done + ;; esac diff --git a/opcode.h b/opcode.h index 6dd31c3..4b32c85 100644 --- a/opcode.h +++ b/opcode.h @@ -1535,9 +1535,9 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */ #ifndef PERL_GLOBAL_STRUCT_INIT #ifndef DOINIT -EXT const U32 PL_opargs[]; +EXTCONST U32 PL_opargs[]; #else -EXT const U32 PL_opargs[] = { +EXTCONST U32 PL_opargs[] = { 0x00000000, /* null */ 0x00000000, /* stub */ 0x00003604, /* scalar */ diff --git a/opcode.pl b/opcode.pl index 3316fd9..7098f13 100755 --- a/opcode.pl +++ b/opcode.pl @@ -287,9 +287,9 @@ print <len) { PerlIOBuf * const b = &m->base; if (b->buf) { - code = munmap(m->mptr, m->len); + /* The munmap address argument is tricky: depending on the + * standard it is either "void *" or "caddr_t" (which is + * usually "char *" (signed or unsigned). If we cast it + * to "void *", those that have it caddr_t and an uptight + * C++ compiler, will freak out. But casting it as char* + * should work. Maybe. (Using Mmap_t figured out by + * Configure doesn't always work, apparently.) */ + code = munmap((char*)m->mptr, m->len); b->buf = NULL; m->len = 0; m->mptr = NULL; diff --git a/unixish.h b/unixish.h index f464d83..631a619 100644 --- a/unixish.h +++ b/unixish.h @@ -138,5 +138,7 @@ #define dXSUB_SYS +#ifndef NO_ENVIRON_ARRAY #define USE_ENVIRON_ARRAY +#endif diff --git a/util.c b/util.c index 7a89c5c..44ff36f 100644 --- a/util.c +++ b/util.c @@ -1557,8 +1557,7 @@ Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const char *const bits, *(s+(nlen+1+vlen)) = '\0' #ifdef USE_ENVIRON_ARRAY - /* VMS' my_setenv() is in vms.c */ -#if !defined(WIN32) && !defined(NETWARE) +/* VMS' my_setenv() is in vms.c */ void Perl_my_setenv(pTHX_ const char *nam, const char *val) { @@ -1570,47 +1569,53 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) { #ifndef PERL_USE_SAFE_PUTENV if (!PL_use_safe_putenv) { - /* most putenv()s leak, so we manipulate environ directly */ - register I32 i=setenv_getix(nam); /* where does it go? */ - int nlen, vlen; - - if (environ == PL_origenviron) { /* need we copy environment? */ - I32 j; - I32 max; - char **tmpenv; - - max = i; - while (environ[max]) - max++; - tmpenv = (char**)safesysmalloc((max+2) * sizeof(char*)); - for (j=0; j= 0) { + if (environ == PL_origenviron) { /* need we copy environment? */ + I32 j; + I32 max; + char **tmpenv; + + max = i; + while (environ[max]) + max++; + tmpenv = (char**)safesysmalloc((max+2) * sizeof(char*)); + for (j=0; j