+#define PERLIO_MAX_REFCOUNTABLE_FD 2048
+
+#ifdef __Lynx__
+/* Missing proto on LynxOS */
+int mkstemp(char*);
+#endif
+
+/* Call the callback or PerlIOBase, and return failure. */
+#define Perl_PerlIO_or_Base(f, callback, base, failure, args) \
+ if (PerlIOValid(f)) { \
+ const PerlIO_funcs * const tab = PerlIOBase(f)->tab;\
+ if (tab && tab->callback) \
+ return (*tab->callback) args; \
+ else \
+ return PerlIOBase_ ## base args; \
+ } \
+ else \
+ SETERRNO(EBADF, SS_IVCHAN); \
+ return failure
+
+/* Call the callback or fail, and return failure. */
+#define Perl_PerlIO_or_fail(f, callback, failure, args) \
+ if (PerlIOValid(f)) { \
+ const PerlIO_funcs * const tab = PerlIOBase(f)->tab;\
+ if (tab && tab->callback) \
+ return (*tab->callback) args; \
+ SETERRNO(EINVAL, LIB_INVARG); \
+ } \
+ else \
+ SETERRNO(EBADF, SS_IVCHAN); \
+ return failure
+
+/* Call the callback or PerlIOBase, and be void. */
+#define Perl_PerlIO_or_Base_void(f, callback, base, args) \
+ if (PerlIOValid(f)) { \
+ const PerlIO_funcs * const tab = PerlIOBase(f)->tab;\
+ if (tab && tab->callback) \
+ (*tab->callback) args; \
+ else \
+ PerlIOBase_ ## base args; \
+ } \
+ else \
+ SETERRNO(EBADF, SS_IVCHAN)
+
+/* Call the callback or fail, and be void. */
+#define Perl_PerlIO_or_fail_void(f, callback, args) \
+ if (PerlIOValid(f)) { \
+ const PerlIO_funcs * const tab = PerlIOBase(f)->tab;\
+ if (tab && tab->callback) \
+ (*tab->callback) args; \
+ else \
+ SETERRNO(EINVAL, LIB_INVARG); \
+ } \
+ else \
+ SETERRNO(EBADF, SS_IVCHAN)
+
+#ifndef USE_SFIO