This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
truncate(FH) flushes FH before truncating it
[perl5.git] / perl.h
diff --git a/perl.h b/perl.h
index f291975..2da6910 100644 (file)
--- a/perl.h
+++ b/perl.h
 #define VOIDUSED 1
 #include "config.h"
 
+#if defined(USE_ITHREADS) && defined(USE_5005THREADS)
+#  include "error: USE_ITHREADS and USE_5005THREADS are incompatible"
+#endif
+
+/* XXX This next guard can disappear if the sources are revised
+   to use USE_5005THREADS throughout. -- A.D  1/6/2000
+*/
+#if defined(USE_ITHREADS) && defined(USE_THREADS)
+#  include "error: USE_ITHREADS and USE_THREADS are incompatible"
+#endif
+
 /* See L<perlguts/"The Perl API"> for detailed notes on
  * PERL_IMPLICIT_CONTEXT and PERL_IMPLICIT_SYS */
 
@@ -40,6 +51,9 @@
 
 #ifdef PERL_CAPI
 #  undef PERL_OBJECT
+#  ifndef MULTIPLICITY
+#    define MULTIPLICITY
+#  endif
 #  ifndef PERL_IMPLICIT_CONTEXT
 #    define PERL_IMPLICIT_CONTEXT
 #  endif
 #  endif
 #endif
 
+#if defined(USE_ITHREADS) && !defined(MULTIPLICITY) && !defined(PERL_OBJECT)
+#  include "error: USE_ITHREADS must be built with MULTIPLICITY"
+#endif
+
 #ifdef PERL_OBJECT
 
 /* PERL_OBJECT explained  - DickH and DougL @ ActiveState.com
@@ -171,6 +189,10 @@ struct perl_thread;
 #  define dTHX         dTHXa(PERL_GET_THX)
 #  define pTHX_                pTHX,
 #  define aTHX_                aTHX,
+#  define pTHX_1       2       
+#  define pTHX_2       3
+#  define pTHX_3       4
+#  define pTHX_4       5
 #endif
 
 #define STATIC static
@@ -203,6 +225,10 @@ struct perl_thread;
 #  define aTHX_
 #  define dTHXa(a)     dNOOP
 #  define dTHX         dNOOP
+#  define pTHX_1       1       
+#  define pTHX_2       2
+#  define pTHX_3       3
+#  define pTHX_4       4
 #endif
 
 #ifndef pTHXo
@@ -383,7 +409,8 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
 /* HP-UX 10.X CMA (Common Multithreaded Architecure) insists that
    pthread.h must be included before all other header files.
 */
-#if defined(USE_THREADS) && defined(PTHREAD_H_FIRST) && defined(I_PTHREAD)
+#if (defined(USE_THREADS) || defined(USE_ITHREADS)) \
+    && defined(PTHREAD_H_FIRST) && defined(I_PTHREAD)
 #  include <pthread.h>
 #endif
 
@@ -1070,10 +1097,16 @@ typedef NVTYPE NV;
 #   define Perl_fmod fmod
 #endif
 
-#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && defined(HAS_ATOLF)
-#   define Perl_atof atolf
-#else
-#   define Perl_atof atof
+#if !defined(Perl_atof) && defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
+#   if !defined(Perl_atof) && defined(HAS_STRTOLD)
+#       define Perl_atof(s) strtold(s, (char**)NULL)
+#   endif
+#   if !defined(Perl_atof) && defined(HAS_ATOLF)
+#       define Perl_atof atolf
+#   endif
+#endif
+#if !defined(Perl_atof)
+#   define Perl_atof atof /* we assume atof being available anywhere */
 #endif
 
 /* Previously these definitions used hardcoded figures. 
@@ -1469,10 +1502,6 @@ typedef struct ptr_tbl PTR_TBL_t;
 #  define PERL_SYS_INIT3(argvp,argcp,envp) PERL_SYS_INIT(argvp,argcp)
 #endif
 
-#ifndef PERL_SYS_INIT3
-#  define PERL_SYS_INIT3(argvp,argcp,envp) PERL_SYS_INIT(argvp,argcp)
-#endif
-
 #ifndef MAXPATHLEN
 #  ifdef PATH_MAX
 #    ifdef _POSIX_PATH_MAX
@@ -1502,11 +1531,12 @@ typedef struct ptr_tbl PTR_TBL_t;
  * May make sense to have threads after "*ish.h" anyway
  */
 
