Re: minimum compiler requirements - fast enumeration

2022-01-31 Thread Frederik Seiffert
I’d be all for this. FWIW there’s also the FOR_IN/END_FOR_IN macros in 
GSFastEnumeration.h, which use fast enumeration with Clang and seem to emulate 
it with other compilers.


> Am 31.01.2022 um 10:40 schrieb Richard Frith-Macdonald :
> 
> A few years ago we declared gcc-4.0 as our minimum supported compiler version.
> Does anyone know if gcc-4.0 support for fast enumeration actually works?
> If it does, it would be good to start using fast enumeration internally (in 
> gnustep-base for instance).
> I'd like to do that as it gives us not only more readable/maintainable code, 
> but also faster code in almost all cases.
> 
> 
> 
> 




minimum compiler requirements - fast enumeration

2022-01-31 Thread Richard Frith-Macdonald
A few years ago we declared gcc-4.0 as our minimum supported compiler version.
Does anyone know if gcc-4.0 support for fast enumeration actually works?
If it does, it would be good to start using fast enumeration internally (in 
gnustep-base for instance).
I'd like to do that as it gives us not only more readable/maintainable code, 
but also faster code in almost all cases.






Re: Fast enumeration, actually working this time.

2009-10-25 Thread Ken Linton

Oh nice. Something I can download?

Sent from my iPhone: 917-940-2709

On Oct 24, 2009, at 9:33 AM, David Chisnall thera...@sucs.org wrote:


On 23 Oct 2009, at 22:21, KNL wrote:


David,

Is this compiler with fast enumeration part of the release of  
GNUStep for
windows? I ask I'm developing some code on Win XP using GNUStep and  
I get

lots of compile time errors when trying to use fast enumeration.


Fast enumeration is supported with clang, but not with GCC.  Clang  
builds on Windows with either Visual Studio or with CMake, but it is  
not (yet) part of the GNUstep Windows distribution.


David


Oh nice. Something I can download?

Sent from my iPhone: 917-940-2709

On Oct 24, 2009, at 9:33 AM, David Chisnall thera...@sucs.org wrote:


On 23 Oct 2009, at 22:21, KNL wrote:


David,

Is this compiler with fast enumeration part of the release of  
GNUStep for
windows? I ask I'm developing some code on Win XP using GNUStep and  
I get

lots of compile time errors when trying to use fast enumeration.


Fast enumeration is supported with clang, but not with GCC.  Clang  
builds on Windows with either Visual Studio or with CMake, but it is  
not (yet) part of the GNUstep Windows distribution.


David



___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: Fast enumeration, actually working this time.

2009-10-24 Thread KNL

David,

Is this compiler with fast enumeration part of the release of GNUStep for
windows? I ask I'm developing some code on Win XP using GNUStep and I get
lots of compile time errors when trying to use fast enumeration.

Many thanks for your reply,

Ken



Now I have a compiler that supports fast enumeration on the GNU  
runtime (no one else does yet, but I hope to fix that soon) I am able  
to actually test the implementation... and it's all wrong.

-- 
View this message in context: 
http://www.nabble.com/Fast-enumeration%2C-actually-working-this-time.-tp21819126p26033419.html
Sent from the GNUstep - Dev mailing list archive at Nabble.com.



___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: Fast enumeration, actually working this time.

2009-10-24 Thread David Chisnall

On 24 Oct 2009, at 17:34, Ken Linton wrote:


Oh nice. Something I can download?



Just grab the latest llvm and trunk clang and build them.

David

-- Sent from my PDP-11



___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Fast enumeration, actually working this time.

2009-02-03 Thread David Chisnall
Now I have a compiler that supports fast enumeration on the GNU  
runtime (no one else does yet, but I hope to fix that soon) I am able  
to actually test the implementation... and it's all wrong.


This diff fixes it.  I've tested it with this program:

#import Foundation/Foundation.h

void objc_enumerationMutation(id obj)
{
NSLog(@%@ changed during enumeration, obj);
}

int main(void)
{
[NSAutoreleasePool new];
id array = [NSArray arrayWithObjects:@0, @1, @2, @3,  
@4, @5, @6, @7, @8, @9, @10, @11, @12, @ 13,  
@14, @15, @16, @17, @18, @19, nil];

NSLog(@Starting enumeration fish);
for (id i in array) { NSLog(@i: %@, i); }
array = [array mutableCopy];
for (id i in array) { NSLog(@i: %@, i); }
for (id i in [array objectEnumerator]) { NSLog(@i: %@, i); }
NSLog(@finished enumeration);
return 0;
}

And it prints 0..19 three times.  Note that objc_enumerationMutation()  
needs to be set.  Ideally this would be a symbol defined in GNU  
libobjc and the function pointer provided by Foundation, but for now  
we can probably just define it ourselves.  The correct definition for  
Apple compatibility would be:


void objc_enumerationMutation(id obj)
{
	[NSException raise: NSGenericException format: @Collection %@ was  
mutated while being enumerated, objc];

}

David

