Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions diagnostic/build-bf2147ac-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"generated_at": "2026-07-01T07:19:07.148091+00:00",
"commit": "bf2147ac",
"diagnostic_logd": [
"diagnostic\\build-bf2147ac-part001.logd",
"diagnostic\\build-bf2147ac-part002.logd"
],
"chunked": true,
"chunk_size_bytes": 41943040,
"password": "95c64f76adfb29120dc8",
"decrypt_command": "encryptly unpack diagnostic\\build-bf2147ac.logd <outdir> --password 95c64f76adfb29120dc8",
"total_modules": 1,
"passed": 1,
"failed": 0,
"modules": [
{
"name": "compliance",
"status": "PASS",
"elapsed_seconds": 1.356,
"artifact": "D:\\code\\\u8d5a\u94b1\\bounty-work\\TentOfTrials-repo\\compliance\\build"
}
],
"module_timings": [
{
"module": "compliance",
"language": "Java",
"command": [
"javac",
"-d",
"build",
"ComplianceAuditor.java"
],
"started_at": "2026-07-01T07:14:24.764120+00:00",
"finished_at": "2026-07-01T07:14:26.120512+00:00",
"elapsed_seconds": 1.356,
"exit_code": 0,
"status": "PASS"
}
],
"pr_note": "Include this metadata and diagnostic\\build-bf2147ac-part001.logd, diagnostic\\build-bf2147ac-part002.logd in your PR. Maintainers may ask you to remove these diagnostic artifacts before merging."
}
102 changes: 59 additions & 43 deletions frailbox/Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
CC = gcc
CFLAGS = -Wall -Wextra -Wpedantic -std=c2x -O2 -g
CFLAGS += -D_FORTIFY_SOURCE=3
CFLAGS += -fstack-protector-strong
CFLAGS += -fPIE
LDFLAGS = -pie -z relro -z now

SRCDIR = src
INCDIR = include
BUILDDIR = build

SRCS = $(wildcard $(SRCDIR)/*.c) main.c
OBJS = $(patsubst %.c, $(BUILDDIR)/%.o, $(SRCS))
DEPS = $(OBJS:.o=.d)

TARGET = frailbox

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -I$(INCDIR) $^ -o $@ $(LDFLAGS)

$(BUILDDIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -MMD -MP -c $< -o $@

-include $(DEPS)

clean:
rm -rf $(BUILDDIR) $(TARGET)

distclean: clean
rm -rf *.o *.d

test: $(TARGET)
./$(TARGET) --sandbox-type seccomp --memory-limit 64 --verbose

valgrind: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all ./$(TARGET)

.PHONY: all clean distclean test valgrind
CC = gcc
UNAME_S := $(shell uname -s)
CFLAGS = -Wall -Wextra -Wpedantic -std=c2x -O2 -g
CFLAGS += -D_FORTIFY_SOURCE=3
CFLAGS += -fstack-protector-strong
CFLAGS += -fPIE
LDFLAGS =
ifeq ($(UNAME_S),Linux)
LDFLAGS += -pie -z relro -z now
endif

SRCDIR = src
INCDIR = include
BUILDDIR = build

SRCS = $(wildcard $(SRCDIR)/*.c) main.c
OBJS = $(patsubst %.c, $(BUILDDIR)/%.o, $(SRCS))
DEPS = $(OBJS:.o=.d)

TARGET = frailbox
BUDDY_TEST = $(BUILDDIR)/test_buddy

.PHONY: all clean test-logger-errors test-buddy

all: $(TARGET)

test-logger-errors:
$(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)/logger.c tests/test_logger_errors.c -o $(BUILDDIR)/test_logger_errors $(LDFLAGS) -lpthread
./$(BUILDDIR)/test_logger_errors

$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -I$(INCDIR) $^ -o $@ $(LDFLAGS)

$(BUILDDIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -MMD -MP -c $< -o $@

$(BUDDY_TEST): tests/test_buddy.c $(SRCDIR)/buddy.c $(INCDIR)/buddy.h
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) tests/test_buddy.c $(SRCDIR)/buddy.c -o $@ $(LDFLAGS)

-include $(DEPS)

clean:
rm -rf $(BUILDDIR) $(TARGET)

distclean: clean
rm -rf *.o *.d

test: $(TARGET)
./$(TARGET) --sandbox-type seccomp --memory-limit 64 --verbose

test-buddy: $(BUDDY_TEST)
./$(BUDDY_TEST)

valgrind: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all ./$(TARGET)

.PHONY: all clean distclean test test-buddy valgrind
41 changes: 41 additions & 0 deletions frailbox/include/buddy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef FRAILBOX_BUDDY_H
#define FRAILBOX_BUDDY_H

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define BUDDY_MIN_BLOCK_SIZE 64u

typedef struct buddy_allocator buddy_allocator_t;

typedef struct buddy_stats {
size_t capacity_bytes;
size_t allocated_bytes;
size_t reserved_bytes;
size_t free_bytes;
size_t largest_free_block;
uint64_t allocation_count;
uint64_t deallocation_count;
uint64_t split_count;
uint64_t coalesce_count;
double fragmentation_ratio;
} buddy_stats_t;

buddy_allocator_t *buddy_create(size_t capacity_bytes);
void buddy_destroy(buddy_allocator_t *allocator);

void *buddy_alloc(buddy_allocator_t *allocator, size_t size);
void buddy_free(buddy_allocator_t *allocator, void *ptr);

buddy_stats_t buddy_stats(const buddy_allocator_t *allocator);
int buddy_contains(const buddy_allocator_t *allocator, const void *ptr);

#ifdef __cplusplus
}
#endif

#endif
Loading