Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 1 | From 08d04d0428cc26935a2d42083f1710432465c98a Mon Sep 17 00:00:00 2001 |
| 2 | From: Philip Withnall <pwithnall@endlessos.org> |
| 3 | Date: Wed, 11 Nov 2020 18:42:43 +0000 |
| 4 | Subject: [PATCH 16/29] gobject: Drop unnecessary volatile qualifiers from |
| 5 | internal variables |
| 6 | MIME-Version: 1.0 |
| 7 | Content-Type: text/plain; charset=UTF-8 |
| 8 | Content-Transfer-Encoding: 8bit |
| 9 | |
| 10 | These variables were already (correctly) accessed atomically. The |
| 11 | `volatile` qualifier doesn’t help with that. |
| 12 | |
| 13 | Signed-off-by: Philip Withnall <pwithnall@endlessos.org> |
| 14 | |
| 15 | Helps: #600 |
| 16 | Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719] |
| 17 | --- |
| 18 | gobject/gclosure.c | 2 +- |
| 19 | gobject/gclosure.h | 20 ++++++++++---------- |
| 20 | gobject/gobject.c | 4 ++-- |
| 21 | gobject/gtype.c | 10 +++++----- |
| 22 | 4 files changed, 18 insertions(+), 18 deletions(-) |
| 23 | |
| 24 | diff --git a/gobject/gclosure.c b/gobject/gclosure.c |
| 25 | index 1d1f2f48a..6d41e6d8a 100644 |
| 26 | --- a/gobject/gclosure.c |
| 27 | +++ b/gobject/gclosure.c |
| 28 | @@ -98,7 +98,7 @@ |
| 29 | |
| 30 | typedef union { |
| 31 | GClosure closure; |
| 32 | - volatile gint vint; |
| 33 | + gint vint; |
| 34 | } ClosureInt; |
| 35 | |
| 36 | #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW) \ |
| 37 | diff --git a/gobject/gclosure.h b/gobject/gclosure.h |
| 38 | index a0f91f538..884e403a8 100644 |
| 39 | --- a/gobject/gclosure.h |
| 40 | +++ b/gobject/gclosure.h |
| 41 | @@ -175,20 +175,20 @@ struct _GClosureNotifyData |
| 42 | struct _GClosure |
| 43 | { |
| 44 | /*< private >*/ |
| 45 | - volatile guint ref_count : 15; |
| 46 | + guint ref_count : 15; /* (atomic) */ |
| 47 | /* meta_marshal is not used anymore but must be zero for historical reasons |
| 48 | as it was exposed in the G_CLOSURE_N_NOTIFIERS macro */ |
| 49 | - volatile guint meta_marshal_nouse : 1; |
| 50 | - volatile guint n_guards : 1; |
| 51 | - volatile guint n_fnotifiers : 2; /* finalization notifiers */ |
| 52 | - volatile guint n_inotifiers : 8; /* invalidation notifiers */ |
| 53 | - volatile guint in_inotify : 1; |
| 54 | - volatile guint floating : 1; |
| 55 | + guint meta_marshal_nouse : 1; /* (atomic) */ |
| 56 | + guint n_guards : 1; /* (atomic) */ |
| 57 | + guint n_fnotifiers : 2; /* finalization notifiers (atomic) */ |
| 58 | + guint n_inotifiers : 8; /* invalidation notifiers (atomic) */ |
| 59 | + guint in_inotify : 1; /* (atomic) */ |
| 60 | + guint floating : 1; /* (atomic) */ |
| 61 | /*< protected >*/ |
| 62 | - volatile guint derivative_flag : 1; |
| 63 | + guint derivative_flag : 1; /* (atomic) */ |
| 64 | /*< public >*/ |
| 65 | - volatile guint in_marshal : 1; |
| 66 | - volatile guint is_invalid : 1; |
| 67 | + guint in_marshal : 1; /* (atomic) */ |
| 68 | + guint is_invalid : 1; /* (atomic) */ |
| 69 | |
| 70 | /*< private >*/ void (*marshal) (GClosure *closure, |
| 71 | GValue /*out*/ *return_value, |
| 72 | diff --git a/gobject/gobject.c b/gobject/gobject.c |
| 73 | index 6e9c44a1e..a3a32be9f 100644 |
| 74 | --- a/gobject/gobject.c |
| 75 | +++ b/gobject/gobject.c |
| 76 | @@ -174,9 +174,9 @@ typedef struct |
| 77 | GTypeInstance g_type_instance; |
| 78 | |
| 79 | /*< private >*/ |
| 80 | - volatile guint ref_count; |
| 81 | + guint ref_count; /* (atomic) */ |
| 82 | #ifdef HAVE_OPTIONAL_FLAGS |
| 83 | - volatile guint optional_flags; |
| 84 | + guint optional_flags; /* (atomic) */ |
| 85 | #endif |
| 86 | GData *qdata; |
| 87 | } GObjectReal; |
| 88 | diff --git a/gobject/gtype.c b/gobject/gtype.c |
| 89 | index 51dad7690..be5989a3e 100644 |
| 90 | --- a/gobject/gtype.c |
| 91 | +++ b/gobject/gtype.c |
| 92 | @@ -221,9 +221,9 @@ typedef enum |
| 93 | /* --- structures --- */ |
| 94 | struct _TypeNode |
| 95 | { |
| 96 | - guint volatile ref_count; |
| 97 | + guint ref_count; /* (atomic) */ |
| 98 | #ifdef G_ENABLE_DEBUG |
| 99 | - guint volatile instance_count; |
| 100 | + guint instance_count; /* (atomic) */ |
| 101 | #endif |
| 102 | GTypePlugin *plugin; |
| 103 | guint n_children; /* writable with lock */ |
| 104 | @@ -233,7 +233,7 @@ struct _TypeNode |
| 105 | guint is_instantiatable : 1; |
| 106 | guint mutatable_check_cache : 1; /* combines some common path checks */ |
| 107 | GType *children; /* writable with lock */ |
| 108 | - TypeData * volatile data; |
| 109 | + TypeData *data; |
| 110 | GQuark qname; |
| 111 | GData *global_gdata; |
| 112 | union { |
| 113 | @@ -569,8 +569,8 @@ type_node_new_W (TypeNode *pnode, |
| 114 | } |
| 115 | |
| 116 | static inline IFaceEntry* |
| 117 | -lookup_iface_entry_I (volatile IFaceEntries *entries, |
| 118 | - TypeNode *iface_node) |
| 119 | +lookup_iface_entry_I (IFaceEntries *entries, |
| 120 | + TypeNode *iface_node) |
| 121 | { |
| 122 | guint8 *offsets; |
| 123 | guint offset_index; |
| 124 | -- |
| 125 | 2.30.1 |
| 126 | |