Try fix new Sys functions in Haiku.

This commit is contained in:
Martín Lucas Golini
2024-09-28 14:26:37 -03:00
parent 5a7e7e5387
commit 8c898b68e2
8 changed files with 48 additions and 21 deletions

View File

@@ -129,7 +129,7 @@ class EE_API Sys {
static std::vector<Uint64> pidof( const std::string& processName );
/** @returns The unix timestamp of the process creation time */
static Uint64 getProcessCreationTime( Uint64 pid );
static Int64 getProcessCreationTime( Uint64 pid );
};
}} // namespace EE::System

View File

@@ -1322,8 +1322,8 @@ std::string Sys::getProcessFilePath() {
#endif
}
Uint64 Sys::getProcessCreationTime( Uint64 pid ) {
Uint64 creationTime = 0;
Int64 Sys::getProcessCreationTime( Uint64 pid ) {
Int64 creationTime = -1;
#if EE_PLATFORM == EE_PLATFORM_WIN
int rpid = static_cast<int>( pid );
@@ -1397,16 +1397,29 @@ Uint64 Sys::getProcessCreationTime( Uint64 pid ) {
creationTime = proc.ki_start.tv_sec;
#elif EE_PLATFORM == EE_PLATFORM_HAIKU
thread_info threadInfo;
int rpid = static_cast<int>( pid );
status_t result = get_thread_info( rpid, &threadInfo ); // Get thread info for the PID passed
if ( result == B_OK ) {
// Approximate creation time by subtracting CPU time (user_time + kernel_time) from current
// time
creationTime = time( NULL ) - ( threadInfo.user_time + threadInfo.kernel_time ) /
1000000; // Convert microseconds to seconds
} else {
return -1;
int32 cookie = 0;
team_info teamInfo;
while ( get_next_team_info( &cookie, &teamInfo ) == B_OK ) {
if ( teamInfo.team != rpid )
continue;
KMessage extendedInfo;
status_t status = get_extended_team_info( teamInfo.team, B_TEAM_INFO_BASIC, extendedInfo );
if ( status == B_BAD_TEAM_ID ) {
// The team might have simply ended between the last function calls.
continue;
} else if ( status != B_OK ) {
break;
}
bigtime_t startTime = 0;
if ( extendedInfo.FindInt64( "start_time", &startTime ) != B_OK )
continue;
return startTime;
}
#endif
@@ -1544,12 +1557,26 @@ std::vector<Uint64> Sys::pidof( const std::string& processName ) {
return pids;
#elif EE_PLATFORM == EE_PLATFORM_HAIKU
std::vector<Uint64> pids;
team_info teamInfo;
int32 cookie = 0;
std::string lProcessName = String::toLower( processName );
team_info teamInfo;
const char* cprocessName = processName.c_str();
while ( get_next_team_info( &cookie, &teamInfo ) == B_OK ) {
if ( lProcessName == String::toLower( FileSystem::fileNameFromPath( teamInfo.args ) ) ) {
KMessage extendedInfo;
status_t status = get_extended_team_info( teamInfo.team, B_TEAM_INFO_BASIC, extendedInfo );
if ( status == B_BAD_TEAM_ID ) {
// The team might have simply ended between the last function calls.
continue;
} else if ( status != B_OK ) {
return {};
}
const char* teamName = NULL;
if ( extendedInfo.FindString( "name", &teamName ) != B_OK )
continue;
if ( strcmp( teamName, cprocessName ) == 0 ) {
pids.push_back( teamInfo.team );
}
}

View File

@@ -63,7 +63,7 @@ class AutoCompletePlugin : public Plugin {
"Auto complete shows the completion popup as you type, so you can fill "
"in long words by typing only a few characters.",
AutoCompletePlugin::New,
{ 0, 2, 5 },
{ 0, 2, 6 },
AutoCompletePlugin::NewSync };
}

View File

@@ -34,7 +34,7 @@ class FormatterPlugin : public Plugin {
static PluginDefinition Definition() {
return {
"autoformatter", "Auto Formatter", "Enables the code formatter/prettifier plugin.",
FormatterPlugin::New, { 0, 2, 4 }, FormatterPlugin::NewSync };
FormatterPlugin::New, { 0, 2, 5 }, FormatterPlugin::NewSync };
}
static Plugin* New( PluginManager* pluginManager );

View File

@@ -36,7 +36,7 @@ static constexpr const char* GIT_STASH = "git-stash";
class GitPlugin : public PluginBase {
public:
static PluginDefinition Definition() {
return { "git", "Git", "Git integration", GitPlugin::New, { 0, 1, 0 }, GitPlugin::NewSync };
return { "git", "Git", "Git integration", GitPlugin::New, { 0, 1, 1 }, GitPlugin::NewSync };
}
static Plugin* New( PluginManager* pluginManager );

View File

@@ -59,7 +59,7 @@ class LinterPlugin : public Plugin {
"Use static code analysis tool used to flag programming errors, bugs, "
"stylistic errors, and suspicious constructs.",
LinterPlugin::New,
{ 0, 2, 5 },
{ 0, 2, 6 },
LinterPlugin::NewSync };
}

View File

@@ -27,7 +27,7 @@ class LSPClientPlugin : public Plugin {
public:
static PluginDefinition Definition() {
return { "lspclient", "LSP Client", "Language Server Protocol Client.",
LSPClientPlugin::New, { 0, 2, 6 }, LSPClientPlugin::NewSync };
LSPClientPlugin::New, { 0, 2, 7 }, LSPClientPlugin::NewSync };
}
static Plugin* New( PluginManager* pluginManager );

View File

@@ -20,7 +20,7 @@ class XMLToolsPlugin : public PluginBase {
"XML Tools",
"Simple tools to improve your XML editing experience.",
XMLToolsPlugin::New,
{ 0, 0, 3 },
{ 0, 0, 4 },
XMLToolsPlugin::NewSync };
}