AUTHORS updates.
[p5sagit/p5-mst-13.2.git] / sv.h
diff --git a/sv.h b/sv.h
index 10ea0af..a896b62 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -1,6 +1,6 @@
 /*    sv.h
  *
- *    Copyright (c) 1991-2000, Larry Wall
+ *    Copyright (c) 1991-2001, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -61,7 +61,7 @@ typedef enum {
 
 /* Using C's structural equivalence to help emulate C++ inheritance here... */
 
-struct sv {
+struct STRUCT_SV {
     void*      sv_any;         /* pointer to something */
     U32                sv_refcnt;      /* how many references to us */
     U32                sv_flags;       /* what we are */
@@ -363,7 +363,19 @@ struct xpvio {
 
     PerlIO *   xio_ifp;        /* ifp and ofp are normally the same */
     PerlIO *   xio_ofp;        /* but sockets need separate streams */
-    DIR *      xio_dirp;       /* for opendir, readdir, etc */
+    /* Cray addresses everything by word boundaries (64 bits) and
+     * code and data pointers cannot be mixed (which is exactly what
+     * Perl_filter_add() tries to do with the dirp), hence the following
+     * union trick (as suggested by Gurusamy Sarathy).
+     * For further information see Geir Johansen's problem report titled
+       [ID 20000612.002] Perl problem on Cray system
+     * The any pointer (known as IoANY()) will also be a good place
+     * to hang any IO disciplines to.
+     */
+    union {
+       DIR *   xiou_dirp;      /* for opendir, readdir, etc */
+       void *  xiou_any;       /* for alignment */
+    } xio_dirpu;
     long       xio_lines;      /* $. */
     long       xio_page;       /* $% */
     long       xio_page_len;   /* $= */
@@ -378,6 +390,8 @@ struct xpvio {
     char       xio_type;
     char       xio_flags;
 };
+#define xio_dirp       xio_dirpu.xiou_dirp
+#define xio_any                xio_dirpu.xiou_any
 
 #define IOf_ARGV       1       /* this fp iterates over ARGV */
 #define IOf_START      2       /* check for null ARGV and substitute '-' */
@@ -428,6 +442,18 @@ Unsets the IV status of an SV.
 =for apidoc Am|void|SvIOK_only|SV* sv
 Tells an SV that it is an integer and disables all other OK bits.
 
+=for apidoc Am|void|SvIOK_only_UV|SV* sv
+Tells and SV that it is an unsigned integer and disables all other OK bits.
+
+=for apidoc Am|void|SvIOK_UV|SV* sv
+Returns a boolean indicating whether the SV contains an unsigned integer.
+
+=for apidoc Am|void|SvUOK|SV* sv
+Returns a boolean indicating whether the SV contains an unsigned integer.
+
+=for apidoc Am|void|SvIOK_notUV|SV* sv
+Returns a boolean indicating whether the SV contains an signed integer.
+
 =for apidoc Am|bool|SvNOK|SV* sv
 Returns a boolean indicating whether the SV contains a double.
 
@@ -452,6 +478,7 @@ Unsets the PV status of an SV.
 
 =for apidoc Am|void|SvPOK_only|SV* sv
 Tells an SV that it is a string and disables all other OK bits.
+Will also turn off the UTF8 status.
 
 =for apidoc Am|bool|SvOOK|SV* sv
 Returns a boolean indicating whether the SvIVX is a valid offset value for
@@ -491,7 +518,8 @@ string.
 Returns the length of the string which is in the SV.  See C<SvLEN>.
 
 =for apidoc Am|STRLEN|SvLEN|SV* sv
-Returns the size of the string buffer in the SV.  See C<SvCUR>.
+Returns the size of the string buffer in the SV, not including any part
+attributable to C<SvOOK>.  See C<SvCUR>.
 
 =for apidoc Am|char*|SvEND|SV* sv
 Returns a pointer to the last character in the string which is in the SV.
@@ -538,6 +566,7 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 
 #define SvIOK_UV(sv)           ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV))   \
                                 == (SVf_IOK|SVf_IVisUV))
+#define SvUOK(sv)              SvIOK_UV(sv)
 #define SvIOK_notUV(sv)                ((SvFLAGS(sv) & (SVf_IOK|SVf_IVisUV))   \
                                 == SVf_IOK)
 
@@ -551,6 +580,24 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 #define SvNOK_only(sv)         ((void)SvOK_off(sv), \
                                    SvFLAGS(sv) |= (SVf_NOK|SVp_NOK))
 
+/*
+=for apidoc Am|void|SvUTF8|SV* sv
+Returns a boolean indicating whether the SV contains UTF-8 encoded data.
+
+=for apidoc Am|void|SvUTF8_on|SV *sv
+Turn on the UTF8 status of an SV (the data is not changed, just the flag).
+Do not use frivolously.
+
+=for apidoc Am|void|SvUTF8_off|SV *sv
+Unsets the UTF8 status of an SV.
+
+=for apidoc Am|void|SvPOK_only_UTF8|SV* sv
+Tells an SV that it is a string and disables all other OK bits,
+and leaves the UTF8 status as it was.
+  
+=cut
+ */
+
 #define SvUTF8(sv)             (SvFLAGS(sv) & SVf_UTF8)
 #define SvUTF8_on(sv)          (SvFLAGS(sv) |= (SVf_UTF8))
 #define SvUTF8_off(sv)         (SvFLAGS(sv) &= ~(SVf_UTF8))
