Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Fix for asm/system.h
@ 1999-04-29 21:22 Nils Faerber
  1999-04-30 11:09 ` Phil Carmody
  1999-05-02 20:16 ` Richard Henderson
  0 siblings, 2 replies; 6+ messages in thread
From: Nils Faerber @ 1999-04-29 21:22 UTC (permalink / raw)
  To: Linux AXP Mailinglist

Hello!
While compiling a C++ program I noticed a little nastiness in asm/system.h
(for Alpha of course). G++ always complained that an implicit cast would not
be allowed with ANSI C++. OK I thought, then make it explicit ;)
Here is a little diff... would someone please include this for the next
kernel release?
Thanks!
CU
  nils

*** /usr/src/linux-2.2.6/include/asm/system.h	Thu Apr  1 00:00:29 1999
--- system.h	Thu Apr 29 17:01:37 1999
***************
*** 292,300 ****
  {
  	switch (size) {
  		case 4:
! 			return xchg_u32(ptr, x);
  		case 8:
! 			return xchg_u64(ptr, x);
  	}
  	__xchg_called_with_bad_pointer();
  	return x;
--- 292,300 ----
  {
  	switch (size) {
  		case 4:
! 			return xchg_u32((volatile int *)ptr, x);
  		case 8:
! 			return xchg_u64((volatile long *)ptr, x);
  	}
  	__xchg_called_with_bad_pointer();
  	return

-- 
Nils Faerber (Linux Nils)        eMail: nils@unix-ag.org
Student of computer science      http://www.si.unix-ag.org/~nils/
Unix user group, University of Siegen, Germany

Siegen ... the arctic rain forest!
--


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for asm/system.h
  1999-04-29 21:22 Fix for asm/system.h Nils Faerber
@ 1999-04-30 11:09 ` Phil Carmody
  1999-04-30 16:35   ` Wes Bauske
  1999-05-02 20:16 ` Richard Henderson
  1 sibling, 1 reply; 6+ messages in thread
From: Phil Carmody @ 1999-04-30 11:09 UTC (permalink / raw)
  To: axp-list

>>>>> "Nils" == Nils Faerber <Nils.Faerber@unix-ag.org> writes:

My view is highly dependent on what system.h actually contains (viz. the
type of ptr), I don't have access to the file at the moment, however, I
would say: 
Never use an explicit cast solely to silence a compiler warning.
The action being preformed by the code remains the same, if it's dangerous
let is be flagged as such.
(And why is code with switch statements in a header file?)

Phil

Nils> Hello!
Nils> While compiling a C++ program I noticed a little nastiness in asm/system.h
Nils> (for Alpha of course). G++ always complained that an implicit cast would not
Nils> be allowed with ANSI C++. OK I thought, then make it explicit ;)
Nils> Here is a little diff... would someone please include this for the next
Nils> kernel release?
Nils> Thanks!
Nils> CU
Nils>   nils

Nils> *** /usr/src/linux-2.2.6/include/asm/system.h	Thu Apr  1 00:00:29 1999
Nils> --- system.h	Thu Apr 29 17:01:37 1999
Nils> ***************
Nils> *** 292,300 ****
Nils>   {
Nils>   	switch (size) {
Nils>   		case 4:
Nils> ! 			return xchg_u32(ptr, x);
Nils>   		case 8:
Nils> ! 			return xchg_u64(ptr, x);
Nils>   	}
Nils>   	__xchg_called_with_bad_pointer();
Nils>   	return x;
Nils> --- 292,300 ----
Nils>   {
Nils>   	switch (size) {
Nils>   		case 4:
Nils> ! 			return xchg_u32((volatile int *)ptr, x);
Nils>   		case 8:
Nils> ! 			return xchg_u64((volatile long *)ptr, x);
Nils>   	}
Nils>   	__xchg_called_with_bad_pointer();
Nils>   	return


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for asm/system.h
  1999-04-30 11:09 ` Phil Carmody
@ 1999-04-30 16:35   ` Wes Bauske
  0 siblings, 0 replies; 6+ messages in thread
From: Wes Bauske @ 1999-04-30 16:35 UTC (permalink / raw)
  To: axp-list

Phil Carmody wrote:
> 
> >>>>> "Nils" == Nils Faerber <Nils.Faerber@unix-ag.org> writes:
> 
> My view is highly dependent on what system.h actually contains (viz. the
> type of ptr), I don't have access to the file at the moment, however, I
> would say:
> Never use an explicit cast solely to silence a compiler warning.
> The action being preformed by the code remains the same, if it's dangerous
> let is be flagged as such.
> (And why is code with switch statements in a header file?)
> 

Because it has several inlined routines which are architecture
dependent (asm). The cast looks reasonable to me.


Wes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for asm/system.h
  1999-04-29 21:22 Fix for asm/system.h Nils Faerber
  1999-04-30 11:09 ` Phil Carmody
@ 1999-05-02 20:16 ` Richard Henderson
  1999-05-03  2:03   ` Nils Faerber
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Henderson @ 1999-05-02 20:16 UTC (permalink / raw)
  To: axp-list

On Thu, Apr 29, 1999 at 11:22:42PM +0200, Nils Faerber wrote:
> While compiling a C++ program I noticed a little nastiness in asm/system.h
> (for Alpha of course).

Why are you including <asm/system.h> from a userland program?


r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for asm/system.h
  1999-05-02 20:16 ` Richard Henderson
@ 1999-05-03  2:03   ` Nils Faerber
  1999-05-03  6:55     ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Nils Faerber @ 1999-05-03  2:03 UTC (permalink / raw)
  To: axp-list

Hello!

> On Thu, Apr 29, 1999 at 11:22:42PM +0200, Nils Faerber wrote:
> > While compiling a C++ program I noticed a little nastiness in asm/system.h
> > (for Alpha of course).
> Why are you including <asm/system.h> from a userland program?
Bacause it needs to do some inb() and outb()...

> r~
CU
  nils

PS: In fact it is the Linux Utility for the Diamond Rio MP3 player...

-- 
Nils Faerber (Linux Nils)        eMail: nils@unix-ag.org
Student of computer science      http://www.si.unix-ag.org/~nils/
Unix user group, University of Siegen, Germany

Siegen ... the arctic rain forest!
--


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for asm/system.h
  1999-05-03  2:03   ` Nils Faerber
@ 1999-05-03  6:55     ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 1999-05-03  6:55 UTC (permalink / raw)
  To: axp-list

On Mon, May 03, 1999 at 04:03:19AM +0200, Nils Faerber wrote:
> > Why are you including <asm/system.h> from a userland program?
> Bacause it needs to do some inb() and outb()...

That ain't the way.  See <sys/io.h>.


r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-05-03  7:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-04-29 21:22 Fix for asm/system.h Nils Faerber
1999-04-30 11:09 ` Phil Carmody
1999-04-30 16:35   ` Wes Bauske
1999-05-02 20:16 ` Richard Henderson
1999-05-03  2:03   ` Nils Faerber
1999-05-03  6:55     ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox