#undef SF_MTSAFE /* no need to worry about thread-safety */
#define SF_MTSAFE 0
-#define SFMTXUNLOCK(f) (void)(0)
#define SFMTXSTART(f,v) { if(!f) return(v); }
#define SFMTXRETURN(f,v) { return(v); }
*************************************************************************/
#include <sfio/sfhdr.h>
-
+#include <stddef.h>
/* Push/pop streams
**
** Written by Kiem-Phong Vo.
*/
-#define STKMTXRETURN(f1,f2,rv) \
- { if(f1) SFMTXUNLOCK(f1); \
- if(f2) SFMTXUNLOCK(f2); \
- return(rv); \
- }
-
/**
* @param f1 base of stack
* @param f2 top of stack
Sfrsrv_t *rsrv;
if (f1 && (f1->mode & SF_RDWR) != f1->mode && _sfmode(f1, 0, 0) < 0)
- STKMTXRETURN(f1, f2, NIL(Sfio_t *));
+ return NULL;
if (f2 && (f2->mode & SF_RDWR) != f2->mode && _sfmode(f2, 0, 0) < 0)
- STKMTXRETURN(f1, f2, NIL(Sfio_t *));
+ return NULL;
if (!f1)
- STKMTXRETURN(f1, f2, f2);
+ return f2;
/* give access to other internal functions */
_Sfstack = sfstack;
if (f2 == SF_POPSTACK) {
if (!(f2 = f1->push))
- STKMTXRETURN(f1, f2, NIL(Sfio_t *));
+ return NULL;
f2->mode &= ~SF_PUSH;
} else {
if (f2->push)
- STKMTXRETURN(f1, f2, NIL(Sfio_t *));
+ return NULL;
if (f1->pool && f1->pool != &_Sfpool && f1->pool != f2->pool && f1 == f1->pool->sf[0]) { /* get something else to pool front since f1 will be locked */
for (n = 1; n < f1->pool->n_sf; ++n) {
if (SFFROZEN(f1->pool->sf[n]))
SFOPEN(f1, 0);
SFOPEN(f2, 0);
- STKMTXRETURN(f1, f2, rf);
+ return rf;
}