[WIP] Continue working on pipeline

This commit is contained in:
Piotr Krygier committed 2025-06-20 13:44:33 +02:00
1 parent f8eb98ddf4
commit daed76f02f
28 files changed
+467 -2156

No files matched your search

+17 -4
View File
@@ -5,9 +5,16 @@
void read_file(const char* file_name, size_t* bytes_count, char* buffer)
{
FILE* file;
errno_t err = 0;
FILE* file = NULL;
err = fopen_s(&file, file_name, "rb");
if (0 != err) {
perror("Failed to open file");
return;
}
file = fopen(file_name, "rb");
fseek(file, 0, SEEK_END);
*bytes_count = ftell(file);
rewind(file);
@@ -26,9 +33,15 @@ void read_file(const char* file_name, size_t* bytes_count, char* buffer)
void write_to_file(const char* file_name, size_t bytes_count, char* buffer)
{
FILE* file;
errno_t err = 0;
FILE* file = NULL;
file = fopen(file_name, "wb");
err = fopen_s(&file, file_name, "wb");
if (0 != err) {
perror("Failed to open file.");
return;
}
fwrite(buffer, bytes_count, 1, file);
fclose(file);
-24
View File
@@ -1,24 +0,0 @@
#include "utilities/task.h"
uint8_t create_task(thread_t* thread_id, thread_worker_t callback, void* args)
{
uint8_t result = 0;
result = pthread_create(thread_id, NULL, callback, args);
return result; //TODO: Do error handling
}
uint8_t task_join(thread_t* thread_id)
{
uint8_t result = 0;
result = pthread_join(*thread_id, NULL);
return result; //TODO: Do error handling
}
void task_exit()
{
pthread_exit(NULL);
}
-28
View File
@@ -1,28 +0,0 @@
/**
* @file task.h
* @author Piotr Krygier (everyonecancode@gmail.com)
* @brief Threads wrapper
* @version 0.1
* @date 2023-08-14
*
* @copyright Copyright (c) 2023
*
*/
#ifndef THREADS_H
#define THREADS_H
#include <stdint.h>
#ifdef __linux__
#include <pthread.h>
typedef pthread_t thread_t;
#endif
typedef void*(*thread_worker_t)(void*);
uint8_t create_task(thread_t* thread_id, thread_worker_t callback, void* args);
uint8_t task_join(thread_t* thread_id);
void task_exit(void);
#endif /* THREADS_H */