bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSConstantString on Darwin revised


From: Markus Hitter
Subject: NSConstantString on Darwin revised
Date: Sun, 3 Mar 2002 20:28:16 +0100


Hello,

last Friday Tim Woods from OmniGroup submitted a patch to Darwin's gcc 3.1 to fix one of the two bugs around constant strings on next runtime. It's expected this fix (or a equal one) will go into the Apple modified gcc as well as FSF gcc.

The other bug remains for now.


This makes the patch to make constant strings work much less ugly. Below a revised one for the configuration system. Should be OK to include it into CVS, since it no longer depends on Foundation.framework and should this work on bare Darwin, too.

Additionally, the test is expanded by _not_ using the class name "NSConstantString", as this is the default name in gcc and Foundation.framework and might give a positive result even with a not fully working -fstring-constant-class. Instead "FooConstantString" is used.

The test still properly detects Darwin's original gcc 2.95.2 as having a non-working -fconstant-string-class.



("cvs diff" of today)
----- snip -----
Index: configure
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/configure,v
retrieving revision 1.139
diff -r1.139 configure
2180c2180
< CPPFLAGS="$CPPFLAGS -fconstant-string-class=NSConstantString"
---
> CPPFLAGS="$CPPFLAGS -fconstant-string-class=FooConstantString"
Index: config/config.constant-string-class.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/config/config.constant-string-
class.m,v
retrieving revision 1.1
diff -r1.1 config.constant-string-class.m
14,22d13
< #ifdef NeXT_RUNTIME
< /* ignore this test with the NeXT runtime - never use
<    -fconstant-string-class */
< int main (int argc, char **argv)
< {
<   abort ();
<   return 1;
< }
< #else /* GNU RUNTIME - the real test */
32c23
< @interface NSConstantString : Object
---
> @interface FooConstantString : Object
39,40c30,37
<
< @implementation NSConstantString
---
>
> #ifdef NeXT_RUNTIME
> /* This structure shouldn't be seen outside the compiler.
>    See Apple Radar 2870817 and the memcpy() in main(). */
> struct objc_class _FooConstantStringClassReference;
> #endif
>
> @implementation FooConstantString
46c43
<
---
>
51c48
<    NSConstantString *string = @"Antonio Valente";
---
>    FooConstantString *string = @"Antonio Valente";
52a50,60
> #ifdef NeXT_RUNTIME
>    /* This memcpy is needed here due to a bug in ObjC gcc when using
>       next runtime. It has to be done once per program and before
> the first message is sent to a constant string. Can't be moved to > the constant string's +initialize since this is already a message.
>       See Apple Radar 2870817 */
>    memcpy(&_FooConstantStringClassReference,
>           objc_getClass("FooConstantString"),
>           sizeof(_FooConstantStringClassReference));
> #endif
>
57a66,70
>    /* Do another, more direct test. */
>    if (strcmp ([@"Jump" customString], "Jump"))
>        {
>          abort ();
>        }
61d73
< #endif /* GNU RUNTIME */
----- snip -----


Have fun,
Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]