-#ifdef USE_THREADS
+#if defined(USE_THREADS) || defined(USE_ITHREADS)
+#  if defined(USE_THREADS)
    /* pending resolution of licensing issues, we avoid the erstwhile
     * atomic.h everywhere */
 #  define EMULATE_ATOMIC_REFCOUNTS
-
+#  endif
 #  ifdef FAKE_THREADS
 #    include "fakethr.h"
 #  else
@@ -1537,10 +1567,10 @@ typedef pthread_key_t   perl_key;
 #      endif /* OS2 */
 #    endif /* WIN32 */
 #  endif /* FAKE_THREADS */
-#endif /* USE_THREADS */
+#endif /* USE_THREADS || USE_ITHREADS */
 
 #ifdef WIN32
-#include "win32.h"
+#  include "win32.h"
 #endif
 
 #ifdef VMS
@@ -1596,7 +1626,13 @@ typedef pthread_key_t    perl_key;
 #define PERL_EXIT_EXPECTED     0x01
 
 #ifndef MEMBER_TO_FPTR
-#define MEMBER_TO_FPTR(name)           name
+#  define MEMBER_TO_FPTR(name)         name
+#endif
+
+/* format to use for version numbers in file/directory names */
+/* XXX move to Configure? */
+#ifndef PERL_FS_VER_FMT
+#  define PERL_FS_VER_FMT      "%d.%d.%d"
 #endif
 
 /* This defines a way to flush all output buffers.  This may be a
@@ -1646,6 +1682,14 @@ typedef pthread_key_t    perl_key;
 #  endif
 #endif
 
+#ifndef SVf
+#  ifdef CHECK_FORMAT
+#    define SVf "p"
+#  else
+#    define SVf "_"
+#  endif 
+#endif
+
 /* Some unistd.h's give a prototype for pause() even though
    HAS_PAUSE ends up undefined.  This causes the #define
    below to be rejected by the compmiler.  Sigh.
@@ -1868,6 +1912,7 @@ Gid_t getegid (void);
 
 #ifndef Perl_error_log
 #  define Perl_error_log       (PL_stderrgv                    \
+                                && IoOFP(GvIOp(PL_stderrgv))   \
                                 ? IoOFP(GvIOp(PL_stderrgv))    \
                                 : PerlIO_stderr())
 #endif
@@ -2956,16 +3001,29 @@ typedef struct am_table_short AMTS;
 
 #endif /* !USE_LOCALE_NUMERIC */
 
-#if defined(USE_LONG_LONG) && defined(HAS_LONG_LONG) && defined(HAS_ATOLL)
-#define Atol atoll 
-#else
-#define Atol atol
+#if !defined(Atol) && defined(USE_LONG_LONG) && defined(HAS_LONG_LONG)
+#   if !defined(Atol) && defined(HAS_STRTOLL)
+#       define Atol(s) strtoll(s, (char**)NULL, 10)
+#   endif
+#   if !defined(Atol) && defined(HAS_ATOLL)
+#       define Atol atoll
+#   endif
+#endif
+/* is there atoq() anywhere? */
+#if !defined(Atol)
+#   define Atol atol /* we assume atol being available anywhere */
 #endif
 
-#if defined(USE_LONG_LONG) && defined(HAS_LONG_LONG) && defined(HAS_STRTOULL)
-#define Strtoul strtoull
-#else
-#define Strtoul strtoul
+#if !defined(Strtoul) && defined(USE_LONG_LONG) && defined(HAS_LONG_LONG) \
+       && defined(HAS_STRTOULL)
+#   define Strtoul strtoull
+#endif
+/* is there atouq() anywhere? */
+#if !defined(Strtoul) && defined(USE_64_BITS) && defined(HAS_STRTOUQ)
+#   define Strtoul strtouq
+#endif
+#if !defined(Strtoul)
+#   define Strtoul strtoul /* we assume strtoul being available anywhere */
 #endif
 
 #if !defined(PERLIO_IS_STDIO) && defined(HASATTRIBUTE)