[v4 1/4] ntdll: Proper handling of debug regs on x86-64.

Andrew Wesie awesie at gmail.com
Mon Feb 13 16:00:12 CST 2017


On Mon, Feb 13, 2017 at 10:41 AM, Sebastian Lackner <sebastian at fds-team.de>
wrote:

>
> Adding those fields should work, but it is a bit dangerous because we only
> have
> limited space. I would suggest adding asserts to ensure we never make this
> struct
> too big. Something like this should work:
>
> C_ASSERT( FIELD_OFFSET(TEB, SpareBytes1) + sizeof(struct
> ntdll_thread_data) <=
>           FIELD_OFFSET(TEB, GdiTebBatch) + sizeof(((TEB *)0)->GdiTebBatch)
> );
>
>
Is the following acceptable:

C_ASSERT( sizeof(struct ntdll_thread_data) <= FIELD_OFFSET(TEB, gdiRgn) -
FIELD_OFFSET(TEB, SpareBytes1) );

It should be equivalent, but it is shorter and has less parenthesis.


> Probably we should also use it for important i386 fields, to ensure they
> are not
> moved.
>
> #ifdef __i386__
> C_ASSERT( FIELD_OFFSET(TEB, SpareBytes1) + FIELD_OFFSET(struct
> ntdll_thread_data, vm86) == FIELD_OFFSET(TEB, GdiTebBatch) );
> C_ASSERT( FIELD_OFFSET(TEB, SpareBytes1) + FIELD_OFFSET(struct
> ntdll_thread_data, vm86) == 0x1fc );
> C_ASSERT( FIELD_OFFSET(TEB, SpareBytes1) + FIELD_OFFSET(struct
> ntdll_thread_data, gs)   == 0x1d8 );
> #endif
>
>
Looks good to me. I'll add that to the patch.

-Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20170213/57f240b5/attachment.html>


More information about the wine-devel mailing list