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

Commit 5a04c20

Browse files
committed
Merge pull request #752 from rainers/gc_nothrow3
make most GC functions nothrow
2 parents 3748ebf + 66a0f0a commit 5a04c20

27 files changed

+354
-255
lines changed

src/core/runtime.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ extern (C) bool runModuleUnitTests()
359359
{
360360
import core.sys.posix.signal; // segv handler
361361

362-
static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr )
362+
static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr ) nothrow
363363
{
364364
static enum MAXFRAMES = 128;
365365
void*[MAXFRAMES] callstack;

src/core/sync/mutex.d

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ class Mutex :
129129
* SyncException on error.
130130
*/
131131
@trusted void lock()
132+
{
133+
lock_impl!SyncException();
134+
}
135+
136+
@trusted void lock_nothrow() nothrow
137+
{
138+
lock_impl!Error();
139+
}
140+
private @trusted void lock_impl(Exc)()
132141
{
133142
version( Windows )
134143
{
@@ -138,11 +147,10 @@ class Mutex :
138147
{
139148
int rc = pthread_mutex_lock( &m_hndl );
140149
if( rc )
141-
throw new SyncException( "Unable to lock mutex" );
150+
throw new Exc( "Unable to lock mutex" );
142151
}
143152
}
144153

145-
146154
/**
147155
* Decrements the internal lock count by one. If this brings the count to
148156
* zero, the lock is released.
@@ -151,6 +159,16 @@ class Mutex :
151159
* SyncException on error.
152160
*/
153161
@trusted void unlock()
162+
{
163+
unlock_impl!SyncException();
164+
}
165+
166+
@trusted void unlock_nothrow() nothrow
167+
{
168+
unlock_impl!Error();
169+
}
170+
171+
private @trusted void unlock_impl(Exc)()
154172
{
155173
version( Windows )
156174
{
@@ -160,11 +178,10 @@ class Mutex :
160178
{
161179
int rc = pthread_mutex_unlock( &m_hndl );
162180
if( rc )
163-
throw new SyncException( "Unable to unlock mutex" );
181+
throw new Exc( "Unable to unlock mutex" );
164182
}
165183
}
166184

167-
168185
/**
169186
* If the lock is held by another caller, the method returns. Otherwise,
170187
* the lock is acquired if it is not already held, and then the internal

src/core/sys/freebsd/dlfcn.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public import core.sys.posix.dlfcn;
1111

1212
version (FreeBSD):
1313
extern (C):
14+
nothrow:
1415

1516
enum __BSD_VISIBLE = true;
1617

@@ -86,7 +87,7 @@ static if (__BSD_VISIBLE)
8687

8788
private template __externC(RT, P...)
8889
{
89-
alias extern(C) RT function(P) __externC;
90+
alias extern(C) RT function(P) nothrow __externC;
9091
}
9192

9293
/* XSI functions first. */

src/core/sys/freebsd/execinfo.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module core.sys.freebsd.execinfo;
1010

1111
version (FreeBSD):
1212
extern (C):
13+
nothrow:
1314

1415
import core.sys.freebsd.dlfcn;
1516

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

4243
extern (D) char** backtrace_symbols(const(void*)* buffer, int size)
4344
{
44-
static void* realloc(void* p, size_t len)
45+
static void* realloc(void* p, size_t len) nothrow
4546
{
4647
static import cstdlib=core.stdc.stdlib;
4748
auto res = cstdlib.realloc(p, len);

src/core/sys/linux/execinfo.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module core.sys.linux.execinfo;
99

1010
version (linux):
1111
extern (C):
12+
nothrow:
1213

1314
int backtrace(void** buffer, int size);
1415
char** backtrace_symbols(const(void*)* buffer, int size);

src/core/sys/osx/execinfo.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module core.sys.osx.execinfo;
99

1010
version (OSX):
1111
extern (C):
12+
nothrow:
1213

1314
int backtrace(void** buffer, int size);
1415
char** backtrace_symbols(const(void*)* buffer, int size);

src/core/sys/osx/mach/thread_act.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module core.sys.osx.mach.thread_act;
1515

1616
version (OSX):
1717
extern (C):
18+
nothrow:
1819

1920
public import core.sys.osx.mach.kern_return;
2021
public import core.sys.osx.mach.port;

src/core/sys/osx/pthread.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module core.sys.osx.pthread;
1515

1616
version (OSX):
1717
extern (C):
18+
nothrow:
1819

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

src/core/sys/posix/dlfcn.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ private import core.sys.posix.config;
1818

1919
version (Posix):
2020
extern (C):
21+
nothrow:
2122

2223
//
2324
// XOpen (XSI)

src/core/sys/posix/semaphore.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ private import core.sys.posix.time;
1919

2020
version (Posix):
2121
extern (C):
22+
nothrow:
2223

2324
//
2425
// Required

src/core/sys/posix/signal.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public import core.sys.posix.sys.types; // for pid_t
2323

2424
version (Posix):
2525
extern (C):
26+
nothrow:
2627

2728
//
2829
// Required
@@ -638,6 +639,7 @@ version( linux )
638639
} _sigpoll_t _sigpoll;
639640
} _sifields_t _sifields;
640641

642+
nothrow:
641643
@property ref pid_t si_pid() { return _sifields._kill.si_pid; }
642644
@property ref uid_t si_uid() { return _sifields._kill.si_uid; }
643645
@property ref void* si_addr() { return _sifields._sigfault.si_addr; }

0 commit comments

Comments
 (0)