all: Use bool where applicable (#30)

This commit is contained in:
Mat M
2018-02-22 22:58:39 -05:00
committed by SciresM
parent 1d8f443f68
commit 83216409d2
15 changed files with 154 additions and 145 deletions

View File

@@ -1,8 +1,9 @@
#ifndef EXOSPHERE_UTILS_H
#define EXOSPHERE_UTILS_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define BIT(x) (1u << (x))
#define BITL(x) (1ull << (x))
@@ -19,18 +20,18 @@ static inline uint32_t read32be(const unsigned char *dword, size_t offset) {
return __builtin_bswap32(read32le(dword, offset));
}
static __attribute__((noinline)) int check_32bit_additive_overflow(uint32_t a, uint32_t b) {
static __attribute__((noinline)) bool check_32bit_additive_overflow(uint32_t a, uint32_t b) {
uint64_t x = (uint64_t)a + (uint64_t)b;
return x > (uint64_t)(UINT32_MAX);
}
static __attribute__((noinline)) int overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be)
static __attribute__((noinline)) bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be)
{
if(as <= bs && bs <= ae)
return 1;
return true;
if(bs <= as && as <= be)
return 1;
return 0;
return true;
return false;
}