Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc4d18e

Browse files
committed
Add fseeko/ftello using fsetpos/fgetpos for BSD/OS.
1 parent641b658 commitdc4d18e

File tree

3 files changed

+86
-3
lines changed

3 files changed

+86
-3
lines changed

‎configure

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10463,7 +10463,8 @@ fi
1046310463
1046410464
1046510465
10466-
forac_funcin gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul
10466+
10467+
forac_funcin fseeko gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul
1046710468
do
1046810469
as_ac_var=`echo"ac_cv_func_$ac_func"|$as_tr_sh`
1046910470
echo"$as_me:$LINENO: checking for$ac_func">&5
@@ -11470,6 +11471,9 @@ fi
1147011471
done
1147111472
1147211473
11474+
case$host_osin bsdi*)
11475+
ac_cv_func_fseeko=yes
11476+
esac
1147311477
echo"$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files">&5
1147411478
echo$ECHO_N"checking for _LARGEFILE_SOURCE value needed for large files...$ECHO_C">&6
1147511479
iftest"${ac_cv_sys_largefile_source+set}" =set;then

‎configure.in

Lines changed: 5 additions & 2 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.211 2002/09/25 13:23:15 momjian Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.212 2002/10/23 20:56:24 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -835,7 +835,7 @@ else
835835
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
836836
fi
837837

838-
AC_REPLACE_FUNCS([gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
838+
AC_REPLACE_FUNCS([fseekogethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
839839

840840
# Solaris has a very slow qsort in certain cases.
841841
case $host_os in
@@ -903,6 +903,9 @@ AC_CHECK_FUNCS(atexit, [],
903903
[AC_CHECK_FUNCS(on_exit, [],
904904
[AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
905905

906+
case $host_os in bsdi*)
907+
ac_cv_func_fseeko=yes
908+
esac
906909
AC_FUNC_FSEEKO
907910

908911

‎src/port/fseeko.c

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* fseeko.c
4+
* 64-bit versions of fseeko/ftello()
5+
*
6+
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
*
10+
* IDENTIFICATION
11+
* $Header: /cvsroot/pgsql/src/port/fseeko.c,v 1.1 2002/10/23 20:56:24 momjian Exp $
12+
*
13+
*-------------------------------------------------------------------------
14+
*/
15+
16+
#ifdef__bsdi__
17+
18+
#include<stdio.h>
19+
#include<sys/types.h>
20+
#include<sys/stat.h>
21+
#include<errno.h>
22+
23+
/*
24+
*On BSD/OS, off_t and fpos_t are the same. Standards say
25+
*off_t is an arithmetic type, but not necessarily integral,
26+
*while fpos_t might be neither.
27+
*
28+
*I don't think this is thread-safe.
29+
*/
30+
31+
int
32+
fseeko(FILE*stream,off_toffset,intwhence)
33+
{
34+
off_tfloc;
35+
structstatfilestat;
36+
37+
switch (whence)
38+
{
39+
caseSEEK_CUR:
40+
if (fgetpos(stream,&floc)!=0)
41+
return-1;
42+
floc+=offset;
43+
if (fsetpos(stream,&floc)!=0)
44+
return-1;
45+
return0;
46+
break;
47+
caseSEEK_SET:
48+
if (fsetpos(stream,&offset)!=0)
49+
return-1;
50+
return0;
51+
break;
52+
caseSEEK_END:
53+
if (fstat(fileno(stream),&filestat)!=0)
54+
return-1;
55+
floc=filestat.st_size;
56+
if (fsetpos(stream,&floc)!=0)
57+
return-1;
58+
return0;
59+
break;
60+
default:
61+
errno=EINVAL;
62+
return-1;
63+
}
64+
}
65+
66+
67+
off_t
68+
ftello(FILE*stream)
69+
{
70+
off_tfloc;
71+
72+
if (fgetpos(stream,&floc)!=0)
73+
return-1;
74+
returnfloc;
75+
}
76+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp