mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
flockfile/funlockfile is POSIX, so NetBSD has them too --- use them.
This commit is contained in:
parent
0a02d47a11
commit
7e4d4354bc
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.8 2003/01/02 06:00:33 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.9 2003/01/02 23:22:49 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -21,9 +21,7 @@
|
|||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
|
||||||
#ifdef bsdi
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -46,17 +44,13 @@ fseeko(FILE *stream, off_t offset, int whence)
|
|||||||
switch (whence)
|
switch (whence)
|
||||||
{
|
{
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
#ifdef bsdi
|
|
||||||
flockfile(stream);
|
flockfile(stream);
|
||||||
#endif
|
|
||||||
if (fgetpos(stream, &floc) != 0)
|
if (fgetpos(stream, &floc) != 0)
|
||||||
goto failure;
|
goto failure;
|
||||||
floc += offset;
|
floc += offset;
|
||||||
if (fsetpos(stream, &floc) != 0)
|
if (fsetpos(stream, &floc) != 0)
|
||||||
goto failure;
|
goto failure;
|
||||||
#ifdef bsdi
|
|
||||||
funlockfile(stream);
|
funlockfile(stream);
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
@ -65,17 +59,13 @@ fseeko(FILE *stream, off_t offset, int whence)
|
|||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
#ifdef bsdi
|
|
||||||
flockfile(stream);
|
flockfile(stream);
|
||||||
#endif
|
|
||||||
if (fstat(fileno(stream), &filestat) != 0)
|
if (fstat(fileno(stream), &filestat) != 0)
|
||||||
goto failure;
|
goto failure;
|
||||||
floc = filestat.st_size;
|
floc = filestat.st_size;
|
||||||
if (fsetpos(stream, &floc) != 0)
|
if (fsetpos(stream, &floc) != 0)
|
||||||
goto failure;
|
goto failure;
|
||||||
#ifdef bsdi
|
|
||||||
funlockfile(stream);
|
funlockfile(stream);
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -84,9 +74,7 @@ fseeko(FILE *stream, off_t offset, int whence)
|
|||||||
}
|
}
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
#ifdef bsdi
|
|
||||||
funlockfile(stream);
|
funlockfile(stream);
|
||||||
#endif
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user