lkml.org 
[lkml]   [1998]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: __initdata and string tables, usage consensus?
I've just tried this __initstr macro, it works on strings inside
functions, but you can't use it to initialise static or global tables of
strings :-( Might give someone some ideas though.

#include <asm/init.h>
#include <stdio.h>

#define __initstr(__s) \
({ static const char __str [] __initdata = (__s); __str; })
#define __initstrw(__s) \
({ static char __str [] __initdata = (__s); __str; })

__initfunc (static void init (void))
{
printf (__initstr ("Hi there!\n"));
}

-- Jamie

----------------------------------------------------------------------

Rafael Reilova wrote:
> I'm curious if there any consensus regarding the use of string tables and
> the __initdata on 2.1.x kernels. As you all know, something like:
>
> static char *table_foo[] __initdata {"string1", "string2", ....};
>
> Only puts the pointers to the strings in the init.data section but does
> not do the same for the actual strings. The same goes for local strings
> used inside an __initfunc.
>
> Currently the only way out is to name all strings, move them out of the
> function or table, and declare each one as __initdata. I.e.
>
> static char table_foo_string1[] __initdata = "string1";
> static char table_foo_string2[] __initdata = "string2";
> etc, etc...
>
> Then do,
>
> static char *table_foo[] __initdata{table_foo_string1,table_foo_string2,
> ........ };
>
> My question is, is this uglyness warranted? And if so, When?
>
> Also, I'm thinking of ways to avoid namespace pollution, since all strings
> now become file-global at least. How about prefixing all strings from a
> table with the table name, like above. Also, local function strings could
> be prefixed with the function name.
>
> I'm working on the Cyrix detection, and I have a lots of strings I don't
> need once the boot process is over :)
>
> Cheers,
>
> Rafael

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:43    [W:3.121 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site