From e371f57fc8fd1b8c58395c0c91bcabc387eb5ffd Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Fri, 30 May 2008 17:17:13 +0200
Subject: [PATCH] Added another svalue initializer macro. Added two global
 constant svalues svalue_int_zero and svalue_int_one for general use.

Rev: src/svalue.h:1.160
---
 src/svalue.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/svalue.h b/src/svalue.h
index f33eb379e9..04520d4b62 100644
--- a/src/svalue.h
+++ b/src/svalue.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: svalue.h,v 1.159 2008/05/30 14:37:05 mast Exp $
+|| $Id: svalue.h,v 1.160 2008/05/30 15:17:13 mast Exp $
 */
 
 #ifndef SVALUE_H
@@ -322,6 +322,14 @@ struct svalue
 
 #define FUNCTION_BUILTIN USHRT_MAX
 
+PMOD_EXPORT const struct svalue svalue_int_zero;
+#ifdef HAVE_UNION_INIT
+PMOD_EXPORT const struct svalue svalue_int_one;
+#else
+/* The value 1 is initialized first thing in init_pike. */
+PMOD_EXPORT struct svalue svalue_int_one;
+#endif
+
 #define is_gt(a,b) is_lt(b,a)
 #define is_ge(a,b) is_le(b,a)
 
@@ -350,7 +358,7 @@ do{ \
 /* var MUST be a variable!!! */
 #define safe_check_destructed(var) do{ \
   if((var->type == PIKE_T_OBJECT || var->type==PIKE_T_FUNCTION) && !var->u.object->prog) \
-    var=&dest_ob_zero; \
+    var=&svalue_int_zero; \
 }while(0)
 
 #define check_short_destructed(U,T) \
@@ -1007,9 +1015,11 @@ struct ref_dummy
 /* The following macro is useful to initialize static svalues. Note
  * that the value isn't always set. */
 #ifdef HAVE_UNION_INIT
+#define SVALUE_INIT(TYPE, SUBTYPE, VAL) {TYPE, SUBTYPE, {VAL}}
 #define SVALUE_INIT_INT(VAL) {T_INT, NUMBER_NUMBER, {VAL}}
 #define SVALUE_INIT_FREE {PIKE_T_FREE, NUMBER_NUMBER, {0}}
 #else
+#define SVALUE_INIT(TYPE, SUBTYPE, VAL) {TYPE, SUBTYPE}
 #define SVALUE_INIT_INT(VAL) {T_INT, NUMBER_NUMBER}
 #define SVALUE_INIT_FREE {PIKE_T_FREE, NUMBER_NUMBER}
 #endif
-- 
GitLab