mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
build: include standards macros for all AST code (re: 7fb814e1
)
Turns out that the standards macros set by features/standards (such as _GNU_SOURCE for Linux or _DARWIN_SOURCE for macOS) were still *not* included for most C source files! Instead, they were selectively included for some files only, sometimes via FEATURE/standards (the output of features/standards), sometimes via ast_standards.h which is copied from FEATURE/standards. Consequently, there were still inconsistencies in the system header interfaces exposed on Linux, macOS, Solaris, et al. It's no wonder it sometimes took so much hackery to keep everything building. Of course, making this consistent had to break things somewhere. Breakage occurred on 32-bit Linux due to a lot of ugly hackery involving direct use of internal GNU types like off64_t and functions like fseek64(). This is now all removed and they are activated by setting the appropriate feature macro instead, so these types and functions can be used with their standard names (off_t, fseek, etc.) Before committing I've tested these changes on the following i386/x86_64 systems: Linux (glibc 32 and 64 bit, musl libc 64 bit), Solaris (32 and 64 bit), illumos (32 and 64 bit), FreeBSD (64 bit), macOS (64 bit), Cygwin (32 bit), and Haiku (64 bit). (Note: ast_standards.h is copied from FEATURE/standards, whereas ast_common.h is copied from FEATURE/common.) src/lib/libast/include/ast_std.h, src/lib/libast/stdio/stdhdr.h: - Include <ast_standards.h> first. This should cause all the AST and dependent code (such as ksh) to get the standards macros. src/lib/libast/features/standards: - For GNU (glibc), #define _FILE_OFFSET_BITS 64 to get large file support with 64-bit offsets. - Stop GNU and Cygwin <string.h> form defining the GNU version of basename(3); on Cygwin, that declaration conflicts with the AST version (and with POSIX) by using a const char* argument instead of char*. It is deactivated by defining the macro 'basename' (as 'basename'); this causes GNU string.h to consider it to be already defined by the standard libgen.h header. All other changed files: - Remove direct use of *64* types and functions and a lot of related hackery.
This commit is contained in:
parent
fb8e239cb4
commit
289dd46c05
43 changed files with 78 additions and 872 deletions
|
@ -491,13 +491,8 @@ extern Shell_t sh;
|
|||
# define write(a,b,c) sh_write(a,b,c)
|
||||
# define umask(a) sh_umask(a)
|
||||
# define dup sh_dup
|
||||
# if _lib_lseek64
|
||||
# define open64 sh_open
|
||||
# define lseek64 sh_seek
|
||||
# else
|
||||
# define open sh_open
|
||||
# define lseek sh_seek
|
||||
# endif
|
||||
# define open sh_open
|
||||
# define lseek sh_seek
|
||||
#endif /* !defs_h_defined */
|
||||
|
||||
#define SH_SIGSET 4
|
||||
|
|
|
@ -23,12 +23,15 @@ make install
|
|||
make ast
|
||||
make libast.a archive
|
||||
make ast.req
|
||||
make FEATURE/standards
|
||||
meta FEATURE/standards features/%>FEATURE/% features/standards standards
|
||||
make features/standards
|
||||
done features/standards
|
||||
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS}" run features/standards
|
||||
done FEATURE/standards generated
|
||||
make ast_standards.h implicit
|
||||
make FEATURE/standards
|
||||
meta FEATURE/standards features/%>FEATURE/% features/standards standards
|
||||
make features/standards
|
||||
done features/standards
|
||||
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS}" run features/standards
|
||||
done FEATURE/standards generated
|
||||
exec - cmp 2>/dev/null -s FEATURE/standards ast_standards.h || { rm -f ast_standards.h; ${STDCP} FEATURE/standards ast_standards.h; }
|
||||
done ast_standards.h generated
|
||||
make FEATURE/lib
|
||||
meta FEATURE/lib features/%>FEATURE/% features/lib lib
|
||||
make features/lib
|
||||
|
@ -262,6 +265,7 @@ make install
|
|||
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS}" run features/fs
|
||||
done FEATURE/fs generated
|
||||
prev FEATURE/lib implicit
|
||||
prev FEATURE/standards implicit
|
||||
done features/fcntl.c
|
||||
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -I. -Icomp -Iinclude -Istd ${LDFLAGS}" run features/fcntl.c
|
||||
make ast_fs.h implicit
|
||||
|
@ -282,6 +286,7 @@ make install
|
|||
exec - cmp 2>/dev/null -s FEATURE/lib ast_lib.h || { rm -f ast_lib.h; silent test -d . || mkdir .; ${STDCP} FEATURE/lib ast_lib.h; }
|
||||
done ast_lib.h dontcare generated
|
||||
prev ast_common.h implicit
|
||||
prev ast_standards.h implicit
|
||||
done include/ast_std.h dontcare
|
||||
done FEATURE/stdio generated
|
||||
exec - cmp 2>/dev/null -s FEATURE/stdio ast_stdio.h || { rm -f ast_stdio.h; silent test -d . || mkdir .; ${STDCP} FEATURE/stdio ast_stdio.h; }
|
||||
|
@ -1482,10 +1487,7 @@ make install
|
|||
done include/mc.h
|
||||
prev ast_wchar.h implicit
|
||||
prev port/lclib.h implicit
|
||||
make ast_standards.h implicit
|
||||
prev FEATURE/standards
|
||||
exec - cmp 2>/dev/null -s FEATURE/standards ast_standards.h || { rm -f ast_standards.h; silent test -d . || mkdir .; ${STDCP} FEATURE/standards ast_standards.h; }
|
||||
done ast_standards.h generated
|
||||
prev ast_standards.h implicit
|
||||
done comp/setlocale.c
|
||||
meta setlocale.o %.c>%.o comp/setlocale.c setlocale
|
||||
prev comp/setlocale.c
|
||||
|
@ -2104,7 +2106,6 @@ make install
|
|||
done include/wait.h dontcare
|
||||
prev sig.h implicit
|
||||
prev include/ast.h implicit
|
||||
prev ast_standards.h implicit
|
||||
done misc/proclib.h
|
||||
done misc/procopen.c
|
||||
meta procopen.o %.c>%.o misc/procopen.c procopen
|
||||
|
@ -3207,14 +3208,6 @@ make install
|
|||
prev comp/waitpid.c
|
||||
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -I. -Icomp -Iinclude -Istd -D_PACKAGE_ast -c comp/waitpid.c
|
||||
done waitpid.o generated
|
||||
make creat64.o
|
||||
make comp/creat64.c
|
||||
prev include/ast.h implicit
|
||||
done comp/creat64.c
|
||||
meta creat64.o %.c>%.o comp/creat64.c creat64
|
||||
prev comp/creat64.c
|
||||
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -I. -Icomp -Iinclude -Istd -D_PACKAGE_ast -c comp/creat64.c
|
||||
done creat64.o generated
|
||||
make fcntl.o
|
||||
make comp/fcntl.c
|
||||
prev include/error.h implicit
|
||||
|
@ -4703,6 +4696,7 @@ make install
|
|||
make stdio/stdhdr.h implicit
|
||||
prev std/stdio.h implicit
|
||||
prev sfio/sfhdr.h implicit
|
||||
prev ast_standards.h implicit
|
||||
done stdio/stdhdr.h
|
||||
done stdio/clearerr.c
|
||||
meta clearerr.o %.c>%.o stdio/clearerr.c clearerr
|
||||
|
@ -6075,7 +6069,7 @@ make install
|
|||
exec - ${AR} rc libast.a state.o transition.o opendir.o readdir.o rewinddir.o seekdir.o telldir.o getcwd.o fastfind.o hashalloc.o hashdump.o hashfree.o hashlast.o hashlook.o hashscan.o hashsize.o hashview.o hashwalk.o memhash.o memsum.o strhash.o strkey.o strsum.o stracmp.o strnacmp.o ccmap.o ccmapid.o ccnative.o chresc.o chrtoi.o
|
||||
exec - ${AR} rc libast.a streval.o strexpr.o strmatch.o strcopy.o modei.o modex.o strmode.o strlcat.o strlcpy.o strlook.o strncopy.o strsearch.o strpsearch.o stresc.o stropt.o strtape.o strpcmp.o strnpcmp.o strvcmp.o strnvcmp.o tok.o tokline.o tokscan.o pathaccess.o pathcat.o pathcanon.o pathcheck.o pathpath.o pathexists.o pathfind.o pathicase.o pathkey.o pathprobe.o pathrepl.o pathnative.o pathposix.o pathtemp.o pathtmp.o pathstat.o pathgetlink.o pathsetlink.o pathbin.o pathshell.o pathcd.o pathprog.o ftwalk.o ftwflags.o fts.o astintercept.o conformance.o getenv.o setenviron.o optget.o optjoin.o optesc.o optctx.o strsort.o struniq.o magic.o mime.o mimetype.o signal.o sigflag.o systrace.o error.o errorf.o errormsg.o errorx.o localeconv.o setlocale.o translate.o catopen.o iconv.o lc.o lctab.o mc.o base64.o recfmt.o recstr.o reclen.o fmtrec.o fmtbase.o fmtbuf.o fmtclock.o fmtdev.o fmtelapsed.o fmterror.o fmtesc.o fmtfmt.o fmtfs.o fmtident.o fmtint.o fmtip4.o fmtip6.o fmtls.o fmtmatch.o fmtmode.o fmtnum.o fmtperm.o fmtre.o fmttime.o
|
||||
exec - ${AR} rc libast.a fmtuid.o fmtgid.o fmtsignal.o fmtscale.o fmttmx.o fmttv.o fmtversion.o strelapsed.o strperm.o struid.o strgid.o strtoip4.o strtoip6.o stack.o stk.o swapget.o swapmem.o swapop.o swapput.o sigdata.o sigcrit.o sigunblock.o procopen.o procclose.o procrun.o procfree.o tmdate.o tmequiv.o tmfix.o tmfmt.o tmform.o tmgoff.o tminit.o tmleap.o tmlex.o tmlocale.o tmmake.o tmpoff.o tmscan.o tmsleep.o tmtime.o tmtype.o tmweek.o tmword.o tmzone.o tmxdate.o tmxduration.o tmxfmt.o tmxgettime.o tmxleap.o tmxmake.o tmxscan.o tmxsettime.o tmxsleep.o tmxtime.o tmxtouch.o tvcmp.o tvgettime.o tvsettime.o tvsleep.o tvtouch.o cmdarg.o vecargs.o vecfile.o vecfree.o vecload.o vecstring.o univdata.o touch.o mnt.o debug.o memccpy.o memchr.o memcmp.o memcpy.o memdup.o memmove.o memset.o mkdir.o mkfifo.o mknod.o rmdir.o remove.o rename.o link.o unlink.o strdup.o strchr.o strrchr.o strstr.o strtod.o strtold.o strtol.o strtoll.o strtoul.o strtoull.o strton.o strtonll.o strntod.o strntold.o strnton.o
|
||||
exec - ${AR} rc libast.a strntonll.o strntol.o strntoll.o strntoul.o strntoull.o strcasecmp.o strncasecmp.o strerror.o mktemp.o tmpnam.o fsync.o execlp.o execve.o execvp.o execvpe.o spawnveg.o vfork.o killpg.o hsearch.o tsearch.o getlogin.o putenv.o setenv.o unsetenv.o lstat.o statvfs.o eaccess.o gross.o omitted.o readlink.o symlink.o getpgrp.o setpgid.o setsid.o waitpid.o creat64.o fcntl.o open.o atexit.o getdents.o getwd.o dup2.o errno.o getpreroot.o ispreroot.o realopen.o setpreroot.o getgroups.o mount.o system.o iblocks.o modedata.o tmdata.o memfatal.o sfkeyprintf.o sfdcdio.o sfdcdos.o sfdcfilter.o sfdcseekable.o sfdcslow.o sfdcsubstr.o sfdctee.o sfdcunion.o sfdcmore.o sfdcprefix.o wc.o wc2utf8.o basename.o closelog.o dirname.o fmtmsglib.o fnmatch.o ftw.o getdate.o getsubopt.o glob.o nftw.o openlog.o re_comp.o resolvepath.o realpath.o regcmp.o regexp.o setlogmask.o strftime.o strptime.o swab.o syslog.o tempnam.o wordexp.o mktime.o regalloc.o regclass.o regcoll.o regcomp.o regcache.o regdecomp.o regerror.o regexec.o regfatal.o reginit.o
|
||||
exec - ${AR} rc libast.a strntonll.o strntol.o strntoll.o strntoul.o strntoull.o strcasecmp.o strncasecmp.o strerror.o mktemp.o tmpnam.o fsync.o execlp.o execve.o execvp.o execvpe.o spawnveg.o vfork.o killpg.o hsearch.o tsearch.o getlogin.o putenv.o setenv.o unsetenv.o lstat.o statvfs.o eaccess.o gross.o omitted.o readlink.o symlink.o getpgrp.o setpgid.o setsid.o waitpid.o fcntl.o open.o atexit.o getdents.o getwd.o dup2.o errno.o getpreroot.o ispreroot.o realopen.o setpreroot.o getgroups.o mount.o system.o iblocks.o modedata.o tmdata.o memfatal.o sfkeyprintf.o sfdcdio.o sfdcdos.o sfdcfilter.o sfdcseekable.o sfdcslow.o sfdcsubstr.o sfdctee.o sfdcunion.o sfdcmore.o sfdcprefix.o wc.o wc2utf8.o basename.o closelog.o dirname.o fmtmsglib.o fnmatch.o ftw.o getdate.o getsubopt.o glob.o nftw.o openlog.o re_comp.o resolvepath.o realpath.o regcmp.o regexp.o setlogmask.o strftime.o strptime.o swab.o syslog.o tempnam.o wordexp.o mktime.o regalloc.o regclass.o regcoll.o regcomp.o regcache.o regdecomp.o regerror.o regexec.o regfatal.o reginit.o
|
||||
exec - ${AR} rc libast.a regnexec.o regsubcomp.o regsubexec.o regsub.o regrecord.o regrexec.o regstat.o dtclose.o dtdisc.o dthash.o dtlist.o dtmethod.o dtopen.o dtstat.o dtstrhash.o dttree.o dtuser.o dtview.o dtwalk.o dtnew.o dtcomp.o sfclose.o sfclrlock.o sfdisc.o sfdlen.o sfexcept.o sfgetl.o sfgetu.o sfcvt.o sfecvt.o sffcvt.o sfextern.o sffilbuf.o sfflsbuf.o sfprints.o sfgetd.o sfgetr.o sfllen.o sfmode.o sfmove.o sfnew.o sfpkrd.o sfnotify.o sfnputc.o sfopen.o sfpeek.o sfpoll.o sfpool.o sfpopen.o sfprintf.o sfputd.o sfputl.o sfputr.o sfputu.o sfrd.o sfread.o sfreserve.o sfscanf.o sfseek.o sfset.o sfsetbuf.o sfsetfd.o sfsize.o sfsk.o sfstack.o sfstrtod.o sfsync.o sfswap.o sftable.o sftell.o sftmp.o sfungetc.o sfvprintf.o sfvscanf.o sfwr.o sfwrite.o sfpurge.o sfraise.o sfwalk.o sfgetm.o sfmutex.o sfputm.o sfresize.o _sfclrerr.o _sfeof.o _sferror.o _sffileno.o _sfopen.o _sfstacked.o _sfvalue.o _sfgetc.o _sfgetl.o _sfgetl2.o _sfgetu.o _sfgetu2.o _sfdlen.o _sfllen.o _sfslen.o _sfulen.o _sfputc.o _sfputd.o _sfputl.o _sfputm.o
|
||||
exec - ${AR} rc libast.a _sfputu.o clearerr.o fclose.o fdopen.o feof.o ferror.o fflush.o fgetc.o fgetpos.o fgets.o fileno.o fopen.o fprintf.o fpurge.o fputc.o fputs.o fread.o freopen.o fscanf.o fseek.o fseeko.o fsetpos.o ftell.o ftello.o fwrite.o flockfile.o ftrylockfile.o funlockfile.o getc.o getchar.o getw.o pclose.o popen.o printf.o putc.o putchar.o puts.o putw.o rewind.o scanf.o setbuf.o setbuffer.o setlinebuf.o setvbuf.o snprintf.o sprintf.o sscanf.o asprintf.o vasprintf.o tmpfile.o ungetc.o vfprintf.o vfscanf.o vprintf.o vscanf.o vsnprintf.o vsprintf.o vsscanf.o _doprnt.o _doscan.o _filbuf.o _flsbuf.o _stdfun.o _stdopen.o _stdprintf.o _stdscanf.o _stdsprnt.o _stdvbuf.o _stdvsnprnt.o _stdvsprnt.o _stdvsscn.o fgetwc.o fwprintf.o putwchar.o vfwscanf.o wprintf.o fgetws.o fwscanf.o swprintf.o vswprintf.o wscanf.o fputwc.o getwc.o swscanf.o vswscanf.o fputws.o getwchar.o ungetwc.o vwprintf.o fwide.o putwc.o vfwprintf.o vwscanf.o stdio_c99.o fcloseall.o fmemopen.o getdelim.o getline.o frexp.o frexpl.o astcopy.o
|
||||
exec - ${AR} rc libast.a astconf.o astdynamic.o astquery.o astwinsize.o conftab.o aststatic.o getopt.o getoptl.o aso.o asolock.o asometh.o asorelax.o aso-sem.o aso-fcntl.o vmbest.o vmclear.o vmclose.o vmdcheap.o vmdebug.o vmdisc.o vmexit.o vmlast.o vmopen.o vmpool.o vmprivate.o vmprofile.o vmregion.o vmsegment.o vmset.o vmstat.o vmstrdup.o vmtrace.o vmwalk.o vmmopen.o malloc.o vmgetmem.o a64l.o acosh.o asinh.o atanh.o cbrt.o crypt.o erf.o err.o exp.o exp__E.o expm1.o gamma.o getpass.o lgamma.o log.o log1p.o log__L.o rand48.o random.o rcmd.o rint.o support.o
|
||||
|
|
|
@ -50,9 +50,7 @@
|
|||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if _hdr_unistd
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define _typ_int32_t 1
|
||||
#ifdef _ast_int8_t
|
||||
|
|
|
@ -170,26 +170,6 @@ KERNEL_STAMP SVID SI 1 O
|
|||
KERN_POINTERS C QQ 1 L
|
||||
KERN_SIM C QQ 1 L
|
||||
LEGACY XOPEN SC 1 FU
|
||||
LFS_CFLAGS POSIX CS 1 MU cc{ -D_LARGEFILE_SOURCE "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" -D_LARGEFILE64_SOURCE -64
|
||||
#include <sys/types.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
if (sizeof(off_t) >= sizeof(off_64_t))
|
||||
{
|
||||
printf("-");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
LFS64_CFLAGS POSIX CS 1 MU : LFS_CFLAGS
|
||||
LFS64_LDFLAGS POSIX CS 1 MU : LFS_CFLAGS
|
||||
LFS64_LIBS POSIX CS 1 MU
|
||||
LFS64_LINTFLAGS POSIX CS 1 MU : LFS_CFLAGS
|
||||
LFS_LDFLAGS POSIX CS 1 MU : LFS_CFLAGS
|
||||
LFS_LIBS POSIX CS 1 MU
|
||||
LFS_LINTFLAGS POSIX CS 1 MU : LFS_CFLAGS
|
||||
LINE_MAX POSIX SC 2 LMN 2048
|
||||
LINK_MAX POSIX PC 1 LMU MAXLINK SHRT_MAX 8
|
||||
LLONG_MAX C XX 1 L
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/***********************************************************************
|
||||
* *
|
||||
* This software is part of the ast package *
|
||||
* Copyright (c) 1985-2011 AT&T Intellectual Property *
|
||||
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
|
||||
* and is licensed under the *
|
||||
* Eclipse Public License, Version 1.0 *
|
||||
* by AT&T Intellectual Property *
|
||||
* *
|
||||
* A copy of the License is available at *
|
||||
* http://www.eclipse.org/org/documents/epl-v10.html *
|
||||
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
|
||||
* *
|
||||
* Information and Software Systems Research *
|
||||
* AT&T Research *
|
||||
* Florham Park NJ *
|
||||
* *
|
||||
* Glenn Fowler <gsf@research.att.com> *
|
||||
* David Korn <dgk@research.att.com> *
|
||||
* Phong Vo <kpv@research.att.com> *
|
||||
* *
|
||||
***********************************************************************/
|
||||
|
||||
#include <ast.h>
|
||||
|
||||
#if defined(_lib_creat64) || !defined(_lib_open64)
|
||||
|
||||
NoN(creat64)
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
creat64(const char* path, mode_t mode)
|
||||
{
|
||||
return open64(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -62,37 +62,6 @@ extern int stat(const char* path, struct stat* st)
|
|||
|
||||
#endif
|
||||
|
||||
#if _lcl_xstat64
|
||||
|
||||
extern int fstat64(int fd, struct stat64* st)
|
||||
{
|
||||
#if _lib___fxstat64
|
||||
return __fxstat64(_STAT_VER, fd, st);
|
||||
#else
|
||||
return _fxstat64(_STAT_VER, fd, st);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int lstat64(const char* path, struct stat64* st)
|
||||
{
|
||||
#if _lib___lxstat64
|
||||
return __lxstat64(_STAT_VER, path, st);
|
||||
#else
|
||||
return _lxstat64(_STAT_VER, path, st);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int stat64(const char* path, struct stat64* st)
|
||||
{
|
||||
#if _lib___xstat64
|
||||
return __xstat64(_STAT_VER, path, st);
|
||||
#else
|
||||
return _xstat64(_STAT_VER, path, st);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if __sgi && _hdr_locale_attr
|
||||
|
||||
#include "gross_sgi.h"
|
||||
|
|
|
@ -50,13 +50,7 @@ __STDPP__directive pragma pp:hide getdents getdirentries
|
|||
|
||||
#ifndef _DIRENT_H
|
||||
#if _hdr_dirent
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#if _typ_off64_t
|
||||
#define off_t off64_t
|
||||
#endif
|
||||
#else
|
||||
#if _hdr_ndir
|
||||
#include <ndir.h>
|
||||
|
@ -99,13 +93,7 @@ __STDPP__directive pragma pp:hide DIR closedir opendir readdir seekdir telldir
|
|||
|
||||
#ifndef _DIRENT_H
|
||||
#if _hdr_dirent
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#if _typ_off64_t
|
||||
#define off_t off64_t
|
||||
#endif
|
||||
#else
|
||||
#if _hdr_direntry
|
||||
#include <direntry.h>
|
||||
|
|
|
@ -1,27 +1,8 @@
|
|||
set nodefine
|
||||
lib stat64
|
||||
typ off64_t
|
||||
set define
|
||||
|
||||
lib opendir
|
||||
hdr dirent,ndir
|
||||
sys dir
|
||||
nxt dirent
|
||||
|
||||
tst botch_d_ino_dirent64 note{ dirent64.d_ino vs. readdir64 mismatch }end compile{
|
||||
#if !__arm__
|
||||
)
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
struct dirent64 ent;
|
||||
char aha[5-((int)sizeof(ent.d_ino))];
|
||||
return sizeof(aha);
|
||||
}
|
||||
}end
|
||||
|
||||
if ( ! _lib_opendir ) {
|
||||
/*
|
||||
* <dirent.h> for systems with no opendir()
|
||||
|
@ -63,94 +44,6 @@ if ( ! _lib_opendir ) {
|
|||
|
||||
#endif
|
||||
}
|
||||
elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t && _botch_d_ino_dirent64 ) pass{
|
||||
cat <<!
|
||||
/*
|
||||
* <dirent.h> for [fl]stat64 and off64_t with sizeof(ino64_t)==4
|
||||
*/
|
||||
|
||||
#ifndef _AST_STD_H
|
||||
|
||||
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
|
||||
|
||||
#else
|
||||
|
||||
#ifndef _DIR64_H
|
||||
#define _DIR64_H
|
||||
|
||||
#include <ast_std.h>
|
||||
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#endif
|
||||
|
||||
#undef __ino64_t
|
||||
#define __ino64_t int64_t
|
||||
|
||||
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
|
||||
|
||||
#undef __ino64_t
|
||||
#define __ino64_t __ino64_t
|
||||
|
||||
#if _typ_off64_t
|
||||
#define off_t off64_t
|
||||
#endif
|
||||
|
||||
#if _lib_readdir64 && _typ_struct_dirent64
|
||||
#ifndef dirent
|
||||
#define dirent dirent64
|
||||
#endif
|
||||
#ifndef readdir
|
||||
#define readdir readdir64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
!
|
||||
}end
|
||||
elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t ) pass{
|
||||
cat <<!
|
||||
/*
|
||||
* <dirent.h> for [fl]stat64 and off64_t
|
||||
*/
|
||||
|
||||
#ifndef _AST_STD_H
|
||||
|
||||
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
|
||||
|
||||
#else
|
||||
|
||||
#ifndef _DIR64_H
|
||||
#define _DIR64_H
|
||||
|
||||
#include <ast_std.h>
|
||||
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#endif
|
||||
|
||||
#include ${_nxt_dirent-_nxt_dirent} /* the native <dirent.h> */
|
||||
|
||||
#if _typ_off64_t
|
||||
#define off_t off64_t
|
||||
#endif
|
||||
|
||||
#if _lib_readdir64 && _typ_struct_dirent64
|
||||
#ifndef dirent
|
||||
#define dirent dirent64
|
||||
#endif
|
||||
#ifndef readdir
|
||||
#define readdir readdir64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
!
|
||||
}end
|
||||
elif ( _nxt_dirent && _hdr_dirent ) pass{
|
||||
cat <<!
|
||||
/*
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
* generate POSIX fcntl.h
|
||||
*/
|
||||
|
||||
#include "FEATURE/standards"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "FEATURE/lib"
|
||||
|
@ -35,17 +37,10 @@
|
|||
#define getpagesize ______getpagesize
|
||||
#define ioctl ______ioctl
|
||||
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#define off_t off_t
|
||||
#endif
|
||||
|
||||
#if _hdr_fcntl
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#if _hdr_unistd
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -57,11 +52,6 @@
|
|||
|
||||
#include "FEATURE/tty"
|
||||
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#define off_t off64_t
|
||||
#endif
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
@ -69,18 +59,7 @@ main()
|
|||
int f_lck = 0;
|
||||
int o_local = 2;
|
||||
|
||||
printf("#if _typ_off64_t\n");
|
||||
printf("#undef off_t\n");
|
||||
printf("#define off_t off_t\n");
|
||||
printf("#endif\n");
|
||||
printf("\n");
|
||||
printf("#include <ast_fs.h>\n");
|
||||
printf("\n");
|
||||
printf("#if _typ_off64_t\n");
|
||||
printf("#undef off_t\n");
|
||||
printf("#define off_t off_t\n");
|
||||
printf("#endif\n");
|
||||
printf("\n");
|
||||
printf("#include <fcntl.h>\n");
|
||||
#if _hdr_mman
|
||||
printf("#include <mman.h>\n");
|
||||
|
@ -334,29 +313,6 @@ main()
|
|||
#endif
|
||||
printf("\n");
|
||||
printf("#include <ast_fs.h>\n");
|
||||
printf("#if _typ_off64_t\n");
|
||||
printf("#undef off_t\n");
|
||||
printf("#define off_t off64_t\n");
|
||||
printf("#endif\n");
|
||||
printf("#if _lib_fstat64\n");
|
||||
printf("#define fstat fstat64\n");
|
||||
printf("#endif\n");
|
||||
printf("#if _lib_lstat64\n");
|
||||
printf("#define lstat lstat64\n");
|
||||
printf("#endif\n");
|
||||
printf("#if _lib_stat64\n");
|
||||
printf("#define stat stat64\n");
|
||||
printf("#endif\n");
|
||||
printf("#if _lib_creat64\n");
|
||||
printf("#define creat creat64\n");
|
||||
printf("#endif\n");
|
||||
printf("#if _lib_mmap64\n");
|
||||
printf("#define mmap mmap64\n");
|
||||
printf("#endif\n");
|
||||
printf("#if _lib_open64\n");
|
||||
printf("#undef open\n");
|
||||
printf("#define open open64\n");
|
||||
printf("#endif\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
lib _fxstat,__fxstat,_lxstat,__lxstat,_xmknod,__xmknod,_xstat,__xstat,lstat,mknod,sync sys/types.h sys/stat.h
|
||||
lib _fxstat64,__fxstat64,_lxstat64,__lxstat64,_xstat64,__xstat64 sys/types.h sys/stat.h
|
||||
mac fstat,lstat,stat,mknod sys/types.h sys/stat.h
|
||||
|
||||
lcl xstat link{
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
struct stat64 { int xxx; }; /* disable if stat64 available */
|
||||
extern int stat(const char* path, struct stat* st)
|
||||
{
|
||||
#if _lib___xstat
|
||||
|
@ -22,25 +20,6 @@ lcl xstat link{
|
|||
}
|
||||
}end
|
||||
|
||||
lcl xstat64 link{
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
extern int stat64(const char* path, struct stat64* st)
|
||||
{
|
||||
#if _lib___xstat64
|
||||
return __xstat64(_STAT_VER, path, st);
|
||||
#else
|
||||
return _xstat64(_STAT_VER, path, st);
|
||||
#endif
|
||||
}
|
||||
int
|
||||
main()
|
||||
{
|
||||
struct stat64 st;
|
||||
return stat64(".",&st) < 0;
|
||||
}
|
||||
}end
|
||||
|
||||
header sys/stat.h
|
||||
header sys/mkdev.h
|
||||
|
||||
|
@ -206,22 +185,6 @@ cat{
|
|||
extern int fstatvfs(int, struct statvfs*);
|
||||
extern int statvfs(const char*, struct statvfs*);
|
||||
#endif
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#define off_t off64_t
|
||||
#if _lib_statvfs64 && !defined(statvfs)
|
||||
#define statvfs statvfs64
|
||||
#if !defined(__USE_LARGEFILE64)
|
||||
extern int statvfs64(const char*, struct statvfs64*);
|
||||
#endif
|
||||
#endif
|
||||
#if _lib_fstatvfs64 && !defined(fstatvfs)
|
||||
#define fstatvfs fstatvfs64
|
||||
#if !defined(__USE_LARGEFILE64)
|
||||
extern int fstatvfs64(int, struct statvfs64*);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* _typ_off64_t */
|
||||
}end
|
||||
|
||||
str st_fstype sys/types.h sys/stat.h note{ stat.st_fstype is a string }end compile{
|
||||
|
|
|
@ -41,9 +41,6 @@ lib strchr,strcoll,strdup,strerror,strcasecmp,strncasecmp,strrchr,strstr
|
|||
lib strmode,strxfrm,strftime,swab,symlink,sysconf,sysinfo,syslog
|
||||
lib telldir,tmpnam,tzset,universe,unlink,utime,wctype
|
||||
lib ftruncate,truncate
|
||||
lib creat64,fstat64,fstatvfs64,ftruncate64
|
||||
lib lseek64,lstat64
|
||||
lib open64,readdir64,stat64,statvfs64,truncate64
|
||||
|
||||
lib,npt strtod,strtold,strtol,strtoll,strtoul,strtoull stdlib.h
|
||||
lib,npt sigflag signal.h
|
||||
|
@ -57,9 +54,6 @@ mem inheritance.pgroup spawn.h
|
|||
sys dir,filio,jioctl,localedef,ptem,resource
|
||||
sys socket,stream,systeminfo,universe,vfork
|
||||
|
||||
typ ino64_t,off64_t
|
||||
typ struct.dirent64 dirent.h
|
||||
|
||||
tst tst_errno note{ errno can be assigned }end link{
|
||||
#define error ______error
|
||||
#define strerror ______strerror
|
||||
|
@ -662,36 +656,3 @@ tst - output{
|
|||
echo "$0: Output block failed to compile. Export IFFEFLAGS=-d1 to debug." >&2
|
||||
exit 1
|
||||
}end
|
||||
|
||||
tst no64 note{ largefile 64 broken }end execute{
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
struct stat64 st;
|
||||
return !stat64(".", &st) && st.st_mode && st.st_mtime;
|
||||
}
|
||||
}end pass{
|
||||
echo "/* can we at least agree that a successful return means success? */"
|
||||
echo "#undef _lib_creat64"
|
||||
echo "#undef _lib_fstat64"
|
||||
echo "#undef _lib_fstatvfs64"
|
||||
echo "#undef _lib_ftruncate64"
|
||||
echo "#undef _lib_lseek64"
|
||||
echo "#undef _lib_lstat64"
|
||||
echo "#undef _lib_mmap64"
|
||||
echo "#undef _lib_stat64"
|
||||
echo "#undef _lib_statvfs64"
|
||||
echo "#undef _lib_truncate64"
|
||||
}end
|
||||
|
||||
tst need64 note{ off64_t necessary }end nocompile{
|
||||
#include <sys/types.h>
|
||||
typedef off64_t __ast_off64_t__;
|
||||
typedef off_t __ast_off_t__;
|
||||
extern __ast_off64_t__ x;
|
||||
__ast_off_t__ x;
|
||||
}end fail{
|
||||
echo "#undef _typ_off64_t"
|
||||
}end
|
||||
|
|
|
@ -70,9 +70,7 @@ __STDPP__directive pragma pp:hide getpagesize getdtablesize
|
|||
#include "FEATURE/lib"
|
||||
#include "FEATURE/common"
|
||||
|
||||
#if _hdr_unistd
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "FEATURE/param"
|
||||
|
||||
|
|
|
@ -115,71 +115,6 @@ tst lib_mmap note{ standard mmap interface that works }end execute{
|
|||
}
|
||||
}end
|
||||
|
||||
tst lib_mmap64 note{ mmap64 interface and implementation work }end execute{
|
||||
#if !_lib_mmap
|
||||
(
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
off64_t off;
|
||||
int fd;
|
||||
int n;
|
||||
char* s;
|
||||
struct stat64 st;
|
||||
char file[32] = {'/','t','m','p','/','m','m','X','X','X','X','X','X'};
|
||||
|
||||
/* hey, stubs are supposed to fail! */
|
||||
if (stat64(".", &st) || !st.st_mode || !st.st_mtime)
|
||||
return 1;
|
||||
if (!mktemp(file) || (fd = open64(file, O_CREAT|O_WRONLY, 0600)) < 0)
|
||||
{
|
||||
remove(file);
|
||||
return 1;
|
||||
}
|
||||
off = (1<<8);
|
||||
off *= off;
|
||||
if (lseek64(fd, off, SEEK_SET) != off)
|
||||
{
|
||||
remove(file);
|
||||
return 1;
|
||||
}
|
||||
n = strlen(file) + 1;
|
||||
if (write(fd, file, n) != n)
|
||||
{
|
||||
remove(file);
|
||||
return 1;
|
||||
}
|
||||
if (close(fd) < 0 || (fd = open64(file, O_RDWR)) < 0)
|
||||
{
|
||||
remove(file);
|
||||
return 1;
|
||||
}
|
||||
if (!(s = mmap64((caddr_t)0, (size_t)n, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, off)))
|
||||
{
|
||||
remove(file);
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(s, file))
|
||||
{
|
||||
remove(file);
|
||||
return 1;
|
||||
}
|
||||
close(fd);
|
||||
remove(file);
|
||||
return 0;
|
||||
}
|
||||
}end
|
||||
|
||||
tst mmap_anon note{ use mmap MAP_ANON to get raw memory }end execute{
|
||||
#if !_lib_mmap
|
||||
(
|
||||
|
@ -328,7 +263,6 @@ cat{
|
|||
|
||||
#if _NO_MMAP
|
||||
#undef _lib_mmap
|
||||
#undef _lib_mmap64
|
||||
#undef _mmap_anon
|
||||
#undef _mmap_devzero
|
||||
#undef _mmap_worthy
|
||||
|
|
|
@ -65,11 +65,7 @@ tst note{ check for Win32 .exe botches }end output{
|
|||
else
|
||||
_rename("foo.exe", "aha.exe");
|
||||
if (_stat("bar", &st))
|
||||
{
|
||||
fix++,printf("#define _win32_botch_stat 1\n");
|
||||
if (sizeof(st.st_ino) == 8)
|
||||
printf("#define _stat _stat64\n");
|
||||
}
|
||||
if (_truncate("aha", 0))
|
||||
fix++,printf("#define _win32_botch_truncate 1\n");
|
||||
if (_unlink("bar"))
|
||||
|
|
|
@ -128,23 +128,14 @@ elif tst note{ SunOS (Solaris, illumos) }end compile{
|
|||
}
|
||||
elif tst note{ GNU (glibc) or Cygwin }end compile{
|
||||
/*
|
||||
* GNU (GNU's Not UNIX). From feature_test_macros(7) on a GNU/Linux system with glibc 2.32:
|
||||
*
|
||||
* _GNU_SOURCE
|
||||
* Defining this macro (with any value) implicitly defines _ATFILE_SOURCE, _LARGE‐
|
||||
* FILE64_SOURCE, _ISOC99_SOURCE, _XOPEN_SOURCE_EXTENDED, _POSIX_SOURCE,
|
||||
* _POSIX_C_SOURCE with the value 200809L (200112L in glibc versions before 2.10;
|
||||
* 199506L in glibc versions before 2.5; 199309L in glibc versions before 2.1) and
|
||||
* _XOPEN_SOURCE with the value 700 (600 in glibc versions before 2.10; 500 in
|
||||
* glibc versions before 2.2). In addition, various GNU-specific extensions are
|
||||
* also exposed.
|
||||
* Since glibc 2.19, defining _GNU_SOURCE also has the effect of implicitly defin‐
|
||||
* ing _DEFAULT_SOURCE. In glibc versions before 2.20, defining _GNU_SOURCE also
|
||||
* had the effect of implicitly defining _BSD_SOURCE and _SVID_SOURCE.
|
||||
*
|
||||
* Additionally, on Cygwin we must use _GNU_SOURCE to enable all features required by libast.
|
||||
* On GNU (GNU's Not UNIX) and Cygwin, _GNU_SOURCE is the "everything and the kitchen sink" macro
|
||||
* (see feature_test_macros(7)), but on GNU we also need to define _FILE_OFFSET_BITS to get large
|
||||
* file support. We also need to define 'basename' to stop string.h from declaring a GNU-specific
|
||||
* version of basename(3) which on Cygwin has a declaration that conflicts with AST basename(3).
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define basename basename
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <features.h>
|
||||
|
@ -164,9 +155,9 @@ elif tst note{ GNU (glibc) or Cygwin }end compile{
|
|||
return 0;
|
||||
}
|
||||
}end {
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define basename basename /* avoid string.h defining this in conflict with AST basename(3) */
|
||||
}
|
||||
elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
|
||||
#define _ALL_SOURCE 1
|
||||
|
|
|
@ -16,7 +16,6 @@ cat{
|
|||
#undef _FILE
|
||||
#undef __FILE_T
|
||||
#undef fpos_t
|
||||
#undef fpos64_t
|
||||
|
||||
typedef struct _sfio_s _sfio_FILE;
|
||||
|
||||
|
@ -63,18 +62,7 @@ cat{
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef _NO_LARGEFILE64_SOURCE
|
||||
#undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
#undef off_t
|
||||
#endif
|
||||
|
||||
#define fpos_t _ast_fpos_t
|
||||
#if _typ_int64_t
|
||||
#define fpos64_t _ast_fpos_t
|
||||
#endif
|
||||
|
||||
typedef struct _ast_fpos_s
|
||||
{
|
||||
|
@ -138,7 +126,6 @@ output{
|
|||
printf("#define fflush _ast_fflush\n");
|
||||
printf("#define fgetc _ast_fgetc\n");
|
||||
printf("#define fgetpos _ast_fgetpos\n");
|
||||
printf("#define fgetpos64 _ast_fgetpos64\n");
|
||||
printf("#define fgets _ast_fgets\n");
|
||||
printf("#define fopen _ast_fopen\n");
|
||||
printf("#define fprintf _ast_fprintf\n");
|
||||
|
@ -148,15 +135,10 @@ output{
|
|||
printf("#define freopen _ast_freopen\n");
|
||||
printf("#define fscanf _ast_fscanf\n");
|
||||
printf("#define fseek _ast_fseek\n");
|
||||
printf("#define fseek64 _ast_fseek64\n");
|
||||
printf("#define fseeko _ast_fseeko\n");
|
||||
printf("#define fseeko64 _ast_fseeko64\n");
|
||||
printf("#define fsetpos _ast_fsetpos\n");
|
||||
printf("#define fsetpos64 _ast_fsetpos64\n");
|
||||
printf("#define ftell _ast_ftell\n");
|
||||
printf("#define ftell64 _ast_ftell64\n");
|
||||
printf("#define ftello _ast_ftello\n");
|
||||
printf("#define ftello64 _ast_ftello64\n");
|
||||
printf("#define fwrite _ast_fwrite\n");
|
||||
printf("#define gets _ast_gets\n");
|
||||
printf("#define getw _ast_getw\n");
|
||||
|
@ -322,44 +304,6 @@ cat{
|
|||
extern int vsprintf(char*, const char*, va_list);
|
||||
extern int vsscanf(const char*, const char*, va_list);
|
||||
|
||||
#if _typ_int64_t
|
||||
|
||||
extern int fgetpos64(FILE*, fpos64_t*);
|
||||
extern int fsetpos64(FILE*, const fpos64_t*);
|
||||
extern int fseek64(FILE*, int64_t, int);
|
||||
extern int fseeko64(FILE*, int64_t, int);
|
||||
extern int64_t ftell64(FILE*);
|
||||
extern int64_t ftello64(FILE*);
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
|
||||
#undef fpos_t
|
||||
#undef off_t
|
||||
#undef fgetpos
|
||||
#undef fsetpos
|
||||
#undef fseek
|
||||
#undef fseeko
|
||||
#undef ftell
|
||||
#undef ftello
|
||||
|
||||
#define fpos_t fpos64_t
|
||||
#if _typ_off64_t
|
||||
#define off_t off64_t
|
||||
#else
|
||||
#define off_t int64_t
|
||||
#endif
|
||||
|
||||
#define fgetpos fgetpos64
|
||||
#define fsetpos fsetpos64
|
||||
#define fseek fseek64
|
||||
#define fseeko fseeko64
|
||||
#define ftell ftell64
|
||||
#define ftello ftello64
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
extern void clearerr_unlocked(FILE*);
|
||||
extern int feof_unlocked(FILE*);
|
||||
extern int ferror_unlocked(FILE*);
|
||||
|
|
|
@ -1,43 +1,6 @@
|
|||
iff AST_SYS
|
||||
ref -D_def_map_ast
|
||||
|
||||
print #if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
|
||||
print #define _NO_LARGEFILE64_SOURCE 1
|
||||
print #endif
|
||||
print #if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
|
||||
print #if !defined(_LARGEFILE64_SOURCE)
|
||||
print #define _LARGEFILE64_SOURCE 1
|
||||
print #endif
|
||||
print #if !defined(_LARGEFILE_SOURCE)
|
||||
print #define _LARGEFILE_SOURCE 1
|
||||
print #endif
|
||||
print #if !defined(_LARGE_FILE_API)
|
||||
print #define _LARGE_FILE_API 1
|
||||
print #endif
|
||||
print #else
|
||||
print #undef _LARGEFILE64_SOURCE
|
||||
print #undef _LARGEFILE_SOURCE
|
||||
print #undef _LARGE_FILE_API
|
||||
print #undef _typ_ino64_t
|
||||
print #undef _typ_off64_t
|
||||
print #undef _typ_struct_dirent64
|
||||
print #undef _lib_creat64
|
||||
print #undef _lib_fstat64
|
||||
print #undef _lib_fstatvfs64
|
||||
print #undef _lib_ftruncate64
|
||||
print #undef _lib_lseek64
|
||||
print #undef _lib_lstat64
|
||||
print #undef _lib_mmap64
|
||||
print #undef _lib_open64
|
||||
print #undef _lib_readdir64
|
||||
print #undef _lib_stat64
|
||||
print #undef _lib_statvfs64
|
||||
print #undef _lib_truncate64
|
||||
print #endif
|
||||
print #if !_lib_readdir64
|
||||
print #undef _typ_ino64_t
|
||||
print #endif
|
||||
|
||||
header stdlib.h
|
||||
header stddef.h
|
||||
header sys/types.h
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#define _AST_STD_H 1
|
||||
#define _AST_STD_I 1
|
||||
|
||||
#include <ast_standards.h>
|
||||
#include <ast_common.h>
|
||||
|
||||
#if _BLD_ast
|
||||
|
@ -292,29 +293,6 @@ extern _Ast_info_t _ast_info;
|
|||
|
||||
#undef extern
|
||||
|
||||
/* largefile hackery -- AST uses the large versions by default */
|
||||
|
||||
#if _typ_ino64_t
|
||||
#undef ino_t
|
||||
#define ino_t ino64_t
|
||||
#endif
|
||||
#if _typ_off64_t
|
||||
#undef off_t
|
||||
#define off_t off64_t
|
||||
#endif
|
||||
#if !defined(ftruncate) && _lib_ftruncate64
|
||||
#define ftruncate ftruncate64
|
||||
extern int ftruncate64(int, off64_t);
|
||||
#endif
|
||||
#if !defined(lseek) && _lib_lseek64
|
||||
#define lseek lseek64
|
||||
extern off64_t lseek64(int, off64_t, int);
|
||||
#endif
|
||||
#if !defined(truncate) && _lib_truncate64
|
||||
#define truncate truncate64
|
||||
extern int truncate64(const char*, off64_t);
|
||||
#endif
|
||||
|
||||
/* direct macro access for bsd crossover */
|
||||
|
||||
#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#ifndef _PROCLIB_H
|
||||
#define _PROCLIB_H
|
||||
|
||||
#include <ast_standards.h>
|
||||
#include <ast.h>
|
||||
#include <errno.h>
|
||||
#include <sig.h>
|
||||
|
|
|
@ -73,9 +73,9 @@ Sfio_t* _sfopen(Sfio_t* f, /* old stream structure */
|
|||
if(f->file >= 0 )
|
||||
{ if ((oflags &= (O_TEXT|O_BINARY|O_APPEND)) != 0 )
|
||||
{ /* set file access control */
|
||||
int ctl = sysfcntlf(f->file, F_GETFL, 0);
|
||||
int ctl = fcntl(f->file, F_GETFL, 0);
|
||||
ctl = (ctl & ~(O_TEXT|O_BINARY|O_APPEND)) | oflags;
|
||||
sysfcntlf(f->file, F_SETFL, ctl);
|
||||
fcntl(f->file, F_SETFL, ctl);
|
||||
}
|
||||
#if !O_cloexec
|
||||
if (fflags & SF_FD_CLOEXEC)
|
||||
|
@ -96,10 +96,10 @@ Sfio_t* _sfopen(Sfio_t* f, /* old stream structure */
|
|||
return NIL(Sfio_t*);
|
||||
|
||||
#if _has_oflags /* open the file */
|
||||
while((fd = sysopenf((char*)file,oflags,SF_CREATMODE)) < 0 && errno == EINTR)
|
||||
while((fd = open((char*)file,oflags,SF_CREATMODE)) < 0 && errno == EINTR)
|
||||
errno = 0;
|
||||
#else
|
||||
while((fd = sysopenf(file,oflags&O_ACCMODE)) < 0 && errno == EINTR)
|
||||
while((fd = open(file,oflags&O_ACCMODE)) < 0 && errno == EINTR)
|
||||
errno = 0;
|
||||
if(fd >= 0)
|
||||
{ if((oflags&(O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) )
|
||||
|
@ -108,19 +108,19 @@ Sfio_t* _sfopen(Sfio_t* f, /* old stream structure */
|
|||
}
|
||||
if(oflags&O_TRUNC ) /* truncate file */
|
||||
{ reg int tf;
|
||||
while((tf = syscreatf(file,SF_CREATMODE)) < 0 &&
|
||||
while((tf = creat(file,SF_CREATMODE)) < 0 &&
|
||||
errno == EINTR)
|
||||
errno = 0;
|
||||
CLOSE(tf);
|
||||
}
|
||||
}
|
||||
else if(oflags&O_CREAT)
|
||||
{ while((fd = syscreatf(file,SF_CREATMODE)) < 0 && errno == EINTR)
|
||||
{ while((fd = creat(file,SF_CREATMODE)) < 0 && errno == EINTR)
|
||||
errno = 0;
|
||||
if((oflags&O_ACCMODE) != O_WRONLY)
|
||||
{ /* the file now exists, reopen it for read/write */
|
||||
CLOSE(fd);
|
||||
while((fd = sysopenf(file,oflags&O_ACCMODE)) < 0 &&
|
||||
while((fd = open(file,oflags&O_ACCMODE)) < 0 &&
|
||||
errno == EINTR)
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ int sfclose(Sfio_t* f)
|
|||
if(_Sfnotify)
|
||||
(*_Sfnotify)(f, SF_CLOSING, (void*)((long)f->file));
|
||||
if(f->file >= 0 && !(f->flags&SF_STRING))
|
||||
{ while(sysclosef(f->file) < 0 )
|
||||
{ while(close(f->file) < 0 )
|
||||
{ if(errno == EINTR)
|
||||
errno = 0;
|
||||
else
|
||||
|
|
|
@ -47,22 +47,6 @@
|
|||
/* define va_list, etc. before including sfio_t.h (sfio.h) */
|
||||
#if !_PACKAGE_ast
|
||||
|
||||
/* some systems don't know large files */
|
||||
#if defined(_NO_LARGEFILE64_SOURCE) || _mips == 2 /* || __hppa */
|
||||
#undef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#undef _LARGEFILE64_SOURCE
|
||||
#undef _LARGEFILE_SOURCE
|
||||
#endif
|
||||
|
||||
#if !_NO_LARGEFILE64_SOURCE && _typ_off64_t && _lib_lseek64 && _lib_stat64
|
||||
#undef _LARGEFILE64_SOURCE
|
||||
#undef _LARGEFILE_SOURCE
|
||||
#undef _FILE_OFFSET_BITS
|
||||
#define _LARGEFILE64_SOURCE 1 /* enabling the *64 stuff */
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
#endif
|
||||
|
||||
#if _hdr_stdarg
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
|
@ -100,24 +84,6 @@
|
|||
#define _lib_locale 1
|
||||
#endif
|
||||
|
||||
#define sfoff_t off_t
|
||||
#define sfstat_t struct stat
|
||||
#define sysclosef close
|
||||
#define syscreatf creat
|
||||
#define sysdupf dup
|
||||
#define sysfcntlf fcntl
|
||||
#define sysfstatf fstat
|
||||
#define sysftruncatef ftruncate
|
||||
#define syslseekf lseek
|
||||
#define sysmmapf mmap
|
||||
#define sysmunmapf munmap
|
||||
#define sysopenf open
|
||||
#define syspipef pipe
|
||||
#define sysreadf read
|
||||
#define sysremovef remove
|
||||
#define sysstatf stat
|
||||
#define syswritef write
|
||||
|
||||
#else /*!_PACKAGE_ast*/
|
||||
|
||||
/* when building the binary compatibility package, a number of header files
|
||||
|
@ -187,28 +153,9 @@
|
|||
#endif /*_FIOCLEX*/
|
||||
#endif /*F_SETFD*/
|
||||
|
||||
#if _hdr_unistd
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !_LARGEFILE64_SOURCE /* turn off the *64 stuff */
|
||||
#undef _typ_off64_t
|
||||
#undef _typ_struct_stat64
|
||||
#undef _lib_creat64
|
||||
#undef _lib_open64
|
||||
#undef _lib_close64
|
||||
#undef _lib_stat64
|
||||
#undef _lib_fstat64
|
||||
#undef _lib_ftruncate64
|
||||
#undef _lib_lseek64
|
||||
#undef _lib_mmap64
|
||||
#undef _lib_munmap64
|
||||
#endif /*!_LARGEFILE64_SOURCE */
|
||||
|
||||
/* see if we can use memory mapping for io */
|
||||
#if _LARGEFILE64_SOURCE && !_lib_mmap64
|
||||
#undef _mmap_worthy
|
||||
#endif
|
||||
#if !_mmap_worthy
|
||||
#undef _hdr_mman
|
||||
#undef _sys_mman
|
||||
|
@ -220,76 +167,9 @@
|
|||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
/* standardize system calls and types dealing with files */
|
||||
#if _typ_off64_t
|
||||
#define sfoff_t off64_t
|
||||
#else
|
||||
#define sfoff_t off_t
|
||||
#if !_lib_remove
|
||||
#define remove unlink
|
||||
#endif
|
||||
#if _typ_struct_stat64
|
||||
#define sfstat_t struct stat64
|
||||
#else
|
||||
#define sfstat_t struct stat
|
||||
#endif
|
||||
#if _lib_lseek64
|
||||
#define syslseekf lseek64
|
||||
#else
|
||||
#define syslseekf lseek
|
||||
#endif
|
||||
#if _lib_stat64
|
||||
#define sysstatf stat64
|
||||
#else
|
||||
#define sysstatf stat
|
||||
#endif
|
||||
#if _lib_fstat64
|
||||
#define sysfstatf fstat64
|
||||
#else
|
||||
#define sysfstatf fstat
|
||||
#endif
|
||||
#if _lib_mmap64
|
||||
#define sysmmapf mmap64
|
||||
#else
|
||||
#define sysmmapf mmap
|
||||
#endif
|
||||
#if _lib_munmap64
|
||||
#define sysmunmapf munmap64
|
||||
#else
|
||||
#define sysmunmapf munmap
|
||||
#endif
|
||||
#if _lib_open64
|
||||
#define sysopenf open64
|
||||
#else
|
||||
#define sysopenf open
|
||||
#endif
|
||||
#if _lib_creat64
|
||||
#define syscreatf creat64
|
||||
#else
|
||||
#define syscreatf creat
|
||||
#endif
|
||||
#if _lib_close64
|
||||
#define sysclosef close64
|
||||
#else
|
||||
#define sysclosef close
|
||||
#endif
|
||||
#if _lib_ftruncate64
|
||||
#undef _lib_ftruncate
|
||||
#define _lib_ftruncate 1
|
||||
#define sysftruncatef ftruncate64
|
||||
#endif
|
||||
#if !_lib_ftruncate64 && _lib_ftruncate
|
||||
#define sysftruncatef ftruncate
|
||||
#endif
|
||||
#if _lib_remove
|
||||
#define sysremovef remove
|
||||
#else
|
||||
#define sysremovef unlink
|
||||
#endif
|
||||
|
||||
#define sysreadf read
|
||||
#define syswritef write
|
||||
#define syspipef pipe
|
||||
#define sysdupf dup
|
||||
#define sysfcntlf fcntl
|
||||
|
||||
#endif /*_PACKAGE_ast*/
|
||||
|
||||
|
@ -553,7 +433,7 @@
|
|||
|
||||
#define SECOND 1000 /* millisecond units */
|
||||
|
||||
/* macros do determine stream types from sfstat_t data */
|
||||
/* macros do determine stream types from 'struct stat' data */
|
||||
#ifndef S_IFDIR
|
||||
#define S_IFDIR 0
|
||||
#endif
|
||||
|
@ -851,12 +731,12 @@ typedef struct _sfextern_s
|
|||
#define SFMMSEQOFF(f,a,s)
|
||||
#endif
|
||||
|
||||
#define SFMUNMAP(f,a,s) (sysmunmapf((caddr_t)(a),(size_t)(s)), \
|
||||
#define SFMUNMAP(f,a,s) (munmap((caddr_t)(a),(size_t)(s)), \
|
||||
((f)->endb = (f)->endr = (f)->endw = (f)->next = \
|
||||
(f)->data = NIL(uchar*)) )
|
||||
|
||||
/* safe closing function */
|
||||
#define CLOSE(f) { while(sysclosef(f) < 0 && errno == EINTR) errno = 0; }
|
||||
#define CLOSE(f) { while(close(f) < 0 && errno == EINTR) errno = 0; }
|
||||
|
||||
/* the bottomless bit bucket */
|
||||
#define DEVNULL "/dev/null"
|
||||
|
@ -1206,33 +1086,6 @@ extern Sfdouble_t ldexpl(Sfdouble_t, int);
|
|||
|
||||
#if !_PACKAGE_ast
|
||||
|
||||
#if !_hdr_unistd
|
||||
extern int sysclosef(int);
|
||||
extern ssize_t sysreadf(int, void*, size_t);
|
||||
extern ssize_t syswritef(int, const void*, size_t);
|
||||
extern sfoff_t syslseekf(int, sfoff_t, int);
|
||||
extern int sysdupf(int);
|
||||
extern int syspipef(int*);
|
||||
extern int sysaccessf(const char*, int);
|
||||
extern int sysremovef(const char*);
|
||||
extern int sysfstatf(int, sfstat_t*);
|
||||
extern int sysstatf(const char*, sfstat_t*);
|
||||
|
||||
extern int isatty(int);
|
||||
|
||||
extern int wait(int*);
|
||||
extern uint sleep(uint);
|
||||
extern int execl(const char*, const char*,...);
|
||||
extern int execv(const char*, char**);
|
||||
#if !defined(fork)
|
||||
extern int fork(void);
|
||||
#endif
|
||||
#if _lib_unlink
|
||||
extern int unlink(const char*);
|
||||
#endif
|
||||
|
||||
#endif /*_hdr_unistd*/
|
||||
|
||||
#if _lib_bcopy && !_proto_bcopy
|
||||
extern void bcopy(const void*, void*, size_t);
|
||||
#endif
|
||||
|
|
|
@ -61,7 +61,7 @@ ssize_t sfpkrd(int fd, /* file descriptor */
|
|||
reg char *buf = (char*)argbuf, *endbuf;
|
||||
|
||||
if(rc < 0 && tm < 0 && action <= 0)
|
||||
return sysreadf(fd,buf,n);
|
||||
return read(fd,buf,n);
|
||||
|
||||
t = (action > 0 || rc >= 0) ? (STREAM_PEEK|SOCKET_PEEK) : 0;
|
||||
#if !_stream_peek
|
||||
|
@ -94,7 +94,7 @@ ssize_t sfpkrd(int fd, /* file descriptor */
|
|||
{ t &= ~SOCKET_PEEK;
|
||||
if(r > 0 && (r = pbuf.databuf.len) <= 0)
|
||||
{ if(action <= 0) /* read past eof */
|
||||
r = sysreadf(fd,buf,1);
|
||||
r = read(fd,buf,1);
|
||||
return r;
|
||||
}
|
||||
if(r == 0)
|
||||
|
@ -151,7 +151,7 @@ ssize_t sfpkrd(int fd, /* file descriptor */
|
|||
|
||||
if(r > 0) /* there is data now */
|
||||
{ if(action <= 0 && rc < 0)
|
||||
return sysreadf(fd,buf,n);
|
||||
return read(fd,buf,n);
|
||||
else r = -1;
|
||||
}
|
||||
else if(tm >= 0) /* timeout exceeded */
|
||||
|
@ -176,7 +176,7 @@ ssize_t sfpkrd(int fd, /* file descriptor */
|
|||
break;
|
||||
else /* read past eof */
|
||||
{ if(action <= 0)
|
||||
r = sysreadf(fd,buf,1);
|
||||
r = read(fd,buf,1);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ ssize_t sfpkrd(int fd, /* file descriptor */
|
|||
if((action = action ? -action : 1) > (int)n)
|
||||
action = n;
|
||||
r = 0;
|
||||
while((t = sysreadf(fd,buf,action)) > 0)
|
||||
while((t = read(fd,buf,action)) > 0)
|
||||
{ r += t;
|
||||
for(endbuf = buf+t; buf < endbuf;)
|
||||
if(*buf++ == rc)
|
||||
|
@ -218,7 +218,7 @@ ssize_t sfpkrd(int fd, /* file descriptor */
|
|||
|
||||
/* advance */
|
||||
if(action <= 0)
|
||||
r = sysreadf(fd,buf,r);
|
||||
r = read(fd,buf,r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -192,9 +192,9 @@ Sfio_t* sfpopen(Sfio_t* f,
|
|||
/* make pipes */
|
||||
parent[0] = parent[1] = child[0] = child[1] = -1;
|
||||
if(sflags&SF_RDWR)
|
||||
{ if(syspipef(parent) < 0)
|
||||
{ if(pipe(parent) < 0)
|
||||
goto error;
|
||||
if((sflags&SF_RDWR) == SF_RDWR && syspipef(child) < 0)
|
||||
if((sflags&SF_RDWR) == SF_RDWR && pipe(child) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ Sfio_t* sfpopen(Sfio_t* f,
|
|||
|
||||
/* must be careful so not to close something useful */
|
||||
if((sflags&SF_RDWR) == SF_RDWR && pkeep == child[ckeep])
|
||||
if((child[ckeep] = sysdupf(pkeep)) < 0)
|
||||
if((child[ckeep] = dup(pkeep)) < 0)
|
||||
_exit(EXIT_NOTFOUND);
|
||||
|
||||
if(sflags&SF_RDWR)
|
||||
|
|
|
@ -124,7 +124,7 @@ ssize_t sfrd(Sfio_t* f, void* buf, size_t n, Sfdisc_t* disc)
|
|||
#ifdef MAP_TYPE
|
||||
if(f->bits&SF_MMAP)
|
||||
{ reg ssize_t a, round;
|
||||
sfstat_t st;
|
||||
struct stat st;
|
||||
|
||||
/* determine if we have to copy data to buffer */
|
||||
if((uchar*)buf >= f->data && (uchar*)buf <= f->endb)
|
||||
|
@ -140,7 +140,7 @@ ssize_t sfrd(Sfio_t* f, void* buf, size_t n, Sfdisc_t* disc)
|
|||
|
||||
/* before mapping, make sure we have data to map */
|
||||
if((f->flags&SF_SHARE) || (size_t)(r = f->extent-f->here) < n)
|
||||
{ if((r = sysfstatf(f->file,&st)) < 0)
|
||||
{ if((r = fstat(f->file,&st)) < 0)
|
||||
goto do_except;
|
||||
if((r = (f->extent = st.st_size) - f->here) <= 0 )
|
||||
{ r = 0; /* eof */
|
||||
|
@ -162,10 +162,10 @@ ssize_t sfrd(Sfio_t* f, void* buf, size_t n, Sfdisc_t* disc)
|
|||
SFMUNMAP(f, f->data, f->endb-f->data);
|
||||
|
||||
for(;;)
|
||||
{ f->data = (uchar*) sysmmapf((caddr_t)0, (size_t)r,
|
||||
{ f->data = (uchar*) mmap((caddr_t)0, (size_t)r,
|
||||
(PROT_READ|PROT_WRITE),
|
||||
MAP_PRIVATE,
|
||||
f->file, (sfoff_t)f->here);
|
||||
f->file, (off_t)f->here);
|
||||
if(f->data && (caddr_t)f->data != (caddr_t)(-1))
|
||||
break;
|
||||
else
|
||||
|
@ -259,7 +259,7 @@ ssize_t sfrd(Sfio_t* f, void* buf, size_t n, Sfdisc_t* disc)
|
|||
else f->mode |= SF_RC;
|
||||
}
|
||||
}
|
||||
else r = sysreadf(f->file,buf,n);
|
||||
else r = read(f->file,buf,n);
|
||||
|
||||
if(errno == 0 )
|
||||
errno = oerrno;
|
||||
|
|
|
@ -64,7 +64,7 @@ ssize_t sfread(Sfio_t* f, /* read from this stream. */
|
|||
{ /* actually read the data now */
|
||||
f->mode &= ~SF_PKRD;
|
||||
if(n > 0)
|
||||
n = (r = sysreadf(f->file,f->data,n)) < 0 ? 0 : r;
|
||||
n = (r = read(f->file,f->data,n)) < 0 ? 0 : r;
|
||||
f->endb = f->data+n;
|
||||
f->here += n;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ int sfresize(Sfio_t* f, Sfoff_t size)
|
|||
{ if(f->next > f->data)
|
||||
SFSYNC(f);
|
||||
#if _lib_ftruncate
|
||||
if(ftruncate(f->file, (sfoff_t)size) < 0)
|
||||
if(ftruncate(f->file, (off_t)size) < 0)
|
||||
SFMTXRETURN(f, -1);
|
||||
#else
|
||||
SFMTXRETURN(f, -1);
|
||||
|
|
|
@ -51,8 +51,8 @@ struct stat
|
|||
{ int st_mode;
|
||||
int st_size;
|
||||
};
|
||||
#undef sysfstatf
|
||||
#define sysfstatf(fd,st) (-1)
|
||||
#undef fstat
|
||||
#define fstat(fd,st) (-1)
|
||||
#endif /*_sys_stat*/
|
||||
|
||||
#if _PACKAGE_ast && !defined(SFSETLINEMODE)
|
||||
|
@ -107,7 +107,7 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
|
|||
int sf_malloc, oflags, init, okmmap, local;
|
||||
ssize_t bufsize, blksz;
|
||||
Sfdisc_t* disc;
|
||||
sfstat_t st;
|
||||
struct stat st;
|
||||
uchar* obuf = NIL(uchar*);
|
||||
ssize_t osize = 0;
|
||||
SFMTXDECL(f);
|
||||
|
@ -227,7 +227,7 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
|
|||
}
|
||||
|
||||
/* get file descriptor status */
|
||||
if(sysfstatf((int)f->file,&st) < 0)
|
||||
if(fstat((int)f->file,&st) < 0)
|
||||
f->here = -1;
|
||||
else
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
|
|||
|
||||
#if O_TEXT /* no memory mapping with O_TEXT because read()/write() alter data stream */
|
||||
if(okmmap && f->here >= 0 &&
|
||||
(sysfcntlf((int)f->file,F_GETFL,0) & O_TEXT) )
|
||||
(fcntl((int)f->file,F_GETFL,0) & O_TEXT) )
|
||||
okmmap = 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
|
|||
dev = (int)st.st_dev;
|
||||
ino = (int)st.st_ino;
|
||||
if(!null_checked)
|
||||
{ if(sysstatf(DEVNULL,&st) < 0)
|
||||
{ if(stat(DEVNULL,&st) < 0)
|
||||
null_checked = -1;
|
||||
else
|
||||
{ null_checked = 1;
|
||||
|
|
|
@ -32,12 +32,12 @@ static int _sfdup(int fd, int newfd)
|
|||
reg int dupfd;
|
||||
|
||||
#ifdef F_DUPFD /* the simple case */
|
||||
while((dupfd = sysfcntlf(fd,F_DUPFD,newfd)) < 0 && errno == EINTR)
|
||||
while((dupfd = fcntl(fd,F_DUPFD,newfd)) < 0 && errno == EINTR)
|
||||
errno = 0;
|
||||
return dupfd;
|
||||
|
||||
#else /* do it the hard way */
|
||||
if((dupfd = sysdupf(fd)) < 0 || dupfd >= newfd)
|
||||
if((dupfd = dup(fd)) < 0 || dupfd >= newfd)
|
||||
return dupfd;
|
||||
|
||||
/* dup() succeeded but didn't get the right number, recurse */
|
||||
|
|
|
@ -61,8 +61,8 @@ Sfoff_t sfsize(Sfio_t* f)
|
|||
}
|
||||
#if _sys_stat
|
||||
else
|
||||
{ sfstat_t st;
|
||||
if(sysfstatf(f->file,&st) < 0)
|
||||
{ struct stat st;
|
||||
if(fstat(f->file,&st) < 0)
|
||||
f->extent = -1;
|
||||
else if((f->extent = st.st_size) < f->here)
|
||||
f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,disc);
|
||||
|
|
|
@ -70,7 +70,7 @@ Sfoff_t sfsk(Sfio_t* f, Sfoff_t addr, int type, Sfdisc_t* disc)
|
|||
{ SFDCSK(f,addr,type,dc,p);
|
||||
}
|
||||
else
|
||||
{ p = syslseekf(f->file,(sfoff_t)addr,type);
|
||||
{ p = lseek(f->file,(off_t)addr,type);
|
||||
}
|
||||
if(p >= 0)
|
||||
SFMTXRETURN(f,p);
|
||||
|
|
|
@ -85,7 +85,7 @@ static int _tmprmfile(Sfio_t* f, int type, void* val, Sfdisc_t* disc)
|
|||
(*_Sfnotify)(f,SF_CLOSING,f->file);
|
||||
CLOSE(f->file);
|
||||
f->file = -1;
|
||||
while(sysremovef(ff->name) < 0 && errno == EINTR)
|
||||
while(remove(ff->name) < 0 && errno == EINTR)
|
||||
errno = 0;
|
||||
|
||||
free((void*)ff);
|
||||
|
@ -130,7 +130,7 @@ static int _rmtmp(Sfio_t* f, char* file)
|
|||
(void)vtmtxunlock(_Sfmutex);
|
||||
|
||||
#else /* can remove now */
|
||||
while(sysremovef(file) < 0 && errno == EINTR)
|
||||
while(remove(file) < 0 && errno == EINTR)
|
||||
errno = 0;
|
||||
#endif
|
||||
|
||||
|
@ -253,22 +253,22 @@ static int _tmpfd(Sfio_t* f)
|
|||
if(!file)
|
||||
return -1;
|
||||
#if _has_oflags
|
||||
if((fd = sysopenf(file,O_RDWR|O_CREAT|O_EXCL|O_TEMPORARY,SF_CREATMODE)) >= 0)
|
||||
if((fd = open(file,O_RDWR|O_CREAT|O_EXCL|O_TEMPORARY,SF_CREATMODE)) >= 0)
|
||||
break;
|
||||
#else
|
||||
if((fd = sysopenf(file,O_RDONLY)) >= 0)
|
||||
if((fd = open(file,O_RDONLY)) >= 0)
|
||||
{ /* file already exists */
|
||||
CLOSE(fd);
|
||||
fd = -1;
|
||||
}
|
||||
else if((fd = syscreatf(file,SF_CREATMODE)) >= 0)
|
||||
else if((fd = creat(file,SF_CREATMODE)) >= 0)
|
||||
{ /* reopen for read and write */
|
||||
CLOSE(fd);
|
||||
if((fd = sysopenf(file,O_RDWR)) >= 0)
|
||||
if((fd = open(file,O_RDWR)) >= 0)
|
||||
break;
|
||||
|
||||
/* don't know what happened but must remove file */
|
||||
while(sysremovef(file) < 0 && errno == EINTR)
|
||||
while(remove(file) < 0 && errno == EINTR)
|
||||
errno = 0;
|
||||
}
|
||||
#endif /* _has_oflags */
|
||||
|
|
|
@ -87,7 +87,7 @@ static ssize_t sfoutput(Sfio_t* f, char* buf, size_t n)
|
|||
{ buf = endbuf;
|
||||
n = s = 0;
|
||||
}
|
||||
if((wr = syswritef(f->file,wbuf,buf-wbuf)) > 0)
|
||||
if((wr = write(f->file,wbuf,buf-wbuf)) > 0)
|
||||
{ w += wr;
|
||||
f->bits &= ~SF_HOLE;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ ssize_t sfwr(Sfio_t* f, const void* buf, size_t n, Sfdisc_t* disc)
|
|||
else
|
||||
{
|
||||
do_write:
|
||||
if((w = syswritef(f->file,buf,n)) > 0)
|
||||
if((w = write(f->file,buf,n)) > 0)
|
||||
f->bits &= ~SF_HOLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ ssize_t sfwrite(Sfio_t* f, /* write to this stream. */
|
|||
for(w = n; w > 0; )
|
||||
{ if((r = w) > sizeof(buf))
|
||||
r = sizeof(buf);
|
||||
if((r = sysreadf(f->file,buf,r)) <= 0)
|
||||
if((r = read(f->file,buf,r)) <= 0)
|
||||
{ n -= w;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
* *
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "stdhdr.h"
|
||||
|
||||
int
|
||||
|
@ -34,15 +30,3 @@ fgetpos(Sfio_t* f, fpos_t* pos)
|
|||
|
||||
return (pos->_sf_offset = sfseek(f, (Sfoff_t)0, SEEK_CUR)) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef _typ_int64_t
|
||||
|
||||
int
|
||||
fgetpos64(Sfio_t* f, fpos64_t* pos)
|
||||
{
|
||||
STDIO_INT(f, "fgetpos64", int, (Sfio_t*, fpos64_t*), (f, pos))
|
||||
|
||||
return (pos->_sf_offset = sfseek(f, (Sfoff_t)0, SEEK_CUR)) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
* *
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "stdhdr.h"
|
||||
|
||||
int
|
||||
|
@ -34,15 +30,3 @@ fseek(Sfio_t* f, long off, int op)
|
|||
|
||||
return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef _typ_int64_t
|
||||
|
||||
int
|
||||
fseek64(Sfio_t* f, int64_t off, int op)
|
||||
{
|
||||
STDIO_INT(f, "fseek64", int, (Sfio_t*, int64_t, int), (f, off, op))
|
||||
|
||||
return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
* *
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "stdhdr.h"
|
||||
|
||||
int
|
||||
|
@ -34,15 +30,3 @@ fseeko(Sfio_t* f, off_t off, int op)
|
|||
|
||||
return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef _typ_int64_t
|
||||
|
||||
int
|
||||
fseeko64(Sfio_t* f, int64_t off, int op)
|
||||
{
|
||||
STDIO_INT(f, "fseeko64", int, (Sfio_t*, int64_t, int), (f, off, op))
|
||||
|
||||
return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
* *
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "stdhdr.h"
|
||||
|
||||
int
|
||||
|
@ -34,15 +30,3 @@ fsetpos(Sfio_t* f, const fpos_t* pos)
|
|||
|
||||
return sfseek(f, (Sfoff_t)pos->_sf_offset, SF_PUBLIC) == (Sfoff_t)pos->_sf_offset ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef _typ_int64_t
|
||||
|
||||
int
|
||||
fsetpos64(Sfio_t* f, const fpos64_t* pos)
|
||||
{
|
||||
STDIO_INT(f, "fsetpos64", int, (Sfio_t*, const fpos64_t*), (f, pos))
|
||||
|
||||
return sfseek(f, (Sfoff_t)pos->_sf_offset, SF_PUBLIC) == (Sfoff_t)pos->_sf_offset ? 0 : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
* *
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "stdhdr.h"
|
||||
|
||||
long
|
||||
|
@ -34,15 +30,3 @@ ftell(Sfio_t* f)
|
|||
|
||||
return (long)sfseek(f, (Sfoff_t)0, SEEK_CUR);
|
||||
}
|
||||
|
||||
#if _typ_int64_t
|
||||
|
||||
int64_t
|
||||
ftell64(Sfio_t* f)
|
||||
{
|
||||
STDIO_INT(f, "ftell64", int64_t, (Sfio_t*), (f))
|
||||
|
||||
return (int64_t)sfseek(f, (Sfoff_t)0, SEEK_CUR);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
* *
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "stdhdr.h"
|
||||
|
||||
off_t
|
||||
|
@ -34,15 +30,3 @@ ftello(Sfio_t* f)
|
|||
|
||||
return sfseek(f, (Sfoff_t)0, SEEK_CUR);
|
||||
}
|
||||
|
||||
#ifdef _typ_int64_t
|
||||
|
||||
int64_t
|
||||
ftello64(Sfio_t* f)
|
||||
{
|
||||
STDIO_INT(f, "ftello64", int64_t, (Sfio_t*), (f))
|
||||
|
||||
return sfseek(f, (Sfoff_t)0, SEEK_CUR) >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,10 +24,7 @@
|
|||
#ifndef _STDHDR_H
|
||||
#define _STDHDR_H 1
|
||||
|
||||
#ifndef _NO_LARGEFILE64_SOURCE
|
||||
#define _NO_LARGEFILE64_SOURCE 1
|
||||
#endif
|
||||
#undef _LARGEFILE64_SOURCE
|
||||
#include <ast_standards.h>
|
||||
|
||||
#define _ast_fseeko ______fseeko
|
||||
#define _ast_ftello ______ftello
|
||||
|
|
|
@ -478,15 +478,7 @@ extern void* sbrk( ssize_t );
|
|||
|
||||
#else
|
||||
|
||||
#if _hdr_unistd
|
||||
#include <unistd.h>
|
||||
#else
|
||||
extern void abort( void );
|
||||
extern ssize_t write( int, const void*, size_t );
|
||||
extern int getpagesize(void);
|
||||
extern void* sbrk(ssize_t);
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -30,9 +30,7 @@ void _STUB_vmmapopen(){}
|
|||
#include "vmhdr.h"
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#if _hdr_unistd
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#undef ALIGN /* some sys/param.h define this */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue