Decouple <cstdint>
This commit is contained in:
@@ -9,15 +9,17 @@
|
||||
#include "archutils/Unix/RunningUnderValgrind.h"
|
||||
#endif
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(LINUX)
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/ptrace.h>
|
||||
@@ -87,7 +89,7 @@ static int waittid( int ThreadID, int *status, int options )
|
||||
return ret;
|
||||
bSupportsWall = false;
|
||||
}
|
||||
|
||||
|
||||
/* XXX: on 2.2, we need to use __WCLONE only if ThreadID isn't the main thread;
|
||||
* perhaps wait and retry without it if errno == ECHILD? */
|
||||
int ret;
|
||||
@@ -125,7 +127,7 @@ static int PtraceDetach( int ThreadID )
|
||||
|
||||
|
||||
/* Get this thread's ID (this may be a TID or a PID). */
|
||||
static uint64_t GetCurrentThreadIdInternal()
|
||||
static std::uint64_t GetCurrentThreadIdInternal()
|
||||
{
|
||||
/* If we're under Valgrind, neither the PID nor the TID is associated with the
|
||||
* thread. Return the pthread ID. This can't be used to kill threads, etc.,
|
||||
@@ -133,7 +135,7 @@ static uint64_t GetCurrentThreadIdInternal()
|
||||
* usable, unique ID, then mutexes won't work. */
|
||||
if( RunningUnderValgrind() )
|
||||
return (int) pthread_self();
|
||||
|
||||
|
||||
InitializePidThreadHelpers(); // for g_bUsingNPTL
|
||||
|
||||
/* Don't keep calling gettid() if it's not supported; it'll make valgrind spam us. */
|
||||
@@ -155,14 +157,14 @@ static uint64_t GetCurrentThreadIdInternal()
|
||||
return getpid();
|
||||
}
|
||||
|
||||
uint64_t GetCurrentThreadId()
|
||||
std::uint64_t GetCurrentThreadId()
|
||||
{
|
||||
#if defined(HAVE_TLS)
|
||||
/* This is called each time we lock a mutex, and gettid() is a little slow, so
|
||||
* cache the result if we support TLS. */
|
||||
if( RageThread::GetSupportsTLS() )
|
||||
{
|
||||
static thread_local uint64_t cached_tid = 0;
|
||||
static thread_local std::uint64_t cached_tid = 0;
|
||||
static thread_local bool cached = false;
|
||||
if( !cached )
|
||||
{
|
||||
@@ -176,7 +178,7 @@ uint64_t GetCurrentThreadId()
|
||||
return GetCurrentThreadIdInternal();
|
||||
}
|
||||
|
||||
int SuspendThread( uint64_t ThreadID )
|
||||
int SuspendThread( std::uint64_t ThreadID )
|
||||
{
|
||||
/*
|
||||
* Linux: We can't simply kill(SIGSTOP) (or tkill), since that will stop all processes
|
||||
@@ -187,7 +189,7 @@ int SuspendThread( uint64_t ThreadID )
|
||||
// kill( ThreadID, SIGSTOP );
|
||||
}
|
||||
|
||||
int ResumeThread( uint64_t ThreadID )
|
||||
int ResumeThread( std::uint64_t ThreadID )
|
||||
{
|
||||
return PtraceDetach( int(ThreadID) );
|
||||
// kill( ThreadID, SIGSTOP );
|
||||
@@ -203,7 +205,7 @@ int ResumeThread( uint64_t ThreadID )
|
||||
* This call leaves the given thread suspended, so the returned context doesn't become invalid.
|
||||
* ResumeThread() can be used to resume a thread after this call. */
|
||||
#if defined(CRASH_HANDLER)
|
||||
bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx )
|
||||
bool GetThreadBacktraceContext( std::uint64_t ThreadID, BacktraceContext *ctx )
|
||||
{
|
||||
/* Can't GetThreadBacktraceContext the current thread. */
|
||||
ASSERT( ThreadID != GetCurrentThreadId() );
|
||||
@@ -264,17 +266,17 @@ RString ThreadsVersion()
|
||||
return "(unknown)";
|
||||
}
|
||||
|
||||
uint64_t GetCurrentThreadId()
|
||||
std::uint64_t GetCurrentThreadId()
|
||||
{
|
||||
return uint64_t( pthread_self() );
|
||||
return std::uint64_t( pthread_self() );
|
||||
}
|
||||
|
||||
int SuspendThread( uint64_t id )
|
||||
int SuspendThread( std::uint64_t id )
|
||||
{
|
||||
return pthread_kill( pthread_t(id), SIGSTOP );
|
||||
}
|
||||
|
||||
int ResumeThread( uint64_t id )
|
||||
int ResumeThread( std::uint64_t id )
|
||||
{
|
||||
return pthread_kill( pthread_t(id), SIGCONT );
|
||||
}
|
||||
@@ -283,7 +285,7 @@ int ResumeThread( uint64_t id )
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -293,7 +295,7 @@ int ResumeThread( uint64_t id )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
#ifndef PID_THREAD_HELPERS_H
|
||||
#define PID_THREAD_HELPERS_H
|
||||
|
||||
#if defined(HAVE_STDINT_H)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include "global.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
RString ThreadsVersion();
|
||||
|
||||
/* Get the current thread's ThreadID. */
|
||||
uint64_t GetCurrentThreadId();
|
||||
std::uint64_t GetCurrentThreadId();
|
||||
|
||||
/* Return true if NPTL libraries are in use, false if linuxthreads. */
|
||||
bool UsingNPTL();
|
||||
|
||||
int SuspendThread( uint64_t ThreadID );
|
||||
int ResumeThread( uint64_t ThreadID );
|
||||
int SuspendThread( std::uint64_t ThreadID );
|
||||
int ResumeThread( std::uint64_t ThreadID );
|
||||
|
||||
struct BacktraceContext;
|
||||
int GetThreadContext( uint64_t ThreadID, BacktraceContext *ctx );
|
||||
|
||||
int GetThreadContext( std::uint64_t ThreadID, BacktraceContext *ctx );
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -35,7 +34,7 @@ int GetThreadContext( uint64_t ThreadID, BacktraceContext *ctx );
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
#if defined(CPU_X86)
|
||||
|
||||
#if defined(HAVE_STDINT_H)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <cstdint>
|
||||
|
||||
inline uint32_t ArchSwap32( uint32_t n )
|
||||
inline std::uint32_t ArchSwap32( std::uint32_t n )
|
||||
{
|
||||
asm(
|
||||
"xchg %b0, %h0\n"
|
||||
@@ -17,7 +15,7 @@ inline uint32_t ArchSwap32( uint32_t n )
|
||||
return n;
|
||||
}
|
||||
|
||||
inline uint32_t ArchSwap24( uint32_t n )
|
||||
inline std::uint32_t ArchSwap24( std::uint32_t n )
|
||||
{
|
||||
asm(
|
||||
"xchg %b0, %h0\n"
|
||||
@@ -28,7 +26,7 @@ inline uint32_t ArchSwap24( uint32_t n )
|
||||
return n;
|
||||
}
|
||||
|
||||
inline uint16_t ArchSwap16( uint16_t n )
|
||||
inline std::uint16_t ArchSwap16( std::uint16_t n )
|
||||
{
|
||||
asm(
|
||||
"xchg %b0, %h0\n":
|
||||
@@ -43,7 +41,7 @@ inline uint16_t ArchSwap16( uint16_t n )
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -53,7 +51,7 @@ inline uint16_t ArchSwap16( uint16_t n )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -6,23 +6,24 @@
|
||||
#include "Backtrace.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
bool SuspendThread( uint64_t threadHandle )
|
||||
bool SuspendThread( std::uint64_t threadHandle )
|
||||
{
|
||||
return !thread_suspend( thread_act_t(threadHandle) );
|
||||
}
|
||||
|
||||
bool ResumeThread( uint64_t threadHandle )
|
||||
bool ResumeThread( std::uint64_t threadHandle )
|
||||
{
|
||||
return !thread_resume( thread_act_t(threadHandle) );
|
||||
}
|
||||
|
||||
uint64_t GetCurrentThreadId()
|
||||
std::uint64_t GetCurrentThreadId()
|
||||
{
|
||||
return mach_thread_self();
|
||||
}
|
||||
|
||||
bool GetThreadBacktraceContext( uint64_t iID, BacktraceContext *ctx )
|
||||
bool GetThreadBacktraceContext( std::uint64_t iID, BacktraceContext *ctx )
|
||||
{
|
||||
/* Can't GetThreadBacktraceContext the current thread. */
|
||||
ASSERT( iID != GetCurrentThreadId() );
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
#ifndef DARWIN_THREAD_HELPERS_H
|
||||
#define DARWIN_THREAD_HELPERS_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief Attempt to suspend the specified thread.
|
||||
* @param threadHandle the thread to suspend.
|
||||
* @return true if the thread is suspended, false otherwise. */
|
||||
bool SuspendThread( uint64_t threadHandle );
|
||||
bool SuspendThread( std::uint64_t threadHandle );
|
||||
/**
|
||||
* @brief Attempt to resume the specified thread.
|
||||
* @param threadHandle the thread to resume.
|
||||
* @return true if the thread is resumed, false otherwise. */
|
||||
bool ResumeThread( uint64_t threadHandle );
|
||||
bool ResumeThread( std::uint64_t threadHandle );
|
||||
/**
|
||||
* @brief Retrieve the current thread ID.
|
||||
* @return the current thread ID. */
|
||||
uint64_t GetCurrentThreadId();
|
||||
std::uint64_t GetCurrentThreadId();
|
||||
/**
|
||||
* @brief Set the precedence for the thread.
|
||||
*
|
||||
@@ -30,7 +32,7 @@ RString SetThreadPrecedence( float prec );
|
||||
* @author Steve Checkoway (c) 2004-2006
|
||||
* @section LICENSE
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -40,7 +42,7 @@ RString SetThreadPrecedence( float prec );
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
#ifndef HIDDEVICE_H
|
||||
#define HIDDEVICE_H
|
||||
|
||||
#include "RageLog.h"
|
||||
#include "RageInputDevice.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
@@ -9,13 +18,6 @@
|
||||
#include <IOKit/usb/USB.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_error.h>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "RageLog.h"
|
||||
#include "RageInputDevice.h"
|
||||
|
||||
/* A few helper functions. */
|
||||
|
||||
@@ -48,11 +50,11 @@ namespace __gnu_cxx
|
||||
{
|
||||
#ifndef __LP64__
|
||||
template<>
|
||||
struct hash<IOHIDElementCookie> : private hash<uintptr_t>
|
||||
struct hash<IOHIDElementCookie> : private hash<std::uintptr_t>
|
||||
{
|
||||
std::size_t operator()( const IOHIDElementCookie& cookie ) const
|
||||
{
|
||||
return hash<unsigned long>::operator()( uintptr_t(cookie) );
|
||||
return hash<unsigned long>::operator()( std::uintptr_t(cookie) );
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "JoystickDevice.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
Joystick::Joystick() : id( InputDevice_Invalid ),
|
||||
x_axis( 0 ), y_axis( 0 ), z_axis( 0 ),
|
||||
x_rot( 0 ), y_rot( 0 ), z_rot( 0 ), hat( 0 ),
|
||||
@@ -43,10 +45,10 @@ void JoystickDevice::AddElement( int usagePage, int usage, IOHIDElementCookie co
|
||||
{
|
||||
int iMin = 0;
|
||||
int iMax = 0;
|
||||
|
||||
|
||||
IntValue( CFDictionaryGetValue(properties, CFSTR(kIOHIDElementMinKey)), iMin );
|
||||
IntValue( CFDictionaryGetValue(properties, CFSTR(kIOHIDElementMaxKey)), iMax );
|
||||
|
||||
|
||||
switch( usage )
|
||||
{
|
||||
case kHIDUsage_GD_X:
|
||||
@@ -142,7 +144,7 @@ bool JoystickDevice::InitDevice( int vid, int pid )
|
||||
if( vid != 0x0507 || pid != 0x0011 )
|
||||
return true;
|
||||
// It's a Para controller, so try to power it on.
|
||||
uint8_t powerOn = 1;
|
||||
std::uint8_t powerOn = 1;
|
||||
IOReturn ret = SetReport( kIOHIDReportTypeFeature, 0, &powerOn, 1, 10 );
|
||||
|
||||
if( ret )
|
||||
@@ -267,7 +269,7 @@ void JoystickDevice::GetDevicesAndDescriptions( std::vector<InputDeviceInfo>& vD
|
||||
/*
|
||||
* (c) 2005-2007 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -277,7 +279,7 @@ void JoystickDevice::GetDevicesAndDescriptions( std::vector<InputDeviceInfo>& vD
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "PumpDevice.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
void PumpDevice::Open()
|
||||
{
|
||||
AddElementToQueue( IOHIDElementCookie(2) );
|
||||
@@ -17,8 +19,8 @@ void PumpDevice::GetButtonPresses( std::vector<DeviceInput>& vPresses, IOHIDElem
|
||||
DeviceButton db2 = DeviceButton_Invalid;
|
||||
bool pressed1 = !(value & 0x1);
|
||||
bool pressed2 = !(value & 0x2);
|
||||
|
||||
switch( uintptr_t(cookie) )
|
||||
|
||||
switch( std::uintptr_t(cookie) )
|
||||
{
|
||||
case 2:
|
||||
db2 = JOY_BUTTON_1; // bit 9
|
||||
@@ -66,7 +68,7 @@ void PumpDevice::GetDevicesAndDescriptions( std::vector<InputDeviceInfo>& vDevic
|
||||
/*
|
||||
* (c) 2006 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -76,7 +78,7 @@ void PumpDevice::GetDevicesAndDescriptions( std::vector<InputDeviceInfo>& vDevic
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#include "VectorHelper.h"
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(USE_VEC)
|
||||
#if defined(__VEC__)
|
||||
#include <vecLib/vecLib.h>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
bool Vector::CheckForVector()
|
||||
{
|
||||
int32_t result = 0;
|
||||
std::int32_t result = 0;
|
||||
std::size_t size = 4;
|
||||
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, nullptr, 0 ) && result;
|
||||
@@ -32,7 +33,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size )
|
||||
vFloat store = (vFloat)(0.0f);
|
||||
|
||||
// If dest is misaligned, pull the first loop iteration out.
|
||||
if( intptr_t(dest) & 0xF )
|
||||
if( std::intptr_t(dest) & 0xF )
|
||||
{
|
||||
vFloat load2Src = vec_ld( 15, src );
|
||||
vFloat load2Dest = vec_ld( 15, dest );
|
||||
@@ -43,7 +44,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size )
|
||||
load1Dest = vec_add( load1Dest, load1Src );
|
||||
store = vec_perm( load1Dest, load1Dest, storeMask );
|
||||
|
||||
while( (intptr_t(dest) + index) & 0xC )
|
||||
while( (std::intptr_t(dest) + index) & 0xC )
|
||||
{
|
||||
vec_ste( store, index, dest );
|
||||
index += 4;
|
||||
@@ -191,7 +192,7 @@ bool Vector::CheckForVector()
|
||||
|
||||
void Vector::FastSoundWrite( float *dest, const float *src, unsigned size )
|
||||
{
|
||||
while( (intptr_t(dest) & 0xF) && size )
|
||||
while( (std::intptr_t(dest) & 0xF) && size )
|
||||
{
|
||||
// Misaligned stores are slow.
|
||||
*(dest++) += *(src++);
|
||||
@@ -199,7 +200,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size )
|
||||
}
|
||||
|
||||
// Misaligned loads are slower so specialize to aligned loads when possible.
|
||||
if( intptr_t(src) & 0xF )
|
||||
if( std::intptr_t(src) & 0xF )
|
||||
{
|
||||
while( size >= 8 )
|
||||
{
|
||||
|
||||
@@ -2,18 +2,19 @@
|
||||
#include "Backtrace.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cerrno>
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(BACKTRACE_METHOD_X86_LINUX)
|
||||
#include "archutils/Common/PthreadHelpers.h"
|
||||
@@ -38,9 +39,9 @@ static const char *itoa(unsigned n)
|
||||
return p;
|
||||
}
|
||||
|
||||
static intptr_t xtoi( const char *hex )
|
||||
static std::intptr_t xtoi( const char *hex )
|
||||
{
|
||||
intptr_t ret = 0;
|
||||
std::intptr_t ret = 0;
|
||||
for(;;)
|
||||
{
|
||||
int val = -1;
|
||||
@@ -501,7 +502,7 @@ static bool PointsToValidCall( vm_address_t start, const void *ptr )
|
||||
|
||||
/* We're reading buf backwards, between buf[-7] and buf[-1]. Find out how
|
||||
* far we can read. */
|
||||
const int len = std::min<int>(intptr_t(ptr) - start, 7);
|
||||
const int len = std::min<int>(std::intptr_t(ptr) - start, 7);
|
||||
|
||||
// Permissible CALL sequences that we care about:
|
||||
//
|
||||
@@ -598,7 +599,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c
|
||||
// Make sure this is on the stack
|
||||
if( !GetRegionInfo(self, frame, start, protection) || protection != PROT_RW )
|
||||
break;
|
||||
if( (start != g_StackPointer && start != stackPointer) || uintptr_t(frame)-uintptr_t(start) < sizeof(Frame) )
|
||||
if( (start != g_StackPointer && start != stackPointer) || std::uintptr_t(frame)-std::uintptr_t(start) < sizeof(Frame) )
|
||||
break;
|
||||
|
||||
/* The stack pointer is always 16 byte aligned _before_ the call. Thus a valid frame
|
||||
@@ -616,7 +617,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c
|
||||
* Therefore, frame + 8 should be on a 16 byte boundary, the frame link should be
|
||||
* at a higher address, the link should be on the stack and it should be RW. The
|
||||
* return address should be EXE and point to a valid call (well, just after). */
|
||||
if( (((uintptr_t)frame+8) & 0xF) != 0 ||// boundary
|
||||
if( (((std::uintptr_t)frame+8) & 0xF) != 0 ||// boundary
|
||||
frame->link <= frame || // the frame link goes up
|
||||
!GetRegionInfo(self, frame->link, start, protection) ||
|
||||
(start != g_StackPointer && start != stackPointer) || // the link is on the stack
|
||||
@@ -628,7 +629,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c
|
||||
/* This is not a valid frame but we might be in code compiled with
|
||||
* -fomit-frame-pointer so look at each address on the stack that is
|
||||
* 4 bytes below a 16 byte boundary. */
|
||||
if( (((uintptr_t)frame+4) & 0xF) == 0 )
|
||||
if( (((std::uintptr_t)frame+4) & 0xF) == 0 )
|
||||
{
|
||||
void *p = *(void **)frame;
|
||||
if( GetRegionInfo(self, p, start, protection) &&
|
||||
@@ -638,7 +639,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c
|
||||
buf[i++] = p;
|
||||
}
|
||||
}
|
||||
frame = (Frame *)(intptr_t(frame)+4);
|
||||
frame = (Frame *)(std::intptr_t(frame)+4);
|
||||
continue;
|
||||
}
|
||||
// Valid.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define BACKTRACE_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
/* This API works like backtrace_pointers(), to retrieve a stack trace. */
|
||||
|
||||
@@ -40,7 +41,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c
|
||||
|
||||
/* 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. */
|
||||
bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx );
|
||||
bool GetThreadBacktraceContext( std::uint64_t ThreadID, BacktraceContext *ctx );
|
||||
|
||||
/* Set up a BacktraceContext to get a backtrace after receiving a signal, given
|
||||
* a ucontext_t (see sigaction(2)). (This interface is UNIX-specific.) */
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
#include "global.h"
|
||||
#include "BacktraceNames.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
|
||||
#include "RageUtil.h"
|
||||
|
||||
@@ -100,7 +101,7 @@ RString BacktraceNames::Format() const
|
||||
#include <dlfcn.h>
|
||||
void BacktraceNames::FromAddr( void * const p )
|
||||
{
|
||||
Address = (intptr_t) p;
|
||||
Address = (std::intptr_t) p;
|
||||
|
||||
/*
|
||||
* When calling a function that doesn't return, gcc will truncate a function.
|
||||
@@ -225,7 +226,7 @@ static const char *osx_find_link_edit( const struct mach_header *header )
|
||||
|
||||
void BacktraceNames::FromAddr( void * const p )
|
||||
{
|
||||
Address = (intptr_t) p;
|
||||
Address = (std::intptr_t) p;
|
||||
|
||||
/* Find the image with the given pointer. */
|
||||
int index = osx_find_image( p );
|
||||
@@ -297,7 +298,7 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
#include <execinfo.h>
|
||||
void BacktraceNames::FromAddr( void * const p )
|
||||
{
|
||||
Address = (intptr_t) p;
|
||||
Address = (std::intptr_t) p;
|
||||
|
||||
char **foo = backtrace_symbols(&p, 1);
|
||||
if( foo == nullptr )
|
||||
@@ -345,7 +346,7 @@ void BacktraceNames::FromString( RString s )
|
||||
#warning Undefined BACKTRACE_LOOKUP_METHOD_*
|
||||
void BacktraceNames::FromAddr( void * const p )
|
||||
{
|
||||
Address = intptr_t(p);
|
||||
Address = std::intptr_t(p);
|
||||
Offset = 0;
|
||||
Symbol = "";
|
||||
File = "";
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#ifndef BACKTRACE_NAMES_H
|
||||
#define BACKTRACE_NAMES_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct BacktraceNames
|
||||
{
|
||||
RString Symbol, File;
|
||||
intptr_t Address;
|
||||
std::intptr_t Address;
|
||||
int Offset;
|
||||
void FromAddr( void * const p );
|
||||
void FromString( RString str );
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "global.h"
|
||||
|
||||
#include <csignal>
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -12,7 +14,6 @@
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <csignal>
|
||||
|
||||
#include "RageLog.h" /* for RageLog::GetAdditionalLog, etc, only */
|
||||
#include "RageThreads.h"
|
||||
@@ -24,7 +25,7 @@
|
||||
#include "CrashHandler.h"
|
||||
#include "CrashHandlerInternal.h"
|
||||
|
||||
extern uint64_t GetInvalidThreadId();
|
||||
extern std::uint64_t GetInvalidThreadId();
|
||||
extern const char *g_pCrashHandlerArgv0;
|
||||
|
||||
static void safe_print( int fd, ... )
|
||||
@@ -314,7 +315,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
static void BacktraceAllThreads( CrashData& crash )
|
||||
{
|
||||
int iCnt = 1;
|
||||
uint64_t iID;
|
||||
std::uint64_t iID;
|
||||
|
||||
for( int i = 0; RageThread::EnumThreadIDs(i, iID); ++i )
|
||||
{
|
||||
@@ -347,7 +348,7 @@ void CrashHandler::ForceCrash( const char *reason )
|
||||
RunCrashHandler( &crash );
|
||||
}
|
||||
|
||||
void CrashHandler::ForceDeadlock( RString reason, uint64_t iID )
|
||||
void CrashHandler::ForceDeadlock( RString reason, std::uint64_t iID )
|
||||
{
|
||||
CrashData crash;
|
||||
memset( &crash, 0, sizeof(crash) );
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define CRASH_HANDLER_H
|
||||
|
||||
#include <csignal>
|
||||
#include <cstdint>
|
||||
|
||||
#include <ucontext.h>
|
||||
|
||||
namespace CrashHandler
|
||||
@@ -10,7 +12,7 @@ namespace CrashHandler
|
||||
void InitializeCrashHandler();
|
||||
void CrashSignalHandler( int signal, siginfo_t *si, const ucontext_t *uc );
|
||||
void ForceCrash( const char *reason );
|
||||
void ForceDeadlock( RString reason, uint64_t CrashHandle );
|
||||
void ForceDeadlock( RString reason, std::uint64_t CrashHandle );
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,7 +20,7 @@ namespace CrashHandler
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -28,7 +30,7 @@ namespace CrashHandler
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "Preference.h"
|
||||
#include "PrefsManager.h" // XXX: only used for m_bShowMouseCursor -aj
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <X11/extensions/dpms.h>
|
||||
|
||||
Display *X11Helper::Dpy = nullptr;
|
||||
@@ -204,8 +206,8 @@ bool X11Helper::SetWMFullscreenMonitors( const DisplaySpec &target )
|
||||
{
|
||||
auto mon = std::find_if( screens, end, [&]( XineramaScreenInfo &screen ) {
|
||||
return screen.x_org == target.currentBounds().left && screen.y_org == target.currentBounds().top
|
||||
&& screen.width >= 0 && static_cast<uint32_t>(screen.width) == target.currentMode()->width
|
||||
&& screen.height >= 0 && static_cast<uint32_t>(screen.height) == target.currentMode()->height;
|
||||
&& screen.width >= 0 && static_cast<std::uint32_t>(screen.width) == target.currentMode()->width
|
||||
&& screen.height >= 0 && static_cast<std::uint32_t>(screen.height) == target.currentMode()->height;
|
||||
} );
|
||||
if (mon != end)
|
||||
{
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STDINT_H) /* need to define int64_t if so */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//#include <stdio.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <windows.h>
|
||||
|
||||
#include "global.h"
|
||||
@@ -580,7 +581,7 @@ static void debug_crash()
|
||||
|
||||
/* Get a stack trace of the current thread and the specified thread.
|
||||
* If iID == GetInvalidThreadId(), then output a stack trace for every thread. */
|
||||
void CrashHandler::ForceDeadlock( RString reason, uint64_t iID )
|
||||
void CrashHandler::ForceDeadlock( RString reason, std::uint64_t iID )
|
||||
{
|
||||
strncpy( g_CrashInfo.m_CrashReason, reason, sizeof(g_CrashInfo.m_CrashReason) );
|
||||
g_CrashInfo.m_CrashReason[ sizeof(g_CrashInfo.m_CrashReason)-1 ] = 0;
|
||||
@@ -607,7 +608,7 @@ void CrashHandler::ForceDeadlock( RString reason, uint64_t iID )
|
||||
context.ContextFlags = CONTEXT_FULL;
|
||||
if( !GetThreadContext( hThread, &context ) )
|
||||
wsprintf( g_CrashInfo.m_CrashReason + strlen(g_CrashInfo.m_CrashReason),
|
||||
"; GetThreadContext(%Ix) failed", reinterpret_cast<uintptr_t>(hThread) );
|
||||
"; GetThreadContext(%Ix) failed", reinterpret_cast<std::uintptr_t>(hThread) );
|
||||
else
|
||||
{
|
||||
static const void *BacktracePointers[BACKTRACE_MAX_SIZE];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CRASH_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <windows.h>
|
||||
|
||||
/** @brief Win32 crash handling. */
|
||||
@@ -12,7 +13,7 @@ namespace CrashHandler
|
||||
void do_backtrace( const void **buf, std::size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext );
|
||||
void SymLookup( const void *ptr, char *buf );
|
||||
void ForceCrash( const char *reason );
|
||||
void ForceDeadlock( RString reason, uint64_t iID );
|
||||
void ForceDeadlock( RString reason, std::uint64_t iID );
|
||||
|
||||
/* Inform the crash handler of a foreground window that may be fullscreen.
|
||||
* If set, the crash handler will attempt to hide the window or reset the
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "global.h"
|
||||
#include "CrashHandlerInternal.h"
|
||||
#include "Crash.h"
|
||||
#include <errno.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include "archutils/Win32/ddk/dbghelp.h"
|
||||
@@ -53,10 +55,10 @@ namespace VDDebugInfo
|
||||
int nBuildNumber;
|
||||
|
||||
const unsigned char *pRVAHeap;
|
||||
uintptr_t nFirstRVA;
|
||||
std::uintptr_t nFirstRVA;
|
||||
|
||||
const char *pFuncNameHeap;
|
||||
const uintptr_t (*pSegments)[2];
|
||||
const std::uintptr_t (*pSegments)[2];
|
||||
int nSegments;
|
||||
char sFilename[1024];
|
||||
RString sError;
|
||||
@@ -110,10 +112,10 @@ namespace VDDebugInfo
|
||||
src += 2 * (sizeof(int) + sizeof(std::size_t));
|
||||
|
||||
pctx->nBuildNumber = *pVer;
|
||||
pctx->pRVAHeap = reinterpret_cast<const unsigned char*>(src + sizeof(uintptr_t));
|
||||
pctx->nFirstRVA = *reinterpret_cast<const uintptr_t*>(src);
|
||||
pctx->pRVAHeap = reinterpret_cast<const unsigned char*>(src + sizeof(std::uintptr_t));
|
||||
pctx->nFirstRVA = *reinterpret_cast<const std::uintptr_t*>(src);
|
||||
pctx->pFuncNameHeap = reinterpret_cast<const char*>(src + *pRVASize);
|
||||
pctx->pSegments = reinterpret_cast<const uintptr_t(*)[2]>(src + *pRVASize + *pFNamSize);
|
||||
pctx->pSegments = reinterpret_cast<const std::uintptr_t(*)[2]>(src + *pRVASize + *pFNamSize);
|
||||
pctx->nSegments = *pSegCnt;
|
||||
|
||||
return true;
|
||||
@@ -167,7 +169,7 @@ namespace VDDebugInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool PointerIsInAnySegment( const Context *pctx, uintptr_t rva )
|
||||
static bool PointerIsInAnySegment( const Context *pctx, std::uintptr_t rva )
|
||||
{
|
||||
for( int i=0; i<pctx->nSegments; ++i )
|
||||
{
|
||||
@@ -186,7 +188,7 @@ namespace VDDebugInfo
|
||||
return heap;
|
||||
}
|
||||
|
||||
intptr_t VDDebugInfoLookupRVA( const Context *pctx, uintptr_t rva, char *buf, int buflen )
|
||||
std::intptr_t VDDebugInfoLookupRVA( const Context *pctx, std::uintptr_t rva, char *buf, int buflen )
|
||||
{
|
||||
if( !PointerIsInAnySegment(pctx, rva) )
|
||||
return -1;
|
||||
@@ -198,13 +200,13 @@ namespace VDDebugInfo
|
||||
// Linearly unpack RVA deltas and find lower_bound
|
||||
rva -= pctx->nFirstRVA;
|
||||
|
||||
if( static_cast<intptr_t>(rva) < 0 )
|
||||
if( static_cast<std::intptr_t>(rva) < 0 )
|
||||
return -1;
|
||||
|
||||
while( pr < pr_limit )
|
||||
{
|
||||
unsigned char c;
|
||||
uintptr_t diff = 0;
|
||||
std::uintptr_t diff = 0;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -215,7 +217,7 @@ namespace VDDebugInfo
|
||||
|
||||
rva -= diff;
|
||||
|
||||
if (static_cast<intptr_t>(rva) < 0) {
|
||||
if (static_cast<std::intptr_t>(rva) < 0) {
|
||||
rva += diff;
|
||||
break;
|
||||
}
|
||||
@@ -234,7 +236,7 @@ namespace VDDebugInfo
|
||||
strncpy( buf, fn_name, buflen );
|
||||
buf[buflen-1] = 0;
|
||||
|
||||
return static_cast<intptr_t>(rva);
|
||||
return static_cast<std::intptr_t>(rva);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +289,7 @@ namespace SymbolLookup
|
||||
return true;
|
||||
}
|
||||
|
||||
SYMBOL_INFO *GetSym( uintptr_t ptr, DWORD64 &disp )
|
||||
SYMBOL_INFO *GetSym( std::uintptr_t ptr, DWORD64 &disp )
|
||||
{
|
||||
InitDbghelp();
|
||||
|
||||
@@ -367,12 +369,12 @@ namespace SymbolLookup
|
||||
VirtualQueryEx( g_hParent, ptr, &meminfo, sizeof meminfo );
|
||||
|
||||
char tmp[512];
|
||||
intptr_t iAddress = VDDebugInfo::VDDebugInfoLookupRVA(pctx, reinterpret_cast<uintptr_t>(ptr), tmp, sizeof(tmp));
|
||||
std::intptr_t iAddress = VDDebugInfo::VDDebugInfoLookupRVA(pctx, reinterpret_cast<std::uintptr_t>(ptr), tmp, sizeof(tmp));
|
||||
if( iAddress >= 0 )
|
||||
{
|
||||
wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s [%" ADDRESS_ZEROS "Ix+%Ix+%Ix]", reinterpret_cast<uintptr_t>(ptr), Demangle(tmp),
|
||||
wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s [%" ADDRESS_ZEROS "Ix+%Ix+%Ix]", reinterpret_cast<std::uintptr_t>(ptr), Demangle(tmp),
|
||||
pctx->nFirstRVA,
|
||||
reinterpret_cast<uintptr_t>(ptr) - pctx->nFirstRVA - iAddress,
|
||||
reinterpret_cast<std::uintptr_t>(ptr) - pctx->nFirstRVA - iAddress,
|
||||
iAddress );
|
||||
return;
|
||||
}
|
||||
@@ -380,21 +382,21 @@ namespace SymbolLookup
|
||||
RString sName = CrashChildGetModuleBaseName( (HMODULE)meminfo.AllocationBase );
|
||||
|
||||
DWORD64 disp;
|
||||
SYMBOL_INFO *pSymbol = GetSym( reinterpret_cast<uintptr_t>(ptr), disp );
|
||||
SYMBOL_INFO *pSymbol = GetSym( reinterpret_cast<std::uintptr_t>(ptr), disp );
|
||||
|
||||
if( pSymbol )
|
||||
{
|
||||
wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s!%s [%" ADDRESS_ZEROS "Ix+%Ix+%Ix]",
|
||||
reinterpret_cast<uintptr_t>(ptr), sName.c_str(), pSymbol->Name,
|
||||
reinterpret_cast<uintptr_t>(meminfo.AllocationBase),
|
||||
static_cast<uintptr_t>(pSymbol->Address) - reinterpret_cast<uintptr_t>(meminfo.AllocationBase),
|
||||
reinterpret_cast<std::uintptr_t>(ptr), sName.c_str(), pSymbol->Name,
|
||||
reinterpret_cast<std::uintptr_t>(meminfo.AllocationBase),
|
||||
static_cast<std::uintptr_t>(pSymbol->Address) - reinterpret_cast<std::uintptr_t>(meminfo.AllocationBase),
|
||||
static_cast<ULONG_PTR>(disp));
|
||||
return;
|
||||
}
|
||||
|
||||
wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s!%" ADDRESS_ZEROS "Ix",
|
||||
reinterpret_cast<uintptr_t>(ptr), sName.c_str(),
|
||||
reinterpret_cast<uintptr_t>(meminfo.AllocationBase) );
|
||||
reinterpret_cast<std::uintptr_t>(ptr), sName.c_str(),
|
||||
reinterpret_cast<std::uintptr_t>(meminfo.AllocationBase) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#include <windows.h>
|
||||
@@ -396,7 +397,7 @@ void NetworkStream_Win32::Open( const RString &sHost, int iPort, ConnectionType
|
||||
sockaddr_in addr;
|
||||
addr.sin_addr.s_addr = *(DWORD *)pHost->h_addr_list[0];
|
||||
addr.sin_family = PF_INET;
|
||||
addr.sin_port = htons( (uint16_t) iPort );
|
||||
addr.sin_port = htons( (std::uint16_t) iPort );
|
||||
|
||||
m_Mutex.Lock();
|
||||
m_Socket = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP );
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "RageUtil.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <sys/stat.h>
|
||||
#include <windows.h>
|
||||
#include <tlhelp32.h>
|
||||
@@ -87,7 +89,7 @@ RString FindSystemFile( RString sFile )
|
||||
|
||||
/* Get the full path of the process running in iProcessID. On error, false is
|
||||
* returned and an error message is placed in sName. */
|
||||
bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
bool GetProcessFileName( std::uint32_t iProcessID, RString &sName )
|
||||
{
|
||||
/* This method works in everything except for NT4, and only uses
|
||||
* kernel32.lib functions. */
|
||||
@@ -173,7 +175,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -183,7 +185,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
#ifndef GET_FILE_INFORMATION_H
|
||||
#define GET_FILE_INFORMATION_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
bool GetFileVersion( RString fsFile, RString &sOut );
|
||||
RString FindSystemFile( RString sFile );
|
||||
bool GetProcessFileName( uint32_t iProcessID, RString &sName );
|
||||
bool GetProcessFileName( std::uint32_t iProcessID, RString &sName );
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -22,7 +24,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName );
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "GotoURL.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
@@ -25,7 +28,7 @@ static LONG GetRegKey( HKEY key, RString subkey, LPTSTR retdata )
|
||||
bool GotoURL( RString sUrl )
|
||||
{
|
||||
// First try ShellExecute()
|
||||
intptr_t iRet = reinterpret_cast<intptr_t>(ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT ));
|
||||
std::intptr_t iRet = reinterpret_cast<std::intptr_t>(ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT ));
|
||||
|
||||
// If it failed, get the .htm regkey and lookup the program
|
||||
if( iRet > 32 )
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "RageSurface_Load.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <wingdi.h>
|
||||
|
||||
HICON IconFromSurface( const RageSurface *pSrcImg )
|
||||
@@ -45,8 +47,8 @@ HICON IconFromSurface( const RageSurface *pSrcImg )
|
||||
pBitmap->biCompression = BI_RGB;
|
||||
pBitmap->biSizeImage = pImg->h * pImg->pitch;
|
||||
|
||||
uint8_t *pImage = ((uint8_t *) pBitmap) + iSize;
|
||||
uint8_t *pMask = pImage + pImg->h * pImg->pitch;
|
||||
std::uint8_t *pImage = ((std::uint8_t *) pBitmap) + iSize;
|
||||
std::uint8_t *pMask = pImage + pImg->h * pImg->pitch;
|
||||
|
||||
memcpy( pImage, pImg->pixels, pImg->h * pImg->pitch );
|
||||
|
||||
@@ -54,8 +56,8 @@ HICON IconFromSurface( const RageSurface *pSrcImg )
|
||||
for( int y = 0; y < pImg->h; ++y )
|
||||
{
|
||||
int bit = 0x80;
|
||||
uint32_t *pRow = (uint32_t *) (pImage + y*pImg->pitch);
|
||||
uint8_t *pMaskRow = pMask + y*iMaskPitch;
|
||||
std::uint32_t *pRow = (std::uint32_t *) (pImage + y*pImg->pitch);
|
||||
std::uint8_t *pMaskRow = pMask + y*iMaskPitch;
|
||||
for( int x = 0; x < pImg->w; ++x )
|
||||
{
|
||||
if( !(pRow[x] & pImg->fmt.Mask[3]) )
|
||||
@@ -107,7 +109,7 @@ HICON IconFromFile( const RString &sIconFile )
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -117,7 +119,7 @@ HICON IconFromFile( const RString &sIconFile )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -72,19 +72,6 @@ struct tm *my_gmtime_r( const time_t *timep, struct tm *result );
|
||||
void my_usleep( unsigned long usec );
|
||||
#define usleep my_usleep
|
||||
|
||||
// Missing stdint types:
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef int int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#define NOMINMAX // make sure Windows doesn't try to define this
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#define MAX_GROUPS (64)
|
||||
|
||||
struct RVAEnt {
|
||||
uintptr_t rva;
|
||||
std::uintptr_t rva;
|
||||
char *line;
|
||||
};
|
||||
|
||||
@@ -25,10 +25,10 @@ std::vector<RVAEnt> rvabuf;
|
||||
char fnambuf[MAX_FNAMBUF];
|
||||
char *fnamptr = fnambuf;
|
||||
|
||||
uintptr_t segbuf[MAX_SEGMENTS][2];
|
||||
std::uintptr_t segbuf[MAX_SEGMENTS][2];
|
||||
int segcnt = 0;
|
||||
uint16_t seggrp[MAX_SEGMENTS];
|
||||
uintptr_t grpstart[MAX_GROUPS];
|
||||
std::uint16_t seggrp[MAX_SEGMENTS];
|
||||
std::uintptr_t grpstart[MAX_GROUPS];
|
||||
|
||||
char line[8192];
|
||||
long codeseg_flags = 0;
|
||||
@@ -94,7 +94,7 @@ void RemoveAnonymousNamespaces( char *p )
|
||||
|
||||
}
|
||||
|
||||
void parsename(uintptr_t rva, char *func_name) {
|
||||
void parsename(std::uintptr_t rva, char *func_name) {
|
||||
RemoveAnonymousNamespaces( func_name );
|
||||
|
||||
fnamptr = strtack(fnamptr, func_name, fnambuf+MAX_FNAMBUF);
|
||||
@@ -140,9 +140,9 @@ int main(int argc, char **argv) {
|
||||
// printf("Reading in segment list.\n");
|
||||
|
||||
while (readline()) {
|
||||
uint16_t grp;
|
||||
uint32_t start;
|
||||
uint32_t len;
|
||||
std::uint16_t grp;
|
||||
std::uint32_t start;
|
||||
std::uint32_t len;
|
||||
|
||||
if (sscanf(line, "%" SCNx16 ":%" SCNx32 " %" SCNx32, &grp, &start, &len) != 3)
|
||||
break;
|
||||
@@ -152,8 +152,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
codeseg_flags |= 1 << grp;
|
||||
|
||||
segbuf[segcnt][0] = static_cast<uintptr_t>(start);
|
||||
segbuf[segcnt][1] = static_cast<uintptr_t>(len);
|
||||
segbuf[segcnt][0] = static_cast<std::uintptr_t>(start);
|
||||
segbuf[segcnt][1] = static_cast<std::uintptr_t>(len);
|
||||
seggrp[segcnt] = grp;
|
||||
++segcnt;
|
||||
}
|
||||
@@ -169,9 +169,9 @@ int main(int argc, char **argv) {
|
||||
// printf("Found public symbol list.\n");
|
||||
|
||||
while (readline()) {
|
||||
uint16_t grp;
|
||||
uint32_t start;
|
||||
uintptr_t rva;
|
||||
std::uint16_t grp;
|
||||
std::uint32_t start;
|
||||
std::uintptr_t rva;
|
||||
char symname[2048];
|
||||
|
||||
if (sscanf(line, "%" SCNx16 ":%" SCNx32 " %s %" SCNxPTR, &grp, &start, symname, &rva) != 4)
|
||||
@@ -199,9 +199,9 @@ int main(int argc, char **argv) {
|
||||
readline();
|
||||
|
||||
while (readline()) {
|
||||
uint16_t grp;
|
||||
uint32_t start;
|
||||
uintptr_t rva;
|
||||
std::uint16_t grp;
|
||||
std::uint32_t start;
|
||||
std::uintptr_t rva;
|
||||
char symname[4096];
|
||||
|
||||
if (sscanf(line, "%" SCNx16 ":%" SCNx32 " %s %" SCNxPTR, &grp, &start, symname, &rva) != 4)
|
||||
@@ -225,15 +225,15 @@ int main(int argc, char **argv) {
|
||||
// printf("Processing RVA entries...\n");
|
||||
|
||||
for (std::size_t i = 0; i < rvabuf.size(); ++i) {
|
||||
uint16_t grp;
|
||||
uint32_t start;
|
||||
uintptr_t rva;
|
||||
std::uint16_t grp;
|
||||
std::uint32_t start;
|
||||
std::uintptr_t rva;
|
||||
char symname[4096];
|
||||
|
||||
if (sscanf(rvabuf[i].line, "%" SCNx16 ":%" SCNx32 " %s %" SCNxPTR, &grp, &start, symname, &rva) != 4)
|
||||
break;
|
||||
|
||||
grpstart[grp] = rva - static_cast<uintptr_t>(start);
|
||||
grpstart[grp] = rva - static_cast<std::uintptr_t>(start);
|
||||
|
||||
parsename(rva, symname);
|
||||
}
|
||||
@@ -253,8 +253,8 @@ int main(int argc, char **argv) {
|
||||
*/
|
||||
std::vector<RVAEnt>::iterator itRVA = rvabuf.begin(), itRVAEnd = rvabuf.end();
|
||||
std::vector<char> rvaout;
|
||||
uintptr_t firstrva = (*itRVA++).rva;
|
||||
uintptr_t lastrva = firstrva;
|
||||
std::uintptr_t firstrva = (*itRVA++).rva;
|
||||
std::uintptr_t lastrva = firstrva;
|
||||
|
||||
for(; itRVA != itRVAEnd; ++itRVA) {
|
||||
std::ptrdiff_t rvadiff = (*itRVA).rva - lastrva;
|
||||
@@ -303,7 +303,7 @@ int main(int argc, char **argv) {
|
||||
fwrite(&firstrva, sizeof firstrva, 1, fo);
|
||||
fwrite(&rvaout[0], rvaout.size(), 1, fo);
|
||||
fwrite(fnambuf, fnamptr - fnambuf, 1, fo);
|
||||
fwrite(segbuf, segcnt * 2 * sizeof(uintptr_t), 1, fo);
|
||||
fwrite(segbuf, segcnt * 2 * sizeof(std::uintptr_t), 1, fo);
|
||||
|
||||
// really all done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user