You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexey Varlamov (JIRA)" <ji...@apache.org> on 2008/03/20 13:09:33 UTC

[jira] Commented: (HARMONY-5623) [drlvm][thread] Fix warnings from the offsetof() macro

    [ https://issues.apache.org/jira/browse/HARMONY-5623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580729#action_12580729 ] 

Alexey Varlamov commented on HARMONY-5623:
------------------------------------------

Many thanks for addressing this annoying issue!
I'd vote for the second approach - indeed access modifier does not do it's job here...

> [drlvm][thread] Fix warnings from the offsetof() macro
> ------------------------------------------------------
>
>                 Key: HARMONY-5623
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5623
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Linux
>            Reporter: Ilya Berezhniuk
>            Priority: Minor
>         Attachments: off_warn2.patch, off_warn_h.patch
>
>
> There are several similar warnings appeared when compiling DRLVM on GCC:
> "perhaps the `offsetof` macro was used incorrectly".
> All these warnings appear because VM_thread structure becomes non-POD structure with private/public access modifiers.
> There are some methods to solve this problem.
> 1) The first one is using runtime offset calculation instead of compile-time 'offsetof'.
> Such a calculation looks like getting an address of some field of a zeroed local pointer to VM_thread structure.
> In release mode compilers turn local var usage into a constant, so there is no performance issue.
> The 'off_warn2.patch' implements this solution.
> Potential problem of such a method, and of using 'private' modifier in #ifdef at all, is that modern optimising compilers could reorder fields in non-POD structure, and even trow away private fields which are not used. In this case VM_thread fields will be different in C and C++ sources.
> 2) Another solution is removing private/public modifiers from VM_thread definition. It's much simpler, and these modifiers actually do not protect anything, because VM_thread to HyThread casting is used everywhere, so everybody can use casted HyThread directly.
> The 'off_warn_h.patch' implements this solution.
> Thread gurus, please decide what method should be used.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.