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

ruby-changes:51105

From: shyouhei <ko1@a...>
Date: Tue, 1 May 2018 13:41:22 +0900 (JST)
Subject: [ruby-changes:51105] shyouhei:r63312 (trunk): LIST_HEAD as a local variable is a C99ism.

shyouhei	2018-05-01 13:41:10 +0900 (Tue, 01 May 2018)

  New Revision: 63312

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

  Log:
    LIST_HEAD as a local variable is a C99ism.
    
    Address of a variable whose storage duration is `auto` is _not_ a
    compile time constant, according to ISO 9899 section 6.4.
    LIST_HEAD takes such thing.  You can't use it to declare local
    variables.
    
    Interestingly, address of a static variable _is_ a compile time
    constant.  So a declaration like `static LIST_HEAD..` is
    completely legal even in C90.
    
    In C99 and newer, this is not a constraint violation.

  Modified files:
    trunk/io.c
    trunk/thread.c
Index: io.c
===================================================================
--- io.c	(revision 63311)
+++ io.c	(revision 63312)
@@ -4670,7 +4670,8 @@ io_close_fptr(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L4670
     rb_io_t *fptr;
     VALUE write_io;
     rb_io_t *write_fptr;
-    LIST_HEAD(busy);
+    struct list_head busy;
+    busy.n.next = busy.n.prev = &busy.n;
 
     write_io = GetWriteIO(io);
     if (io != write_io) {
Index: thread.c
===================================================================
--- thread.c	(revision 63311)
+++ thread.c	(revision 63312)
@@ -2288,7 +2288,8 @@ rb_notify_fd_close(int fd, struct list_h https://github.com/ruby/ruby/blob/trunk/thread.c#L2288
 void
 rb_thread_fd_close(int fd)
 {
-    LIST_HEAD(busy);
+    struct list_head busy;
+    busy.n.next = busy.n.prev = &busy.n;
 
     if (rb_notify_fd_close(fd, &busy)) {
 	do rb_thread_schedule(); while (!list_empty(&busy));

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

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