Skip to content

Commit 4668d54

Browse files
committed
Add fseeko for NetBSD.
1 parent d36caf1 commit 4668d54

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

configure

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10543,9 +10543,10 @@ done
1054310543
1054410544
1054510545
10546-
# BSD/OS has a custom fseeko/ftello built on fsetpos/fgetpos
10546+
# BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
1054710547
# We override the previous test that said fseeko/ftello didn't exist
10548-
case $host_os in bsdi*)
10548+
# OS tests are also done in include/c.h and port/fseeko.c
10549+
case $host_os in bsdi*|netbsd*)
1054910550
ac_cv_func_fseeko=yes
1055010551
esac
1055110552

configure.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.215 2002/10/24 03:03:37 momjian Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.216 2002/10/24 03:11:05 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -837,9 +837,10 @@ fi
837837

838838
AC_REPLACE_FUNCS([fseeko gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
839839

840-
# BSD/OS has a custom fseeko/ftello built on fsetpos/fgetpos
840+
# BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
841841
# We override the previous test that said fseeko/ftello didn't exist
842-
case $host_os in bsdi*)
842+
# OS tests are also done in include/c.h and port/fseeko.c
843+
case $host_os in bsdi*|netbsd*)
843844
ac_cv_func_fseeko=yes
844845
esac
845846

src/include/c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: c.h,v 1.129 2002/10/23 23:37:47 momjian Exp $
15+
* $Id: c.h,v 1.130 2002/10/24 03:11:05 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -639,7 +639,7 @@ typedef NameData *Name;
639639
#include <unistd.h>
640640
#endif
641641

642-
#if defined(bsdi)
642+
#if defined(bsdi) || defined(netbsd)
643643
int fseeko(FILE *stream, off_t offset, int whence);
644644
off_t ftello(FILE *stream);
645645
#endif

src/port/fseeko.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#ifdef __bsdi__
16+
#if defined(bsdi) || defined(netbsd)
1717

1818
#include <pthread.h>
1919
#include <stdio.h>
@@ -22,11 +22,11 @@
2222
#include <errno.h>
2323

2424
/*
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,
2727
* while fpos_t might be neither.
2828
*
29-
* This is thread-safe using flockfile/funlockfile.
29+
* This is thread-safe on BSD/OS using flockfile/funlockfile.
3030
*/
3131

3232
int
@@ -38,13 +38,17 @@ fseeko(FILE *stream, off_t offset, int whence)
3838
switch (whence)
3939
{
4040
case SEEK_CUR:
41+
#ifdef bsdi
4142
flockfile(stream);
43+
#endif
4244
if (fgetpos(stream, &floc) != 0)
4345
goto failure;
4446
floc += offset;
4547
if (fsetpos(stream, &floc) != 0)
4648
goto failure;
49+
#ifdef bsdi
4750
flockfile(stream);
51+
#endif
4852
return 0;
4953
break;
5054
case SEEK_SET:
@@ -53,13 +57,17 @@ fseeko(FILE *stream, off_t offset, int whence)
5357
return 0;
5458
break;
5559
case SEEK_END:
60+
#ifdef bsdi
5661
flockfile(stream);
62+
#endif
5763
if (fstat(fileno(stream), &filestat) != 0)
5864
goto failure;
5965
floc = filestat.st_size;
6066
if (fsetpos(stream, &floc) != 0)
6167
goto failure;
68+
#ifdef bsdi
6269
funlockfile(stream);
70+
#endif
6371
return 0;
6472
break;
6573
default:
@@ -68,7 +76,9 @@ fseeko(FILE *stream, off_t offset, int whence)
6876
}
6977

7078
failure:
79+
#ifdef bsdi
7180
funlockfile(stream);
81+
#endif
7282
return -1;
7383
}
7484

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy