diff options
Diffstat (limited to 'examples/performance-thread/common')
-rw-r--r-- | examples/performance-thread/common/lthread.h | 2 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_sched.c | 14 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_tls.c | 9 |
3 files changed, 14 insertions, 11 deletions
diff --git a/examples/performance-thread/common/lthread.h b/examples/performance-thread/common/lthread.h index 8c77af82..01843ba5 100644 --- a/examples/performance-thread/common/lthread.h +++ b/examples/performance-thread/common/lthread.h @@ -83,7 +83,7 @@ int _lthread_desched_sleep(struct lthread *lt); void _lthread_free(struct lthread *lt); -struct lthread_sched *_lthread_sched_get(int lcore_id); +struct lthread_sched *_lthread_sched_get(unsigned int lcore_id); struct lthread_stack *_stack_alloc(void); diff --git a/examples/performance-thread/common/lthread_sched.c b/examples/performance-thread/common/lthread_sched.c index c64c21ff..fbda112f 100644 --- a/examples/performance-thread/common/lthread_sched.c +++ b/examples/performance-thread/common/lthread_sched.c @@ -562,11 +562,14 @@ void lthread_run(void) * Return the scheduler for this lcore * */ -struct lthread_sched *_lthread_sched_get(int lcore_id) +struct lthread_sched *_lthread_sched_get(unsigned int lcore_id) { - if (lcore_id > LTHREAD_MAX_LCORES) - return NULL; - return schedcore[lcore_id]; + struct lthread_sched *res = NULL; + + if (lcore_id < LTHREAD_MAX_LCORES) + res = schedcore[lcore_id]; + + return res; } /* @@ -578,10 +581,9 @@ int lthread_set_affinity(unsigned lcoreid) struct lthread *lt = THIS_LTHREAD; struct lthread_sched *dest_sched; - if (unlikely(lcoreid > LTHREAD_MAX_LCORES)) + if (unlikely(lcoreid >= LTHREAD_MAX_LCORES)) return POSIX_ERRNO(EINVAL); - DIAG_EVENT(lt, LT_DIAG_LTHREAD_AFFINITY, lcoreid, 0); dest_sched = schedcore[lcoreid]; diff --git a/examples/performance-thread/common/lthread_tls.c b/examples/performance-thread/common/lthread_tls.c index 6876f831..e58388b9 100644 --- a/examples/performance-thread/common/lthread_tls.c +++ b/examples/performance-thread/common/lthread_tls.c @@ -199,11 +199,12 @@ void _lthread_tls_destroy(struct lthread *lt) void *lthread_getspecific(unsigned int k) { + void *res = NULL; - if (k > LTHREAD_MAX_KEYS) - return NULL; + if (k < LTHREAD_MAX_KEYS) + res = THIS_LTHREAD->tls->data[k]; - return THIS_LTHREAD->tls->data[k]; + return res; } /* @@ -213,7 +214,7 @@ void */ int lthread_setspecific(unsigned int k, const void *data) { - if (k > LTHREAD_MAX_KEYS) + if (k >= LTHREAD_MAX_KEYS) return POSIX_ERRNO(EINVAL); int n = THIS_LTHREAD->tls->nb_keys_inuse; |