BuildSystem: Cleanup userspace directory layout

userspace programs are now in userspace/programs
userspace tests are now in userspace/tests

This makes listing userspace projects much cleaner. Libraries were
already separated to their own directory, so other programs should also.
This commit is contained in:
2024-07-03 09:15:22 +03:00
parent 5dc441c4af
commit 8ddab05ed3
107 changed files with 78 additions and 67 deletions

View File

@@ -0,0 +1,8 @@
set(SOURCES
main.cpp
)
add_executable(u8sum ${SOURCES})
banan_link_library(u8sum libc)
install(TARGETS u8sum OPTIONAL)

View File

@@ -0,0 +1,29 @@
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char** argv)
{
for (int i = 1; i < argc; i++)
{
FILE* fp = fopen(argv[i], "r");
if (fp == nullptr)
{
perror("fopen");
continue;
}
uint8_t sum = 0;
uint8_t buffer[1024];
while (size_t ret = fread(buffer, 1, sizeof(buffer), fp))
for (size_t j = 0; j < ret; j++)
sum += buffer[j];
if (ferror(fp))
perror("fread");
else
printf("%s: %02x\n", argv[i], sum);
fclose(fp);
}
}