On Sat, Dec 08, 2018 at 02:30:48PM -0800, Linus Torvalds wrote: > 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? Partly that and partly because I an old patch somewhere which combined ctype.as and ctype.alignment. > 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'. No, not really (IIRC there is a single other case where ctype.as can't be used as a pointer but it shouldn't be a problem). Anyway, I wan't really happy about this series with its names array. I'll rewrite it using directly an ident it will be cleaner (and ctype will indded not increase in size). Thanks, -- Luc