mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-29 11:31:11 +00:00
Surrounded by #if for mach.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1027 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a9db0be31a
commit
98a91e5fb3
1 changed files with 27 additions and 21 deletions
|
@ -1,8 +1,8 @@
|
||||||
/* Implementation of Machport-based port object for use with Connection
|
/* Implementation of Machport-based port object for use with Connection
|
||||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
Copyright (C) 1994, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||||
Date: September 1994
|
Created: September 1994
|
||||||
|
|
||||||
This file is part of the GNU Objective C Class Library.
|
This file is part of the GNU Objective C Class Library.
|
||||||
|
|
||||||
|
@ -21,11 +21,14 @@
|
||||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* This old code really needs work; it does not currently compile. */
|
||||||
|
|
||||||
|
#if __mach__
|
||||||
|
|
||||||
#include <objects/MachPort.h>
|
#include <objects/MachPort.h>
|
||||||
#include <objects/Connection.h>
|
#include <objects/Connection.h>
|
||||||
#include <objects/Lock.h>
|
#include <objects/Lock.h>
|
||||||
#include <objects/Set.h>
|
#include <objects/Set.h>
|
||||||
#include <objc/hash.h>
|
|
||||||
|
|
||||||
#include <mach/cthreads.h>
|
#include <mach/cthreads.h>
|
||||||
#include <mach/notify.h>
|
#include <mach/notify.h>
|
||||||
|
@ -47,7 +50,7 @@ static Lock *portDictionaryGate;
|
||||||
|
|
||||||
/* This not tested */
|
/* This not tested */
|
||||||
static int
|
static int
|
||||||
worry (any_t arg)
|
listen_for_invalidation (any_t arg)
|
||||||
{
|
{
|
||||||
kern_return_t r;
|
kern_return_t r;
|
||||||
notification_t m;
|
notification_t m;
|
||||||
|
@ -88,11 +91,11 @@ worry (any_t arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This not tested */
|
/* This not tested */
|
||||||
+ worryAboutPortInvalidation
|
+ listenForPortInvalidation
|
||||||
{
|
{
|
||||||
MachPort *worryPort = [MachPort new];
|
MachPort *listenPort = [MachPort new];
|
||||||
task_set_special_port(task_self(), TASK_NOTIFY_PORT, [worryPort machPort]);
|
task_set_special_port(task_self(), TASK_NOTIFY_PORT, [listenPort mach_port]);
|
||||||
cthread_detach(cthread_fork((any_t)worry, (any_t)0));
|
cthread_detach(cthread_fork((any_t)listen_for_invalidation, (any_t)0));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +111,7 @@ worry (any_t arg)
|
||||||
return aPort;
|
return aPort;
|
||||||
}
|
}
|
||||||
aPort = [[self alloc] init];
|
aPort = [[self alloc] init];
|
||||||
aPort->machPort = p;
|
aPort->mach_port = p;
|
||||||
aPort->deallocate = f;
|
aPort->deallocate = f;
|
||||||
[portDictionary addElement:aPort atKey:(int)p];
|
[portDictionary addElement:aPort atKey:(int)p];
|
||||||
[portDictionaryGate unlock];
|
[portDictionaryGate unlock];
|
||||||
|
@ -132,24 +135,26 @@ worry (any_t arg)
|
||||||
return [self newFromMachPort:p];
|
return [self newFromMachPort:p];
|
||||||
}
|
}
|
||||||
|
|
||||||
- encodeUsing: aPortal
|
- (void) encodeWithCoder: aCoder
|
||||||
{
|
{
|
||||||
[aPortal encodeData:&deallocate ofType:@encode(BOOL)];
|
[aCoder encodeValueOfCType: @encode(BOOL)
|
||||||
[aPortal encodeMachPort:machPort];
|
at: &deallocate
|
||||||
return self;
|
withName: @""];
|
||||||
|
[aCoder encodeMachPort: mach_port];
|
||||||
}
|
}
|
||||||
|
|
||||||
- decodeUsing: aPortal
|
+ newWithCoder: aCoder
|
||||||
{
|
{
|
||||||
BOOL f;
|
BOOL f;
|
||||||
port_t mp;
|
port_t mp;
|
||||||
MachPort *p;
|
MachPort *p;
|
||||||
|
|
||||||
[aPortal decodeData:&f ofType:@encode(BOOL)];
|
[aCoder decodeValueOfCType: @encode(BOOL)
|
||||||
[aPortal decodeMachPort:&mp];
|
at: &f
|
||||||
/* Is this right? Can we return a different object than 'self' */
|
withName: NULL];
|
||||||
|
[aCoder decodeMachPort: &mp];
|
||||||
|
|
||||||
p = [MachPort newFromMachPort:mp dealloc:f];
|
p = [MachPort newFromMachPort:mp dealloc:f];
|
||||||
[self release];
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,10 +185,11 @@ worry (any_t arg)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (port_t) machPort
|
- (mach_port_t) machPort
|
||||||
{
|
{
|
||||||
return machPort;
|
return mach_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif /* __mach__ */
|
||||||
|
|
Loading…
Reference in a new issue