#else
# define TAINT (PL_tainted = TRUE)
# define TAINT_NOT (PL_tainted = FALSE)
-# define TAINT_IF(c) if (c) { PL_tainted = TRUE; }
-# define TAINT_ENV() if (PL_tainting) { taint_env(); }
-# define TAINT_PROPER(s) if (PL_tainting) { taint_proper(NULL, s); }
+# define TAINT_IF(c) if (UNLIKELY(c)) { PL_tainted = TRUE; }
+# define TAINT_ENV() if (UNLIKELY(PL_tainting)) { taint_env(); }
+# define TAINT_PROPER(s) if (UNLIKELY(PL_tainting)) { taint_proper(NULL, s); }
# define TAINT_set(s) (PL_tainted = (s))
# define TAINT_get (PL_tainted)
# define TAINTING_get (PL_tainting)
# define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
#endif
-/* BeOS 5.0 and Haiku R1 seem to define S_IREAD and S_IWRITE in <posix/fcntl.h>
+/* Haiku R1 seems to define S_IREAD and S_IWRITE in <posix/fcntl.h>
* which would get included through <sys/file.h >, but that is 3000
* lines in the future. --jhi */
-#if !defined(S_IREAD) && !(defined(__BEOS__) || defined(__HAIKU__))
+#if !defined(S_IREAD) && !defined(__HAIKU__)
# define S_IREAD S_IRUSR
#endif
-#if !defined(S_IWRITE) && !(defined(__BEOS__) || defined(__HAIKU__))
+#if !defined(S_IWRITE) && !defined(__HAIKU__)
# define S_IWRITE S_IWUSR
#endif
typedef AV PADNAMELIST;
typedef SV PADNAME;
-#if !defined(PERL_OLD_COPY_ON_WRITE) && !defined(PERL_NEW_COPY_ON_WRITE) && !defined(PERL_NO_COW)
-# define PERL_NEW_COPY_ON_WRITE
-#endif
+/* XXX for 5.18, disable the COW by default
+ * #if !defined(PERL_OLD_COPY_ON_WRITE) && !defined(PERL_NEW_COPY_ON_WRITE) && !defined(PERL_NO_COW)
+ * # define PERL_NEW_COPY_ON_WRITE
+ * #endif
+ */
#if defined(PERL_OLD_COPY_ON_WRITE) || defined(PERL_NEW_COPY_ON_WRITE)
# if defined(PERL_OLD_COPY_ON_WRITE) && defined(PERL_NEW_COPY_ON_WRITE)
# else
# define PERL_ANY_COW
# endif
+#else
+# define PERL_SAWAMPERSAND
#endif
#include "handy.h"
#if defined(__HAIKU__)
# include "haiku/haikuish.h"
# define ISHISH "haiku"
-#elif defined(__BEOS__)
-# include "beos/beosish.h"
-# define ISHISH "beos"
#endif
#ifndef ISHISH
#else
# define EXPECT(expr,val) (expr)
#endif
-#define LIKELY(cond) EXPECT(cond,1)
-#define UNLIKELY(cond) EXPECT(cond,0)
+#define LIKELY(cond) EXPECT(cBOOL(cond),TRUE)
+#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#ifdef HAS_BUILTIN_CHOOSE_EXPR
/* placeholder */
#endif
#define HAS_NTOHS
#endif
#ifndef HAS_HTONL
-#if (BYTEORDER & 0xffff) != 0x4321
#define HAS_HTONS
#define HAS_HTONL
#define HAS_NTOHS
#define HAS_NTOHL
+# if (BYTEORDER & 0xffff) == 0x4321
+/* Big endian system, so ntohl, ntohs, htonl and htons do not need to
+ re-order their values. However, to behave identically to the alternative
+ implementations, they should truncate to the correct size. */
+# define ntohl(x) ((x)&0xFFFFFFFF)
+# define htonl(x) ntohl(x)
+# define ntohs(x) ((x)&0xFFFF)
+# define htons(x) ntohs(x)
+# elif BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
+
+/* Note that we can't straight out declare our own htonl and htons because
+ the Win32 build process forcibly undefines HAS_HTONL etc for its miniperl,
+ to avoid the overhead of initialising the socket subsystem, but the headers
+ that *declare* the various functions are still seen. If we declare our own
+ htonl etc they will clash with the declarations in the Win32 headers. */
+
+PERL_STATIC_INLINE U32
+my_swap32(const U32 x) {
+ return ((x & 0xFF) << 24) | ((x >> 24) & 0xFF)
+ | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8);
+}
+
+PERL_STATIC_INLINE U16
+my_swap16(const U16 x) {
+ return ((x & 0xFF) << 8) | ((x >> 8) & 0xFF);
+}
+
+# define htonl(x) my_swap32(x)
+# define ntohl(x) my_swap32(x)
+# define ntohs(x) my_swap16(x)
+# define htons(x) my_swap16(x)
+# else
+/* Assumed to be mixed endian. */
#define MYSWAP
#define htons my_swap
#define htonl my_htonl
#define ntohs my_swap
#define ntohl my_ntohl
#endif
-#else
-#if (BYTEORDER & 0xffff) == 0x4321
-#undef HAS_HTONS
-#undef HAS_HTONL
-#undef HAS_NTOHS
-#undef HAS_NTOHL
-#endif
#endif
/*
* Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
* -DWS
*/
-#if BYTEORDER != 0x1234
-# define HAS_VTOHL
-# define HAS_VTOHS
-# define HAS_HTOVL
-# define HAS_HTOVS
+#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
+/* Little endian system, so vtohl, vtohs, htovl and htovs do not need to
+ re-order their values. However, to behave identically to the alternative
+ implementations, they should truncate to the correct size. */
+# define vtohl(x) ((x)&0xFFFFFFFF)
+# define vtohs(x) ((x)&0xFFFF)
+# define htovl(x) vtohl(x)
+# define htovs(x) vtohs(x)
+#else
# if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
# define vtohl(x) ((((x)&0xFF)<<24) \
+(((x)>>24)&0xFF) \
248-32, 249-32, 250-32, 251-32, 252-32, 253-32, 254-32, 255
};
#else /* ! DOINIT */
+#ifndef EBCDIC
EXTCONST unsigned char PL_fold[];
EXTCONST unsigned char PL_fold_latin1[];
+#endif
EXTCONST unsigned char PL_mod_latin1_uc[];
EXTCONST unsigned char PL_latin1_lc[];
#endif
/* This will be useful for subsequent releases, because this has to be the
same in your libperl as in main(), else you have a mismatch and must abort.
*/
-EXTCONST U16 PL_interp_size_5_16_0
- INIT(PERL_INTERPRETER_SIZE_UPTO_MEMBER(PERL_LAST_5_16_0_INTERP_MEMBER));
+EXTCONST U16 PL_interp_size_5_18_0
+ INIT(PERL_INTERPRETER_SIZE_UPTO_MEMBER(PERL_LAST_5_18_0_INTERP_MEMBER));
# ifdef PERL_GLOBAL_STRUCT
#endif
-/* Static inline funcs that depend on includes and declarations above */
-#include "inline.h"
+#ifndef PERL_NO_INLINE_FUNCTIONS
+/* Static inline funcs that depend on includes and declarations above.
+ Some of these reference functions in the perl object files, and some
+ compilers aren't smart enough to eliminate unused static inline
+ functions, so including this file in source code can cause link errors
+ even if the source code uses none of the functions. Hence including these
+ can be be suppressed by setting PERL_NO_INLINE_FUNCTIONS. Doing this will
+ (obviously) result in unworkable XS code, but allows simple probing code
+ to continue to work, because it permits tests to include the perl headers
+ for definitions without creating a link dependency on the perl library
+ (which may not exist yet).
+*/
+
+# include "inline.h"
+#endif
#include "overload.h"
#if O_TEXT != O_BINARY
/* If you have different O_TEXT and O_BINARY and you are a CLRF shop,
* that is, you are somehow DOSish. */
-# if defined(__BEOS__) || defined(__HAIKU__) || defined(__VOS__) || \
- defined(__CYGWIN__)
- /* BeOS/Haiku has O_TEXT != O_BINARY but O_TEXT and O_BINARY have no effect;
- * BeOS/Haiku is always UNIXoid (LF), not DOSish (CRLF). */
+# if defined(__HAIKU__) || defined(__VOS__) || defined(__CYGWIN__)
+ /* Haiku has O_TEXT != O_BINARY but O_TEXT and O_BINARY have no effect;
+ * Haiku is always UNIXoid (LF), not DOSish (CRLF). */
/* VOS has O_TEXT != O_BINARY, and they have effect,
* but VOS always uses LF, never CRLF. */
/* If you have O_TEXT different from your O_BINARY but you still are