Subject: Re: gcc 4 and casts stripping volatile
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 06/23/2007 15:18:42
In article <l03102800c2a2e26cd19d@q840.causeuse.org>,
Hauke Fath  <hauke@NetBSD.org> wrote:
>Hi,
>
>building a mac68k kernel with kgdb enabled, I was stopped by a warning from
>gcc 4 where the code strips a volatile qualifier from a variable by a cast:
>
>--- zs_kgdb.o ---
>cc1: warnings being treated as errors
>../../../../arch/mac68k/dev/zs_kgdb.c: In function 'zs_kgdb_init':
>../../../../arch/mac68k/dev/zs_kgdb.c:182: warning: cast discards
>qualifiers from pointer target type
>*** [zs_kgdb.o] Error code 1
>
>Looking through the source, other ports with the Z8530 SIO seem to have the
>same issue, and only sparc has fixed it:
>
>[hauke@pizza] /<3>sys/arch > grep -E 'kgdb_attach.+zs' */dev/*
>mac68k/dev/zs_kgdb.c:   kgdb_attach(zs_getc, zs_putc, (void *)zc);
>macppc/dev/zs_kgdb.c:   kgdb_attach(zs_getc, zs_putc, (void *)zc);
>next68k/dev/zs_kgdb.c:  kgdb_attach(zs_getc, zs_putc, (void *)zc);
>sgimips/dev/zs_kgdb.c:  kgdb_attach(zs_getc, zs_putc, (void *)zc);
>sparc/dev/zs_kgdb.c:    kgdb_attach(zs_getc, zs_putc, __UNVOLATILE(zc));
>sun2/dev/zs_kgdb.c:     kgdb_attach(zs_getc, zs_putc, (void *)zc);
>sun3/dev/zs_kgdb.c:     kgdb_attach(zs_getc, zs_putc, (void *)zc);
>[hauke@pizza] /<3>sys/arch > fgrep __UNVOLATILE ../sys/*
>../sys/cdefs.h:#define __UNVOLATILE(a)  ((void *)(unsigned long)(volatile
>void *)(a))
>[hauke@pizza] /<3>sys/arch >
>
>Is it okay if I go in, make the __UNVOLATILE() change, and request a pullup
>to netbsd-4?

Sure, go ahead.

christos