* or variables/arguments that are used only in certain configurations.
*/
#ifndef PERL_UNUSED_ARG
-# if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
-# include <note.h>
-# define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x))
-# else
-# define PERL_UNUSED_ARG(x) ((void)sizeof(x))
-# endif
+# define PERL_UNUSED_ARG(x) ((void)sizeof(x))
#endif
#ifndef PERL_UNUSED_VAR
# define PERL_UNUSED_VAR(x) ((void)sizeof(x))
* that should be true only if the snprintf()/vsnprintf() are true
* to the standard. */
-#define PERL_SNPRINTF_CHECK(len, max, api) STMT_START { if ((max) > 0 && (Size_t)len >= (max)) Perl_croak_nocontext("panic: %s buffer overflow", STRINGIFY(api)); } STMT_END
+#define PERL_SNPRINTF_CHECK(len, max, api) STMT_START { if ((max) > 0 && (Size_t)len > (max)) Perl_croak_nocontext("panic: %s buffer overflow", STRINGIFY(api)); } STMT_END
#ifdef USE_QUADMATH
# define my_snprintf Perl_my_snprintf
/* placeholder */
#endif
-/* STATIC_ASSERT_GLOBAL/STATIC_ASSERT_STMT are like assert(), but for compile
+/* STATIC_ASSERT_DECL/STATIC_ASSERT_STMT are like assert(), but for compile
time invariants. That is, their argument must be a constant expression that
can be verified by the compiler. This expression can contain anything that's
known to the compiler, e.g. #define constants, enums, or sizeof (...). If
the expression evaluates to 0, compilation fails.
Because they generate no runtime code (i.e. their use is "free"), they're
always active, even under non-DEBUGGING builds.
- STATIC_ASSERT_GLOBAL expands to a declaration and is suitable for use at
+ STATIC_ASSERT_DECL expands to a declaration and is suitable for use at
file scope (outside of any function).
STATIC_ASSERT_STMT expands to a statement and is suitable for use inside a
function.
*/
#if (defined(static_assert) || (defined(__cplusplus) && __cplusplus >= 201103L)) && (!defined(__IBMC__) || __IBMC__ >= 1210)
/* static_assert is a macro defined in <assert.h> in C11 or a compiler
- builtin in C++11.
+ builtin in C++11. But IBM XL C V11 does not support _Static_assert, no
+ matter what <assert.h> says.
*/
-/* IBM XL C V11 does not support _Static_assert, no matter what <assert.h> says */
-# define STATIC_ASSERT_GLOBAL(COND) static_assert(COND, #COND)
+# define STATIC_ASSERT_DECL(COND) static_assert(COND, #COND)
#else
/* We use a bit-field instead of an array because gcc accepts
'typedef char x[n]' where n is not a compile-time constant.
unsigned int _static_assertion_failed_##SUFFIX : (COND) ? 1 : -1; \
} _static_assertion_failed_##SUFFIX PERL_UNUSED_DECL
# define STATIC_ASSERT_1(COND, SUFFIX) STATIC_ASSERT_2(COND, SUFFIX)
-# define STATIC_ASSERT_GLOBAL(COND) STATIC_ASSERT_1(COND, __LINE__)
+# define STATIC_ASSERT_DECL(COND) STATIC_ASSERT_1(COND, __LINE__)
#endif
/* We need this wrapper even in C11 because 'case X: static_assert(...);' is an
error (static_assert is a declaration, and only statements can have labels).
*/
-#define STATIC_ASSERT_STMT(COND) do { STATIC_ASSERT_GLOBAL(COND); } while (0)
+#define STATIC_ASSERT_STMT(COND) do { STATIC_ASSERT_DECL(COND); } while (0)
#ifndef __has_builtin
# define __has_builtin(x) 0 /* not a clang style compiler */
# define ASSUME(x) assert(x)
#endif
-#define NOT_REACHED ASSUME(0)
+#if defined(__sun) /* ASSUME() generates warnings on Solaris */
+# define NOT_REACHED
+#else
+# define NOT_REACHED ASSUME(0)
+#endif
/* Some unistd.h's give a prototype for pause() even though
HAS_PAUSE ends up undefined. This causes the #define
# define USEMYBINMODE /**/
# include <io.h> /* for setmode() prototype */
# define my_binmode(fp, iotype, mode) \
- (PerlLIO_setmode(fileno(fp), mode) != -1 ? TRUE : FALSE)
+ cBOOL(PerlLIO_setmode(fileno(fp), mode) != -1)
#endif
#ifdef __CYGWIN__
#endif
/* [perl #22371] Algorimic Complexity Attack on Perl 5.6.1, 5.8.0.
- * Note that the USE_HASH_SEED and USE_HASH_SEED_EXPLICIT are *NOT*
- * defined by Configure, despite their names being similar to the
- * other defines like USE_ITHREADS. Configure in fact knows nothing
- * about the randomised hashes. Therefore to enable/disable the hash
- * randomisation defines use the Configure -Accflags=... instead. */
-#if !defined(NO_HASH_SEED) && !defined(USE_HASH_SEED) && !defined(USE_HASH_SEED_EXPLICIT)
+ * Note that the USE_HASH_SEED and similar defines are *NOT* defined by
+ * Configure, despite their names being similar to other defines like
+ * USE_ITHREADS. Configure in fact knows nothing about the randomised
+ * hashes. Therefore to enable/disable the hash randomisation defines
+ * use the Configure -Accflags=... instead. */
+#if !defined(NO_HASH_SEED) && !defined(USE_HASH_SEED)
# define USE_HASH_SEED
#endif
#define DEBUG_u_FLAG 0x00000800 /* 2048 */
/* U is reserved for Unofficial, exploratory hacking */
#define DEBUG_U_FLAG 0x00001000 /* 4096 */
-#define DEBUG_H_FLAG 0x00002000 /* 8192 */
+/* spare 8192 */
#define DEBUG_X_FLAG 0x00004000 /* 16384 */
#define DEBUG_D_FLAG 0x00008000 /* 32768 */
#define DEBUG_S_FLAG 0x00010000 /* 65536 */
#define DEBUG_DB_RECURSE_FLAG 0x40000000
#define DEBUG_TOP_FLAG 0x80000000 /* -D was given --> PL_debug |= FLAG */
-# define DEBUG_p_TEST_ (PL_debug & DEBUG_p_FLAG)
-# define DEBUG_s_TEST_ (PL_debug & DEBUG_s_FLAG)
-# define DEBUG_l_TEST_ (PL_debug & DEBUG_l_FLAG)
-# define DEBUG_t_TEST_ (PL_debug & DEBUG_t_FLAG)
-# define DEBUG_o_TEST_ (PL_debug & DEBUG_o_FLAG)
-# define DEBUG_c_TEST_ (PL_debug & DEBUG_c_FLAG)
-# define DEBUG_P_TEST_ (PL_debug & DEBUG_P_FLAG)
-# define DEBUG_m_TEST_ (PL_debug & DEBUG_m_FLAG)
-# define DEBUG_f_TEST_ (PL_debug & DEBUG_f_FLAG)
-# define DEBUG_r_TEST_ (PL_debug & DEBUG_r_FLAG)
-# define DEBUG_x_TEST_ (PL_debug & DEBUG_x_FLAG)
-# define DEBUG_u_TEST_ (PL_debug & DEBUG_u_FLAG)
-# define DEBUG_U_TEST_ (PL_debug & DEBUG_U_FLAG)
-# define DEBUG_H_TEST_ (PL_debug & DEBUG_H_FLAG)
-# define DEBUG_X_TEST_ (PL_debug & DEBUG_X_FLAG)
-# define DEBUG_D_TEST_ (PL_debug & DEBUG_D_FLAG)
-# define DEBUG_S_TEST_ (PL_debug & DEBUG_S_FLAG)
-# define DEBUG_T_TEST_ (PL_debug & DEBUG_T_FLAG)
-# define DEBUG_R_TEST_ (PL_debug & DEBUG_R_FLAG)
-# define DEBUG_J_TEST_ (PL_debug & DEBUG_J_FLAG)
-# define DEBUG_v_TEST_ (PL_debug & DEBUG_v_FLAG)
-# define DEBUG_C_TEST_ (PL_debug & DEBUG_C_FLAG)
-# define DEBUG_A_TEST_ (PL_debug & DEBUG_A_FLAG)
-# define DEBUG_q_TEST_ (PL_debug & DEBUG_q_FLAG)
-# define DEBUG_M_TEST_ (PL_debug & DEBUG_M_FLAG)
-# define DEBUG_B_TEST_ (PL_debug & DEBUG_B_FLAG)
-# define DEBUG_L_TEST_ (PL_debug & DEBUG_L_FLAG)
-# define DEBUG_i_TEST_ (PL_debug & DEBUG_i_FLAG)
+# define DEBUG_p_TEST_ UNLIKELY(PL_debug & DEBUG_p_FLAG)
+# define DEBUG_s_TEST_ UNLIKELY(PL_debug & DEBUG_s_FLAG)
+# define DEBUG_l_TEST_ UNLIKELY(PL_debug & DEBUG_l_FLAG)
+# define DEBUG_t_TEST_ UNLIKELY(PL_debug & DEBUG_t_FLAG)
+# define DEBUG_o_TEST_ UNLIKELY(PL_debug & DEBUG_o_FLAG)
+# define DEBUG_c_TEST_ UNLIKELY(PL_debug & DEBUG_c_FLAG)
+# define DEBUG_P_TEST_ UNLIKELY(PL_debug & DEBUG_P_FLAG)
+# define DEBUG_m_TEST_ UNLIKELY(PL_debug & DEBUG_m_FLAG)
+# define DEBUG_f_TEST_ UNLIKELY(PL_debug & DEBUG_f_FLAG)
+# define DEBUG_r_TEST_ UNLIKELY(PL_debug & DEBUG_r_FLAG)
+# define DEBUG_x_TEST_ UNLIKELY(PL_debug & DEBUG_x_FLAG)
+# define DEBUG_u_TEST_ UNLIKELY(PL_debug & DEBUG_u_FLAG)
+# define DEBUG_U_TEST_ UNLIKELY(PL_debug & DEBUG_U_FLAG)
+# define DEBUG_X_TEST_ UNLIKELY(PL_debug & DEBUG_X_FLAG)
+# define DEBUG_D_TEST_ UNLIKELY(PL_debug & DEBUG_D_FLAG)
+# define DEBUG_S_TEST_ UNLIKELY(PL_debug & DEBUG_S_FLAG)
+# define DEBUG_T_TEST_ UNLIKELY(PL_debug & DEBUG_T_FLAG)
+# define DEBUG_R_TEST_ UNLIKELY(PL_debug & DEBUG_R_FLAG)
+# define DEBUG_J_TEST_ UNLIKELY(PL_debug & DEBUG_J_FLAG)
+# define DEBUG_v_TEST_ UNLIKELY(PL_debug & DEBUG_v_FLAG)
+# define DEBUG_C_TEST_ UNLIKELY(PL_debug & DEBUG_C_FLAG)
+# define DEBUG_A_TEST_ UNLIKELY(PL_debug & DEBUG_A_FLAG)
+# define DEBUG_q_TEST_ UNLIKELY(PL_debug & DEBUG_q_FLAG)
+# define DEBUG_M_TEST_ UNLIKELY(PL_debug & DEBUG_M_FLAG)
+# define DEBUG_B_TEST_ UNLIKELY(PL_debug & DEBUG_B_FLAG)
+# define DEBUG_L_TEST_ UNLIKELY(PL_debug & DEBUG_L_FLAG)
+# define DEBUG_i_TEST_ UNLIKELY(PL_debug & DEBUG_i_FLAG)
# define DEBUG_Xv_TEST_ (DEBUG_X_TEST_ && DEBUG_v_TEST_)
# define DEBUG_Uv_TEST_ (DEBUG_U_TEST_ && DEBUG_v_TEST_)
# define DEBUG_Pv_TEST_ (DEBUG_P_TEST_ && DEBUG_v_TEST_)
# define DEBUG_x_TEST DEBUG_x_TEST_
# define DEBUG_u_TEST DEBUG_u_TEST_
# define DEBUG_U_TEST DEBUG_U_TEST_
-# define DEBUG_H_TEST DEBUG_H_TEST_
# define DEBUG_X_TEST DEBUG_X_TEST_
# define DEBUG_D_TEST DEBUG_D_TEST_
# define DEBUG_S_TEST DEBUG_S_TEST_
# define DEBUG_x(a) DEBUG__(DEBUG_x_TEST, a)
# define DEBUG_u(a) DEBUG__(DEBUG_u_TEST, a)
# define DEBUG_U(a) DEBUG__(DEBUG_U_TEST, a)
-# define DEBUG_H(a) DEBUG__(DEBUG_H_TEST, a)
# define DEBUG_X(a) DEBUG__(DEBUG_X_TEST, a)
# define DEBUG_D(a) DEBUG__(DEBUG_D_TEST, a)
# define DEBUG_Xv(a) DEBUG__(DEBUG_Xv_TEST, a)
# define DEBUG_x_TEST (0)
# define DEBUG_u_TEST (0)
# define DEBUG_U_TEST (0)
-# define DEBUG_H_TEST (0)
# define DEBUG_X_TEST (0)
# define DEBUG_D_TEST (0)
# define DEBUG_S_TEST (0)
# define DEBUG_x(a)
# define DEBUG_u(a)
# define DEBUG_U(a)
-# define DEBUG_H(a)
# define DEBUG_X(a)
# define DEBUG_D(a)
# define DEBUG_S(a)
EXTCONST char PL_uuemap[65]
INIT("`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_");
+/* a special string address whose value is "isa", but which perl knows
+ * to treat as if it were really "DOES" when printing the method name in
+ * the "Can't call method '%s'" error message */
+EXTCONST char PL_isa_DOES[]
+ INIT("isa");
+
#ifdef DOINIT
EXTCONST char PL_uudmap[256] =
# ifdef PERL_MICRO
STMT_START { \
if (! PL_in_utf8_CTYPE_locale && ckWARN(WARN_LOCALE)) { \
Perl_warner(aTHX_ packWARN(WARN_LOCALE), \
- "Wide character (U+%"UVXf") in %s", \
- (UV) cp, OP_DESC(PL_op)); \
+ "Wide character (U+%" UVXf ") in %s",\
+ (UV) cp, OP_DESC(PL_op)); \
} \
} STMT_END
if (! PL_in_utf8_CTYPE_locale && ckWARN(WARN_LOCALE)) { \
UV cp = utf8_to_uvchr_buf((U8 *) s, (U8 *) send, NULL); \
Perl_warner(aTHX_ packWARN(WARN_LOCALE), \
- "Wide character (U+%"UVXf") in %s", \
+ "Wide character (U+%" UVXf ") in %s", \
(cp == 0) \
? UNICODE_REPLACEMENT \
: (UV) cp, \
_restore_LC_NUMERIC_function = &Perl_set_numeric_standard; \
}
-/* Lock to the C locale until unlock is called */
+/* Lock/unlock to the C locale until unlock is called. This needs to be
+ * recursively callable. [perl #128207] */
#define LOCK_LC_NUMERIC_STANDARD() \
(__ASSERT_(PL_numeric_standard) \
- PL_numeric_standard = 2)
-
+ PL_numeric_standard++)
#define UNLOCK_LC_NUMERIC_STANDARD() \
- (__ASSERT_(PL_numeric_standard == 2) \
- PL_numeric_standard = 1)
+ STMT_START { \
+ if (PL_numeric_standard > 1) { \
+ PL_numeric_standard--; \
+ } \
+ else { \
+ assert(0); \
+ } \
+ } STMT_END
#define RESTORE_LC_NUMERIC_UNDERLYING() \
if (_was_local) set_numeric_local();