This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
Some preparations for implementation of glob64
- To: libc-hacker@gnu.org
- Subject: Some preparations for implementation of glob64
- From: Mark Kettenis <kettenis@phys.uva.nl>
- Date: Sun, 9 Aug 1998 15:37:29 +0200 (CEST)
Hi,
Here is a patch that fixes some inconsistencies I found: The macros
`__stat' and `__fstat' were not declared in `include/sys/stat.h'
wheras `__lstat' was declared. This would cause problems if the
library was compiled without optimization (which, obviously, nobody
does at the moment). However this triggered some problems in libio,
where `__stat' is used as a function pointer struct member.
The real reason for this patch is to avoid the redefenition of the
macros in `include/sys/stat.h', because in my implementation of
glob64 (path will follow), I need to redefine the macros `stat' and
`__stat'.
Mark
1998-08-09 Mark Kettenis <kettenis@phys.uva.nl>
* include/sys/stat.h: Define __stat and __fstat as
macros so the library compiles correctly even without
optimization. Define all macros only if they are not already
defined.
* io/stat.c: Undef __stat.
* io/fstat.c: Undef __fstat.
* io/lstat.c: Undef __lstat.
* libio/filedoalloc.c [_LIBC]: Undef __stat.
* libio/fileops.c: Likewise.
* libio/oldfileops.c: Likewise.
Index: io/lstat.c
--- 0.4/io/lstat.c Sun, 09 Aug 1998 14:24:02 +0200 kettenis (libc/20_lstat.c 1.1 666)
+++ Local.5(w)/io/lstat.c Sun, 09 Aug 1998 03:43:19 +0200 kettenis (libc/20_lstat.c 1.2 666)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -37,6 +37,7 @@
all callers. */
#undef lstat
+#undef __lstat
int
__lstat (const char *file, struct stat *buf)
{
Index: io/fstat.c
--- 0.4/io/fstat.c Sun, 09 Aug 1998 14:24:02 +0200 kettenis (libc/21_fstat.c 1.1 666)
+++ Local.5(w)/io/fstat.c Sun, 09 Aug 1998 14:58:20 +0200 kettenis (libc/21_fstat.c 1.2 666)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -37,6 +37,7 @@
all callers. */
#undef fstat
+#undef __fstat
int
__fstat (int fd, struct stat *buf)
{
Index: io/stat.c
--- 0.4/io/stat.c Sun, 09 Aug 1998 14:24:02 +0200 kettenis (libc/22_stat.c 1.1 666)
+++ Local.5(w)/io/stat.c Sun, 09 Aug 1998 03:44:13 +0200 kettenis (libc/22_stat.c 1.2 666)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -37,6 +37,7 @@
all callers. */
#undef stat
+#undef __stat
int
__stat (const char *file, struct stat *buf)
{
Index: libio/oldfileops.c
--- 0.4/libio/oldfileops.c Sun, 09 Aug 1998 14:24:02 +0200 kettenis (libc/23_oldfileops 1.1 666)
+++ Local.5(w)/libio/oldfileops.c Sun, 09 Aug 1998 01:31:15 +0200 kettenis (libc/23_oldfileops 1.2 666)
@@ -53,6 +53,7 @@
# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
+# undef __stat
#endif
/* An fstream can be in at most one of put mode, get mode, or putback mode.
Index: libio/fileops.c
--- 0.4/libio/fileops.c Sun, 09 Aug 1998 14:24:02 +0200 kettenis (libc/24_fileops.c 1.1 666)
+++ Local.5(w)/libio/fileops.c Sun, 09 Aug 1998 01:29:17 +0200 kettenis (libc/24_fileops.c 1.2 666)
@@ -48,6 +48,7 @@
# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
+# undef __stat
#endif
/* An fstream can be in at most one of put mode, get mode, or putback mode.
Index: libio/filedoalloc.c
--- 0.4/libio/filedoalloc.c Sun, 09 Aug 1998 14:24:02 +0200 kettenis (libc/25_filedoallo 1.1 666)
+++ Local.5(w)/libio/filedoalloc.c Sun, 09 Aug 1998 01:29:00 +0200 kettenis (libc/25_filedoallo 1.2 666)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU IO Library.
This library is free software; you can redistribute it and/or
@@ -56,6 +56,7 @@
#ifdef _LIBC
# undef isatty
# define isatty(Fd) __isatty (Fd)
+# undef __stat
#endif
/*
Index: include/sys/stat.h
--- 0.4/include/sys/stat.h Sun, 09 Aug 1998 14:24:02 +0200 kettenis (libc/26_stat.h 1.1 666)
+++ Local.5(w)/include/sys/stat.h Sun, 09 Aug 1998 14:46:50 +0200 kettenis (libc/26_stat.h 1.2 666)
@@ -5,10 +5,30 @@
functions in the shared library must reference the `xstat' etc functions.
We have to use macros but we cannot define them in the normal headers
since on user level we must use real functions. */
+#ifndef stat
#define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
+#endif
+#ifndef __stat
+#define __stat(fname, buf) __xstat (_STAT_VER, fname, buf)
+#endif
+#ifndef fstat
#define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
+#endif
+#ifndef __fstat
+#define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
+#endif
+#ifndef lstat
#define lstat(fname, buf) __lxstat (_STAT_VER, fname, buf)
+#endif
+#ifndef __lstat
#define __lstat(fname, buf) __lxstat (_STAT_VER, fname, buf)
+#endif
+#ifndef stat64
#define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
+#endif
+#ifndef fstat64
#define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
+#endif
+#ifndef lstat64
#define lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf)
+#endif