develooper Front page | perl.perl5.porters | Postings from May 2012

[perl #112796] The reentrant API should always have prototypes

From:
Craig A . Berry
Date:
May 6, 2012 15:15
Subject:
[perl #112796] The reentrant API should always have prototypes
Message ID:
rt-3.6.HEAD-4610-1336342530-430.112796-75-0@perl.org
# New Ticket Created by  Craig A. Berry 
# Please include the string:  [perl #112796]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=112796 >


reentr.c always defines and exports its functions even when USE_REENTRANT_API is not defined (though they'll be empty functions in that case).  In general we shouldn't be exporting functions without providing prototypes for them, but specifically, when compiling with C++, the prototype-less functions get their names mangled because there is no 'extern "C"' wrapped around their definitions.  So the purpose of defining the functions when we aren't using them (to have a consistent API) is defeated because no one looking for those functions under their proper names would be able to find them.

The mangled names are easily observed by doing "nm reentr.o" or "analyze/object reentr.obj" or your local equivalent in a dirty build directory after configuring with -Dcc=c++ (or whatever your C++ compiler is called).

The attached patch simply stops hiding the prototypes when USE_REENTRANT_API is not defined; if we're not hiding the function definitions, it seems we shouldn't be hiding the prototypes either.

Not really a platform-specific problem, but here's what I'm fiddling with at the moment:

$ mcr []miniperl -"Ilib" -"V"
Summary of my perl5 (revision 5 version 15 subversion 9) configuration:
  Snapshot of: f51e780d50ba816e170f9eaa2b939142234b2fb7
  Platform:
    osname=VMS, osvers=V8.4, archname=VMS_IA64
    uname='VMS alma V8.4 HP rx2600  (1.50GHz/6.0MB)'
    config_args='-"Dusecxx" -"Dusedevel" -"Dusevmsdebug" -"des" -"Duser_c_flags=/WARN=(INFORMATIONAL=(CASTQUALTYP,ASSCOMMEA))"'
    hint=none, useposix=false, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=undef, bincompat5005=undef
  Compiler:
    cc='CXX', ccflags ='/Include=[]/Standard=ANSI/Prefix=All/Obj=.obj /NOANSI_ALIAS/float=ieee/ieee=denorm/NAMES=(SHORTENED)/WARN=(I
NFORMATIONAL=(CASTQUALTYP,ASSCOMMEA))/Define=_USE_STD_STAT=1',
    optimize='/List/Debug/NoOpt',
    cppflags='undef'
    ccversion='70490004', gccversion='', gccosandvers='undef'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='Link/nodebug', ldflags ='/Debug/Trace/Map'
    libpth=/sys$share /sys$library
    libs= 
    perllibs= 
    libc=(DECCRTL), so=exe, useshrplib=true, libperl=undef
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_vms.c, dlext=exe, d_dlsymun=undef, ccdlflags=''
    cccdlflags='', lddlflags='/Share'


Characteristics of this PERLSHR image: 
  Compile-time options: HAS_TIMES HAVE_INTERP_INTERN PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV PERL_EXTERNAL_GLOB
                        PERL_IS_MINIPERL PERL_MALLOC_WRAP PERL_PRESERVE_IVUV
                        USE_IEEE USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_SITECUSTOMIZE VMS_DO_SOCKETS
                        VMS_SHORTEN_LONG_SYMBOLS
  Built under VMS
  Compiled at May  6 2012 16:41:54
  %ENV:
    PERLSHR="PERL_ROOT:[000000]PERLSHR.EXE"
    PERL_ROOT="MDA0:[SMOKE.BLEAD.]"
  @INC:
    D0:[CRAIG.BLEAD.cpan.AutoLoader.lib]
    D0:[CRAIG.BLEAD.dist.Carp.lib]
    D0:[CRAIG.BLEAD.dist.Cwd]
    D0:[CRAIG.BLEAD.dist.Cwd.lib]
    D0:[CRAIG.BLEAD.dist.ExtUtils-Command.lib]
    D0:[CRAIG.BLEAD.dist.ExtUtils-Install.lib]
    D0:[CRAIG.BLEAD.cpan.ExtUtils-MakeMaker.lib]
    D0:[CRAIG.BLEAD.dist.ExtUtils-Manifest.lib]
    D0:[CRAIG.BLEAD.cpan.File-Path.lib]
    D0:[CRAIG.BLEAD.ext.re]
    D0:[CRAIG.BLEAD.dist.Term-ReadLine.lib]
    D0:[CRAIG.BLEAD]lib
    .

________________________________________
Craig A. Berry
mailto:craigberry@mac.com

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About