Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread Michal Schmidt

Rob Prowel wrote:
[1.] One line summary of the problem:


2.4 and 2.6 kernel headers use c++ reserved word "new"
as identifier in function prototypes.


Yes, the kernel is written in C, not C++.


using the identifier "new" in kernel headers that are
visible to applications programs is a bad idea.


Programs are not supposed to include kernel headers.
This is a FAQ, see the archives.

Michal
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread Schneelocke
On 06/07/05, Rob Prowel <[EMAIL PROTECTED]> wrote:
> 2.4 and 2.6 kernel headers use c++ reserved word "new"
> as identifier in function prototypes.
> [...]
> While not an error, per se, it is kind of sloppy and
> it is amazing that it hasn't shown up before now.
> using the identifier "new" in kernel headers that are
> visible to applications programs is a bad idea.

This has been discussed before: see
http://marc.theaimsgroup.com/?l=linux-kernel&m=111637766131104&w=2 and
the ensuing thread.

-- 
schnee
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread Richard B. Johnson

On Wed, 6 Jul 2005, Alexey Dobriyan wrote:


On Wednesday 06 July 2005 13:26, Rob Prowel wrote:

When kernel headers are included in compilation of c++
programs the compile fails because some header files
use "new" in a way that is illegal for c++.  This
shows up when compiling mySQL under linux 2.6.  It
uses $KERNELSOURCE/include/asm-i386/system.h.


Please read http://marc.theaimsgroup.com/?t=1116301&r=2&w=2
where people discuss this brokeness of MySQL.



Just for kicks, see if this 'fixes' it. Then contact the MySQL
people and complain.


--- /usr/src/linux-2.6.12/include/asm-i386/system.h.orig2005-07-06 
14:01:25.0 -0400
+++ /usr/src/linux-2.6.12/include/asm-i386/system.h 2005-07-06 
14:03:42.0 -0400
@@ -235,7 +235,7 @@

 /*
  * Atomic compare and exchange.  Compare OLD with MEM, if identical,
- * store NEW in MEM.  Return the initial value in MEM.  Success is
+ * store New in MEM.  Return the initial value in MEM.  Success is
  * indicated by comparing RETURN with OLD.
  */

@@ -244,26 +244,26 @@
 #endif

 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
- unsigned long new, int size)
+ unsigned long New, int size)
 {
unsigned long prev;
switch (size) {
case 1:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
 : "=a"(prev)
-: "q"(new), "m"(*__xg(ptr)), "0"(old)
+: "q"(New), "m"(*__xg(ptr)), "0"(old)
 : "memory");
return prev;
case 2:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
 : "=a"(prev)
-: "q"(new), "m"(*__xg(ptr)), "0"(old)
+: "q"(New), "m"(*__xg(ptr)), "0"(old)
 : "memory");
return prev;
case 4:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
 : "=a"(prev)
-: "q"(new), "m"(*__xg(ptr)), "0"(old)
+: "q"(New), "m"(*__xg(ptr)), "0"(old)
 : "memory");
return prev;
}




Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips).
 Notice : All mail here is now cached for review by Dictator Bush.
 98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread Jakob Oestergaard
On Wed, Jul 06, 2005 at 02:26:57AM -0700, Rob Prowel wrote:
> [1.] One line summary of the problem:
> 
> 2.4 and 2.6 kernel headers use c++ reserved word "new"
> as identifier in function prototypes.

Correction:

[1.] One line summary of problem:

Userspace application is making use of private kernel headers.

> 
> [2.] Full description of the problem/report:
> 
> When kernel headers are included in compilation of c++
> programs the compile fails because some header files
> use "new" in a way that is illegal for c++.  This
> shows up when compiling mySQL under linux 2.6.  It
> uses $KERNELSOURCE/include/asm-i386/system.h.

Corrected:

[2.] Full description of the problem/report:

When userspace applications include headers they shouldn't, all kinds of
problems can appear. One example of this shows up when compiling mySQL
under linux 2.6.  It uses $KERNELSOURCE/include/asm-i386/system.h.

...
> While not an error, per se, it is kind of sloppy and
> it is amazing that it hasn't shown up before now. 

It has shown up, and it has been discussed. Search the archives. I'm
pretty sure the exact problem you're reporting was discussed here a few
months back.

> using the identifier "new" in kernel headers that are
> visible to applications programs is a bad idea.

Noone's doing that. Because the headers aren't meant to be visible.

This is not a C vs. C++ problem and it has nothing to do with
'sloppiness'. Something much subtler could have happened had it been C
application code which would have parsed cleanly but just broken in
strange ways (due to assumptions in kernel header code which just happen
to not be met in the userspace code). Actually, you should be greatful
someone used 'new' - at least now the error is caught at compile time ;)

It should be simple to fix MySQL to keep it's dirty little fingers off
of the kernel's private parts..

Really, that is the solution.

Take a look at *what* MySQL is doing with the header. If it is the same
problem (I have not double checked, but I guess chances are good) as was
reported earlier, it's really just a small braindamage in MySQL which is
easily fixed (thus removing the need for inclusion of the header in
question).

-- 

 / jakob

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread David Woodhouse
On Wed, 2005-07-06 at 02:26 -0700, Rob Prowel wrote:
> While not an error, per se, it is kind of sloppy and
> it is amazing that it hasn't shown up before now. 
> using the identifier "new" in kernel headers that are
> visible to applications programs is a bad idea.

It _is_ an error, on mysql's part. The kernel headers are _not_ intended
to be visible to applications, in the general case. Why is mysql
including this header? 

-- 
dwmw2

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread Alexey Dobriyan
On Wednesday 06 July 2005 13:26, Rob Prowel wrote:
> When kernel headers are included in compilation of c++
> programs the compile fails because some header files
> use "new" in a way that is illegal for c++.  This
> shows up when compiling mySQL under linux 2.6.  It
> uses $KERNELSOURCE/include/asm-i386/system.h.

Please read http://marc.theaimsgroup.com/?t=1116301&r=2&w=2
where people discuss this brokeness of MySQL.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread Jesper Juhl
On 7/6/05, Rob Prowel <[EMAIL PROTECTED]> wrote:
> [1.] One line summary of the problem:
> 
> 2.4 and 2.6 kernel headers use c++ reserved word "new"
> as identifier in function prototypes.
> 
"new" is not a reserved word in C. the kernel is written in C.


> [2.] Full description of the problem/report:
> 
> When kernel headers are included in compilation of c++
> programs the compile fails because some header files
> use "new" in a way that is illegal for c++.

Userspace programs should not include kernel headers directly.

But, if you really want it changed I suggest you create a patch and
submit that for review/inclusion and see what feedback you get.


-- 
Jesper Juhl <[EMAIL PROTECTED]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please  http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: PROBLEM: please remove reserved word "new" from kernel headers

2005-07-06 Thread Jurriaan on adsl-gate
On Wed, Jul 06, 2005 at 02:26:57AM -0700, Rob Prowel wrote:
> [1.] One line summary of the problem:
> 
> 2.4 and 2.6 kernel headers use c++ reserved word "new"
> as identifier in function prototypes.
> 
This is a FAQ.

1) kernel headers are for kernel use.
2) the kernel is written in C, not C++.
3) if userspace needs those headers, write your own based on the kernel
headers.

Do you really think you're the first to notice this since it exists in
2.4 headers?

Good luck,
Jurriaan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/