* include/mach/message.h: Change mach_msg_type_name_t to unsigned char and mach_msg_type_size_t to unsigned short. Update definition of mach_msg_type_long_t. * include/mach/std_types.defs: Use char for mach_msg_type_name_t. * doc/mach.texi: Update info about mach_msg_type_{name,size}_t. ---
Hey On Mon, Apr 04, 2016 at 12:01:13PM +0200, Justus Winter wrote: > Quoting Samuel Thibault (2016-04-04 09:16:17) > > Hello, > > > > Flavio Cruz, on Sun 03 Apr 2016 16:12:48 +0200, wrote: > > > mach_msg_type_name_t and mach_msg_type_size_t are used as 8 bit fields in > > > mach_msg_type_t struct, therefore they should be treated as unsigned > > > char's to > > > avoid warnings when using macros such as MACH_MSG_TYPE_POLYMORPIC. > > > > Mmm, looking quickly at the mach code shows that there is a "long" > > variant of these fields, see for instance ipc_kmsg_clean_body() which > > uses a mach_msg_type_long_t > > I don't see a problem with that for mach_msg_type_name_t. The long > form is used if e.g. an array is transmitted with a size that cannot > be expressed with mach_msg_type_t, but there cannot be at type that > doesn't fit in 8 bits afaics. Exactly. > > If we restrict mach_msg_type_size_t to 8 bits, we limit the size a > single object in an array can have even for the long form. I was under the assumption that the size field would only go up to the maximum size of the basic mach types. I also noticed now that for some stubs the size can go up to 2^15. Since the long form uses unsigned short for the msgtl_size field, I propose we restrict mach_msg_type_size_t to unsigned short. diff --git a/doc/mach.texi b/doc/mach.texi index 0aeed76..eecba4d 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -1387,13 +1387,13 @@ descriptor allows larger values for some fields. The inline, longform, and deallocate bits. @deftp {Data type} mach_msg_type_name_t -This is an @code{unsigned int} and can be used to hold the +This is an @code{unsigned char} and can be used to hold the @code{msgt_name} component of the @code{mach_msg_type_t} and @code{mach_msg_type_long_t} structure. @end deftp @deftp {Data type} mach_msg_type_size_t -This is an @code{unsigned int} and can be used to hold the +This is an @code{unsigned short} and can be used to hold the @code{msgt_size} component of the @code{mach_msg_type_t} and @code{mach_msg_type_long_t} structure. @end deftp diff --git a/include/mach/message.h b/include/mach/message.h index 0a7297e..27f337b 100644 --- a/include/mach/message.h +++ b/include/mach/message.h @@ -188,8 +188,8 @@ typedef struct { * a mach_msg_type_long_t should be zero. */ -typedef unsigned int mach_msg_type_name_t; -typedef unsigned int mach_msg_type_size_t; +typedef unsigned char mach_msg_type_name_t; +typedef unsigned short mach_msg_type_size_t; typedef natural_t mach_msg_type_number_t; typedef struct { @@ -203,10 +203,10 @@ typedef struct { } mach_msg_type_t; typedef struct { - mach_msg_type_t msgtl_header; - unsigned short msgtl_name; - unsigned short msgtl_size; - natural_t msgtl_number; + mach_msg_type_t msgtl_header; + mach_msg_type_name_t msgtl_name; + mach_msg_type_size_t msgtl_size; + natural_t msgtl_number; } mach_msg_type_long_t; diff --git a/include/mach/std_types.defs b/include/mach/std_types.defs index 5d95ab4..3e8d6a8 100644 --- a/include/mach/std_types.defs +++ b/include/mach/std_types.defs @@ -75,7 +75,7 @@ type mach_port_mscount_t = unsigned; type mach_port_msgcount_t = unsigned; type mach_port_rights_t = unsigned; type mach_msg_id_t = integer_t; -type mach_msg_type_name_t = unsigned; +type mach_msg_type_name_t = char; type mach_msg_type_number_t = natural_t; type mach_port_move_receive_t = MACH_MSG_TYPE_MOVE_RECEIVE -- 2.7.0