2006-05-02 18:23:39

by Al Boldi

[permalink] [raw]
Subject: Re: Compiling C++ modules

Christer Weinigel <[email protected]> wrote:
>> eCos is nice enough -- because it's mostly C :)
>
> And those parts that are C++ (from a 2 year old eCos dist) won't
> compile with a modern g++.

C++ is OO, and OO is great! OO is the natural way of doing things, and
allows one to concentrate on the issues at hand, while leaving the
nitty-gritty to the compiler to decide.

And this is the problem, as kernel development is highly sensitive to
compiler output, and which is why there are parts written in asm and others
in C.

So rewriting C with C++ would be as dumb as rewriting asm with C.

But there may be certain higher level parts in the kernel that could benefit
from rewriting C with C++, much the same as lower level parts have benefited
from rewriting them in asm.

So we have a situation like this:

low-level written in asm when needed

main-level written in C mostly

high-level written in C++ when needed

Note though, C++ is not currently viable for kernel development, due to its
enormous overhead generated by immature compiler technology. Once this has
matured, there should be no problem.

> --
> "Just how much can I get away with and still go to heaven?"

Just know that HE is one and only one.

Thanks!

--
Al


2006-05-02 20:28:18

by J.A. Magallon

[permalink] [raw]
Subject: Re: Compiling C++ modules

On Tue, 2 May 2006 21:21:44 +0300, Al Boldi <[email protected]> wrote:

> Christer Weinigel <[email protected]> wrote:
> >> eCos is nice enough -- because it's mostly C :)
> >
> > And those parts that are C++ (from a 2 year old eCos dist) won't
> > compile with a modern g++.
>
> C++ is OO, and OO is great! OO is the natural way of doing things, and
> allows one to concentrate on the issues at hand, while leaving the
> nitty-gritty to the compiler to decide.
>
> And this is the problem, as kernel development is highly sensitive to
> compiler output, and which is why there are parts written in asm and others
> in C.
>
> So rewriting C with C++ would be as dumb as rewriting asm with C.
>
> But there may be certain higher level parts in the kernel that could benefit
> from rewriting C with C++, much the same as lower level parts have benefited
> from rewriting them in asm.
>
> So we have a situation like this:
>
> low-level written in asm when needed
>
> main-level written in C mostly
>
> high-level written in C++ when needed
>

You can control low level features in C++ even much better than in asm.
Just an example. You can be pretty sure that a function like this:

inline void f(const int& x)
{
}

would use the parameter you pass to it without doing a copy on the stack.
And that is not dependent on anything.
For example, I wrote a vector library to do math with SSE, and there it
is fundamental that you don't _ever_ write a xmm register to the stack or
to memory in temporary variables. Look like this:

class Vector {
float f[4];

typedef float __vr __attribute__((__mode__(__V4SF__),__aligned__(16)));

Vector operator+(const __vr that) const
{
return __builtin_ia32_addps(...);
};
Vector operator-(const __vr that) const
{
return __builtin_ia32_subps(...);
};
...
};

--
J.A. Magallon <jamagallon()able!es> \ Software is like sex:
werewolf!able!es \ It's better when it's free
Mandriva Linux release 2006.1 (Cooker) for i586
Linux 2.6.16-jam11 (gcc 4.1.1 20060330 (prerelease)) #1 SMP PREEMPT Mon


Attachments:
signature.asc (191.00 B)

2006-05-02 23:55:22

by Peter Williams

[permalink] [raw]
Subject: Re: Compiling C++ modules

Al Boldi wrote:
> Christer Weinigel <[email protected]> wrote:
>
>>>eCos is nice enough -- because it's mostly C :)
>>
>>And those parts that are C++ (from a 2 year old eCos dist) won't
>>compile with a modern g++.
>
>
> C++ is OO,

But not a very good implementation of it :-(.

> and OO is great! OO is the natural way of doing things, and
> allows one to concentrate on the issues at hand, while leaving the
> nitty-gritty to the compiler to decide.
>
> And this is the problem, as kernel development is highly sensitive to
> compiler output, and which is why there are parts written in asm and others
> in C.
>
> So rewriting C with C++ would be as dumb as rewriting asm with C.
>
> But there may be certain higher level parts in the kernel that could benefit
> from rewriting C with C++, much the same as lower level parts have benefited
> from rewriting them in asm.
>
> So we have a situation like this:
>
> low-level written in asm when needed
>
> main-level written in C mostly
>
> high-level written in C++ when needed
>
> Note though, C++ is not currently viable for kernel development, due to its
> enormous overhead generated by immature compiler technology. Once this has
> matured, there should be no problem.
>
>
>>--
>>"Just how much can I get away with and still go to heaven?"
>
>
> Just know that HE is one and only one.
>
> Thanks!
>
> --
> Al
>
> -
> 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/


--
Peter Williams [email protected]

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce

2006-05-03 08:10:09

by Steven Rostedt

[permalink] [raw]
Subject: Re: Compiling C++ modules



On Tue, 2 May 2006, Al Boldi wrote:

> > --
> > "Just how much can I get away with and still go to heaven?"
>
> Just know that HE is one and only one.
>

Who's "HE"? Linus? ;-)

-- Steve