internal.h: add BITFIELD macro to aid C99 users
I plan to use this macro to pack other enums in the VM. * internal.h: add BITFIELD macro * method.h: use BITFIELD for rb_method_visibility_t [ruby-core:85074] [Misc #14395] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6cf78f0e67
commit
46bfa65fcc
13
internal.h
13
internal.h
@ -2066,6 +2066,19 @@ rb_obj_builtin_type(VALUE obj)
|
|||||||
# define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
|
# define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For declaring bitfields out of non-unsigned int types:
|
||||||
|
* struct date {
|
||||||
|
* BITFIELD(enum months) month:4;
|
||||||
|
* ...
|
||||||
|
* };
|
||||||
|
*/
|
||||||
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||||
|
# define BITFIELD(type) type
|
||||||
|
#else
|
||||||
|
# define BITFIELD(type) unsigned int
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#if 0
|
#if 0
|
||||||
{ /* satisfy cc-mode */
|
{ /* satisfy cc-mode */
|
||||||
|
8
method.h
8
method.h
@ -32,16 +32,10 @@ typedef enum {
|
|||||||
METHOD_VISI_MASK = 0x03
|
METHOD_VISI_MASK = 0x03
|
||||||
} rb_method_visibility_t;
|
} rb_method_visibility_t;
|
||||||
|
|
||||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
|
||||||
#define bits_t rb_method_visibility_t
|
|
||||||
#else
|
|
||||||
#define bits_t unsigned int
|
|
||||||
#endif
|
|
||||||
typedef struct rb_scope_visi_struct {
|
typedef struct rb_scope_visi_struct {
|
||||||
bits_t method_visi : 3;
|
BITFIELD(rb_method_visibility_t) method_visi : 3;
|
||||||
unsigned int module_func : 1;
|
unsigned int module_func : 1;
|
||||||
} rb_scope_visibility_t;
|
} rb_scope_visibility_t;
|
||||||
#undef bits_t
|
|
||||||
|
|
||||||
/*! CREF (Class REFerence) */
|
/*! CREF (Class REFerence) */
|
||||||
typedef struct rb_cref_struct {
|
typedef struct rb_cref_struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user