This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] Use non-underscore stat() and fstat()
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: newlib at sourceware dot org
- Cc: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- Date: Thu, 18 Apr 2013 11:11:35 +0200
- Subject: [PATCH] Use non-underscore stat() and fstat()
The change
2012-08-08 Corinna Vinschen <vinschen@redhat.com>
Throughout, run newlib with -Wall -Werror option and fix bugs and
compiler warnings found this way.
[...]
* libc/search/hash.c: Throughout use underscored variants of the stat
function family.
[...]
introduces a problem on RTEMS:
/scratch/opt/rtems-4.11/lib64/gcc/mips-rtems4.11/4.8.1/../../../../mips-rtems4.11/lib/libc.a(lib_a-hash.o):
In function `__hash_open':
(.text+0xed8): undefined reference to `_stat'
/scratch/opt/rtems-4.11/lib64/gcc/mips-rtems4.11/4.8.1/../../../../mips-rtems4.11/lib/libc.a(lib_a-hash.o):
In function `__hash_open':
(.text+0x116c): undefined reference to `_stat'
/scratch/opt/rtems-4.11/lib64/gcc/mips-rtems4.11/4.8.1/../../../../mips-rtems4.11/lib/libc.a(lib_a-hash.o):
In function `__hash_open':
(.text+0x1220): undefined reference to `_fstat'
I don't get compiler warnings for this file:
make[3]: Entering directory
`/scratch/git-build/b-gcc-git-mips-rtems4.11/mips-rtems4.11/soft-float/newlib/libc/search'
/scratch/git-build/b-gcc-git-mips-rtems4.11/./gcc/xgcc
-B/scratch/git-build/b-gcc-git-mips-rtems4.11/./gcc/ -nostdinc
-B/scratch/git-build/b-gcc-git-mips-rtems4.11/mips-rtems4.11/soft-float/newlib/
-isystem
/scratch/git-build/b-gcc-git-mips-rtems4.11/mips-rtems4.11/soft-float/newlib/targ-include
-isystem /home/sh/archive/gcc-git/newlib/libc/include
-B/scratch/opt/rtems-4.11/mips-rtems4.11/bin/
-B/scratch/opt/rtems-4.11/mips-rtems4.11/lib/ -isystem
/scratch/opt/rtems-4.11/mips-rtems4.11/include -isystem
/scratch/opt/rtems-4.11/mips-rtems4.11/sys-include -msoft-float
-DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\"
-DPACKAGE_VERSION=\"2.0.0\" -DPACKAGE_STRING=\"newlib\ 2.0.0\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I.
-I/home/sh/archive/gcc-git/newlib/libc/search -D_COMPILING_NEWLIB
-DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED
-DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE
-DHAVE_FCNTL -DHAVE_ASSERT_FUNC -D_NO_GETLOGIN -D_NO_GETPWENT
-D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN
-fno-builtin -g -O2 -c -o lib_a-hash.o `test -f 'hash.c' || echo
'/home/sh/archive/gcc-git/newlib/libc/search/'`hash.c rm -f lib.a
/scratch/opt/rtems-4.11/mips-rtems4.11/bin/ar cru lib.a lib_a-bsearch.o
lib_a-qsort.o lib_a-hash.o lib_a-hash_bigkey.o lib_a-hash_buf.o
lib_a-hash_func.o lib_a-hash_log2.o lib_a-hash_page.o lib_a-hcreate.o
lib_a-hcreate_r.o lib_a-tdelete.o lib_a-tdestroy.o lib_a-tfind.o
lib_a-tsearch.o lib_a-twalk.o
/scratch/opt/rtems-4.11/mips-rtems4.11/bin/ar: `u' modifier ignored
since `D' is the default (see `U')
/scratch/opt/rtems-4.11/mips-rtems4.11/bin/ranlib lib.a make[3]: Leaving
directory
`/scratch/git-build/b-gcc-git-mips-rtems4.11/mips-rtems4.11/soft-float/newlib/libc/search'
Why did this change introduce the _stat() and _fstat() functions?
newlib/ChangeLog
2013-04-18 Sebastian Huber <sebastian.huber@embedded-brains.de>
* newlib/libc/search/hash.c: Use stat() and fstat() instead of
_stat() and _fstat().
---
newlib/libc/search/hash.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/newlib/libc/search/hash.c b/newlib/libc/search/hash.c
index 997acb3..2b102c8 100644
--- a/newlib/libc/search/hash.c
+++ b/newlib/libc/search/hash.c
@@ -143,7 +143,7 @@ _DEFUN(__hash_open, (file, flags, mode, info, dflags),
#ifdef __USE_INTERNAL_STAT64
(_stat64(file, &statbuf) && (errno == ENOENT))) {
#else
- (_stat(file, &statbuf) && (errno == ENOENT))) {
+ (stat(file, &statbuf) && (errno == ENOENT))) {
#endif
if (errno == ENOENT)
errno = 0; /* Just in case someone looks at errno */
@@ -159,7 +159,7 @@ _DEFUN(__hash_open, (file, flags, mode, info, dflags),
#ifdef __USE_INTERNAL_STAT64
_fstat64(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
#else
- _fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
+ fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
#endif
new_table = 1;
@@ -341,7 +341,7 @@ init_hash(hashp, file, info)
#ifdef __USE_INTERNAL_STAT64
if (_stat64(file, &statbuf))
#else
- if (_stat(file, &statbuf))
+ if (stat(file, &statbuf))
#endif
return (NULL);
hashp->BSIZE = statbuf.st_blksize;
--
1.7.7