projects
/
crypto.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
13e0ad8
)
Branch prediction optimizations.
author
Pekka Riikonen
<priikone@silcnet.org>
Mon, 18 Dec 2006 14:38:42 +0000
(14:38 +0000)
committer
Pekka Riikonen
<priikone@silcnet.org>
Mon, 18 Dec 2006 14:38:42 +0000
(14:38 +0000)
lib/silcutil/silcfdstream.c
patch
|
blob
|
history
lib/silcutil/silcfsm.c
patch
|
blob
|
history
lib/silcutil/silcschedule.c
patch
|
blob
|
history
lib/silcutil/silcsocketstream.c
patch
|
blob
|
history
diff --git
a/lib/silcutil/silcfdstream.c
b/lib/silcutil/silcfdstream.c
index c614811dbc0c02f5ae86dfc571f00c587ac15c05..e7a469048ad31cb96c4f413c742913ad43933c54 100644
(file)
--- a/
lib/silcutil/silcfdstream.c
+++ b/
lib/silcutil/silcfdstream.c
@@
-49,14
+49,14
@@
SILC_TASK_CALLBACK(silc_fd_stream_io)
return;
switch (type) {
return;
switch (type) {
- case SILC_TASK_WRITE:
- stream->notifier(stream, SILC_STREAM_CAN_WRITE, stream->notifier_context);
- break;
-
case SILC_TASK_READ:
stream->notifier(stream, SILC_STREAM_CAN_READ, stream->notifier_context);
break;
case SILC_TASK_READ:
stream->notifier(stream, SILC_STREAM_CAN_READ, stream->notifier_context);
break;
+ case SILC_TASK_WRITE:
+ stream->notifier(stream, SILC_STREAM_CAN_WRITE, stream->notifier_context);
+ break;
+
default:
break;
}
default:
break;
}
diff --git
a/lib/silcutil/silcfsm.c
b/lib/silcutil/silcfsm.c
index 4feffdffba0f74110f3d13f929278dcf49b8336e..47c9b51f8357949c8d01829af97df36f9a0c2af4 100644
(file)
--- a/
lib/silcutil/silcfsm.c
+++ b/
lib/silcutil/silcfsm.c
@@
-23,10
+23,10
@@
SILC_TASK_CALLBACK(silc_fsm_run);
SILC_TASK_CALLBACK(silc_fsm_finish_fsm);
SILC_TASK_CALLBACK(silc_fsm_sema_timedout);
SILC_TASK_CALLBACK(silc_fsm_start_real_thread);
SILC_TASK_CALLBACK(silc_fsm_finish_fsm);
SILC_TASK_CALLBACK(silc_fsm_sema_timedout);
SILC_TASK_CALLBACK(silc_fsm_start_real_thread);
-static void *silc_fsm_thread(void *context);
static void silc_fsm_thread_termination_post(SilcFSMSema sema);
static void silc_fsm_sema_ref(SilcFSMSema sema);
static void silc_fsm_sema_unref(SilcFSMSema sema);
static void silc_fsm_thread_termination_post(SilcFSMSema sema);
static void silc_fsm_sema_ref(SilcFSMSema sema);
static void silc_fsm_sema_unref(SilcFSMSema sema);
+void *silc_fsm_thread(void *context);
/* Allocate FSM */
/* Allocate FSM */
@@
-714,7
+714,7
@@
static void silc_fsm_thread_termination_post(SilcFSMSema sema)
/* Real thread */
/* Real thread */
-
static
void *silc_fsm_thread(void *context)
+void *silc_fsm_thread(void *context)
{
SilcFSM fsm = context;
SilcSchedule old = fsm->schedule;
{
SilcFSM fsm = context;
SilcSchedule old = fsm->schedule;
diff --git
a/lib/silcutil/silcschedule.c
b/lib/silcutil/silcschedule.c
index ac96afab07ae8f46aa829fd9c12ea02ba0651e89..cd5a32030506a105799c1403f4c4f080f1607446 100644
(file)
--- a/
lib/silcutil/silcschedule.c
+++ b/
lib/silcutil/silcschedule.c
@@
-51,7
+51,8
@@
static void silc_schedule_dispatch_fd(SilcSchedule schedule)
SilcUInt32 fd;
silc_hash_table_list(schedule->fd_queue, &htl);
SilcUInt32 fd;
silc_hash_table_list(schedule->fd_queue, &htl);
- while (silc_hash_table_get(&htl, (void **)&fd, (void **)&task)) {
+ while (silc_likely(silc_hash_table_get(&htl, (void **)&fd,
+ (void **)&task))) {
t = (SilcTask)task;
if (silc_unlikely(!t->valid)) {
t = (SilcTask)task;
if (silc_unlikely(!t->valid)) {
@@
-103,6
+104,8
@@
static void silc_schedule_dispatch_timeout(SilcSchedule schedule,
/* First task in the task queue has always the earliest timeout. */
silc_list_start(schedule->timeout_queue);
task = silc_list_get(schedule->timeout_queue);
/* First task in the task queue has always the earliest timeout. */
silc_list_start(schedule->timeout_queue);
task = silc_list_get(schedule->timeout_queue);
+ if (silc_unlikely(!task))
+ return;
do {
t = (SilcTask)task;
do {
t = (SilcTask)task;
@@
-112,18
+115,14
@@
static void silc_schedule_dispatch_timeout(SilcSchedule schedule,
continue;
}
continue;
}
- SILC_SCHEDULE_UNLOCK(schedule);
-
/* Execute the task if the timeout has expired */
/* Execute the task if the timeout has expired */
- if (!silc_compare_timeval(&task->timeout, &curtime) && !dispatch_all) {
- SILC_SCHEDULE_LOCK(schedule);
+ if (!silc_compare_timeval(&task->timeout, &curtime) && !dispatch_all)
break;
break;
- }
t->valid = FALSE;
t->valid = FALSE;
+ SILC_SCHEDULE_UNLOCK(schedule);
t->callback(schedule, schedule->app_context, SILC_TASK_EXPIRE, 0,
t->context);
t->callback(schedule, schedule->app_context, SILC_TASK_EXPIRE, 0,
t->context);
-
SILC_SCHEDULE_LOCK(schedule);
/* Remove the expired task */
SILC_SCHEDULE_LOCK(schedule);
/* Remove the expired task */
@@
-153,6
+152,8
@@
static void silc_schedule_select_timeout(SilcSchedule schedule)
/* First task in the task queue has always the earliest timeout. */
silc_list_start(schedule->timeout_queue);
task = silc_list_get(schedule->timeout_queue);
/* First task in the task queue has always the earliest timeout. */
silc_list_start(schedule->timeout_queue);
task = silc_list_get(schedule->timeout_queue);
+ if (silc_unlikely(!task))
+ return;
do {
t = (SilcTask)task;
do {
t = (SilcTask)task;
diff --git
a/lib/silcutil/silcsocketstream.c
b/lib/silcutil/silcsocketstream.c
index 0e40d4141ddd64ab799c7a59b4c68c427281b9ed..1c4e952a232cd1540075f180f1d207d2e95ebb54 100644
(file)
--- a/
lib/silcutil/silcsocketstream.c
+++ b/
lib/silcutil/silcsocketstream.c
@@
-64,14
+64,14
@@
SILC_TASK_CALLBACK(silc_socket_stream_io)
return;
switch (type) {
return;
switch (type) {
- case SILC_TASK_WRITE:
- stream->notifier(stream, SILC_STREAM_CAN_WRITE, stream->notifier_context);
- break;
-
case SILC_TASK_READ:
stream->notifier(stream, SILC_STREAM_CAN_READ, stream->notifier_context);
break;
case SILC_TASK_READ:
stream->notifier(stream, SILC_STREAM_CAN_READ, stream->notifier_context);
break;
+ case SILC_TASK_WRITE:
+ stream->notifier(stream, SILC_STREAM_CAN_WRITE, stream->notifier_context);
+ break;
+
default:
break;
}
default:
break;
}