This commit is contained in:
Guillem George 2025-11-04 15:27:56 +01:00
parent 18540d32e4
commit fd1c0872a4
2 changed files with 20 additions and 0 deletions

10
alignment/alignment.c Normal file
View file

@ -0,0 +1,10 @@
#include "alignment.h"
size_t align(size_t size)
{
size_t res;
if (__builtin_add_overflow(size, 8 - (size % 8), &res))
return 0;
return res;
}

10
alignment/alignment.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef ALIGNMENT_H
#define ALIGNMENT_H
#define _GNU_SOURCE
#include <stddef.h>
size_t align(size_t size);
#endif /* !ALIGNMENT_H */