use clang-format to format code

This commit is contained in:
Rongsong Shen 2025-11-25 14:58:09 +08:00
parent 2bad284582
commit de090dce35
58 changed files with 8745 additions and 7237 deletions

View file

@ -1,50 +1,49 @@
#ifndef _XCECD_CGROUPS_H_
#define _XCECD_CGROUPS_H_
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <systemd/sd-bus.h>
#include <unistd.h>
typedef struct {
// CPU limit
uint64_t cpu_quota; // CPU quota in microseconds (e.g. 200000 = 20%, cpu_limit)
uint64_t cpu_period; // CPU period in microseconds (e.g. 1000000 = 1 second)
uint32_t cpu_weight; // CPU weight (e.g. 100 = default)
uint64_t cpu_limit; // CPU limit (run time limit in seconds)
uint64_t core_limit; // Core limit (in number of cores, e.g. 2 = 2 cores)
char *cpu_affinity; // CPU affinity list (e.g. "0,1,2")
uint64_t
cpu_quota; // CPU quota in microseconds (e.g. 200000 = 20%, cpu_limit)
uint64_t cpu_period; // CPU period in microseconds (e.g. 1000000 = 1 second)
uint32_t cpu_weight; // CPU weight (e.g. 100 = default)
uint64_t cpu_limit; // CPU limit (run time limit in seconds)
uint64_t core_limit; // Core limit (in number of cores, e.g. 2 = 2 cores)
char* cpu_affinity; // CPU affinity list (e.g. "0,1,2")
// Memory limit
uint64_t memory_max; // Maximum memory usage (rss_limit)
uint64_t memory_high; // Memory high usage level (in bytes)
uint64_t memory_swap_max; // Maximum swap space usage (swap_limit)
uint64_t memory_max; // Maximum memory usage (rss_limit)
uint64_t memory_high; // Memory high usage level (in bytes)
uint64_t memory_swap_max; // Maximum swap space usage (swap_limit)
// IO limit
uint64_t io_weight; // IO weight (e.g. 100 = default)
uint64_t io_read_bps_max; // Maximum read speed (bytes/second)
uint64_t io_write_bps_max; // Maximum write speed (bytes/second)
char *io_device_path; // IO device path (e.g. "/dev/sda")
uint64_t io_weight; // IO weight (e.g. 100 = default)
uint64_t io_read_bps_max; // Maximum read speed (bytes/second)
uint64_t io_write_bps_max; // Maximum write speed (bytes/second)
char* io_device_path; // IO device path (e.g. "/dev/sda")
// Tasks limit
uint64_t tasks_max; // Max number of threads (thread_limit)
uint64_t run_limit; // Max run time (in seconds)
uint64_t core_size_limit; // Max core file size (in bytes)
uint64_t data_limit; // Max data size (in bytes)
uint64_t fsize_limit; // Max file size (in bytes)
uint64_t stack_limit; // Max stack size (in bytes)
uint64_t process_limit; // Max number of processes
uint64_t tasks_max; // Max number of threads (thread_limit)
uint64_t run_limit; // Max run time (in seconds)
uint64_t core_size_limit; // Max core file size (in bytes)
uint64_t data_limit; // Max data size (in bytes)
uint64_t fsize_limit; // Max file size (in bytes)
uint64_t stack_limit; // Max stack size (in bytes)
uint64_t process_limit; // Max number of processes
// OOM score
int32_t oom_score_adjust; // OOM (-1000 to 1000)
int32_t oom_score_adjust; // OOM (-1000 to 1000)
char *user_name; // User name
char* user_name; // User name
} res_limits_t;
/**
* start worker with resource limits
* @param command command with arguments
@ -54,10 +53,8 @@ typedef struct {
* @param extra_args extra command line arguments (NULL if none)
* @return unit name if success, NULL if failed
*/
char* start_systemd_job(const char* command,
const res_limits_t* limits,
const char* unit_name_prefix,
uint64_t job_id,
char* start_systemd_job(const char* command, const res_limits_t* limits,
const char* unit_name_prefix, uint64_t job_id,
char* extra_args);
/**
@ -91,7 +88,7 @@ int get_systemd_job_exit_code(const char* unit_name);
/**
* @brief Get systemd job status text
* @param unit_name unit name
* @return status text if success, NULL if failed.
* @return status text if success, NULL if failed.
* Caller must free the returned string.
*/
char* get_systemd_job_status_text(const char* unit_name);