mirror of
https://github.com/diamante0018/MonitorRam.git
synced 2025-05-09 22:14:54 +00:00
build: arm64 / c89 (#2)
This commit is contained in:
parent
e5081680ab
commit
2521e83c98
33
.github/workflows/build.yml
vendored
33
.github/workflows/build.yml
vendored
@ -16,41 +16,54 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
arch:
|
||||
- x86
|
||||
- x64
|
||||
- arm64
|
||||
include:
|
||||
- configuration: Debug
|
||||
config: debug
|
||||
- configuration: Release
|
||||
config: release
|
||||
steps:
|
||||
- name: Check out files
|
||||
uses: actions/checkout@v3.5.2
|
||||
uses: actions/checkout@v3.5.3
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
# NOTE - If LFS ever starts getting used during builds, switch this to true!
|
||||
lfs: false
|
||||
|
||||
- name: Install dependencies (x86)
|
||||
if: matrix.arch == 'x86'
|
||||
- name: Install crossbuild tools (arm64)
|
||||
if: matrix.arch == 'arm64'
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install gcc-multilib g++-multilib
|
||||
sudo apt-get install crossbuild-essential-arm64 -y
|
||||
|
||||
- name: Install Premake5
|
||||
uses: abel0b/setup-premake@v2.2
|
||||
with:
|
||||
version: "5.0.0-beta2"
|
||||
|
||||
- name: Generate project files
|
||||
run: ./generate.sh
|
||||
run: premake5 gmake2
|
||||
|
||||
- name: Set up problem matching
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Set up CC environment variable
|
||||
if: matrix.arch == 'arm64'
|
||||
run: |
|
||||
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up CXX environment variable
|
||||
if: matrix.arch == 'arm64'
|
||||
run: |
|
||||
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
|
||||
|
||||
- name: Build ${{matrix.configuration}} ${{matrix.arch}} binaries
|
||||
run: |
|
||||
pushd build
|
||||
make config=${{matrix.config}}_${{matrix.arch}} -j$(nproc)
|
||||
|
||||
- name: Upload ${{matrix.configuration}} ${{matrix.arch}} binaries
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
|
@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
./tools/premake5-linux gmake2
|
20
premake5.lua
20
premake5.lua
@ -6,7 +6,7 @@ targetdir "%{wks.location}/bin/%{cfg.platform}/%{cfg.buildcfg}"
|
||||
|
||||
configurations {"Debug", "Release"}
|
||||
|
||||
platforms {"x86", "x64"}
|
||||
platforms {"x86", "x64", "arm64"}
|
||||
|
||||
filter "platforms:x86"
|
||||
architecture "x86"
|
||||
@ -16,7 +16,9 @@ filter "platforms:x64"
|
||||
architecture "x86_64"
|
||||
filter {}
|
||||
|
||||
buildoptions {"-std=gnu11"}
|
||||
filter "platforms:arm64"
|
||||
architecture "ARM64"
|
||||
filter {}
|
||||
|
||||
symbols "On"
|
||||
staticruntime "On"
|
||||
@ -25,20 +27,18 @@ warnings "Extra"
|
||||
characterset "ASCII"
|
||||
|
||||
if os.istarget("linux") then
|
||||
buildoptions {"-pthread"}
|
||||
linkoptions {"-pthread"}
|
||||
buildoptions "-pthread"
|
||||
linkoptions "-pthread"
|
||||
end
|
||||
|
||||
if os.getenv("CI") then
|
||||
defines {"CI"}
|
||||
defines "CI"
|
||||
end
|
||||
|
||||
flags {"NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64BitChecks"}
|
||||
|
||||
filter "configurations:Release"
|
||||
optimize "Speed"
|
||||
defines {"NDEBUG"}
|
||||
flags {"FatalCompileWarnings"}
|
||||
defines "NDEBUG"
|
||||
flags "FatalCompileWarnings"
|
||||
filter {}
|
||||
|
||||
filter "configurations:Debug"
|
||||
@ -48,7 +48,9 @@ filter {}
|
||||
|
||||
project "MonitorRam"
|
||||
kind "ConsoleApp"
|
||||
|
||||
language "C"
|
||||
cdialect "gnu89"
|
||||
|
||||
targetname "MonitorRam"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common.h"
|
||||
@ -14,7 +14,6 @@ void sigint_handler(int a) {
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc < 2) {
|
||||
printf("Name of the program is missing\n");
|
||||
printf("Usage: <name of the program>\n");
|
||||
return 2;
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "monitor.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
#include "monitor.h"
|
||||
|
||||
#define MAX_MEMORY 1048576
|
||||
#define MAX_TRACK_SIZE 30
|
||||
@ -96,7 +97,7 @@ static int is_process_wild(int curr_real_mem, int peak_real_mem,
|
||||
"KiB\ncurr_virt_mem:%d KiB\npeak_virt_mem:%d KiB\n",
|
||||
id, curr_real_mem, peak_real_mem, curr_virt_mem, peak_virt_mem);
|
||||
|
||||
if (result != 0) {
|
||||
if (result) {
|
||||
fprintf(fp, "Error while terminating process: %d\n", id);
|
||||
fprintf(fp, "Error message: %s\n", strerror(errno));
|
||||
}
|
||||
@ -111,7 +112,7 @@ int setup(const char* pid) {
|
||||
|
||||
char* command = va("pgrep %s", pid);
|
||||
FILE* file = popen(command, "r");
|
||||
if (file == NULL) {
|
||||
if (!file) {
|
||||
perror("popen");
|
||||
return 1;
|
||||
}
|
||||
@ -128,7 +129,7 @@ int setup(const char* pid) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
if (!i) {
|
||||
printf("No process was found\n");
|
||||
pclose(file);
|
||||
return 1;
|
||||
@ -140,13 +141,11 @@ int setup(const char* pid) {
|
||||
int analyse() {
|
||||
int i;
|
||||
FILE* status;
|
||||
int curr_real_mem = 0, peak_real_mem = 0, curr_virt_mem = 0,
|
||||
peak_virt_mem = 0;
|
||||
|
||||
for (i = 0; i < MAX_TRACK_SIZE && processes[i].active == 1; ++i) {
|
||||
char* command = va("cat /proc/%d/status", processes[i].id);
|
||||
status = popen(command, "r");
|
||||
if (status == NULL) {
|
||||
if (!status) {
|
||||
perror("popen");
|
||||
pclose(status);
|
||||
return 1;
|
||||
@ -156,6 +155,9 @@ int analyse() {
|
||||
printf("Checking %d\n", processes[i].id);
|
||||
#endif
|
||||
|
||||
int curr_real_mem = 0, peak_real_mem = 0, curr_virt_mem = 0,
|
||||
peak_virt_mem = 0;
|
||||
|
||||
check_status(status, &curr_real_mem, &peak_real_mem, &curr_virt_mem,
|
||||
&peak_virt_mem);
|
||||
if (is_process_wild(curr_real_mem, peak_real_mem, curr_virt_mem,
|
||||
@ -164,7 +166,6 @@ int analyse() {
|
||||
}
|
||||
|
||||
pclose(status);
|
||||
curr_real_mem = 0, peak_real_mem = 0, curr_virt_mem = 0, peak_virt_mem = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
15
src/utils.c
15
src/utils.c
@ -1,23 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <threads.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define VA_BUFFER_COUNT 4
|
||||
#define VA_BUFFER_SIZE 4096
|
||||
|
||||
thread_local struct {
|
||||
struct va_info_s {
|
||||
char va_string[VA_BUFFER_COUNT][VA_BUFFER_SIZE];
|
||||
int index;
|
||||
} va_info_t;
|
||||
};
|
||||
|
||||
static __thread struct va_info_s va_provider;
|
||||
|
||||
char* va(const char* fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
int index = va_info_t.index;
|
||||
va_info_t.index = (va_info_t.index + 1) % VA_BUFFER_COUNT;
|
||||
char* buf = va_info_t.va_string[index];
|
||||
int index = va_provider.index;
|
||||
va_provider.index = (va_provider.index + 1) % VA_BUFFER_COUNT;
|
||||
char* buf = va_provider.va_string[index];
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, VA_BUFFER_SIZE, fmt, ap);
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user