perlio_closer(void *handle);
static void
perlio_destroy(void *handle);
-static const char *my_strerror(int err);
+static const char *my_strerror(pTHX_ int err);
+
+#ifndef tTHX
+#define tTHX PerlInterpreter *
+#endif
typedef struct {
PerlIO *handle;
pIMCTX;
-#ifdef USE_PERLIO
+#ifdef MULTIPLICITY
tTHX my_perl;
#endif
} im_perlio;
dIMCTX;
state->handle = handle;
-#ifdef USE_PERLIO
+#ifdef MULTIPLICITY
state->aTHX = aTHX;
#endif
state->aIMCTX = aIMCTX;
ssize_t result = PerlIO_read(state->handle, buf, count);
if (result == 0 && PerlIO_error(state->handle)) {
- im_push_errorf(aIMCTX, errno, "read() failure (%s)", my_strerror(errno));
+ im_push_errorf(aIMCTX, errno, "read() failure (%s)", my_strerror(aTHX_ errno));
return -1;
}
result = PerlIO_write(state->handle, buf, count);
if (result == 0) {
- im_push_errorf(aIMCTX, errno, "write() failure (%s)", my_strerror(errno));
+ im_push_errorf(aIMCTX, errno, "write() failure (%s)", my_strerror(aTHX_ errno));
}
return result;
if (whence != SEEK_CUR || offset != 0) {
if (PerlIO_seek(state->handle, offset, whence) < 0) {
- im_push_errorf(aIMCTX, errno, "seek() failure (%s)", my_strerror(errno));
+ im_push_errorf(aIMCTX, errno, "seek() failure (%s)", my_strerror(aTHX_ errno));
return -1;
}
}
dIMCTXperlio(state);
if (PerlIO_flush(state->handle) < 0) {
- im_push_errorf(aIMCTX, errno, "flush() failure (%s)", my_strerror(errno));
+ im_push_errorf(aIMCTX, errno, "flush() failure (%s)", my_strerror(aTHX_ errno));
return -1;
}
return 0;
}
static
-const char *my_strerror(int err) {
+const char *my_strerror(pTHX_ int err) {
const char *result = strerror(err);
if (!result)