This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib 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: libgloss/debug.h and mem_err


Joel Sherrill wrote:
> 
> "J. Johnston" wrote:
> >
> > Joel Sherrill wrote:
> > >
> > > debug.h thinks mem_err is not volatile.
> > >
> > > All the files that have mem_err seem to think it is.
> > >
> > > [joel@mail libgloss]$ grep mem_err */*.c | grep int
> > > mips/lsi33k-stub.c:static volatile int mem_err = 0;
> > > sparc/sparc-stub.c:static volatile int mem_err = 0;
> > > sparc/sparcl-stub.c:static volatile int mem_err = 0;
> > > sparc/sparclet-stub.c:static volatile int mem_err = 0;
> > >
> > > This patch fixes it for the sparc.  I have not tried the
> > > mips yet but if it included debug.h, I would think it
> > > would have the same problem.
> > >
> > > What's the right fix?  This works for sparc:
> > >
> >
> > Could you describe the bug that you originally saw?
> 
> The sparc-elf target doesn't compile because is says the
> the type conflicts.
> 
> > The variable mem_err is being used in two different scopes.
> > In the stub files, it is declared as static which means it is file-scope.
> > In the header file, it is being declared global.  Are you seeing a warning
> > that the file-scope variable is over-riding the global declaration of the
> > same name?
> 
> I can't really see why it is debug.h since it appears to be a static
> variable most of the time.  Maybe the right solution is to take it
> out of debug.h.
> 
> I am not sure what the right fix is.  But sparc and debug.h
> should agree on it somehow.
> 

I have checked in the change.  The global definition in debug.c has it as volatile
so it should match.

-- Jeff J.


> >
> > > Index: debug.h
> > > ===================================================================
> > > RCS file: /cvs/src/src/libgloss/debug.h,v
> > > retrieving revision 1.1
> > > diff -u -r1.1 debug.h
> > > --- debug.h     17 Mar 2000 22:48:49 -0000      1.1
> > > +++ debug.h     16 Apr 2002 16:42:52 -0000
> > > @@ -77,7 +77,7 @@
> > >   * indicate to caller of mem2hex or hex2mem that there has been an
> > > error.
> > >   * 0 means ok, 1 means error
> > >   */
> > > -extern int mem_err;
> > > +extern volatile int mem_err;
> > >
> > >  /*
> > >   * indicate whether the debug vectors have been initialized
> > >
> --joel


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