stack addressing & type nomenclature



I recently worked with a piece of code where dereferencing the pointer
was too slow, and I was able to achieve a nearly 2x speed-up by
replacing a local array of size 8 with 8 local variables. (*x requires
2 fetches, x requires 1, so it's easy to explain it, I was just
surprised that I actually encountered a situation where it makes sense
to do this optimization.) Now, I want to test a similar situation, but
the array that will be replaced is substantially larger, and I'd like
to make the code "cleaner" by doing something like the following:

u_int32_t x0, x1, x2, ...., xN;
u_int32_t *p;
int i;
p = &xN;

for (i=0; i<N+1; i++) {
p[i] = initialize(i);
}

Really, the only advantage I get is that I don't have N+1 lines of
initialization in the source. This works in the one case I've
tested...is there any chance that I can rely on this? I'm not worried
about portability, but I am wondering if there's a chance that, for
instance, increasing N might cause the implementation to not put the
local variables in contiguous memory on the stack. Would it be safer
to declare a struct, or should I just avoid this 'trick' altogether?

Also, on a slightly related note, what's the deal with linux defining
"u_int32_t" instead of "uint32_t"? There's a comment before the
declarations of u_int{8,16,32}_t in /usr/include/sys/type.h (on Fedora
Core 3) that reads "But these were defined by ISO C without the first
`_'." Does this mean that ISO C wants the "_" to not be there, but the
linux implementation decided to add it? Which is the proper
nomenclature? My syntax highlighting (vim) recognizes uint32_t and not
u_int32_t, but gcc doesn't like uint32_t. Does it matter? And if so,
which is correct? I stated above that I don't care about portability,
but I want to do things properly at least!

.



Relevant Pages

  • Re: Lost A Good One
    ... They may have a higher chance here too. ... what you mean by "proper ones". ... engine and the tanker and the special services unit truck. ... paid firefighters here, ...
    (rec.scuba)
  • Re: ACES Status During STS-107 Re-Entry
    ... If the crew are wearing ACES properly they have ... >> chance to respond, if they aren't they have no chance. ... >> I'm trying to find out if not wearing ACES is something that all Shuttle ... leave their seats to enforce proper behaviour on the other crew ...
    (sci.space.shuttle)
  • Re: Tuqiri At Fullback
    ... [I don't know, this is proper, not a rhetorical ... with Latham injured isn't there the chance that ... Tuquiri is either pushing for that spot or being groomed for it? ... fit. ...
    (rec.sport.rugby.union)
  • Re: Which MBP should I get?
    ... should I stick to the 15in screen for greater portability do you think? ... If you get a chance, check them out in a store, see how they handle etc. ... new batch going to better? ...
    (uk.comp.sys.mac)
  • Re: Yanks pursuing Farnsworth
    ... >The proper place to "give the young pitchers a chance" is in Spring ... Or Robinson Cano or Chien-Mien Wang or Aaron Small (not he's so ...
    (alt.sports.baseball.ny-yankees)