Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
moved OSX-specific pthread stuff into core.sys.osx.pthread
Browse files Browse the repository at this point in the history
  • Loading branch information
complexmath committed Aug 2, 2011
1 parent 9252837 commit d711ae8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 58 deletions.
50 changes: 50 additions & 0 deletions src/core/sys/osx/pthread.d
@@ -0,0 +1,50 @@
/**
* D header file for OSX.
*
* Copyright: Copyright Sean Kelly 2008 - 2009.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: Sean Kelly
*/

/* Copyright Sean Kelly 2008 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module core.sys.osx.pthread;

version (OSX):

public import core.sys.posix.pthread;
public import core.sys.osx.mach.port;

extern (C):

int pthread_is_threaded_np();
int pthread_threadid_np(pthread_t, ulong*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int pthread_rwlock_longrdlock_np(pthread_rwlock_t*);
int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
int pthread_rwlock_downgrade_np(pthread_rwlock_t*);
int pthread_rwlock_upgrade_np(pthread_rwlock_t*);
int pthread_rwlock_tryupgrade_np(pthread_rwlock_t*);
int pthread_rwlock_held_np(pthread_rwlock_t*);
int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
int pthread_rwlock_wrheld_np(pthread_rwlock_t*);
int pthread_getname_np(pthread_t, char*, size_t);
int pthread_setname_np(in char*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int pthread_main_np();
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void* pthread_get_stackaddr_np(pthread_t);
int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);
int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);
int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
int pthread_kill(pthread_t, int);
pthread_t pthread_from_mach_thread_np(mach_port_t);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int pthread_sigmask(int, in sigset_t*, sigset_t*);
// ^ __DARWIN_ALIAS(pthread_sigmask)
void pthread_yield_np();
58 changes: 1 addition & 57 deletions src/core/sys/posix/pthread.d
Expand Up @@ -704,6 +704,7 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
*/

version( FreeBSD )
{
int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
Expand All @@ -722,60 +723,3 @@ else version( OSX )
int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
}

//
// Non-POSIX OS-Specific Additions
//

version( OSX )
{
import core.sys.osx.mach.port;

// returns non-zero if pthread_create or cthread_fork have been called
int pthread_is_threaded_np();

int pthread_threadid_np(pthread_t, ulong*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)

int pthread_rwlock_longrdlock_np(pthread_rwlock_t*);
int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
int pthread_rwlock_downgrade_np(pthread_rwlock_t*);
int pthread_rwlock_upgrade_np(pthread_rwlock_t*);
int pthread_rwlock_tryupgrade_np(pthread_rwlock_t*);
int pthread_rwlock_held_np(pthread_rwlock_t*);
int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
int pthread_rwlock_wrheld_np(pthread_rwlock_t*);

// SPI to set and get pthread name
int pthread_getname_np(pthread_t, char*, size_t);
int pthread_setname_np(in char*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)

// returns non-zero if the current thread is the main thread
int pthread_main_np();

// return the mach thread bound to the pthread
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void* pthread_get_stackaddr_np(pthread_t);

// Like pthread_cond_signal(), but only wake up the specified pthread
int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);

// Like pthread_cond_timedwait, but use a relative timeout
int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);

// Like pthread_create(), but leaves the thread suspended
int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
int pthread_kill(pthread_t, int);

pthread_t pthread_from_mach_thread_np(mach_port_t);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)

int pthread_sigmask(int, in sigset_t*, sigset_t*);
// ^ __DARWIN_ALIAS(pthread_sigmask)

void pthread_yield_np();
}

2 changes: 1 addition & 1 deletion src/rt/memory.d
Expand Up @@ -44,7 +44,7 @@ private
}
version( OSX )
{
import core.sys.posix.pthread;
import core.sys.osx.pthread;
}
extern (C) void gc_addRange( void* p, size_t sz );
extern (C) void gc_removeRange( void* p );
Expand Down

0 comments on commit d711ae8

Please sign in to comment.