8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.3 2002/10/23 21:39:27 momjian Exp $
11
+ * $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.4 2002/10/24 03:11:05 momjian Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
15
15
16
- #ifdef __bsdi__
16
+ #if defined( bsdi ) || defined( netbsd )
17
17
18
18
#include <pthread.h>
19
19
#include <stdio.h>
22
22
#include <errno.h>
23
23
24
24
/*
25
- *On BSD/OS, off_t and fpos_t are the same. Standards say
26
- *off_t is an arithmetic type, but not necessarily integral,
25
+ *On BSD/OS and NetBSD , off_t and fpos_t are the same. Standards
26
+ *say off_t is an arithmetic type, but not necessarily integral,
27
27
*while fpos_t might be neither.
28
28
*
29
- *This is thread-safe using flockfile/funlockfile.
29
+ *This is thread-safeon BSD/OS using flockfile/funlockfile.
30
30
*/
31
31
32
32
int
@@ -38,13 +38,17 @@ fseeko(FILE *stream, off_t offset, int whence)
38
38
switch (whence )
39
39
{
40
40
case SEEK_CUR :
41
+ #ifdef bsdi
41
42
flockfile (stream );
43
+ #endif
42
44
if (fgetpos (stream ,& floc )!= 0 )
43
45
gotofailure ;
44
46
floc += offset ;
45
47
if (fsetpos (stream ,& floc )!= 0 )
46
48
gotofailure ;
49
+ #ifdef bsdi
47
50
flockfile (stream );
51
+ #endif
48
52
return 0 ;
49
53
break ;
50
54
case SEEK_SET :
@@ -53,13 +57,17 @@ fseeko(FILE *stream, off_t offset, int whence)
53
57
return 0 ;
54
58
break ;
55
59
case SEEK_END :
60
+ #ifdef bsdi
56
61
flockfile (stream );
62
+ #endif
57
63
if (fstat (fileno (stream ),& filestat )!= 0 )
58
64
gotofailure ;
59
65
floc = filestat .st_size ;
60
66
if (fsetpos (stream ,& floc )!= 0 )
61
67
gotofailure ;
68
+ #ifdef bsdi
62
69
funlockfile (stream );
70
+ #endif
63
71
return 0 ;
64
72
break ;
65
73
default :
@@ -68,7 +76,9 @@ fseeko(FILE *stream, off_t offset, int whence)
68
76
}
69
77
70
78
failure :
79
+ #ifdef bsdi
71
80
funlockfile (stream );
81
+ #endif
72
82
return -1 ;
73
83
}
74
84