[前][次][番号順一覧][スレッド一覧]

ruby-changes:49457

From: normal <ko1@a...>
Date: Wed, 3 Jan 2018 06:23:52 +0900 (JST)
Subject: [ruby-changes:49457] normal:r61573 (trunk): thread_pthread.c: use container_of

normal	2018-01-03 06:23:47 +0900 (Wed, 03 Jan 2018)

  New Revision: 61573

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61573

  Log:
    thread_pthread.c: use container_of
    
    It's easier to read this macro from ccan than open-coding pointer
    arithmetic.
    
    thread_pthread.c (ubf_wakeup_all_threads): use container_of

  Modified files:
    trunk/thread_pthread.c
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 61572)
+++ thread_pthread.c	(revision 61573)
@@ -1226,8 +1226,7 @@ ubf_wakeup_all_threads(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1226
     if (!ubf_threads_empty()) {
 	native_mutex_lock(&ubf_list_lock);
 	list_for_each(&ubf_list_head, dat, ubf_list) {
-	    th = (rb_thread_t *)(
-		((char *)dat) - offsetof(rb_thread_t, native_thread_data));
+	    th = container_of(dat, rb_thread_t, native_thread_data);
 	    ubf_wakeup_thread(th);
 	}
 	native_mutex_unlock(&ubf_list_lock);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]