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

Commit

Permalink
Merge pull request #752 from rainers/gc_nothrow3
Browse files Browse the repository at this point in the history
make most GC functions nothrow
  • Loading branch information
MartinNowak committed May 11, 2014
2 parents 3748ebf + 66a0f0a commit 5a04c20
Show file tree
Hide file tree
Showing 27 changed files with 354 additions and 255 deletions.
2 changes: 1 addition & 1 deletion src/core/runtime.d
Expand Up @@ -359,7 +359,7 @@ extern (C) bool runModuleUnitTests()
{
import core.sys.posix.signal; // segv handler

static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr )
static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr ) nothrow
{
static enum MAXFRAMES = 128;
void*[MAXFRAMES] callstack;
Expand Down
25 changes: 21 additions & 4 deletions src/core/sync/mutex.d
Expand Up @@ -129,6 +129,15 @@ class Mutex :
* SyncException on error.
*/
@trusted void lock()
{
lock_impl!SyncException();
}

@trusted void lock_nothrow() nothrow
{
lock_impl!Error();
}
private @trusted void lock_impl(Exc)()
{
version( Windows )
{
Expand All @@ -138,11 +147,10 @@ class Mutex :
{
int rc = pthread_mutex_lock( &m_hndl );
if( rc )
throw new SyncException( "Unable to lock mutex" );
throw new Exc( "Unable to lock mutex" );
}
}


/**
* Decrements the internal lock count by one. If this brings the count to
* zero, the lock is released.
Expand All @@ -151,6 +159,16 @@ class Mutex :
* SyncException on error.
*/
@trusted void unlock()
{
unlock_impl!SyncException();
}

@trusted void unlock_nothrow() nothrow
{
unlock_impl!Error();
}

private @trusted void unlock_impl(Exc)()
{
version( Windows )
{
Expand All @@ -160,11 +178,10 @@ class Mutex :
{
int rc = pthread_mutex_unlock( &m_hndl );
if( rc )
throw new SyncException( "Unable to unlock mutex" );
throw new Exc( "Unable to unlock mutex" );
}
}


/**
* If the lock is held by another caller, the method returns. Otherwise,
* the lock is acquired if it is not already held, and then the internal
Expand Down
3 changes: 2 additions & 1 deletion src/core/sys/freebsd/dlfcn.d
Expand Up @@ -11,6 +11,7 @@ public import core.sys.posix.dlfcn;

version (FreeBSD):
extern (C):
nothrow:

enum __BSD_VISIBLE = true;

Expand Down Expand Up @@ -86,7 +87,7 @@ static if (__BSD_VISIBLE)

private template __externC(RT, P...)
{
alias extern(C) RT function(P) __externC;
alias extern(C) RT function(P) nothrow __externC;
}

/* XSI functions first. */
Expand Down
3 changes: 2 additions & 1 deletion src/core/sys/freebsd/execinfo.d
Expand Up @@ -10,6 +10,7 @@ module core.sys.freebsd.execinfo;

version (FreeBSD):
extern (C):
nothrow:

import core.sys.freebsd.dlfcn;

Expand Down Expand Up @@ -41,7 +42,7 @@ extern (D) int backtrace(void** buffer, int size)

extern (D) char** backtrace_symbols(const(void*)* buffer, int size)
{
static void* realloc(void* p, size_t len)
static void* realloc(void* p, size_t len) nothrow
{
static import cstdlib=core.stdc.stdlib;
auto res = cstdlib.realloc(p, len);
Expand Down
1 change: 1 addition & 0 deletions src/core/sys/linux/execinfo.d
Expand Up @@ -9,6 +9,7 @@ module core.sys.linux.execinfo;

version (linux):
extern (C):
nothrow:

int backtrace(void** buffer, int size);
char** backtrace_symbols(const(void*)* buffer, int size);
Expand Down
1 change: 1 addition & 0 deletions src/core/sys/osx/execinfo.d
Expand Up @@ -9,6 +9,7 @@ module core.sys.osx.execinfo;

version (OSX):
extern (C):
nothrow:

int backtrace(void** buffer, int size);
char** backtrace_symbols(const(void*)* buffer, int size);
Expand Down
1 change: 1 addition & 0 deletions src/core/sys/osx/mach/thread_act.d
Expand Up @@ -15,6 +15,7 @@ module core.sys.osx.mach.thread_act;

version (OSX):
extern (C):
nothrow:

public import core.sys.osx.mach.kern_return;
public import core.sys.osx.mach.port;
Expand Down
1 change: 1 addition & 0 deletions src/core/sys/osx/pthread.d
Expand Up @@ -15,6 +15,7 @@ module core.sys.osx.pthread;

version (OSX):
extern (C):
nothrow:

public import core.sys.posix.pthread;
public import core.sys.osx.mach.port;
Expand Down
1 change: 1 addition & 0 deletions src/core/sys/posix/dlfcn.d
Expand Up @@ -18,6 +18,7 @@ private import core.sys.posix.config;

version (Posix):
extern (C):
nothrow:

//
// XOpen (XSI)
Expand Down
1 change: 1 addition & 0 deletions src/core/sys/posix/semaphore.d
Expand Up @@ -19,6 +19,7 @@ private import core.sys.posix.time;

version (Posix):
extern (C):
nothrow:

//
// Required
Expand Down
2 changes: 2 additions & 0 deletions src/core/sys/posix/signal.d
Expand Up @@ -23,6 +23,7 @@ public import core.sys.posix.sys.types; // for pid_t

version (Posix):
extern (C):
nothrow:

//
// Required
Expand Down Expand Up @@ -638,6 +639,7 @@ version( linux )
} _sigpoll_t _sigpoll;
} _sifields_t _sifields;

nothrow:
@property ref pid_t si_pid() { return _sifields._kill.si_pid; }
@property ref uid_t si_uid() { return _sifields._kill.si_uid; }
@property ref void* si_addr() { return _sifields._sigfault.si_addr; }
Expand Down

0 comments on commit 5a04c20

Please sign in to comment.