88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.9 2003/01/02 23:22:49 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.10 2003/01/11 19:38:23 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
2121
2222#include "c.h"
2323
24+ #ifdef bsdi
2425#include <pthread.h>
26+ #endif
2527#include <stdio.h>
2628#include <sys/types.h>
2729#include <sys/stat.h>
@@ -44,13 +46,17 @@ fseeko(FILE *stream, off_t offset, int whence)
4446switch (whence )
4547{
4648case SEEK_CUR :
49+ #ifdef bsdi
4750flockfile (stream );
51+ #endif
4852if (fgetpos (stream ,& floc )!= 0 )
4953gotofailure ;
5054floc += offset ;
5155if (fsetpos (stream ,& floc )!= 0 )
5256gotofailure ;
57+ #ifdef bsdi
5358funlockfile (stream );
59+ #endif
5460return 0 ;
5561break ;
5662case SEEK_SET :
@@ -59,13 +65,17 @@ fseeko(FILE *stream, off_t offset, int whence)
5965return 0 ;
6066break ;
6167case SEEK_END :
68+ #ifdef bsdi
6269flockfile (stream );
70+ #endif
6371if (fstat (fileno (stream ),& filestat )!= 0 )
6472gotofailure ;
6573floc = filestat .st_size ;
6674if (fsetpos (stream ,& floc )!= 0 )
6775gotofailure ;
76+ #ifdef bsdi
6877funlockfile (stream );
78+ #endif
6979return 0 ;
7080break ;
7181default :
@@ -74,7 +84,9 @@ fseeko(FILE *stream, off_t offset, int whence)
7484}
7585
7686failure :
87+ #ifdef bsdi
7788funlockfile (stream );
89+ #endif
7890return -1 ;
7991}
8092