Re: How to extend the task_struct?

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Tue, 4 Aug 1998 13:16:07 +0200 (MET DST)


>
>
> On Tue, 4 Aug 1998, Marc Bechler wrote:
>
> > I had to extend the task_struct structure in the kernel (in sched.h) for
> > some measurements. First I thought this won't so difficult: I append a
> > new component at the end of the structure (an integer) and adapt the
> > INIT_TASK definition by inserting a ,0 at the end.
>
> yep, thats the way it's done. Take a look at say patch-2.1.107 as an
> example. (two new fields were added)
>
> > While compiling the kernel I got the following errors:
> >
> > init_task.c:24: parse error before ','
> > init_task.c:24: warning: missing braces around initializer after 'init_task_union.task.sigmask.lock'
> > init_task.c:24: warning: excess elements in struct initializer after 'init_task_union.task.sigmask.lock'
> > gcc: internal compiler error...
>
> most probably a simple typo :)

That was not a typo. This is the same problem discussed now regarding 114
with empty structure initializers. In 109, just keep sigmask_lock as the
last member...

BTW: Isn't it much better to use a
typedef struct { char old_gcc_is_buggy } spinlock_t;

isntead of
typedef { int gcc_is_buggy } spinlock_t;

for spinlock_t on UP (so that it does
not waste that much space) or even better, conditionally define it to {} for
egcs and gcc 2.8 if those handle it right?

Like
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 8
typedef struct {} spinlock_t;
#define SPIN_LOCK_UNLOCKED {}
#else
typedef struct { char old_gcc_is_buggy } spinlock_t;
#define SPIN_LOCK_UNLOCKED { 0 }
#endif

Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
Ultralinux - first 64bit OS to take full power of the UltraSparc
Linux version 2.1.112 on a sparc64 machine (498.80 BogoMips).
___________________________________________________________________

-
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