Bug 12035 - [3.4/4.0 Regression] Patch for libobjc/gc.c that fixes compilation error of Objective-C with garbage collector enabled
Summary: [3.4/4.0 Regression] Patch for libobjc/gc.c that fixes compilation error of O...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libobjc (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.4
Assignee: Andrew Pinski
URL:
Keywords: build
Depends on:
Blocks: 13946
  Show dependency treegraph
 
Reported: 2003-08-22 20:27 UTC by Václav Haisman
Modified: 2004-12-20 22:37 UTC (History)
2 users (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-cygwin
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed: 2004-11-22 04:48:08


Attachments
The patch. (256 bytes, patch)
2003-08-22 20:29 UTC, Václav Haisman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Václav Haisman 2003-08-22 20:27:44 UTC
I had to make this small change to libobjc/gc.c to be able to compile it. There
was missing definition for BITS_PER_WORD.
Comment 1 Václav Haisman 2003-08-22 20:29:00 UTC
Created attachment 4643 [details]
The patch.
Comment 2 Andrew Pinski 2003-08-22 20:40:23 UTC
Can you post this to gcc-patches@ after reading <http://gcc.gnu.org/contribute.html> and make 
a changelog for it?
Comment 3 Václav Haisman 2003-08-22 21:03:22 UTC
http://gcc.gnu.org/ml/gcc-patches/2003-08/msg01385.html
Comment 4 Zack Weinberg 2003-12-01 22:39:48 UTC
This patch is wrong.  coretypes.h and tm.h are not to be referenced outside of
the gcc directory -- I realize that some files in libobjc already do that, but
that's not a reason to do it more.

See if you can't include <limits.h> and use CHAR_BIT * sizeof(void *) or a
similar construct.
Comment 5 Gabriel Dos Reis 2003-12-01 22:56:55 UTC
Subject: Re:  Patch for libobjc/gc.c that fixes compilation error of Objective-C with garbage collector enabled

"zack at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| This patch is wrong.  coretypes.h and tm.h are not to be referenced
| outside of the gcc directory -- I realize that some files in libobjc
| already do that, but that's not a reason to do it more.

I completely agree.  For that matter, something similar was proposed
for V3 and I strongly disagreed with doing so.

-- Gaby
Comment 6 Andrew Pinski 2003-12-02 16:35:26 UTC
I was going to clean up libobjc one of these days to remove the references to GCC's internal header 
files but it is going to be hard because libobjc needs to find the layout of a struct.
Comment 7 Andrew Pinski 2004-01-25 06:49:03 UTC
I am doing the cleanup.
Comment 8 Andrew Pinski 2004-12-20 21:55:05 UTC
I think there is a better patch:
Index: gc.c
===============================================================
====
RCS file: /cvs/gcc/gcc/libobjc/gc.c,v
retrieving revision 1.6
diff -u -p -r1.6 gc.c
--- gc.c	23 May 2003 20:04:58 -0000	1.6
+++ gc.c	20 Dec 2004 21:51:20 -0000
@@ -40,18 +40,6 @@ Boston, MA 02111-1307, USA.  */
 typedef GC_word word;
 typedef GC_signed_word signed_word;
 
-#if BITS_PER_WORD == 32
-# define LOGWL	5
-# define modWORDSZ(n) ((n) & 0x1f)        /* n mod size of word
	    */
-#endif
-
-#if BITS_PER_WORD == 64
-# define LOGWL 6
-# define modWORDSZ(n) ((n) & 0x3f)        /* n mod size of word
	    */
-#endif
-
-#define divWORDSZ(n) ((n) >> LOGWL)	   /* divide n by size of word      */
-
 #include <gc_typed.h>
 
 /* The following functions set up in `mask` the corresponding pointers.


Which just removes the use of BITS_PER_WORD which are not used anywhere else.
Comment 9 GCC Commits 2004-12-20 22:32:56 UTC
Subject: Bug 12035

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2004-12-20 22:32:42

Modified files:
	libobjc        : ChangeLog gc.c 

Log message:
	2004-12-20  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR libobjc/12035
	* gc.c: Remove definition of LOGWL, modWORDSZ, and divWORDSZ since
	they are not used.  Include limits.h and stdlib.h.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/ChangeLog.diff?cvsroot=gcc&r1=1.155&r2=1.156
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/gc.c.diff?cvsroot=gcc&r1=1.6&r2=1.7

Comment 10 GCC Commits 2004-12-20 22:34:22 UTC
Subject: Bug 12035

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	pinskia@gcc.gnu.org	2004-12-20 22:34:18

Modified files:
	libobjc        : ChangeLog gc.c 

Log message:
	2004-12-20  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR libobjc/12035
	* gc.c: Remove definition of LOGWL, modWORDSZ, and divWORDSZ since
	they are not used.
	Include limits.h and stdlib.h.
	Define BITS_PER_WORD.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.106.2.6&r2=1.106.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/gc.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.6&r2=1.6.16.1

Comment 11 GCC Commits 2004-12-20 22:35:21 UTC
Subject: Bug 12035

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2004-12-20 22:35:08

Modified files:
	libobjc        : ChangeLog 

Log message:
	change the changelog entry to:
	2004-12-20  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR libobjc/12035
	* gc.c: Remove definition of LOGWL, modWORDSZ, and divWORDSZ since
	they are not used.
	Include limits.h and stdlib.h.
	Define BITS_PER_WORD.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libobjc/ChangeLog.diff?cvsroot=gcc&r1=1.156&r2=1.157

Comment 12 Andrew Pinski 2004-12-20 22:37:22 UTC
Fixed with a slightly different patch that I added before.