New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] INTERN/EXTERN C++ cleanup #14469
Comments
From @bulk88Created by @bulk88This patch never got any comments in its its original thread at Perl Info
|
From @bulk880001-INTERN-EXTERN-C-cleanup.patchFrom 8a12f1e05d9aac2ed5ca1d716ad142f79e4e0f1c Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Sat, 24 Jan 2015 04:09:17 -0500
Subject: [PATCH] INTERN/EXTERN C++ cleanup
---
EXTERN.h | 20 ++++++++++----------
INTERN.h | 11 +++++++----
opcode.h | 10 ----------
perl.h | 19 +++++--------------
perlapi.c | 3 ---
perlapi.h | 8 --------
regcomp.h | 5 -----
regen/opcode.pl | 10 ----------
utf8.h | 3 ---
utfebcdic.h | 4 ----
10 files changed, 22 insertions(+), 71 deletions(-)
diff --git a/EXTERN.h b/EXTERN.h
index 4e4f1ad..345eccd 100644
--- a/EXTERN.h
+++ b/EXTERN.h
@@ -22,33 +22,33 @@
# if (defined(WIN32) || defined(__SYMBIAN32__)) && !defined(PERL_STATIC_SYMS)
/* miniperl should not export anything */
# if defined(PERL_IS_MINIPERL) && !defined(UNDER_CE) && defined(_MSC_VER)
-# define EXT extern
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# else
# if defined(PERLDLL) || defined(__SYMBIAN32__)
-# define EXT extern __declspec(dllexport)
+# define EXT EXTERN_C __declspec(dllexport)
# define dEXT
-# define EXTCONST extern __declspec(dllexport) const
+# define EXTCONST EXTERN_C __declspec(dllexport) const
# define dEXTCONST const
# else
-# define EXT extern __declspec(dllimport)
+# define EXT EXTERN_C __declspec(dllimport)
# define dEXT
-# define EXTCONST extern __declspec(dllimport) const
+# define EXTCONST EXTERN_C __declspec(dllimport) const
# define dEXTCONST const
# endif
# endif
# else
# if defined(__CYGWIN__) && defined(USEIMPORTLIB)
-# define EXT extern __declspec(dllimport)
+# define EXT EXTERN_C __declspec(dllimport)
# define dEXT
-# define EXTCONST extern __declspec(dllimport) const
+# define EXTCONST EXTERN_C __declspec(dllimport) const
# define dEXTCONST const
# else
-# define EXT extern
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# endif
# endif
diff --git a/INTERN.h b/INTERN.h
index e6e0602..8b8df49 100644
--- a/INTERN.h
+++ b/INTERN.h
@@ -21,9 +21,12 @@
# if (defined(WIN32) && defined(__MINGW32__)) || defined(__SYMBIAN32__)
# ifdef __cplusplus
-# define EXT __declspec(dllexport)
+# define EXT EXTERN_C __declspec(dllexport)
# define dEXT
-# define EXTCONST __declspec(dllexport) extern const
+/* Win32 GCC errors out with
+ "..\perl.h:4614:35: error: expected unqualified-id before string constant"
+ if dllexport is first, then EXTERN_C */
+# define EXTCONST EXTERN_C __declspec(dllexport) const
# define dEXTCONST const
# else
# define EXT __declspec(dllexport)
@@ -33,9 +36,9 @@
# endif
# else
# ifdef __cplusplus
-# define EXT
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# else
# define EXT
diff --git a/opcode.h b/opcode.h
index 5d910fd..d16da3f 100644
--- a/opcode.h
+++ b/opcode.h
@@ -142,7 +142,6 @@
#define Perl_pp_custom Perl_unimplemented_op
#define Perl_pp_reach Perl_pp_rkeys
#define Perl_pp_rvalues Perl_pp_rkeys
-START_EXTERN_C
#ifndef DOINIT
EXTCONST char* const PL_op_name[];
@@ -936,12 +935,8 @@ EXTCONST char* const PL_op_desc[] = {
};
#endif
-END_EXTERN_C
-
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-START_EXTERN_C
-
#ifdef PERL_GLOBAL_STRUCT_INIT
# define PERL_PPADDR_INITED
static const Perl_ppaddr_t Gppaddr[]
@@ -2153,8 +2148,6 @@ EXTCONST U32 PL_opargs[] = {
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
#define OPpLVREF_SV 0x00
#define OPpARG1_MASK 0x01
@@ -2250,7 +2243,6 @@ END_EXTERN_C
#define OPpPV_IS_UTF8 0x80
#define OPpSPLIT_IMPLIM 0x80
#define OPpTRANS_DELETE 0x80
-START_EXTERN_C
#ifndef PERL_GLOBAL_STRUCT_INIT
@@ -3263,8 +3255,6 @@ EXTCONST U8 PL_op_private_valid[] = {
# endif /* !DOINIT */
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
/* ex: set ro: */
diff --git a/perl.h b/perl.h
index d9cfdb3..270bffd 100644
--- a/perl.h
+++ b/perl.h
@@ -4608,8 +4608,6 @@ extern char ** environ; /* environment variables supplied via exec */
STRINGIFY(PERL_API_VERSION) "." \
STRINGIFY(PERL_API_SUBVERSION)
-START_EXTERN_C
-
/* handy constants */
EXTCONST char PL_warn_uninit[]
INIT("Use of uninitialized value%s%s%s");
@@ -5191,8 +5189,6 @@ EXTCONST char *const PL_phase_names[];
#define PL_hints PL_compiling.cop_hints
-END_EXTERN_C
-
/*****************************************************************************/
/* This lexer/parser stuff is currently global since yacc is hard to reenter */
/*****************************************************************************/
@@ -5512,15 +5508,18 @@ struct tempsym; /* defined in pp_pack.c */
* these include variables that would have been their struct-s
*/
+#ifdef DOINIT
+#define PERLVAR(prefix,var,type) EXT type PL_##var; type PL_##var;
+#define PERLVARA(prefix,var,n,type) EXT type PL_##var[n]; type PL_##var[n];
+#else
#define PERLVAR(prefix,var,type) EXT type PL_##var;
#define PERLVARA(prefix,var,n,type) EXT type PL_##var[n];
+#endif
#define PERLVARI(prefix,var,type,init) EXT type PL_##var INIT(init);
#define PERLVARIC(prefix,var,type,init) EXTCONST type PL_##var INIT(init);
#if !defined(MULTIPLICITY)
-START_EXTERN_C
# include "intrpvar.h"
-END_EXTERN_C
#endif
#ifdef PERL_CORE
@@ -5534,11 +5533,7 @@ END_EXTERN_C
#include "embed.h"
#ifndef PERL_GLOBAL_STRUCT
-START_EXTERN_C
-
# include "perlvars.h"
-
-END_EXTERN_C
#endif
#undef PERLVAR
@@ -5566,8 +5561,6 @@ struct PerlHandShakeInterpreter {
# undef PERLVARIC
#endif
-START_EXTERN_C
-
/* dummy variables that hold pointers to both runops functions, thus forcing
* them *both* to get linked in (useful for Peek.xs, debugging etc) */
@@ -5663,8 +5656,6 @@ EXTCONST bool PL_valid_types_NV_set[];
#include "overload.h"
-END_EXTERN_C
-
struct am_table {
U8 flags;
U8 fallback;
diff --git a/perlapi.c b/perlapi.c
index 7858337..90111d8 100644
--- a/perlapi.c
+++ b/perlapi.c
@@ -31,7 +31,6 @@
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
/* accessor functions for Perl "global" variables */
-START_EXTERN_C
#undef PERLVARI
#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
@@ -53,8 +52,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
/* ex: set ro: */
diff --git a/perlapi.h b/perlapi.h
index 5268c2c..4d512a2 100644
--- a/perlapi.h
+++ b/perlapi.h
@@ -22,8 +22,6 @@
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
-START_EXTERN_C
-
#undef PERLVAR
#undef PERLVARA
#undef PERLVARI
@@ -41,8 +39,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#if defined(PERL_CORE)
/* accessor functions for Perl "global" variables */
@@ -52,8 +48,6 @@ END_EXTERN_C
#ifndef PERL_NO_FORCE_LINK
-START_EXTERN_C
-
#ifndef DOINIT
EXTCONST void * const PL_force_link_funcs[];
#else
@@ -93,8 +87,6 @@ EXTCONST void * const PL_force_link_funcs[] = {
};
#endif /* DOINIT */
-END_EXTERN_C
-
#endif /* PERL_NO_FORCE_LINK */
#else /* !PERL_CORE */
diff --git a/regcomp.h b/regcomp.h
index de31d65..edafd59 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -610,8 +610,6 @@ struct regnode_ssc {
#define REG_UNBOUNDED_QUANTIFIER_SEEN 0x00001000
-START_EXTERN_C
-
#ifdef PLUGGABLE_RE_EXTENSION
#include "re_nodes.h"
#else
@@ -643,9 +641,6 @@ EXTCONST regexp_engine PL_core_reg_engine = {
#endif /* PLUGGABLE_RE_EXTENSION */
-END_EXTERN_C
-
-
/* .what is a character array with one character for each member of .data
* The character describes the function of the corresponding .data item:
* a - AV for paren_name_list under DEBUGGING
diff --git a/regen/opcode.pl b/regen/opcode.pl
index 327e45e..8cc9e5c 100755
--- a/regen/opcode.pl
+++ b/regen/opcode.pl
@@ -814,7 +814,6 @@ sub print_PL_op_private_tables {
}
print $fh <<EOF;
-START_EXTERN_C
#ifndef PERL_GLOBAL_STRUCT_INIT
@@ -893,8 +892,6 @@ $PL_op_private_valid
# endif /* !DOINIT */
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
EOF
@@ -971,7 +968,6 @@ print $on "#define OP_FREED MAXO\n";
# Emit op names and descriptions.
print $oc <<'END';
-START_EXTERN_C
#ifndef DOINIT
EXTCONST char* const PL_op_name[];
@@ -1008,8 +1004,6 @@ print $oc <<'END';
};
#endif
-END_EXTERN_C
-
#endif /* !PERL_GLOBAL_STRUCT_INIT */
END
@@ -1017,8 +1011,6 @@ END
print $oc <<'END';
-START_EXTERN_C
-
#ifdef PERL_GLOBAL_STRUCT_INIT
# define PERL_PPADDR_INITED
static const Perl_ppaddr_t Gppaddr[]
@@ -1185,8 +1177,6 @@ print $oc <<'END';
#endif
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-
-END_EXTERN_C
END
# Emit OP_IS_* macros
diff --git a/utf8.h b/utf8.h
index aaf878c..8313298 100644
--- a/utf8.h
+++ b/utf8.h
@@ -89,7 +89,6 @@ than just the ASCII characters, so C<is_invariant_string> is preferred.
#include "utfebcdic.h"
#else /* ! EBCDIC */
-START_EXTERN_C
#ifdef DOINIT
EXTCONST unsigned char PL_utf8skip[] = {
@@ -117,8 +116,6 @@ EXTCONST unsigned char PL_utf8skip[] = {
EXTCONST unsigned char PL_utf8skip[];
#endif
-END_EXTERN_C
-
/* Native character to/from iso-8859-1. Are the identity functions on ASCII
* platforms */
#define NATIVE_TO_LATIN1(ch) (ch)
diff --git a/utfebcdic.h b/utfebcdic.h
index 23b4ae2..04e7276 100644
--- a/utfebcdic.h
+++ b/utfebcdic.h
@@ -97,8 +97,6 @@
* UTF-EBCDIC is 0x3FFF, instead of 0x7FFF in UTF-8.
*/
-START_EXTERN_C
-
#ifdef DOINIT
#include "ebcdic_tables.h"
@@ -115,8 +113,6 @@ EXTCONST U8 PL_latin1_lc[];
EXTCONST U8 PL_mod_latin1_uc[];
#endif
-END_EXTERN_C
-
/* EBCDIC-happy ways of converting native code to UTF-8 */
#define NATIVE_TO_LATIN1(ch) PL_e2a[(U8)(ch)]
--
1.7.9.msysgit.0
|
From @steve-m-hayOn 4 February 2015 at 07:18, bulk88 <perlbug-followup@perl.org> wrote:
A couple of thoughts, without having tested it yet: I don't think the comment "Win32 GCC errors out with I've stared at the line # if (defined(WIN32) && defined(__MINGW32__)) || defined(__SYMBIAN32__) in INTERN.h before and wondered why something different is done for Otherwise it looks good to me, except for the "#ifdef DOINIT" part in |
The RT System itself - Status changed from 'new' to 'open' |
From @bulk88On Tue Feb 03 23:18:42 2015, bulk88 wrote:
Updated patch attached. It fixes a regen.t failure. This doesn't address any of Steve Hay's concerns which I will get to later. -- |
From @bulk880001-INTERN-EXTERN-C-cleanup.patchFrom 0396b6e086746f16c9d4f0e0b36bf18c0d9f29ca Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Thu, 26 Mar 2015 19:14:29 -0400
Subject: [PATCH] INTERN/EXTERN C++ cleanup
---
EXTERN.h | 20 ++++++++++----------
INTERN.h | 11 +++++++----
opcode.h | 10 ----------
perl.h | 19 +++++--------------
perlapi.c | 3 ---
perlapi.h | 8 --------
regcomp.h | 5 -----
regen/embed.pl | 11 -----------
regen/opcode.pl | 10 ----------
utf8.h | 3 ---
utfebcdic.h | 4 ----
11 files changed, 22 insertions(+), 82 deletions(-)
diff --git a/EXTERN.h b/EXTERN.h
index 4e4f1ad..345eccd 100644
--- a/EXTERN.h
+++ b/EXTERN.h
@@ -22,33 +22,33 @@
# if (defined(WIN32) || defined(__SYMBIAN32__)) && !defined(PERL_STATIC_SYMS)
/* miniperl should not export anything */
# if defined(PERL_IS_MINIPERL) && !defined(UNDER_CE) && defined(_MSC_VER)
-# define EXT extern
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# else
# if defined(PERLDLL) || defined(__SYMBIAN32__)
-# define EXT extern __declspec(dllexport)
+# define EXT EXTERN_C __declspec(dllexport)
# define dEXT
-# define EXTCONST extern __declspec(dllexport) const
+# define EXTCONST EXTERN_C __declspec(dllexport) const
# define dEXTCONST const
# else
-# define EXT extern __declspec(dllimport)
+# define EXT EXTERN_C __declspec(dllimport)
# define dEXT
-# define EXTCONST extern __declspec(dllimport) const
+# define EXTCONST EXTERN_C __declspec(dllimport) const
# define dEXTCONST const
# endif
# endif
# else
# if defined(__CYGWIN__) && defined(USEIMPORTLIB)
-# define EXT extern __declspec(dllimport)
+# define EXT EXTERN_C __declspec(dllimport)
# define dEXT
-# define EXTCONST extern __declspec(dllimport) const
+# define EXTCONST EXTERN_C __declspec(dllimport) const
# define dEXTCONST const
# else
-# define EXT extern
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# endif
# endif
diff --git a/INTERN.h b/INTERN.h
index e6e0602..8b8df49 100644
--- a/INTERN.h
+++ b/INTERN.h
@@ -21,9 +21,12 @@
# if (defined(WIN32) && defined(__MINGW32__)) || defined(__SYMBIAN32__)
# ifdef __cplusplus
-# define EXT __declspec(dllexport)
+# define EXT EXTERN_C __declspec(dllexport)
# define dEXT
-# define EXTCONST __declspec(dllexport) extern const
+/* Win32 GCC errors out with
+ "..\perl.h:4614:35: error: expected unqualified-id before string constant"
+ if dllexport is first, then EXTERN_C */
+# define EXTCONST EXTERN_C __declspec(dllexport) const
# define dEXTCONST const
# else
# define EXT __declspec(dllexport)
@@ -33,9 +36,9 @@
# endif
# else
# ifdef __cplusplus
-# define EXT
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# else
# define EXT
diff --git a/opcode.h b/opcode.h
index cf39a4b..a11e372 100644
--- a/opcode.h
+++ b/opcode.h
@@ -144,7 +144,6 @@
#define Perl_pp_custom Perl_unimplemented_op
#define Perl_pp_reach Perl_pp_rkeys
#define Perl_pp_rvalues Perl_pp_rkeys
-START_EXTERN_C
#ifndef DOINIT
EXTCONST char* const PL_op_name[];
@@ -954,12 +953,8 @@ EXTCONST char* const PL_op_desc[] = {
};
#endif
-END_EXTERN_C
-
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-START_EXTERN_C
-
#ifdef PERL_GLOBAL_STRUCT_INIT
# define PERL_PPADDR_INITED
static const Perl_ppaddr_t Gppaddr[]
@@ -2195,8 +2190,6 @@ EXTCONST U32 PL_opargs[] = {
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
#define OPpLVREF_SV 0x00
#define OPpARG1_MASK 0x01
@@ -2292,7 +2285,6 @@ END_EXTERN_C
#define OPpPV_IS_UTF8 0x80
#define OPpSPLIT_IMPLIM 0x80
#define OPpTRANS_DELETE 0x80
-START_EXTERN_C
#ifndef PERL_GLOBAL_STRUCT_INIT
@@ -3321,8 +3313,6 @@ EXTCONST U8 PL_op_private_valid[] = {
# endif /* !DOINIT */
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
/* ex: set ro: */
diff --git a/perl.h b/perl.h
index cc4111a..55383ad 100644
--- a/perl.h
+++ b/perl.h
@@ -4620,8 +4620,6 @@ extern char ** environ; /* environment variables supplied via exec */
STRINGIFY(PERL_API_VERSION) "." \
STRINGIFY(PERL_API_SUBVERSION)
-START_EXTERN_C
-
/* handy constants */
EXTCONST char PL_warn_uninit[]
INIT("Use of uninitialized value%s%s%s");
@@ -5203,8 +5201,6 @@ EXTCONST char *const PL_phase_names[];
#define PL_hints PL_compiling.cop_hints
-END_EXTERN_C
-
/*****************************************************************************/
/* This lexer/parser stuff is currently global since yacc is hard to reenter */
/*****************************************************************************/
@@ -5524,15 +5520,18 @@ struct tempsym; /* defined in pp_pack.c */
* these include variables that would have been their struct-s
*/
+#ifdef DOINIT
+#define PERLVAR(prefix,var,type) EXT type PL_##var; type PL_##var;
+#define PERLVARA(prefix,var,n,type) EXT type PL_##var[n]; type PL_##var[n];
+#else
#define PERLVAR(prefix,var,type) EXT type PL_##var;
#define PERLVARA(prefix,var,n,type) EXT type PL_##var[n];
+#endif
#define PERLVARI(prefix,var,type,init) EXT type PL_##var INIT(init);
#define PERLVARIC(prefix,var,type,init) EXTCONST type PL_##var INIT(init);
#if !defined(MULTIPLICITY)
-START_EXTERN_C
# include "intrpvar.h"
-END_EXTERN_C
#endif
#ifdef PERL_CORE
@@ -5546,11 +5545,7 @@ END_EXTERN_C
#include "embed.h"
#ifndef PERL_GLOBAL_STRUCT
-START_EXTERN_C
-
# include "perlvars.h"
-
-END_EXTERN_C
#endif
#undef PERLVAR
@@ -5578,8 +5573,6 @@ struct PerlHandShakeInterpreter {
# undef PERLVARIC
#endif
-START_EXTERN_C
-
/* dummy variables that hold pointers to both runops functions, thus forcing
* them *both* to get linked in (useful for Peek.xs, debugging etc) */
@@ -5675,8 +5668,6 @@ EXTCONST bool PL_valid_types_NV_set[];
#include "overload.h"
-END_EXTERN_C
-
struct am_table {
U8 flags;
U8 fallback;
diff --git a/perlapi.c b/perlapi.c
index 7858337..90111d8 100644
--- a/perlapi.c
+++ b/perlapi.c
@@ -31,7 +31,6 @@
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
/* accessor functions for Perl "global" variables */
-START_EXTERN_C
#undef PERLVARI
#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
@@ -53,8 +52,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
/* ex: set ro: */
diff --git a/perlapi.h b/perlapi.h
index 5268c2c..4d512a2 100644
--- a/perlapi.h
+++ b/perlapi.h
@@ -22,8 +22,6 @@
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
-START_EXTERN_C
-
#undef PERLVAR
#undef PERLVARA
#undef PERLVARI
@@ -41,8 +39,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#if defined(PERL_CORE)
/* accessor functions for Perl "global" variables */
@@ -52,8 +48,6 @@ END_EXTERN_C
#ifndef PERL_NO_FORCE_LINK
-START_EXTERN_C
-
#ifndef DOINIT
EXTCONST void * const PL_force_link_funcs[];
#else
@@ -93,8 +87,6 @@ EXTCONST void * const PL_force_link_funcs[] = {
};
#endif /* DOINIT */
-END_EXTERN_C
-
#endif /* PERL_NO_FORCE_LINK */
#else /* !PERL_CORE */
diff --git a/regcomp.h b/regcomp.h
index c17bf62..a6c63e8 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -610,8 +610,6 @@ struct regnode_ssc {
#define REG_UNBOUNDED_QUANTIFIER_SEEN 0x00001000
-START_EXTERN_C
-
#ifdef PLUGGABLE_RE_EXTENSION
#include "re_nodes.h"
#else
@@ -643,9 +641,6 @@ EXTCONST regexp_engine PL_core_reg_engine = {
#endif /* PLUGGABLE_RE_EXTENSION */
-END_EXTERN_C
-
-
/* .what is a character array with one character for each member of .data
* The character describes the function of the corresponding .data item:
* a - AV for paren_name_list under DEBUGGING
diff --git a/regen/embed.pl b/regen/embed.pl
index 07438de..5e28743 100755
--- a/regen/embed.pl
+++ b/regen/embed.pl
@@ -501,8 +501,6 @@ print $capih <<'EOT';
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
-START_EXTERN_C
-
#undef PERLVAR
#undef PERLVARA
#undef PERLVARI
@@ -520,8 +518,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#if defined(PERL_CORE)
/* accessor functions for Perl "global" variables */
@@ -531,8 +527,6 @@ END_EXTERN_C
#ifndef PERL_NO_FORCE_LINK
-START_EXTERN_C
-
#ifndef DOINIT
EXTCONST void * const PL_force_link_funcs[];
#else
@@ -572,8 +566,6 @@ EXTCONST void * const PL_force_link_funcs[] = {
};
#endif /* DOINIT */
-END_EXTERN_C
-
#endif /* PERL_NO_FORCE_LINK */
#else /* !PERL_CORE */
@@ -615,7 +607,6 @@ print $capi <<'EOT';
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
/* accessor functions for Perl "global" variables */
-START_EXTERN_C
#undef PERLVARI
#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
@@ -637,8 +628,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
EOT
diff --git a/regen/opcode.pl b/regen/opcode.pl
index fe10584..6a80e1b 100755
--- a/regen/opcode.pl
+++ b/regen/opcode.pl
@@ -816,7 +816,6 @@ sub print_PL_op_private_tables {
}
print $fh <<EOF;
-START_EXTERN_C
#ifndef PERL_GLOBAL_STRUCT_INIT
@@ -895,8 +894,6 @@ $PL_op_private_valid
# endif /* !DOINIT */
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
EOF
@@ -973,7 +970,6 @@ print $on "#define OP_FREED MAXO\n";
# Emit op names and descriptions.
print $oc <<'END';
-START_EXTERN_C
#ifndef DOINIT
EXTCONST char* const PL_op_name[];
@@ -1010,8 +1006,6 @@ print $oc <<'END';
};
#endif
-END_EXTERN_C
-
#endif /* !PERL_GLOBAL_STRUCT_INIT */
END
@@ -1019,8 +1013,6 @@ END
print $oc <<'END';
-START_EXTERN_C
-
#ifdef PERL_GLOBAL_STRUCT_INIT
# define PERL_PPADDR_INITED
static const Perl_ppaddr_t Gppaddr[]
@@ -1189,8 +1181,6 @@ print $oc <<'END';
#endif
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-
-END_EXTERN_C
END
# Emit OP_IS_* macros
diff --git a/utf8.h b/utf8.h
index aaf878c..8313298 100644
--- a/utf8.h
+++ b/utf8.h
@@ -89,7 +89,6 @@ than just the ASCII characters, so C<is_invariant_string> is preferred.
#include "utfebcdic.h"
#else /* ! EBCDIC */
-START_EXTERN_C
#ifdef DOINIT
EXTCONST unsigned char PL_utf8skip[] = {
@@ -117,8 +116,6 @@ EXTCONST unsigned char PL_utf8skip[] = {
EXTCONST unsigned char PL_utf8skip[];
#endif
-END_EXTERN_C
-
/* Native character to/from iso-8859-1. Are the identity functions on ASCII
* platforms */
#define NATIVE_TO_LATIN1(ch) (ch)
diff --git a/utfebcdic.h b/utfebcdic.h
index 23b4ae2..04e7276 100644
--- a/utfebcdic.h
+++ b/utfebcdic.h
@@ -97,8 +97,6 @@
* UTF-EBCDIC is 0x3FFF, instead of 0x7FFF in UTF-8.
*/
-START_EXTERN_C
-
#ifdef DOINIT
#include "ebcdic_tables.h"
@@ -115,8 +113,6 @@ EXTCONST U8 PL_latin1_lc[];
EXTCONST U8 PL_mod_latin1_uc[];
#endif
-END_EXTERN_C
-
/* EBCDIC-happy ways of converting native code to UTF-8 */
#define NATIVE_TO_LATIN1(ch) PL_e2a[(U8)(ch)]
--
1.7.9.msysgit.0
|
From @bulk88Another patch update. VC6 but not any newer VCs doesn't like a "static __inline" declaration inside an "extern "C" {" block. So proto.h was fixed. Also PERL_CALLCONV_NO_RET was missing "extern "C"" in win32.h. -- |
From @bulk880001-INTERN-EXTERN-C-cleanup.patchFrom 9ab5732b45d6aadfc130d15845c3dbdf09318d11 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 19 May 2015 11:58:34 -0400
Subject: [PATCH] INTERN/EXTERN C++ cleanup
---
EXTERN.h | 20 ++++++++++----------
INTERN.h | 11 +++++++----
opcode.h | 10 ----------
perl.h | 19 +++++--------------
perlapi.c | 3 ---
perlapi.h | 8 --------
proto.h | 2 --
regcomp.h | 5 -----
regen/embed.pl | 13 -------------
regen/opcode.pl | 10 ----------
utf8.h | 3 ---
utfebcdic.h | 4 ----
win32/win32.h | 6 +++++-
13 files changed, 27 insertions(+), 87 deletions(-)
diff --git a/EXTERN.h b/EXTERN.h
index 4e4f1ad..345eccd 100644
--- a/EXTERN.h
+++ b/EXTERN.h
@@ -22,33 +22,33 @@
# if (defined(WIN32) || defined(__SYMBIAN32__)) && !defined(PERL_STATIC_SYMS)
/* miniperl should not export anything */
# if defined(PERL_IS_MINIPERL) && !defined(UNDER_CE) && defined(_MSC_VER)
-# define EXT extern
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# else
# if defined(PERLDLL) || defined(__SYMBIAN32__)
-# define EXT extern __declspec(dllexport)
+# define EXT EXTERN_C __declspec(dllexport)
# define dEXT
-# define EXTCONST extern __declspec(dllexport) const
+# define EXTCONST EXTERN_C __declspec(dllexport) const
# define dEXTCONST const
# else
-# define EXT extern __declspec(dllimport)
+# define EXT EXTERN_C __declspec(dllimport)
# define dEXT
-# define EXTCONST extern __declspec(dllimport) const
+# define EXTCONST EXTERN_C __declspec(dllimport) const
# define dEXTCONST const
# endif
# endif
# else
# if defined(__CYGWIN__) && defined(USEIMPORTLIB)
-# define EXT extern __declspec(dllimport)
+# define EXT EXTERN_C __declspec(dllimport)
# define dEXT
-# define EXTCONST extern __declspec(dllimport) const
+# define EXTCONST EXTERN_C __declspec(dllimport) const
# define dEXTCONST const
# else
-# define EXT extern
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# endif
# endif
diff --git a/INTERN.h b/INTERN.h
index e6e0602..8b8df49 100644
--- a/INTERN.h
+++ b/INTERN.h
@@ -21,9 +21,12 @@
# if (defined(WIN32) && defined(__MINGW32__)) || defined(__SYMBIAN32__)
# ifdef __cplusplus
-# define EXT __declspec(dllexport)
+# define EXT EXTERN_C __declspec(dllexport)
# define dEXT
-# define EXTCONST __declspec(dllexport) extern const
+/* Win32 GCC errors out with
+ "..\perl.h:4614:35: error: expected unqualified-id before string constant"
+ if dllexport is first, then EXTERN_C */
+# define EXTCONST EXTERN_C __declspec(dllexport) const
# define dEXTCONST const
# else
# define EXT __declspec(dllexport)
@@ -33,9 +36,9 @@
# endif
# else
# ifdef __cplusplus
-# define EXT
+# define EXT EXTERN_C
# define dEXT
-# define EXTCONST extern const
+# define EXTCONST EXTERN_C const
# define dEXTCONST const
# else
# define EXT
diff --git a/opcode.h b/opcode.h
index 5c4254b..b81bd4f 100644
--- a/opcode.h
+++ b/opcode.h
@@ -144,7 +144,6 @@
#define Perl_pp_custom Perl_unimplemented_op
#define Perl_pp_reach Perl_pp_rkeys
#define Perl_pp_rvalues Perl_pp_rkeys
-START_EXTERN_C
#ifndef DOINIT
EXTCONST char* const PL_op_name[];
@@ -954,12 +953,8 @@ EXTCONST char* const PL_op_desc[] = {
};
#endif
-END_EXTERN_C
-
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-START_EXTERN_C
-
#ifdef PERL_GLOBAL_STRUCT_INIT
# define PERL_PPADDR_INITED
static const Perl_ppaddr_t Gppaddr[]
@@ -2195,8 +2190,6 @@ EXTCONST U32 PL_opargs[] = {
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
#define OPpLVREF_SV 0x00
#define OPpARG1_MASK 0x01
@@ -2292,7 +2285,6 @@ END_EXTERN_C
#define OPpPV_IS_UTF8 0x80
#define OPpSPLIT_IMPLIM 0x80
#define OPpTRANS_DELETE 0x80
-START_EXTERN_C
#ifndef PERL_GLOBAL_STRUCT_INIT
@@ -3319,8 +3311,6 @@ EXTCONST U8 PL_op_private_valid[] = {
# endif /* !DOINIT */
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
/* ex: set ro: */
diff --git a/perl.h b/perl.h
index b9de947..9c9b8c0 100644
--- a/perl.h
+++ b/perl.h
@@ -4638,8 +4638,6 @@ extern char ** environ; /* environment variables supplied via exec */
STRINGIFY(PERL_API_VERSION) "." \
STRINGIFY(PERL_API_SUBVERSION)
-START_EXTERN_C
-
/* handy constants */
EXTCONST char PL_warn_uninit[]
INIT("Use of uninitialized value%s%s%s");
@@ -5221,8 +5219,6 @@ EXTCONST char *const PL_phase_names[];
#define PL_hints PL_compiling.cop_hints
-END_EXTERN_C
-
/*****************************************************************************/
/* This lexer/parser stuff is currently global since yacc is hard to reenter */
/*****************************************************************************/
@@ -5542,15 +5538,18 @@ struct tempsym; /* defined in pp_pack.c */
* these include variables that would have been their struct-s
*/
+#ifdef DOINIT
+#define PERLVAR(prefix,var,type) EXT type PL_##var; type PL_##var;
+#define PERLVARA(prefix,var,n,type) EXT type PL_##var[n]; type PL_##var[n];
+#else
#define PERLVAR(prefix,var,type) EXT type PL_##var;
#define PERLVARA(prefix,var,n,type) EXT type PL_##var[n];
+#endif
#define PERLVARI(prefix,var,type,init) EXT type PL_##var INIT(init);
#define PERLVARIC(prefix,var,type,init) EXTCONST type PL_##var INIT(init);
#if !defined(MULTIPLICITY)
-START_EXTERN_C
# include "intrpvar.h"
-END_EXTERN_C
#endif
#ifdef PERL_CORE
@@ -5564,11 +5563,7 @@ END_EXTERN_C
#include "embed.h"
#ifndef PERL_GLOBAL_STRUCT
-START_EXTERN_C
-
# include "perlvars.h"
-
-END_EXTERN_C
#endif
#undef PERLVAR
@@ -5596,8 +5591,6 @@ struct PerlHandShakeInterpreter {
# undef PERLVARIC
#endif
-START_EXTERN_C
-
/* dummy variables that hold pointers to both runops functions, thus forcing
* them *both* to get linked in (useful for Peek.xs, debugging etc) */
@@ -5693,8 +5686,6 @@ EXTCONST bool PL_valid_types_NV_set[];
#include "overload.h"
-END_EXTERN_C
-
struct am_table {
U8 flags;
U8 fallback;
diff --git a/perlapi.c b/perlapi.c
index 7858337..90111d8 100644
--- a/perlapi.c
+++ b/perlapi.c
@@ -31,7 +31,6 @@
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
/* accessor functions for Perl "global" variables */
-START_EXTERN_C
#undef PERLVARI
#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
@@ -53,8 +52,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
/* ex: set ro: */
diff --git a/perlapi.h b/perlapi.h
index 5268c2c..4d512a2 100644
--- a/perlapi.h
+++ b/perlapi.h
@@ -22,8 +22,6 @@
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
-START_EXTERN_C
-
#undef PERLVAR
#undef PERLVARA
#undef PERLVARI
@@ -41,8 +39,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#if defined(PERL_CORE)
/* accessor functions for Perl "global" variables */
@@ -52,8 +48,6 @@ END_EXTERN_C
#ifndef PERL_NO_FORCE_LINK
-START_EXTERN_C
-
#ifndef DOINIT
EXTCONST void * const PL_force_link_funcs[];
#else
@@ -93,8 +87,6 @@ EXTCONST void * const PL_force_link_funcs[] = {
};
#endif /* DOINIT */
-END_EXTERN_C
-
#endif /* PERL_NO_FORCE_LINK */
#else /* !PERL_CORE */
diff --git a/proto.h b/proto.h
index 8ad321f..9fa5b7f 100644
--- a/proto.h
+++ b/proto.h
@@ -16,7 +16,6 @@
* Edit those files and run 'make regen_headers' to effect changes.
*/
-START_EXTERN_C
PERL_CALLCONV UV ASCII_TO_NEED(const UV enc, const UV ch)
__attribute__deprecated__
__attribute__warn_unused_result__
@@ -8353,6 +8352,5 @@ PERL_CALLCONV int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg)
#ifdef PERL_CORE
# include "pp_proto.h"
#endif
-END_EXTERN_C
/* ex: set ro: */
diff --git a/regcomp.h b/regcomp.h
index f418086..eda2b46 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -608,8 +608,6 @@ struct regnode_ssc {
#define REG_UNBOUNDED_QUANTIFIER_SEEN 0x00001000
-START_EXTERN_C
-
#ifdef PLUGGABLE_RE_EXTENSION
#include "re_nodes.h"
#else
@@ -641,9 +639,6 @@ EXTCONST regexp_engine PL_core_reg_engine = {
#endif /* PLUGGABLE_RE_EXTENSION */
-END_EXTERN_C
-
-
/* .what is a character array with one character for each member of .data
* The character describes the function of the corresponding .data item:
* a - AV for paren_name_list under DEBUGGING
diff --git a/regen/embed.pl b/regen/embed.pl
index 07438de..cb8068c 100755
--- a/regen/embed.pl
+++ b/regen/embed.pl
@@ -65,7 +65,6 @@ my ($embed, $core, $ext, $api) = setup_embed();
# generate proto.h
{
my $pr = open_print_header("proto.h");
- print $pr "START_EXTERN_C\n";
my $ret;
foreach (@$embed) {
@@ -229,7 +228,6 @@ my ($embed, $core, $ext, $api) = setup_embed();
#ifdef PERL_CORE
# include "pp_proto.h"
#endif
-END_EXTERN_C
EOF
read_only_bottom_close_and_rename($pr);
@@ -501,8 +499,6 @@ print $capih <<'EOT';
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
-START_EXTERN_C
-
#undef PERLVAR
#undef PERLVARA
#undef PERLVARI
@@ -520,8 +516,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#if defined(PERL_CORE)
/* accessor functions for Perl "global" variables */
@@ -531,8 +525,6 @@ END_EXTERN_C
#ifndef PERL_NO_FORCE_LINK
-START_EXTERN_C
-
#ifndef DOINIT
EXTCONST void * const PL_force_link_funcs[];
#else
@@ -572,8 +564,6 @@ EXTCONST void * const PL_force_link_funcs[] = {
};
#endif /* DOINIT */
-END_EXTERN_C
-
#endif /* PERL_NO_FORCE_LINK */
#else /* !PERL_CORE */
@@ -615,7 +605,6 @@ print $capi <<'EOT';
#if defined (MULTIPLICITY) && defined (PERL_GLOBAL_STRUCT)
/* accessor functions for Perl "global" variables */
-START_EXTERN_C
#undef PERLVARI
#define PERLVARI(p,v,t,i) PERLVAR(p,v,t)
@@ -637,8 +626,6 @@ START_EXTERN_C
#undef PERLVARI
#undef PERLVARIC
-END_EXTERN_C
-
#endif /* MULTIPLICITY && PERL_GLOBAL_STRUCT */
EOT
diff --git a/regen/opcode.pl b/regen/opcode.pl
index fe10584..6a80e1b 100755
--- a/regen/opcode.pl
+++ b/regen/opcode.pl
@@ -816,7 +816,6 @@ sub print_PL_op_private_tables {
}
print $fh <<EOF;
-START_EXTERN_C
#ifndef PERL_GLOBAL_STRUCT_INIT
@@ -895,8 +894,6 @@ $PL_op_private_valid
# endif /* !DOINIT */
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-END_EXTERN_C
-
EOF
@@ -973,7 +970,6 @@ print $on "#define OP_FREED MAXO\n";
# Emit op names and descriptions.
print $oc <<'END';
-START_EXTERN_C
#ifndef DOINIT
EXTCONST char* const PL_op_name[];
@@ -1010,8 +1006,6 @@ print $oc <<'END';
};
#endif
-END_EXTERN_C
-
#endif /* !PERL_GLOBAL_STRUCT_INIT */
END
@@ -1019,8 +1013,6 @@ END
print $oc <<'END';
-START_EXTERN_C
-
#ifdef PERL_GLOBAL_STRUCT_INIT
# define PERL_PPADDR_INITED
static const Perl_ppaddr_t Gppaddr[]
@@ -1189,8 +1181,6 @@ print $oc <<'END';
#endif
#endif /* !PERL_GLOBAL_STRUCT_INIT */
-
-END_EXTERN_C
END
# Emit OP_IS_* macros
diff --git a/utf8.h b/utf8.h
index 3e15707..6a6315f 100644
--- a/utf8.h
+++ b/utf8.h
@@ -95,7 +95,6 @@ than just the ASCII characters, so C<is_invariant_string> is preferred.
#include "utfebcdic.h"
#else /* ! EBCDIC */
-START_EXTERN_C
#ifdef DOINIT
EXTCONST unsigned char PL_utf8skip[] = {
@@ -123,8 +122,6 @@ EXTCONST unsigned char PL_utf8skip[] = {
EXTCONST unsigned char PL_utf8skip[];
#endif
-END_EXTERN_C
-
/* Native character to/from iso-8859-1. Are the identity functions on ASCII
* platforms */
#define NATIVE_TO_LATIN1(ch) (ch)
diff --git a/utfebcdic.h b/utfebcdic.h
index 24101ed..df3404a 100644
--- a/utfebcdic.h
+++ b/utfebcdic.h
@@ -108,8 +108,6 @@
* UTF-EBCDIC is 0x3FFF, instead of 0x7FFF in UTF-8.
*/
-START_EXTERN_C
-
#ifdef DOINIT
#include "ebcdic_tables.h"
@@ -126,8 +124,6 @@ EXTCONST U8 PL_latin1_lc[];
EXTCONST U8 PL_mod_latin1_uc[];
#endif
-END_EXTERN_C
-
/* EBCDIC-happy ways of converting native code to UTF-8 */
#define NATIVE_TO_LATIN1(ch) PL_e2a[(U8)(ch)]
diff --git a/win32/win32.h b/win32/win32.h
index 107062a..c0e9073 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -120,7 +120,11 @@
# endif
#else /* MSVC noreturn support inside the interp */
# ifdef _MSC_VER
-# define PERL_CALLCONV_NO_RET __declspec(noreturn)
+# ifdef __cplusplus
+# define PERL_CALLCONV_NO_RET extern "C" __declspec(noreturn)
+# else
+# define PERL_CALLCONV_NO_RET __declspec(noreturn)
+# endif
# endif
#endif
--
1.7.9.msysgit.0
|
From @tonycozOn Tue May 19 09:02:06 2015, bulk88 wrote:
Is this still "not intended to be committed as is"? The description still doesn't say what it's trying to fix. Tony |
From @bulk88On Tue Jul 28 19:11:50 2015, tonyc wrote:
This patch was a proof of concept based on discussions in this thread http://www.nntp.perl.org/group/perl.perl5.porters/2015/01/msg225087.html It removed the requirement to keep declarations and definitions inside multi-line blocks, and instead each declaration or definition statement, on its own, does the extern "C" for itself alone. In a C++ perl build there were problems where some symbols were just "extern" not "extern "C"" and that was causing linking problems with plain C XS or plain C parts of perl core in some corner cases. The patch also removes usage of "extern" (implied C++) from perl core. Everything should be more uniformly C names in C++ mode with this patch, rather than a pool of C++ perl symbols existing that plain C XS code happens to never try to link with since those C++ perl symbols aren't public api (not like p5p can technically enforce public API), but once in a while for whatever (perl macro got changed by P5P, XS author decides to use non-public macro or func/global data var) reason plain C code tries linking with that C++ symbol and C++ builds break. For example this commit came as a result of that ML thread 7aa20b4..6635f04:/handy.h which shows perl is inconsistent in using extern "C" inside itself. |
@bulk88 This patch no longer applies and appears to be only a proof of concept. I suggest a rebase and submitting the patch as a PR if we want to pursue it further. |
Migrated from rt.perl.org#123727 (status was 'open')
Searchable as RT123727$
The text was updated successfully, but these errors were encountered: