libgloss/debug.h and mem_err
J. Johnston
jjohnstn@redhat.com
Tue Apr 16 13:10:00 GMT 2002
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 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?
-- 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 Sherrill, Ph.D. Director of Research & Development
> joel@OARcorp.com On-Line Applications Research
> Ask me about RTEMS: a free RTOS Huntsville AL 35805
> Support Available (256) 722-9985
More information about the Newlib
mailing list