perl.h can include embed.h in the same location on all operating systems.
authorNicholas Clark <nick@ccl4.org>
Thu, 8 Dec 2011 14:30:02 +0000 (15:30 +0100)
committerNicholas Clark <nick@ccl4.org>
Fri, 9 Dec 2011 15:49:49 +0000 (16:49 +0100)
Commit 22c35a8c2392967a (October 1988) added a #include "embed.h" later in
perl.h for when building with PERL_OBJECT defined. Commit d18c61170a306915
(November 1988) added an effectively duplicate #include for all WIN32.

Commit 0cb9638729211ea7 (June 1999) corrected the made the earlier #include
in perl.h also conditional on !PERL_OBJECT (in addition to the
!PERL_FOR_X2P added by 22c35a8c2392967a), but it wasn't until commit
d18c61170a306915 (November 1999) that this changed this to !WIN32, and
embed.h was included exactly once by perl.h (as a2p never actually includes
perl.h).

Commit acfe0abcedaf592f (August 2001) removed the PERL_OBJECT code from
perl.h, reducing the duplication somewhat, but commit 96e176bf068724d0
(October 2001) created analogous special case duplication for VMS, and
commit 27da23d53ccce622 (April 2005) for Symbian. Commit eb8433b7af0f2e09
(March 2006) then neatly put the same #ifndef PERL_MAD code after all 4
locations that included embed.h and commit b3f24c00097febc1 (April 2006)
made the same correction in all 4 places.

But, the daft part of all this is that there was no reason why Win32 was
special - every other operating system can build perl with embed.h included
later in perl.h

Hence the earlier 3 locations can be eliminated, and the was-just-Win32
location made unconditional.

Which saves some lines of code. But fewer lines than are in this commit
message.

perl.h

diff --git a/perl.h b/perl.h
index 9514a19..e203dfe 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -974,17 +974,6 @@ EXTERN_C int usleep(unsigned int);
 #define PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION
 #endif
 
-/* Cannot include embed.h here on Win32 as win32.h has not
-   yet been included and defines some config variables e.g. HAVE_INTERP_INTERN
- */
-#if !(defined(WIN32)||defined(VMS))
-#  include "embed.h"
-#  ifndef PERL_MAD
-#    undef op_getmad
-#    define op_getmad(arg,pegop,slot) NOOP
-#  endif
-#endif
-
 #define MEM_SIZE Size_t
 
 /* Round all values passed to malloc up, by default to a multiple of
@@ -2581,11 +2570,6 @@ typedef struct clone_params CLONE_PARAMS;
 
 #if defined(VMS)
 #   include "vmsish.h"
-#   include "embed.h"
-#  ifndef PERL_MAD
-#    undef op_getmad
-#    define op_getmad(arg,pegop,slot) NOOP
-#  endif
 #   define ISHISH "vms"
 #endif
 
@@ -2615,11 +2599,6 @@ typedef struct clone_params CLONE_PARAMS;
 
 #ifdef __SYMBIAN32__
 #   include "symbian/symbianish.h"
-#   include "embed.h"
-#  ifndef PERL_MAD
-#    undef op_getmad
-#    define op_getmad(arg,pegop,slot) NOOP
-#  endif
 #   define ISHISH "symbian"
 #endif
 
@@ -5073,13 +5052,13 @@ END_EXTERN_C
 #  undef PL_na
 #endif
 
-#if defined(WIN32)
-/* Now all the config stuff is setup we can include embed.h */
-#  include "embed.h"
-#  ifndef PERL_MAD
-#    undef op_getmad
-#    define op_getmad(arg,pegop,slot) NOOP
-#  endif
+/* Now all the config stuff is setup we can include embed.h
+   In particular, need the relevant *ish file included already, as it may
+   define HAVE_INTERP_INTERN  */
+#include "embed.h"
+#ifndef PERL_MAD
+#  undef op_getmad
+#  define op_getmad(arg,pegop,slot) NOOP
 #endif
 
 #ifndef PERL_GLOBAL_STRUCT