Re: [PATCH 3/4] as-name: allow ident as address_space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 8, 2018 at 2:04 PM Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
>
> Since directly using the name instead of an number creates some
> problems internally, allow this syntax but for the moment keep
> the address space number and use a table to lookup the number
> from the name.

I suspect it would be much nicer to just make ctype.as be a "struct ident *".

It wouldn't even make "struct ctype" any bigger, because we already
pack that "unsigned int as" between two pointers, so making it a
pointer would just get rid of possible padding with 64-bit pointers.

Is it the odd combination rules that keeps us from doing that? We have
a couple of cases that treat address space numbers as bitmasks, and do

    as |= sym->ctype.as;

but I think we could just do it as some kind of

    struct ident *combine_address_space(struct ident *as1, struct ident *as2)
    {
        static struct ident bad_address_space = { .len = 6, .name="bad AS" };
        if (!as1) return as2;
        if (!as2) return as1;
        if (as1 == as2) return as1;
        return &bad_address_space;
    }

or something instead.

And yes, you'd obviously have to have the opposite "generate a ident
for numeric users" when parsing an old-style address space with just a
number, but that should be no worse than the current "generate a
string from numbers".  In fact, it should be simpler, since you can
just do something like

    struct ident *numeric_ident(unsigned int num)
    {
        static char buf[20];
        int len = snprintf(buf, sizeof(buf), "%u", num);
        return create_hashed_ident(name, len, hash_name(name, len));
    }

or similar.

Hmm?

Maybe I'm missing some other use of 'ctype.as'.

             Linus



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux