fix: Adding casts for C++ and optimizing pointer comparison.

This commit is contained in:
2025-06-29 02:33:07 +02:00
parent 3f5cbdd276
commit 1401e1d70b

View File

@@ -2,6 +2,7 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/shm.h> #include <sys/shm.h>
@@ -160,8 +161,8 @@ bool tear_down();
void suit_name##_suit(struct SETSuit *suit, bool count); \ void suit_name##_suit(struct SETSuit *suit, bool count); \
struct SETSuit *suit_name##_suit_contructor() \ struct SETSuit *suit_name##_suit_contructor() \
{ \ { \
struct SETSuit *suit = \ struct SETSuit *suit = (struct SETSuit *)mmap( \
mmap(NULL, sizeof(struct SETSuit), PROT_READ | PROT_WRITE, \ NULL, sizeof(struct SETSuit), PROT_READ | PROT_WRITE, \
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
madvise(suit, sizeof(struct SETSuit), MADV_DONTFORK); \ madvise(suit, sizeof(struct SETSuit), MADV_DONTFORK); \
suit->len = 0; \ suit->len = 0; \
@@ -169,8 +170,8 @@ bool tear_down();
suit->shm_key = \ suit->shm_key = \
create_shared_suit_space(suit->len * sizeof(struct SETest)); \ create_shared_suit_space(suit->len * sizeof(struct SETest)); \
suit->name = #suit_name; \ suit->name = #suit_name; \
suit->tests = shmat(suit->shm_key, 0, 0); \ suit->tests = (struct SETest *)shmat(suit->shm_key, 0, 0); \
if (suit->tests == (struct SETest *)-1) \ if ((uint64_t)suit->tests == -1) \
{ \ { \
fprintf(stderr, "Couldn't attach suit space.\n"); \ fprintf(stderr, "Couldn't attach suit space.\n"); \
perror("shmat"); \ perror("shmat"); \