This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fixinc help with Solaris 9?


Gerald Pfeifer wrote:
> 
> Bruce,
> 
> given that this problem has been plaguing me for several months now,
> and I believe this is really a problem for real-world users, would
> you mind having a look at the following issue concerning Solaris 9
> and fixinc?
> 
>   http://gcc.gnu.org/ml/libstdc++/2002-08/msg00114.html
>   http://gcc.gnu.org/ml/libstdc++/2002-08/msg00173.html
>   http://gcc.gnu.org/ml/libstdc++/2002-08/msg00174.html
> 
> I'll try to provide whatever help I can provide, but this is beyond
> the scope of things I could try to tackle without spending days to
> get started. :-(

Sure.  A few preliminaries:
1.  I do the best I can to monitor GCC & gcc-patches, but I'm not
    guaranteed to see anything that is not either addressed to me
    or contains the string "fixinc" in the subject line.  Sorry.

    In libstdc++ mailing list:
    > Loren provided a fixincludes patch, but it never went in.
    >  (See audit trail for more.)
    [[ I didn't see an audit trail and I've slept enough times
       since then that I don't remember any more. ]]

2.  I will never see anything on C++ lists

> I've been hunting through Sun's bug reports, none of them mention a
> bracketing problem with the initializer.  If it is fixed, there's nothing
> particular at Sun to point to.

That silly PTHREAD_MUTEX_INITIALIZER macro is a monsterous monstrosity.
Its structure depends upon various settings, so no one format will work.
That "upad64_t" thing is quite ugly:

> /*
>  * The [u]pad64_t is to be used in structures such that those structures
>  * may be accessed by code produced by compilation environments which don't
>  * support a 64 bit integral datatype.  This intention is not to allow
>  * use of these fields in such environments, but to maintain the alignment
>  * and offsets of the structure.
>  */
> #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
> typedef uint64_t        upad64_t;
> #else
> typedef union {
>         double   _d;
>         uint32_t _l[2];
> } upad64_t;
> #endif

> To satisfy Bruce, I think you will want to update the
> hack without adding a new hack.

Bruce will be readily satisfied with anything that works.
Bruce has preferences, but the crucial bottom line is that
it has to work.  I'm sorry, Loren, if you felt put off.


Anyway, below are the initializers and structures for the
various solaris releases with whatever patches may have been
applied.  I don't know.  Please suggest a fix.  I don't mean
to be too picky, but the hack must:

1.  Fix all occurrances of real problems
2.  not make real problems where none existed before

Beyond that, there are "nice to haves":

3.  avoid shell script fixes (sed, awk, etc.)  they are slow
    and portability is limited.
4.  More fixes --> more time.  So, if convenient, and if it
    doesn't lead to obscurity, ....
5.  Avoid altering files in ways that do not make a difference.

The fix may be written in C, sed, my weirdo "format" construct
or even a shell script.  (Remember to rely on portable constructs, tho)

=============  Solaris 2.9:
#pragma ident   "@(#)pthread.h  1.32    01/11/10 SMI"

/*
 * macros - default initializers defined as in synch.h
 * Any change here should be reflected in synch.h.
 *
 * NOTE:
 * Make sure that any change in the macros is consistent with the definition
 * of the corresponding types in sys/types.h (e.g. PTHREAD_MUTEX_INITIALIZER
 * should be consistent with the definition for pthread_mutex_t).
 */
#define PTHREAD_MUTEX_INITIALIZER               /* = DEFAULTMUTEX */    \
        {{0, 0, 0, DEFAULT_TYPE, _MUTEX_MAGIC}, {{{0}}}, 0}
/*
 * Thread and LWP mutexes have the same type
 * definitions.
 *
 * NOTE:
 *
 * POSIX requires that <pthread.h> define the structures pthread_mutex_t
 * and pthread_cond_t.  Although these structures are identical to mutex_t
 * (lwp_mutex_t) and cond_t (lwp_cond_t), defined here, a typedef of these
 * types would require including <synch.h> in <pthread.h>, pulling in
 * non-posix symbols/constants, violating POSIX namespace restrictions.  Hence,
 * pthread_mutex_t/pthread_cond_t have been redefined (in <sys/types.h>).
 * Any modifications done to mutex_t/lwp_mutex_t or cond_t/lwp_cond_t must
 * also be done to pthread_mutex_t/pthread_cond_t.
 */
typedef struct _lwp_mutex {
        struct {
                uint16_t        flag1;
                uint8_t         flag2;
                uint8_t         ceiling;
                union {
                        uint16_t bcptype;
                        struct {
                                uint8_t count_type1;
                                uint8_t count_type2;
                        } mtype_rcount;
                } mbcp_type_un;
                uint16_t        magic;
        } flags;
        union {
                struct {
                        uint8_t pad[8];
                } lock64;
                struct {
                        uint32_t ownerpid;
                        uint32_t lockword;
                } lock32;
                upad64_t owner64;
        } lock;
        upad64_t data;
} lwp_mutex_t;

=============  Solaris 2.8:
#pragma ident   "@(#)pthread.h  1.28    99/11/15 SMI"

/*
 * macros - default initializers defined as in synch.h
 * Any change here should be reflected in synch.h.
 *
 * NOTE:
 * Make sure that any change in the macros is consistent with the definition
 * of the corresponding types in sys/types.h (e.g. PTHREAD_MUTEX_INITIALIZER
 * should be consistent with the definition for pthread_mutex_t).
 */
/* = DEFAULTMUTEX */
#define PTHREAD_MUTEX_INITIALIZER       {{0, 0, 0, 0}, {{{0}}}, 0}

/*
 * Thread and LWP mutexes have the same type
 * definitions.
 *
 * NOTE:
 *
 * POSIX requires that <pthread.h> define the structures pthread_mutex_t
 * and pthread_cond_t.  Although these structures are identical to mutex_t
 * (lwp_mutex_t) and cond_t (lwp_cond_t), defined here, a typedef of these
 * types would require including <synch.h> in <pthread.h>, pulling in
 * non-posix symbols/constants, violating POSIX namespace restrictions.  Hence,
 * pthread_mutex_t/pthread_cond_t have been redefined (in <sys/types.h>).
 * Any modifications done to mutex_t/lwp_mutex_t or cond_t/lwp_cond_t must
 * also be done to pthread_mutex_t/pthread_cond_t.
 */
typedef struct _lwp_mutex {
        struct _mutex_flags {
                uint16_t        flag1;
                uint8_t         flag2;
                uint8_t         ceiling;
                union _mbcp_type_un {
                        uint16_t bcptype;
                        struct _mtype_rcount {
                                uint8_t         count_type1;
                                uint8_t         count_type2;
                        } mtype_rcount;
                } mbcp_type_un;
                uint16_t        magic;
        } flags;
        union _mutex_lock_un {
                struct _mutex_lock {
                        uint8_t pad[8];
                } lock64;
                upad64_t owner64;
        } lock;
        upad64_t data;
} lwp_mutex_t;

=============  Solaris 2.7:
#pragma ident   "@(#)pthread.h  1.26    98/04/12 SMI"

/*
 * macros - default initializers defined as in synch.h
 * Any change here should be reflected in synch.h.
 */
/* = DEFAULTMUTEX */
#define PTHREAD_MUTEX_INITIALIZER       {{{0}, 0}, {{{0}}}, 0}

/*
 * Thread and LWP mutexes have the same type
 * definitions.
 */
typedef struct _lwp_mutex {
        struct _mutex_flags {
                uint16_t        flag[2];
                union _mbcp_type_un {
                        uint16_t bcptype;
                        struct _mtype_rcount {
                                uint8_t         count_type1;
                                uint8_t         count_type2;
                        } mtype_rcount;
                } mbcp_type_un;
                uint16_t        magic;
        } flags;
        union _mutex_lock_un {
                struct _mutex_lock {
                        uint8_t pad[8];
                } lock64;
                upad64_t owner64;
        } lock;
        upad64_t data;
} lwp_mutex_t;

=============  Solaris 2.6:
#pragma ident   "@(#)pthread.h  1.16    97/05/05 SMI"

/*
 * macros - default initializers defined as in synch.h
 * Any change here should be reflected in synch.h.
 */
#define PTHREAD_MUTEX_INITIALIZER       {0, 0, 0}       /* = DEFAULTMUTEX */

/*
 * Thread and LWP mutexes have the same type
 * definitions.
 */
typedef struct _lwp_mutex {
        struct _mutex_flags {
                uint8_t         flag[4];
                uint16_t        type;
                uint16_t        magic;
        } flags;
        union _mutex_lock_un {
                struct _mutex_lock {
                        uint8_t pad[8];
                } lock64;
                upad64_t owner64;
        } lock;
        upad64_t data;
} lwp_mutex_t;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]