P.S. In most of the world it is considered bad form to commit other  
people's patches without acknowledging them in the commit message.   
For those of us in the EU, it is also illegal.




fastenumeration.diff
Description: Binary data
___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: Fast enumeration, actually working this time.

2009-02-03 Thread David Chisnall

On 3 Feb 2009, at 21:12, David Chisnall wrote:

Now I have a compiler that supports fast enumeration on the GNU  
runtime (no one else does yet, but I hope to fix that soon)


Much faster than I expected.  Clang trunk now supports fast  
enumeration with the GNU runtime.


Note that ccc, the clang driver, currently dies if you pass it -g (no  
idea why) so you have to build with debug=no and you will need a line  
like this in your GNUmakefile to use it:


CC=~/llvm/tools/clang/utils/ccc

David


___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Fast enumeration

2009-01-28 Thread David Chisnall
Since we're likely to get a compiler that knows about fast enumeration  
soon, I thought I'd start implementing the library support it needs.   
This patch defines the protocol and implements it for NSEnumerator.   
The collection classes will each need this implementing too.  I'll do  
this in subsequent patches if no one else does.


David


fastenumeration.diff
Description: Binary data
___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: Fast enumeration

2009-01-28 Thread Richard Frith-Macdonald


On 28 Jan 2009, at 11:45, David Chisnall wrote:

Since we're likely to get a compiler that knows about fast  
enumeration soon, I thought I'd start implementing the library  
support it needs.  This patch defines the protocol and implements it  
for NSEnumerator.  The collection classes will each need this  
implementing too.  I'll do this in subsequent patches if no one else  
does.


Thanks ... I added that.
I had to fixing indentation/whitespace use to match GNUstep coding  
standards though, and remove the spurious change to NSProcessInfo.m  
which was also in the patch.


Could you please review your local copy of NSProcessInfo.m ...
Your patch contains an additional line saying '#include sys/ 
sysctl.h' which looks like it should not be needed as a few lines  
below we have the same include inside an '#ifdef HAVE_SYS_SYSCTL_H'
Did you need to add the include explicitly?  If so, can you figure out  
why the test for the header in configure.ac failed on your machine?





___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: Fast enumeration

2009-01-28 Thread David Chisnall


On 28 Jan 2009, at 12:08, Richard Frith-Macdonald wrote:

 and remove the spurious change to NSProcessInfo.m which was also in  
the patch.


Ah, I forgot that was in there.  It's not entirely spurious - GNUStep- 
base doesn't build on FreeBSD without it.


David


___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: Fast enumeration

2009-01-28 Thread David Chisnall

On 28 Jan 2009, at 12:08, Richard Frith-Macdonald wrote:

Your patch contains an additional line saying '#include sys/ 
sysctl.h' which looks like it should not be needed as a few lines  
below we have the same include inside an '#ifdef HAVE_SYS_SYSCTL_H'
Did you need to add the include explicitly?  If so, can you figure  
out why the test for the header in configure.ac failed on your  
machine?


On closer inspection, this has been fixed in GNUstep trunk and it now  
builds happily without the patch.  I think I sent this to the list a  
while ago and didn't remove my quick hack when it was merged.


David


___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: Fast enumeration

2009-01-28 Thread Richard Frith-Macdonald


On 28 Jan 2009, at 12:16, David Chisnall wrote:



On 28 Jan 2009, at 12:08, Richard Frith-Macdonald wrote:

and remove the spurious change to NSProcessInfo.m which was also in  
the patch.


Ah, I forgot that was in there.  It's not entirely spurious -  
GNUStep-base doesn't build on FreeBSD without it.


So why not?
It's not present on all systems, so we can't include it  
unconditionally, but we *do* include it if configure was able to find  
it.

So what breakage of configure on FreeBSD causes it to not be found?
It would be good to have that fixed.


___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


More fast enumeration

2009-01-28 Thread David Chisnall
This patch fixes a bug in the last one (I forgot to set the items  
pointer) and adds enumeration support to GSArray and GSMutableArray.


GSArray just returns a pointer to its contents directly.   
GSMutableArray has a _version ivar added.  This is incremented every  
time the collection is mutated.  This allows the caller to check if  
the collection has changed between invocations and throw an exception  
if it has (this is done by calling objc_collectionMutation() which is  
not yet implemented on the GNU runtime).


David



fastenumeration2.diff
Description: Binary data
___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: More fast enumeration

2009-01-28 Thread Richard Frith-Macdonald


On 28 Jan 2009, at 13:13, David Chisnall wrote:

This patch fixes a bug in the last one (I forgot to set the items  
pointer) and adds enumeration support to GSArray and GSMutableArray.


GSArray just returns a pointer to its contents directly.   
GSMutableArray has a _version ivar added.  This is incremented every  
time the collection is mutated.  This allows the caller to check if  
the collection has changed between invocations and throw an  
exception if it has (this is done by calling  
objc_collectionMutation() which is not yet implemented on the GNU  
runtime).


Thanks ... I added that patch to svn


___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev