This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cpplib: Start moving switch handling to front ends

On Thursday, August 8, 2002, at 12:11 AM, Zack Weinberg wrote:

On Thu, Aug 08, 2002 at 07:24:31AM +0100, Neil Booth wrote:
Zack Weinberg wrote:-

No, really.  The semantics of #import (and #pragma once) require that
the compiler be able to determine whether two include requests refer
to the same file, with 100% accuracy, for _correctness_.  This is
impossible without making unportable assumptions about file system
semantics, which cpplib does not do.
We have them at the top of cppinit.c for duplicate directory checking.
Are you sure there's nothing we can do (granted, it might be a bit
awkward).  I think expecting the millions of lines of ObjC code to
suddenly stop using it is a bit much.
It would not be that hard to do the inode/dev check after opening the
file, we call fstat() anyway. And that'd be a good idea. (Have to figure
out a way to index the include cache on two different keys, though.)
We do have local inode/dev check. Here is the code snippet...

static ino_t new_inode;
static dev_t new_device;
static struct include_file *repl_file;

static int inode_finder PARAMS ((splay_tree_node, void *data));

static int
inode_finder (x, data)
splay_tree_node x;
ino_t inode = 0;
dev_t device = 0;

if ((repl_file = (struct include_file *)x->value))
inode = repl_file->st.st_ino;
device = repl_file->st.st_dev;
if (inode == new_inode && device == new_device && DO_NOT_REREAD (repl_file))
return 1;
return 0;

and inside open_file()....

if (file->fd != -1 && fstat (file->fd, &file->st) == 0)
new_inode = file->st.st_ino;
new_device = file->st.st_dev;
if (splay_tree_foreach (pfile->all_include_files, inode_finder, 0))
close (file->fd);
file->fd = -1;
return repl_file;

if (!S_ISDIR (file->st.st_mode))
return file;

/* If it's a directory, we return null and continue the search
as the file we're looking for may appear elsewhere in the
search path. */
errno = ENOENT;
close (file->fd);
file->fd = -1;

If interesting, I will prepare patch.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]