summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-01-31 14:48:36 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-01-31 23:01:50 +0900
commitb38c610c7e60cbdcb45fd6d27450e39e3a9c9dd1 (patch)
treebdf85273343cd3618493d79d6b292701ea0d029e /src/lib/eina
parente2fe31fc09fa4622a7c1e2591db15a98cec6aca0 (diff)
evlog - remove setting stack var to 0 until it is needed later
we set stack var to 0 even if evlog was off and thus didn't use it. this cleans up the evlog func a bit and also moves locking until later so it's locked for the minimum period to punt something into the log buffer. it's an improvement, but no bug fix.
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_evlog.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/lib/eina/eina_evlog.c b/src/lib/eina/eina_evlog.c
index 7fec80962f..359badb150 100644
--- a/src/lib/eina/eina_evlog.c
+++ b/src/lib/eina/eina_evlog.c
@@ -131,35 +131,33 @@ eina_evlog(const char *event, void *obj, double srctime, const char *detail)
131 int size; 131 int size;
132 char *strings; 132 char *strings;
133 double now; 133 double now;
134 unsigned short detail_offset = 0; 134 unsigned short detail_offset, event_size;
135 unsigned short event_size;
136 135
137 if (!_evlog_go) return; 136 if (!_evlog_go) return;
138 now = get_time(); 137
139 eina_spinlock_take(&_evlog_lock); 138 now = get_time();
140 size = sizeof(Eina_Evlog_Item);
141 event_size = strlen(event) + 1; 139 event_size = strlen(event) + 1;
142 size += event_size; 140 size = sizeof(Eina_Evlog_Item) + event_size;
143 if (detail) 141 if (detail)
144 { 142 {
145 detail_offset = size; 143 detail_offset = size;
146 size += strlen(detail) + 1; 144 size += strlen(detail) + 1;
147 } 145 }
146 else detail_offset = 0;
148 size = sizeof(double) * ((size + sizeof(double) - 1) / sizeof(double)); 147 size = sizeof(double) * ((size + sizeof(double) - 1) / sizeof(double));
149 148
150 strings = push_buf(buf, size); 149 eina_spinlock_take(&_evlog_lock);
151 item = (Eina_Evlog_Item *)strings; 150 strings = push_buf(buf, size);
152 item->tim = now; 151 item = (Eina_Evlog_Item *)strings;
153 item->srctim = srctime; 152 item->tim = now;
154 item->thread = (unsigned long long)pthread_self(); 153 item->srctim = srctime;
155 item->obj = (unsigned long long)obj; 154 item->thread = (unsigned long long)pthread_self();
156 item->event_offset = sizeof(Eina_Evlog_Item); 155 item->obj = (unsigned long long)obj;
157 item->detail_offset = detail_offset; 156 item->event_offset = sizeof(Eina_Evlog_Item);
158 item->event_next = size; 157 item->detail_offset = detail_offset;
159 158 item->event_next = size;
160 strcpy(strings + sizeof(Eina_Evlog_Item), event); 159 strcpy(strings + size, event);
161 if (detail_offset > 0) strcpy(strings + detail_offset, detail); 160 if (detail_offset > 0) strcpy(strings + detail_offset, detail);
162
163 eina_spinlock_release(&_evlog_lock); 161 eina_spinlock_release(&_evlog_lock);
164} 162}
165 163