public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Reza Roboubi <reza@parvan.net>
To: Andrew Haley <aph@redhat.com>
Cc: Nicholas Sherlock <n.sherlock@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: short pointers (32 bit) in 64 bit apps
Date: Wed, 19 May 2010 19:08:00 -0000	[thread overview]
Message-ID: <4BF42C4C.2050606@parvan.net> (raw)
In-Reply-To: <4BF3AE52.4080608@redhat.com>

Andrew Haley wrote:
>> Essentially, you would want a pointer type modifier:
>>
>> struct list {
>>   struct list short * next;
>> };
>>
>>> Then you can add the top 32-bits to pointer addresses within your data
>>> structure before you attempt to dereference them.
>> That's the point:  not having to do this manually.
> 
> I don't see the point of changing the language.  Define a custom allocator
> and store the pointers in uint32_t variables.  C++ makes this very easy:
> see below.
> 
> Andrew.
> 
> #include <cstdint>
> #include <cstdio>
> 
> template<class T> class shortptr
> {
 > [...]

---------------------------------------
Two more quotes from Linus Torvalds:
"C++ leads to really really bad design choices [...]"
"the whole C++ exception handling thing is fundamentally broken. It's
    _especially_ broken for kernels"
---------------------------------------

Trust me, doing this in the compiler is a _much_ more sane, easy to 
implement, and clean solution.  As Ian Taylor said, you just need some 
tweaking of loads and stores.  That, and the "short" language keyword.
(The problem is that gcc is huge and complex for getting started.)

If you use C++ templates, it can get crazy very quickly:  imagine trying 
to reference this template based object (using a void short **) (for 
passing to a generic function like memcpy.)  Now suddenly, you must 
write another template to represent that (assuming C++ even allows that, 
and the g++ implementation of "void **" or "char **" templates is bug 
free.)  You must then make your generic function("memcpy") aware of 
these types, which wasn't part of the original design plan (it's really 
crazy!)  Then, you'll have to write type converters (say what!) to go 
back and forth between all these templates.

It's an awful mess!  The more you try to "fix" it, the more you realize 
it's broken.  The reason is that this "type-first-logic-second" 
mentality of C++ is just WRONG at a fundamental level, and that cannot 
be fixed.

C++ _might_ be useful for something like KDE, but then again GUI people 
don't need things like "short pointers" in the first place.

Reza.

  reply	other threads:[~2010-05-19 18:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17  9:51 Reza Roboubi
2010-05-18 14:45 ` Ian Lance Taylor
2010-05-19  5:58   ` Reza Roboubi
2010-05-19  8:27     ` Ian Lance Taylor
2010-05-19  8:55     ` Nicholas Sherlock
2010-05-19  9:24       ` Reza Roboubi
2010-05-19  9:46         ` Nicholas Sherlock
2010-05-19 18:34           ` Reza Roboubi
2010-05-19 21:24             ` Clemens Eisserer
2010-05-19 21:29               ` phi benard
2010-05-24 21:52                 ` Clemens Eisserer
2010-05-20  3:16             ` Ian Lance Taylor
2010-05-20 11:36               ` Nicholas Sherlock
2010-05-19  9:50         ` Andrew Haley
2010-05-19 19:08           ` Reza Roboubi [this message]
2010-05-20  2:29             ` John S. Fine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BF42C4C.2050606@parvan.net \
    --to=reza@parvan.net \
    --cc=aph@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=n.sherlock@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).