--
View this message in context: http://www.nabble.com/QNX---GNUstep-and-Objective-C-tp26047107p26047107.html
Sent from the GNUstep - General mailing list archive at Nabble.com.
>
> Hi everyone.
> I work in QNX.
> QNX supports officially only gcc4.3 and languages c and c ++ and has
> own GUI
> - QNX Photon.
> I compile gcc4.4 / gcc4.5 in QNX.
> That is why I have the working on QNX compiler objc. I use to tests
> objc
> from gcc4.5.0.
> I made the test of writing the program in objc to working in the
> environment
> Photon. We practically use only language c to the programming in
> Photon,
> then the transfer on the language objc turned out very simple.
> I porting and compiled on QNX 6.4.1 gnustep-make-2.2.0 and
> gnustep-base-1.19.3.
That's really great - I was wondering if anyone was running GNUstep on
QNX. Would it be possible for you to try a recent svn version and
make sure that the changes to the threading support work with QNX's
version of pthreads?
> Simple test program work correctly.
> Because I have small knowledge in objc and GNUstep I have the
> question:
> when I using objc from gcc4.4 / gcc4.5 to use for GNUstep I should use
> gnustep-objc-1.6.0 ?
> and what from http://svn.gna.org/viewcvs/gnustep/libs/libobjc2/ ?
> or the better use libobjc from gcc ?
I should really write something on the web site about this.
Basically, at the moment, you should use libobjc from GCC if it's
relatively modern.
The 1.6.0 libobjc in GNUstep is a really old version of GCC libobjc,
for use with platforms that only support an even older GCC (things
that Riccardo runs, which only support GCC 2.95). This should only be
used if your GCC comes with a broken libobjc.
The libobjc2 is an experimental fork of a recent GCC libobjc, with
support for a new ABI and a load of other stuff. I've made some very
invasive changes in this and they haven't been adequately tested. I'm
currently running it, and as of today I can run all of the GNUstep
apps I have installed with it, but I wouldn't recommend that anyone
else runs it yet unless you are interested in fixing bugs that you
encounter, or testing experimental features in clang.
David
-- Sent from my brain
and Ada - gnat4.2.2
pid name sid start time utime stime
24789088 ./diners 495654 Oct 31 23:30 0.014 0.004
This looks from the point of the sight of threads:
Show thread times.
pid tid name STATE start time thread
start sutime
11956301 1 diningPhilosophers RUNNING Oct 31 23:00 Oct 31 23:00 7.958
11956301 2 diningPhilosophers MUTEX Oct 31 23:00 Oct 31 23:00 2.221
11956301 3 diningPhilosophers READY Oct 31 23:00 Oct 31 23:00
2.127
11956301 4 diningPhilosophers MUTEX Oct 31 23:00 Oct 31 23:00 2.220
11956301 5 diningPhilosophers READY Oct 31 23:00 Oct 31 23:00 2.015
11956301 6 diningPhilosophers MUTEX Oct 31 23:00 Oct 31 23:00 2.075
..............................
pid tid name STATE start time
thread start sutime
11620427 1 diningPhilosophers_2 RUNNING Oct 31 22:58 Oct 31 22:58
8.277
11620427 2 diningPhilosophers_2 MUTEX Oct 31 22:58 Oct 31 22:58
0.000
11620427 3 diningPhilosophers_2 NANOSLEEP Oct 31 22:58 Oct 31 22:58
0.000
11620427 4 diningPhilosophers_2 MUTEX Oct 31 22:58 Oct 31 22:58
0.000
11620427 5 diningPhilosophers_2 MUTEX Oct 31 22:58 Oct 31 22:58
0.000
11620427 6 diningPhilosophers_2 NANOSLEEP Oct 31 22:58 Oct 31 22:58
0.000
start_time The thread's starting time, in nanoseconds..
sutime The thread's system plus user running time, in nanoseconds.
diningPhilosophers:
stack tid pid-tid STATE cpu prio kernel call
12K(516K)* 1 12689488-0 RUNNING 3 10r
4096(132K) 2 12689488-0 RUNNING 1 10r
4096(132K) 3 12689488-0 MUTEX 2 10r sync_mutex_lock
4096(132K) 4 12689488-0 READY 2 10r
4096(132K) 5 12689488-0 MUTEX 3 10r sync_mutex_lock
4096(132K) 6 12689488-0 MUTEX 0 10r sync_mutex_lock
diningPhilosophers_2:
stack tid pid-tid STATE cpu prio kernel call
16K(516K)* 1 13897811-0 RUNNING 3 10r
4096(132K) 2 13897811-0 MUTEX 1 10r sync_mutex_lock
4096(132K) 3 13897811-0 NANOSLEEP 1 10r timer_timeout
4096(132K) 4 13897811-0 MUTEX 0 10r sync_mutex_lock
4096(132K) 5 13897811-0 MUTEX 0 10r sync_mutex_lock
4096(132K) 6 13897811-0 MUTEX 2 10r sync_mutex_lock
Vala
pid tid name STATE start time thread
start sutime
17399899 1 ./philosofers SIGWAITINFO Oct 31 23:19 Oct 31 23:19 0.002
17399899 2 ./philosofers NANOSLEEP Oct 31 23:19 Oct 31 23:19
0.000
17399899 3 ./philosofers NANOSLEEP Oct 31 23:19 Oct 31 23:19
0.000
17399899 4 ./philosofers CONDVAR Oct 31 23:19 Oct 31 23:19
0.000
17399899 5 ./philosofers CONDVAR Oct 31 23:19 Oct 31 23:19
0.000
17399899 6 ./philosofers NANOSLEEP Oct 31 23:19 Oct 31 23:19
0.000
stack tid pid-tid STATE cpu prio kernel call
12K(516K)* 1 14442581-0 SIGWAITINFO 2 10r signal_waitinfo
4096(132K) 2 14442581-0 NANOSLEEP 2 10r timer_timeout
4096(132K) 3 14442581-0 NANOSLEEP 3 10r timer_timeout
4096(132K) 4 14442581-0 CONDVAR 0 10r sync_condvar_wa
4096(132K) 5 14442581-0 CONDVAR 0 10r sync_condvar_wa
4096(132K) 6 14442581-0 NANOSLEEP 3 10r timer_timeout
Ada - gnat4.2.2
pid tid name STATE start time thread
start sutime
25940065 1 ./diners CONDVAR Oct 31 23:32 Oct 31 23:32 0.006
25940065 2 ./diners CONDVAR Oct 31 23:32 Oct 31 23:32 0.015
25940065 3 ./diners CONDVAR Oct 31 23:32 Oct 31 23:32 0.000
25940065 4 ./diners CONDVAR Oct 31 23:32 Oct 31 23:32 0.000
25940065 5 ./diners CONDVAR Oct 31 23:32 Oct 31 23:32 0.000
25940065 6 ./diners CONDVAR Oct 31 23:32 Oct 31 23:32 0.000
25940065 7 ./diners CONDVAR Oct 31 23:32 Oct 31 23:32 0.000
stack tid pid-tid STATE cpu prio kernel call
12K(516K)* 1 20852829-0 CONDVAR 2 31o sync_condvar_wa
4096(2052K) 2 20852829-0 CONDVAR 2 31o sync_condvar_wa
4096(2052K) 3 20852829-0 CONDVAR 1 31o sync_condvar_wa
4096(2052K) 4 20852829-0 CONDVAR 3 31o sync_condvar_wa
4096(2052K) 5 20852829-0 CONDVAR 1 31o sync_condvar_wa
4096(2052K) 6 20852829-0 CONDVAR 0 31o sync_condvar_wa
4096(2052K) 7 20852829-0 CONDVAR 2 31o sync_condvar_wa
diningPhilosophers.m
..............
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
int i;
..............
for (i = 0;i < 5; ++i)
[forks[i] unlockWithCondition:FOOD_SERVED];
while (1);
[arp release];
}
Executing the statement while(1); in the main thread of the program
diningPhilosophers makes
the loop of the expectation and such large time sutime results from here.
In Vala this looks as follows:
static int main (string[] args) {
if (!Thread.supported ()) {
error ("Cannot run without thread support.");
}
..................
new MainLoop (null, true).run ();
return 0;
}
In ada/gnat this realized using the mechanism of tasks.
Someone could me maybe prompt as realize the loop of the expectation in
GNUstep better.
And as you can see Vala and gnat they use the mechanism condvare to the
synchronisation of threads.
GNUstep uses mutex. Is to use however condvare not better ?
===============================
Javier Miranda explains in "A Detailed Description of the GNU Ada Run Time"
why gnat uses condvare and not mutex
for the synchronisation of threads.
Low-Level Locks
The GNAT run-time uses Lock/Unlock operations in order to maintain data
consistency under concurrent
read/update operations by multiple threads of control.
.................
Mutual exclusion is provided through POSIX mutexes. When a thread wants
exclusive access to some shared resource,
it locks the associated mutex, via pthread_mutex_lock(); if some other
thread has already locked that mutex,
the requesting thread is suspended until the thread holding the mutex
unlocks it, via pthread_mutex_unlock().
Any number of tasks can be suspended on the same mutex; one of them is
granted the mutex and permitted to continue
execution when the holder unlocks the mutex. Mutexes are similar to binary
semaphores; the principal difference
is that the thread which holds the mutex must be the one to unlock it. This
makes mutexes difficult to use for
general communication between threads; an arbitrary thread cannot signal to
other threads that something has
occurred by unlocking a locked mutex. For this kind of synchronization,
condition variables are used.
A thread waits for a condition to become true by calling pthread_cond_wait()
on a condition variable.
Another thread can signal that the condition has become true by signaling
the condition variable, via
pthread_cond_signal() (this is not to be confused with operations on POSIX
signals). A mutex is associated with
the condition variable by the pthread_cond_wait() call. This mutex must be
locked before the call;
it is unlocked (atomically) by the call and locked again before the call
returns. This is to protect the
condition for which the thread is waiting. A pthread_cond_signal() call is
guaranteed to wake up at least one
waiting thread, but it turns out to be more efficient (particularly on
multiprocessors) to allow more than one
waiting thread to return. Since the first thread to reacquire the associated
mutex might make the condition false
again, each thread needs to check that the condition is true when
pthread_cond_wait() returns.
This is usually done in a while loop.
--
View this message in context: http://old.nabble.com/QNX---GNUstep-and-Objective-C-tp26047107p26148884.html
> And as you can see Vala and gnat they use the mechanism condvare to
> the
> synchronisation of threads.
> GNUstep uses mutex. Is to use however condvare not better ?
I'm not sure what the point you are trying to make is. GNUstep
provides mutexes via NSLock and NSRecursiveLock and condition
variables via NSCondition and NSConditionLock.
In future it would help if you can state your questions succinctly.
It took me quite a while to wade through the output dumps and quotes
in your email to find something that looked a bit like a question...
David
-- Sent from my Apple II
--
View this message in context: http://old.nabble.com/QNX---GNUstep-and-Objective-C-tp26047107p27004526.html
This error will appear if the first instance variable in a class
appears before the end of the last instance variable in the
superclass. In this case, the first instance variable is a 'struct
stat' and it is (apparently) overlapping with the isa pointer.
It's not clear from your post. Are you linking against both libobjc2
(which installs itself as libobjc.so.4) and against GCC libobjc
(libobjc.so.3 or libobjc.so.2)? If so, then you can expect things to
break quite badly, because both export the same symbols. Please use
one or the other, not both. If this is not the problem then...
Both NSObject and GSAttrDictionary are part of -base, so you will have
compiled them with the same compiler. The problem is therefore not an
issue of mismatched compilers, but it may well be something related to
the ABI handling in clang. The ivar offset calculation code is not
yet particularly well tested beyond x86 *NIX platforms. It is
possible that there is a bug.
I've just added a bit more debugging code to libobjc2, so it will tell
you what the name and offsets of the offending ivars are. Please can
you run the new version and see what the message is? Please can you
also let me know what architecture you are using, so I can check that
clang is generating the correct IR?
You can also comment out line 787 in libobjc2's init.c. This will
revert to the behaviour of the older versions of libobjc and see if
things actually break.
David
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss...@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnustep
-- Send from my Jacquard Loom
1. -fgnu-runtime => this is correct ?
2. I work on x86 PC , QNX 6.4.1 (32 bit), CPU Intel Core2 Quad Q6600 2.40
GHz
3. and this is not the mistake:
[gnustep]/libs/base/trunk/Source/NSObject.m
@interface NSZombie
{
Class isa;
}
- (Class) class;
.................
@end
but
@implementation NSZombie
- (Class) originalClass => is it correct ?
{
return NSMapGet(zombieMap, (void*)self);
}
.................
--
View this message in context: http://old.nabble.com/QNX---GNUstep-and-Objective-C-tp26047107p27026421.html
> Error: Instance variables in GSAttrDictionary overlap superclass
> NSObject
> Offset of first instance variable, statbuf, is 8
> Last instance variable in superclass, isa, ends at offset 4
> This probably means that you are subclassing a class from a library,
> which
> has changed in a
> binary-incompatible way.
Ah, this is indeed my fault. I was not allowing for alignment in the
checking. I think I've fixed that now, let me know if it still breaks
for you.
David
-- Sent from my Cray X1
"David Chisnall" <ther...@sucs.org> napisaĆ(a):
int
main (void)
{
NSLog (@"Executing");
return 0;
}
=========
make CC=clang and use libobjc2
Error appears in when library function be called out:
static void __objc_compute_ivar_offsets (Class class); from init.c
which be called out by:
static void
__objc_create_classes_tree (Module_t module)
{
...................
objc_tree_insert_class (class);
__objc_compute_ivar_offsets (class);
...................
}
I made in function __objc_compute_ivar_offsets change:
1. I added on beginning fprintf( ..........)
static void
__objc_compute_ivar_offsets (Class class)
{
int i = 0;
/* If this class was compiled with support for late-bound ivars, the
* instance_size field will contain 0 - {the size of the instance
variables
* declared for just this class}. The individual instance variable offset
* fields will then be the offsets from the start of the class, and so
must
* have the size of the parent class prepended. */
fprintf(stderr, "class: %s ->instance_size %d \n",
class->name, class->instance_size);
if (class->instance_size <= 0)
{
super = class_superclass_of_class(class);
if (Nil == super) { return; }
.............................
and I comment abort() on end of function:
.............................
fprintf(stderr, "This probably means that you are subclassing a class
from a library, which has changed in a binary-incompatible way.\n");
// abort();
}
}
Result is following:
class: NXConstantString ->instance_size 12
class: Object ->instance_size 4
class: Protocol ->instance_size 20
class: GSInet6ServerStream ->instance_size 160
class: GSInetServerStream ->instance_size 160
class: GSInet6OutputStream ->instance_size 160
................................
class: NSException ->instance_size 16
class: NSFileHandle ->instance_size 4
class: GSAttrDictionaryEnumerator ->instance_size 12
class: GSAttrDictionary ->instance_size 80
Error: Instance variables in GSAttrDictionary overlap superclass NSObject
Offset of first instance variable, statbuf, is 8
Last instance variable in superclass, isa, ends at offset 4
This probably means that you are subclassing a class from a library, which
has changed in a binary-incompatible way.
class: NSDirectoryEnumerator ->instance_size 24
class: NSFileManager ->instance_size 8
..................................
class: GSRunLoopCtxt ->instance_size 76
class: GSLocalServerStream ->instance_size 264
Error: Instance variables in GSLocalServerStream overlap superclass
GSSocketServerStream
Offset of first instance variable, _serverAddr, is 158
Last instance variable in superclass, _address, ends at offset 160
This probably means that you are subclassing a class from a library, which
has changed in a binary-incompatible way.
class: NSOutputStream ->instance_size 4
class: NSInputStream ->instance_size 4
class: NSStream ->instance_size 4
..................................
class: Protocol2 ->instance_size 36
class: Protocol ->instance_size 20
class: Object ->instance_size 4
class: NXConstantString ->instance_size 12
2010-01-08 12:39:27.031 LogTest[40984635] Executing
Function __objc_compute_ivar_offsets() be called out 379 times. For two
classes GSAttrDictionary and GSLocalServerStream appeared mistake.
It can from this was infer, that mistake however appears in different place
?
--
View this message in context: http://old.nabble.com/QNX---GNUstep-and-Objective-C-tp26047107p27080734.html
> Error: Instance variables in GSAttrDictionary overlap superclass
> NSObject
> Offset of first instance variable, statbuf, is 8
> Last instance variable in superclass, isa, ends at offset 4
> This probably means that you are subclassing a class from a library,
> which
> has changed in a binary-incompatible way.
This one should have been fixed - I'm now allowing for alignment. If
statbuf only requires alignment of 4 but is being aligned on an 8-byte
boundary, then this is a bug in clang. If statbuf really requires
alignment of 8 then it's a bug in libobjc2.
I don't think clang has a QNX target, so this may be the issue, but
usually alignment is per-CPU, not per-target.
> Error: Instance variables in GSLocalServerStream overlap superclass
> GSSocketServerStream
> Offset of first instance variable, _serverAddr, is 158
> Last instance variable in superclass, _address, ends at offset 160
> This probably means that you are subclassing a class from a library,
> which
> has changed in a binary-incompatible way.
This one is more concerning. The sockaddr ivar from
GSSocketServerStream
appears to end two bytes after the first ivar declared in
GSLocalServerStream.
> Function __objc_compute_ivar_offsets() be called out 379 times.
Yes, it's called once per class.
> For two
> classes GSAttrDictionary and GSLocalServerStream appeared mistake.
> It can from this was infer, that mistake however appears in
> different place
> ?
In both cases, the first instance variable is a structure, but I'm not
sure that this makes a difference. Unfortunately, they're both
structures from system headers, so I can't reproduce the same
situation on other platforms...
Do you get different behaviour if you compile these two classes with
GCC? I note that you're using the GCC ABI with clang, so you should
get equivalent code from both compilers; if you don't then it's a bug.
David