Integrate C++11 branch into 5_1-new
This commit is contained in:
@@ -103,7 +103,7 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
while( got < size-1 )
|
||||
{
|
||||
char *p = (char *) memchr( file, '\n', file_used );
|
||||
if( p == NULL )
|
||||
if( p == nullptr )
|
||||
break;
|
||||
*p++ = 0;
|
||||
|
||||
@@ -114,13 +114,13 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
|
||||
/* Search for the hyphen. */
|
||||
char *hyphen = strchr( line, '-' );
|
||||
if( hyphen == NULL )
|
||||
if( hyphen == nullptr )
|
||||
continue; /* Parse error. */
|
||||
|
||||
|
||||
/* Search for the space. */
|
||||
char *space = strchr( hyphen, ' ' );
|
||||
if( space == NULL )
|
||||
if( space == nullptr )
|
||||
continue; /* Parse error. */
|
||||
|
||||
/* " rwxp". If space[1] isn't 'r', then the block isn't readable. */
|
||||
@@ -132,10 +132,10 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
if( strlen(space) < 4 || space[3] != 'x' )
|
||||
continue;
|
||||
|
||||
/* If, for some reason, either end is NULL, skip it; that's our terminator. */
|
||||
/* If, for some reason, either end is nullptr, skip it; that's our terminator. */
|
||||
const void *start = (const void *) xtoi( line );
|
||||
const void *end = (const void *) xtoi( hyphen+1 );
|
||||
if( start != NULL && end != NULL )
|
||||
if( start != nullptr && end != nullptr )
|
||||
{
|
||||
*starts++ = start;
|
||||
*ends++ = end;
|
||||
@@ -153,8 +153,8 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
|
||||
close(fd);
|
||||
|
||||
*starts++ = NULL;
|
||||
*ends++ = NULL;
|
||||
*starts++ = nullptr;
|
||||
*ends++ = nullptr;
|
||||
|
||||
return got;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ static int find_address( const void *p, const void **starts, const void **ends )
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void *SavedStackPointer = NULL;
|
||||
static void *SavedStackPointer = nullptr;
|
||||
|
||||
void InitializeBacktrace()
|
||||
{
|
||||
@@ -380,7 +380,7 @@ static void do_backtrace( const void **buf, size_t size, const BacktraceContext
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
|
||||
#if defined(CPU_X86)
|
||||
@@ -408,11 +408,11 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
InitializeBacktrace();
|
||||
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
CurrentCtx.ip = NULL;
|
||||
CurrentCtx.ip = nullptr;
|
||||
CurrentCtx.bp = __builtin_frame_address(0);
|
||||
CurrentCtx.sp = __builtin_frame_address(0);
|
||||
CurrentCtx.pid = GetCurrentThreadId();
|
||||
@@ -543,16 +543,16 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
if( g_StackPointer == 0 )
|
||||
{
|
||||
buf[0] = BACKTRACE_METHOD_NOT_AVAILABLE;
|
||||
buf[1] = NULL;
|
||||
buf[1] = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
CurrentCtx.ip = NULL;
|
||||
CurrentCtx.ip = nullptr;
|
||||
CurrentCtx.bp = __builtin_frame_address(0);
|
||||
CurrentCtx.sp = __builtin_frame_address(0);
|
||||
}
|
||||
@@ -582,7 +582,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
/* There isn't much we can do if this is the case. The stack should be read/write
|
||||
* and since it isn't, give up. */
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
return;
|
||||
}
|
||||
const Frame *frame = (Frame *)ctx->sp;
|
||||
@@ -640,7 +640,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
#undef PROT_RW
|
||||
#undef PROT_EXE
|
||||
@@ -664,14 +664,14 @@ void InitializeBacktrace() { }
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
/* __builtin_frame_address is broken on OS X; it sometimes returns bogus results. */
|
||||
register void *r1 __asm__ ("r1");
|
||||
CurrentCtx.FramePtr = (const Frame *) r1;
|
||||
CurrentCtx.PC = NULL;
|
||||
CurrentCtx.PC = nullptr;
|
||||
}
|
||||
|
||||
const Frame *frame = ctx->FramePtr;
|
||||
@@ -688,7 +688,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
frame = frame->stackPointer;
|
||||
}
|
||||
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
|
||||
#elif defined(BACKTRACE_METHOD_PPC_LINUX)
|
||||
@@ -713,13 +713,13 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
BacktraceContext CurrentCtx;
|
||||
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
register void *r1 __asm__("1");
|
||||
CurrentCtx.FramePtr = (const Frame *)r1;
|
||||
CurrentCtx.PC = NULL;
|
||||
CurrentCtx.PC = nullptr;
|
||||
}
|
||||
|
||||
const Frame *frame = (const Frame *)ctx->FramePtr;
|
||||
@@ -733,7 +733,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
if( frame->linkReg )
|
||||
buf[i++] = frame->linkReg;
|
||||
}
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -744,7 +744,7 @@ void InitializeBacktrace() { }
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
buf[0] = BACKTRACE_METHOD_NOT_AVAILABLE;
|
||||
buf[1] = NULL;
|
||||
buf[1] = nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,10 +31,10 @@ struct BacktraceContext
|
||||
void InitializeBacktrace();
|
||||
|
||||
/* Retrieve up to size-1 backtrace pointers in buf. The array will be
|
||||
* null-terminated. If ctx is NULL, retrieve the current backtrace; otherwise
|
||||
* null-terminated. If ctx is nullptr, retrieve the current backtrace; otherwise
|
||||
* retrieve a backtrace for the given context. (Not all backtracers may
|
||||
* support contexts.) */
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx = NULL );
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx = nullptr );
|
||||
|
||||
/* Set up a BacktraceContext to get a backtrace for a thread. ThreadID may
|
||||
* not be the current thread. True is returned on success, false on failure. */
|
||||
|
||||
@@ -44,7 +44,7 @@ void BacktraceNames::Demangle()
|
||||
return;
|
||||
|
||||
int status = 0;
|
||||
char *name = abi::__cxa_demangle( Symbol, NULL, NULL, &status );
|
||||
char *name = abi::__cxa_demangle( Symbol, nullptr, nullptr, &status );
|
||||
if( name )
|
||||
{
|
||||
Symbol = name;
|
||||
@@ -121,7 +121,7 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
* between one function and the next, because the first lookup will succeed.
|
||||
*/
|
||||
Dl_info di;
|
||||
if( !dladdr((void *) p, &di) || di.dli_sname == NULL )
|
||||
if( !dladdr((void *) p, &di) || di.dli_sname == nullptr )
|
||||
{
|
||||
if( !dladdr( ((char *) p) - 8, &di) )
|
||||
return;
|
||||
@@ -177,7 +177,7 @@ static int osx_find_image( const void *p )
|
||||
for( unsigned i = 0; i < image_count; i++ )
|
||||
{
|
||||
const struct mach_header *header = _dyld_get_image_header(i);
|
||||
if( header == NULL )
|
||||
if( header == nullptr )
|
||||
continue;
|
||||
|
||||
/* The load commands directly follow the mach_header. */
|
||||
@@ -219,7 +219,7 @@ static const char *osx_find_link_edit( const struct mach_header *header )
|
||||
return (char *) ( scmd->vmaddr - scmd->fileoff );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BacktraceNames::FromAddr( void * const p )
|
||||
@@ -235,7 +235,7 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
|
||||
/* Find the link-edit pointer. */
|
||||
const char *link_edit = osx_find_link_edit( _dyld_get_image_header(index) );
|
||||
if( link_edit == NULL )
|
||||
if( link_edit == nullptr )
|
||||
return;
|
||||
link_edit += _dyld_get_image_vmaddr_slide( index );
|
||||
|
||||
@@ -244,8 +244,8 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
const struct load_command *cmd = (struct load_command *) &header[1];
|
||||
unsigned long diff = 0xffffffff;
|
||||
|
||||
const char *dli_sname = NULL;
|
||||
void *dli_saddr = NULL;
|
||||
const char *dli_sname = nullptr;
|
||||
void *dli_saddr = nullptr;
|
||||
|
||||
for( unsigned long i = 0; i < header->ncmds; i++, cmd = next_load_command(cmd) )
|
||||
{
|
||||
@@ -299,7 +299,7 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
Address = (intptr_t) p;
|
||||
|
||||
char **foo = backtrace_symbols(&p, 1);
|
||||
if( foo == NULL )
|
||||
if( foo == nullptr )
|
||||
return;
|
||||
FromString( foo[0] );
|
||||
free(foo);
|
||||
|
||||
@@ -34,7 +34,7 @@ static void safe_print( int fd, ... )
|
||||
for(;;)
|
||||
{
|
||||
const char *p = va_arg( ap, const char * );
|
||||
if( p == NULL )
|
||||
if( p == nullptr )
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -88,13 +88,13 @@ static void NORETURN spawn_child_process( int from_parent )
|
||||
strncpy( magic, CHILD_MAGIC_PARAMETER, sizeof(magic) );
|
||||
|
||||
/* Use execve; it's the lowest-level of the exec calls. The others may allocate. */
|
||||
char *argv[3] = { path, magic, NULL };
|
||||
char *envp[1] = { NULL };
|
||||
char *argv[3] = { path, magic, nullptr };
|
||||
char *envp[1] = { nullptr };
|
||||
execve( path, argv, envp );
|
||||
|
||||
/* If we got here, the exec failed. We can't call strerror. */
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", NULL);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", NULL );
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", nullptr);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@@ -116,13 +116,13 @@ static bool parent_write( int to_child, const void *p, size_t size )
|
||||
int ret = retried_write( to_child, p, size );
|
||||
if( ret == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( size_t(ret) != size )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
/* 4. Write RecentLogs. */
|
||||
int cnt = 0;
|
||||
const char *ps[1024];
|
||||
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != NULL )
|
||||
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != nullptr )
|
||||
++cnt;
|
||||
|
||||
parent_write(to_child, &cnt, sizeof(cnt));
|
||||
@@ -211,9 +211,9 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
|
||||
static void RunCrashHandler( const CrashData *crash )
|
||||
{
|
||||
if( g_pCrashHandlerArgv0 == NULL )
|
||||
if( g_pCrashHandlerArgv0 == nullptr )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -221,9 +221,9 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
struct sigaction sa;
|
||||
memset( &sa, 0, sizeof(sa) );
|
||||
sa.sa_handler = SIG_IGN;
|
||||
if( sigaction( SIGPIPE, &sa, NULL ) != 0 )
|
||||
if( sigaction( SIGPIPE, &sa, nullptr ) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), NULL );
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), nullptr );
|
||||
/* non-fatal */
|
||||
}
|
||||
|
||||
@@ -237,22 +237,22 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
switch( crash->type )
|
||||
{
|
||||
case CrashData::SIGNAL:
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", NULL );
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", nullptr );
|
||||
break;
|
||||
|
||||
case CrashData::FORCE_CRASH:
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", nullptr );
|
||||
break;
|
||||
|
||||
default:
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", nullptr );
|
||||
break;
|
||||
}
|
||||
|
||||
if( active == 1 )
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", NULL);
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", nullptr);
|
||||
else if( active == 2 )
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", NULL);
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", nullptr);
|
||||
|
||||
_exit( 1 );
|
||||
}
|
||||
@@ -267,14 +267,14 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
int fds[2];
|
||||
if( pipe(fds) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", nullptr );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
pid_t childpid = fork();
|
||||
if( childpid == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
RageThread::ResumeAllThreads();
|
||||
|
||||
if( WIFSIGNALED(status) )
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ void CrashHandler::ForceCrash( const char *reason )
|
||||
strncpy( crash.reason, reason, sizeof(crash.reason) );
|
||||
crash.reason[ sizeof(crash.reason)-1 ] = 0;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
RunCrashHandler( &crash );
|
||||
}
|
||||
@@ -352,7 +352,7 @@ void CrashHandler::ForceDeadlock( RString reason, uint64_t iID )
|
||||
|
||||
crash.type = CrashData::FORCE_CRASH;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
if( iID == GetInvalidThreadId() )
|
||||
{
|
||||
@@ -384,7 +384,7 @@ void CrashHandler::CrashSignalHandler( int signal, siginfo_t *si, const ucontext
|
||||
static volatile bool bInCrashSignalHandler = false;
|
||||
if( bInCrashSignalHandler )
|
||||
{
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", NULL );
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
bool child_read( int fd, void *p, int size );
|
||||
|
||||
const char *g_pCrashHandlerArgv0 = NULL;
|
||||
const char *g_pCrashHandlerArgv0 = nullptr;
|
||||
|
||||
|
||||
static void output_stack_trace( FILE *out, const void **BacktracePointers )
|
||||
@@ -153,7 +153,7 @@ static void child_process()
|
||||
|
||||
FD_ZERO( &rs );
|
||||
FD_SET( 3, &rs );
|
||||
int ret = select( 4, &rs, NULL, NULL, &timeout );
|
||||
int ret = select( 4, &rs, nullptr, nullptr, &timeout );
|
||||
|
||||
if( ret == 0 )
|
||||
{
|
||||
@@ -194,7 +194,7 @@ static void child_process()
|
||||
sCrashInfoPath += "/crashinfo.txt";
|
||||
|
||||
FILE *CrashDump = fopen( sCrashInfoPath, "w+" );
|
||||
if(CrashDump == NULL)
|
||||
if(CrashDump == nullptr)
|
||||
{
|
||||
fprintf( stderr, "Couldn't open " + sCrashInfoPath + ": %s\n", strerror(errno) );
|
||||
exit(1);
|
||||
@@ -271,7 +271,7 @@ static void child_process()
|
||||
/* stdout may have been inadvertently closed by the crash in the parent;
|
||||
* write to /dev/tty instead. */
|
||||
FILE *tty = fopen( "/dev/tty", "w" );
|
||||
if( tty == NULL )
|
||||
if( tty == nullptr )
|
||||
tty = stderr;
|
||||
|
||||
fputs( "\n"
|
||||
|
||||
@@ -59,7 +59,7 @@ SaveSignals::SaveSignals()
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
{
|
||||
struct sigaction sa;
|
||||
sigaction( signals[i], NULL, &sa );
|
||||
sigaction( signals[i], nullptr, &sa );
|
||||
old_handlers.push_back( sa );
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ SaveSignals::~SaveSignals()
|
||||
{
|
||||
/* Restore the old signal handlers. */
|
||||
for( unsigned i = 0; i < old_handlers.size(); ++i )
|
||||
sigaction( signals[i], &old_handlers[i], NULL );
|
||||
sigaction( signals[i], &old_handlers[i], nullptr );
|
||||
}
|
||||
|
||||
static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
@@ -88,7 +88,7 @@ static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
struct sigaction old;
|
||||
sigaction( signal, &sa, &old );
|
||||
raise( signal );
|
||||
sigaction( signal, &old, NULL );
|
||||
sigaction( signal, &old, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ static void *CreateStack( int size )
|
||||
*
|
||||
* mmap entries always show up individually in /proc/#/maps. We could use posix_memalign as
|
||||
* a fallback, but we'd have to put a barrier page on both sides to guarantee that. */
|
||||
char *p = NULL;
|
||||
p = (char *) mmap( NULL, size+PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
|
||||
char *p = nullptr;
|
||||
p = (char *) mmap( nullptr, size+PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
|
||||
|
||||
if( p == (void *) -1 )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
// if( posix_memalign( (void**) &p, PageSize, RealSize ) != 0 )
|
||||
// return NULL;
|
||||
// return nullptr;
|
||||
|
||||
if( find_stack_direction() < 0 )
|
||||
{
|
||||
@@ -143,7 +143,7 @@ static void *CreateStack( int size )
|
||||
/* Hook up events to fatal signals, so we can clean up if we're killed. */
|
||||
void SignalHandler::OnClose( handler h )
|
||||
{
|
||||
if( saved_sigs == NULL )
|
||||
if( saved_sigs == nullptr )
|
||||
{
|
||||
saved_sigs = new SaveSignals;
|
||||
|
||||
@@ -158,27 +158,27 @@ void SignalHandler::OnClose( handler h )
|
||||
/* Allocate a separate signal stack. This makes the crash handler work
|
||||
* if we run out of stack space. */
|
||||
const int AltStackSize = 1024*64;
|
||||
void *p = NULL;
|
||||
void *p = nullptr;
|
||||
if( bUseAltSigStack )
|
||||
p = CreateStack( AltStackSize );
|
||||
|
||||
if( p != NULL )
|
||||
if( p != nullptr )
|
||||
{
|
||||
stack_t ss;
|
||||
ss.ss_sp = (char*)p; /* cast for Darwin */
|
||||
ss.ss_size = AltStackSize;
|
||||
ss.ss_flags = 0;
|
||||
if( sigaltstack( &ss, NULL ) == -1 )
|
||||
if( sigaltstack( &ss, nullptr ) == -1 )
|
||||
{
|
||||
LOG->Info( "sigaltstack failed: %s", strerror(errno) );
|
||||
p = NULL; /* no SA_ONSTACK */
|
||||
p = nullptr; /* no SA_ONSTACK */
|
||||
}
|
||||
}
|
||||
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_flags = 0;
|
||||
if( p != NULL )
|
||||
if( p != nullptr )
|
||||
sa.sa_flags |= SA_ONSTACK;
|
||||
sa.sa_flags |= SA_NODEFER;
|
||||
sa.sa_flags |= SA_SIGINFO;
|
||||
@@ -187,11 +187,11 @@ void SignalHandler::OnClose( handler h )
|
||||
/* Set up our signal handlers. */
|
||||
sa.sa_sigaction = SigHandler;
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
sigaction( signals[i], &sa, NULL );
|
||||
sigaction( signals[i], &sa, nullptr );
|
||||
|
||||
/* Block SIGPIPE, so we get EPIPE. */
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction( SIGPIPE, &sa, NULL );
|
||||
sigaction( SIGPIPE, &sa, nullptr );
|
||||
}
|
||||
handlers.push_back(h);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <X11/extensions/dpms.h>
|
||||
|
||||
Display *X11Helper::Dpy = NULL;
|
||||
Display *X11Helper::Dpy = nullptr;
|
||||
Window X11Helper::Win = None;
|
||||
|
||||
static int ErrorCallback( Display*, XErrorEvent* );
|
||||
@@ -20,9 +20,9 @@ static bool dpms_state_at_startup= false;
|
||||
|
||||
bool X11Helper::OpenXConnection()
|
||||
{
|
||||
DEBUG_ASSERT( Dpy == NULL && Win == None );
|
||||
DEBUG_ASSERT( Dpy == nullptr && Win == None );
|
||||
Dpy = XOpenDisplay(0);
|
||||
if( Dpy == NULL )
|
||||
if( Dpy == nullptr )
|
||||
return false;
|
||||
|
||||
XSetIOErrorHandler( FatalCallback );
|
||||
@@ -65,10 +65,10 @@ void X11Helper::CloseXConnection()
|
||||
}
|
||||
}
|
||||
// The window should have been shut down
|
||||
DEBUG_ASSERT( Dpy != NULL );
|
||||
DEBUG_ASSERT( Dpy != nullptr );
|
||||
DEBUG_ASSERT( Win == None );
|
||||
XCloseDisplay( Dpy );
|
||||
Dpy = NULL;
|
||||
Dpy = nullptr;
|
||||
}
|
||||
|
||||
bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visual, int width, int height, bool overrideRedirect )
|
||||
@@ -103,7 +103,7 @@ bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visua
|
||||
return false;
|
||||
|
||||
XClassHint *hint = XAllocClassHint();
|
||||
if ( hint == NULL ) {
|
||||
if ( hint == nullptr ) {
|
||||
LOG->Warn("Could not set class hint for X11 Window");
|
||||
} else {
|
||||
hint->res_name = (char*)g_XWMName.Get().c_str();
|
||||
|
||||
Reference in New Issue
Block a user