Add fseeko for NetBSD.
authorBruce Momjian
Thu, 24 Oct 2002 03:11:05 +0000 (03:11 +0000)
committerBruce Momjian
Thu, 24 Oct 2002 03:11:05 +0000 (03:11 +0000)
configure
configure.in
src/include/c.h
src/port/fseeko.c

index bc31d4d62e384f2d53c36f48500a7733ce14af84..325303a1ba9b6ced41bde9023b0325825309974f 100755 (executable)
--- a/configure
+++ b/configure
@@ -10543,9 +10543,10 @@ done
 
 
 
-# BSD/OS has a custom fseeko/ftello built on fsetpos/fgetpos
+# BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
 # We override the previous test that said fseeko/ftello didn't exist
-case $host_os in bsdi*)
+# OS tests are also done in include/c.h and port/fseeko.c
+case $host_os in bsdi*|netbsd*)
 ac_cv_func_fseeko=yes
 esac
 
index 266a290ab19f8480b81ef6c761e61336aa662811..783320a1586874dc2e9f2e5f657a89c5cf86cd64 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.215 2002/10/24 03:03:37 momjian Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.216 2002/10/24 03:11:05 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -837,9 +837,10 @@ fi
 
 AC_REPLACE_FUNCS([fseeko gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
 
-# BSD/OS has a custom fseeko/ftello built on fsetpos/fgetpos
+# BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
 # We override the previous test that said fseeko/ftello didn't exist
-case $host_os in bsdi*)
+# OS tests are also done in include/c.h and port/fseeko.c
+case $host_os in bsdi*|netbsd*)
 ac_cv_func_fseeko=yes
 esac
 
index ba0fb355d25c282b444c1a2d3dec9899b9f5eba8..0bdc2ab32c557d75c3f06a462c6e0a571a9bab98 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.129 2002/10/23 23:37:47 momjian Exp $
+ * $Id: c.h,v 1.130 2002/10/24 03:11:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -639,7 +639,7 @@ typedef NameData *Name;
 #include 
 #endif
 
-#if defined(bsdi)
+#if defined(bsdi) || defined(netbsd)
 int fseeko(FILE *stream, off_t offset, int whence);
 off_t ftello(FILE *stream);
 #endif
index dd4ef3247187dc6b834758b6e1e6a2a51dfe799d..ca68e1a272b8401773bb5127218a9231e419d31c 100644 (file)
@@ -8,12 +8,12 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.3 2002/10/23 21:39:27 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.4 2002/10/24 03:11:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
-#ifdef __bsdi__
+#if defined(bsdi) || defined(netbsd)
 
 #include 
 #include 
 #include 
 
 /*
- * On BSD/OS, off_t and fpos_t are the same.  Standards say
- * off_t is an arithmetic type, but not necessarily integral,
+ * On BSD/OS and NetBSD, off_t and fpos_t are the same.  Standards
+ * say off_t is an arithmetic type, but not necessarily integral,
  * while fpos_t might be neither.
  *
- * This is thread-safe using flockfile/funlockfile.
+ * This is thread-safe on BSD/OS using flockfile/funlockfile.
  */
 
 int
@@ -38,13 +38,17 @@ fseeko(FILE *stream, off_t offset, int whence)
    switch (whence)
    {
        case SEEK_CUR:
+#ifdef bsdi
            flockfile(stream);
+#endif
            if (fgetpos(stream, &floc) != 0)
                goto failure;
            floc += offset;
            if (fsetpos(stream, &floc) != 0)
                goto failure;
+#ifdef bsdi
            flockfile(stream);
+#endif
            return 0;
            break;
        case SEEK_SET:
@@ -53,13 +57,17 @@ fseeko(FILE *stream, off_t offset, int whence)
            return 0;
            break;
        case SEEK_END:
+#ifdef bsdi
            flockfile(stream);
+#endif
            if (fstat(fileno(stream), &filestat) != 0)
                goto failure;
            floc = filestat.st_size;
            if (fsetpos(stream, &floc) != 0)
                goto failure;
+#ifdef bsdi
            funlockfile(stream);
+#endif
            return 0;
            break;
        default:
@@ -68,7 +76,9 @@ fseeko(FILE *stream, off_t offset, int whence)
    }
 
 failure:
+#ifdef bsdi
    funlockfile(stream);
+#endif
    return -1;
 }