[#1378] differences between Module and Class ? — Mathieu Bouchard <matju@...>

25 messages 2003/08/11
[#1387] Re: differences between Module and Class ? — matz@... (Yukihiro Matsumoto) 2003/08/12

Hi,

[#1442] Re: differences between Module and Class ? — Mathieu Bouchard <matju@...> 2003/08/21

[#1406] _id2ref bug? — Ryan Pavlik <rpav@...>

While debugging some caching code, I've come across a segfault related

22 messages 2003/08/14
[#1407] Re: _id2ref bug? — matz@... (Yukihiro Matsumoto) 2003/08/14

Hi,

[#1413] Re: _id2ref bug? (REPRODUCED, short) — Ryan Pavlik <rpav@...> 2003/08/14

On Fri, 15 Aug 2003 01:57:18 +0900

[patch] "_FILE_OFFSET_BITS redefined" warning on Solaris (II)

From: Johan Holmberg <holmberg@...>
Date: 2003-08-04 14:21:48 UTC
List: ruby-core #1336
Hi !

A while ago I submitted a patch to remove compile time warnings on
Solaris, caused by redefinition of _FILE_OFFSET_BITS.

When I built ruby 1.8.0 today I noticed some more warnings of the
same kind. The code affected is in the extensions

    ext/bigdecimal
    ext/syck

Below is a patch to remove the warnings (and a duplicate #include
in "bigdecimal.c").

I also append the content of my earlier mail on the same subject
(for easy reference).

/Johan Holmberg

------------------------------------------------
First the patch:
------------------------------------------------

Index: ext/bigdecimal/bigdecimal.c
===================================================================
RCS file: /src/ruby/ext/bigdecimal/bigdecimal.c,v
retrieving revision 1.18
diff -u -r1.18 bigdecimal.c
--- ext/bigdecimal/bigdecimal.c	1 Aug 2003 04:48:32 -0000	1.18
+++ ext/bigdecimal/bigdecimal.c	4 Aug 2003 14:01:32 -0000
@@ -31,6 +31,7 @@
  *
  */

+#include "ruby.h"
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -38,8 +39,6 @@
 #include <errno.h>
 #include <float.h>
 #include <math.h>
-#include "ruby.h"
-#include "math.h"
 #include "version.h"

 /* #define ENABLE_NUMERIC_STRING */
Index: ext/syck/emitter.c
===================================================================
RCS file: /src/ruby/ext/syck/emitter.c,v
retrieving revision 1.5
diff -u -r1.5 emitter.c
--- ext/syck/emitter.c	28 Jul 2003 19:27:42 -0000	1.5
+++ ext/syck/emitter.c	4 Aug 2003 14:01:33 -0000
@@ -9,11 +9,12 @@
  * All Base64 code from Ruby's pack.c.
  * Ruby is Copyright (C) 1993-2003 Yukihiro Matsumoto
  */
+#include "ruby.h"
+
 #include <stdio.h>
 #include <string.h>

 #include "syck.h"
-#include "ruby.h"

 #define DEFAULT_ANCHOR_FORMAT "id%03d"

Index: ext/syck/handler.c
===================================================================
RCS file: /src/ruby/ext/syck/handler.c,v
retrieving revision 1.9
diff -u -r1.9 handler.c
--- ext/syck/handler.c	28 Jul 2003 19:27:42 -0000	1.9
+++ ext/syck/handler.c	4 Aug 2003 14:01:33 -0000
@@ -7,8 +7,8 @@
  * Copyright (C) 2003 why the lucky stiff
  */

-#include "syck.h"
 #include "ruby.h"
+#include "syck.h"

 SYMID
 syck_hdlr_add_node( SyckParser *p, SyckNode *n )
Index: ext/syck/implicit.c
===================================================================
RCS file: /src/ruby/ext/syck/implicit.c,v
retrieving revision 1.8
diff -u -r1.8 implicit.c
--- ext/syck/implicit.c	28 Jul 2003 19:27:42 -0000	1.8
+++ ext/syck/implicit.c	4 Aug 2003 14:01:33 -0000
@@ -9,8 +9,8 @@
  * Copyright (C) 2003 why the lucky stiff
  */

-#include "syck.h"
 #include "ruby.h"
+#include "syck.h"

 #define YYCTYPE     char
 #define YYCURSOR    cursor
Index: ext/syck/node.c
===================================================================
RCS file: /src/ruby/ext/syck/node.c,v
retrieving revision 1.6
diff -u -r1.6 node.c
--- ext/syck/node.c	28 Jul 2003 19:27:42 -0000	1.6
+++ ext/syck/node.c	4 Aug 2003 14:01:33 -0000
@@ -7,8 +7,8 @@
  * Copyright (C) 2003 why the lucky stiff
  */

-#include "syck.h"
 #include "ruby.h"
+#include "syck.h"

 /*
  * Node allocation functions
Index: ext/syck/syck.c
===================================================================
RCS file: /src/ruby/ext/syck/syck.c,v
retrieving revision 1.15
diff -u -r1.15 syck.c
--- ext/syck/syck.c	28 Jul 2003 19:27:42 -0000	1.15
+++ ext/syck/syck.c	4 Aug 2003 14:01:33 -0000
@@ -6,11 +6,12 @@
  *
  * Copyright (C) 2003 why the lucky stiff
  */
+#include "ruby.h"
+
 #include <stdio.h>
 #include <string.h>

 #include "syck.h"
-#include "ruby.h"

 void syck_parser_pop_level( SyckParser * );

Index: ext/syck/token.c
===================================================================
RCS file: /src/ruby/ext/syck/token.c,v
retrieving revision 1.21
diff -u -r1.21 token.c
--- ext/syck/token.c	29 Jul 2003 03:27:01 -0000	1.21
+++ ext/syck/token.c	4 Aug 2003 14:01:34 -0000
@@ -8,8 +8,8 @@
  *
  * Copyright (C) 2003 why the lucky stiff
  */
-#include "syck.h"
 #include "ruby.h"
+#include "syck.h"
 #include "gram.h"

 /*

------------------------------------------------
And here is the previous mail:
------------------------------------------------

On Sat, 3 May 2003, Johan Holmberg wrote:

> Date: Sat, 3 May 2003 22:07:11 +0900
> From: Johan Holmberg <holmberg@iar.se>
> Reply-To: ruby-core@ruby-lang.org
> To: ruby-core@ruby-lang.org
> Subject: [patch] "_FILE_OFFSET_BITS redefined" warning on Solaris
>
>
> Hi !
>
> When I compiled Ruby on Solaris 2.8 today I noticed some strange
> warnings, looking like:
>
>      /home/holmberg/proj/ruby-1.8-via-CVS/ruby/config.h:2: \
>          warning: `_FILE_OFFSET_BITS' redefined
>
> This happens when compiling the following files:
>
> 	ext/curses/curses.c
> 	ext/digest/sha2/sha2.c
> 	ext/iconv/iconv.c
> 	ext/racc/cparse/cparse.c
>
> I have tried to understand why this happens, and it seems to me that
> the reason is that "ruby.h" is included too late when these files are
> compiled (it is actually "config.h" that matters, but the modules of
> Ruby use "ruby.h" that in its turn include "config.h").
>
> If I'm not mistaken the symbol _FILE_OFFSET_BITS can be set by an
> application to get access to 64-bit versions of certain file related
> APIs. Ruby sets this symbol (via "configure"), and the setting is in
> "config.h" ("#define _FILE_OFFSET_BITS 64" on my Solaris machine).
>
> The system header files on Solaris act differently depending on whether
> this symbol is set or not (and also set it to a default value if not
> set).
>
> So I guess it would be a good idea to have all source files of Ruby
> set this variable the same way. This is accomplished in most files by
> including "ruby.h" (and thereby "config.h") as one of the first
> include files. But the files above fail to do so.
>
> As far as I can understand moving the inclusion of "ruby.h" earlier
> in these files can have no other negative impact. I tried this in my
> local copy of the source and recomiled all of Ruby. The
> _FILE_OFFSET_BITS warnings disappeared.
>
> I append a patch below if you want to see what I did to the source.
>
> /Johan Holmberg
>
>
> [... old patch removed ...]
>

In This Thread

Prev Next