@@ -597,6 +644,8 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 #define SvAMAGIC_on(sv)                (SvFLAGS(sv) |= SVf_AMAGIC)
 #define SvAMAGIC_off(sv)       (SvFLAGS(sv) &= ~SVf_AMAGIC)
 
+#define SvGAMAGIC(sv)           (SvFLAGS(sv) & (SVs_GMG|SVf_AMAGIC)) 
+
 /*
 #define Gv_AMG(stash) \
         (HV_AMAGICmb(stash) && \
@@ -671,6 +720,12 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 #define SvMAGIC(sv)    ((XPVMG*)  SvANY(sv))->xmg_magic
 #define SvSTASH(sv)    ((XPVMG*)  SvANY(sv))->xmg_stash
 
+/* Ask a scalar nicely to try to become an IV, if possible.
+   Not guaranteed to stay returning void */
+/* Macro won't actually call sv_2iv if already IOK */
+#define SvIV_please(sv) \
+       STMT_START {if (!SvIOKp(sv) && (SvNOK(sv) || SvPOK(sv))) \
+               (void) SvIV(sv); } STMT_END
 #define SvIV_set(sv, val) \
        STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
                (((XPVIV*)  SvANY(sv))->xiv_iv = val); } STMT_END
@@ -704,6 +759,7 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 #define IoIFP(sv)      ((XPVIO*)  SvANY(sv))->xio_ifp
 #define IoOFP(sv)      ((XPVIO*)  SvANY(sv))->xio_ofp
 #define IoDIRP(sv)     ((XPVIO*)  SvANY(sv))->xio_dirp
+#define IoANY(sv)      ((XPVIO*)  SvANY(sv))->xio_any
 #define IoLINES(sv)    ((XPVIO*)  SvANY(sv))->xio_lines
 #define IoPAGE(sv)     ((XPVIO*)  SvANY(sv))->xio_page
 #define IoPAGE_LEN(sv) ((XPVIO*)  SvANY(sv))->xio_page_len
@@ -718,18 +774,15 @@ Set the length of the string which is in the SV.  See C<SvCUR>.
 #define IoTYPE(sv)     ((XPVIO*)  SvANY(sv))->xio_type
 #define IoFLAGS(sv)    ((XPVIO*)  SvANY(sv))->xio_flags
 
-/*
-IoTYPE(sv) is a single character saying what type of I/O connection
-this is:
-    |        pipe
-    -        stdin or stdout
-    <        read-only
-    >        write-only
-    a        append
-    +        read and write
-    s        socket
-    space    closed
-*/
+/* IoTYPE(sv) is a single character telling the type of I/O connection. */
+#define IoTYPE_RDONLY  '<'
+#define IoTYPE_WRONLY  '>'
+#define IoTYPE_RDWR    '+'
+#define IoTYPE_APPEND  'a'
+#define IoTYPE_PIPE    '|'
+#define IoTYPE_STD     '-'     /* stdin or stdout */
+#define IoTYPE_SOCKET  's'
+#define IoTYPE_CLOSED  ' '
 
 /*
 =for apidoc Am|bool|SvTAINTED|SV* sv
@@ -760,7 +813,6 @@ Taints an SV if tainting is enabled
 #define SvTAINT(sv)                    \
     STMT_START {                       \
        if (PL_tainting) {              \
-           dTHR;                       \
            if (PL_tainted)             \
                SvTAINTED_on(sv);       \
        }                               \
@@ -1001,19 +1053,12 @@ more than once.
 Calls a non-destructive version of C<sv_setsv> if dsv is not the same as
 ssv. May evaluate arguments more than once.
 
-=for apidoc Am|void|SvGROW|SV* sv|STRLEN len
+=for apidoc Am|char *|SvGROW|SV* sv|STRLEN len
 Expands the character buffer in the SV so that it has room for the
 indicated number of bytes (remember to reserve space for an extra trailing
 NUL character).  Calls C<sv_grow> to perform the expansion if necessary. 
 Returns a pointer to the character buffer.
 
-=for apidoc Am|void|SvLOCK|SV* sv
-Aquires an internal mutex for a SV. Used to make sure multiple threads
-don't stomp on the guts of an SV at the same time
-
-=for apidoc Am|void|SvUNLOCK|SV* sv
-Release the internal mutex for an SV.
-
 =cut
 */
 
@@ -1049,9 +1094,6 @@ Release the internal mutex for an SV.
                SvSetSV_nosteal_and(dst,src,SvSETMAGIC(dst))
 
 #ifdef DEBUGGING
-
-#define SvLOCK(sv)     MUTEX_LOCK(&PL_sv_lock_mutex)
-#define SvUNLOCK(sv)   MUTEX_UNLOCK(&PL_sv_lock_mutex)
 #define SvPEEK(sv) sv_peek(sv)
 #else
 #define SvPEEK(sv) ""
@@ -1066,10 +1108,8 @@ Release the internal mutex for an SV.
 #define SvGROW(sv,len) (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv))
 #define Sv_Grow sv_grow
 
-#ifdef USE_THREADS
-#   define FDPID_LOCK()                MUTEX_LOCK(&PL_fdpid_mutex)
-#   define FDPID_UNLOCK()      MUTEX_UNLOCK(&PL_fdpid_mutex)
-#else
-#   define FDPID_LOCK()
-#   define FDPID_UNLOCK()
-#endif
+#define SV_IMMEDIATE_UNREF     1
+
+#define CLONEf_COPY_STACKS 1
+#define CLONEf_KEEP_PTR_TABLE 2
+