From ee26b8ff850add4f83b912635a71dbde06f268d1 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 3 Feb 2017 22:20:35 +0100 Subject: Continuing Implementation... --- src/core/index.c | 16 ++++++++++++++++ src/core/index.h | 2 ++ src/core/index_types.h | 10 +++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/index.c b/src/core/index.c index dc52d03..5c93ed3 100644 --- a/src/core/index.c +++ b/src/core/index.c @@ -64,3 +64,19 @@ ZoO_index ZoO_index_random_up_to (const ZoO_index max) * ((float) max) ); } + +int ZoO_index_cmp (const ZoO_index a, const ZoO_index b) +{ + if (a < b) + { + return -1; + } + else if (a > b) + { + return 1; + } + else + { + return 0; + } +} diff --git a/src/core/index.h b/src/core/index.h index eb3c471..bd77cb4 100644 --- a/src/core/index.h +++ b/src/core/index.h @@ -21,4 +21,6 @@ ZoO_index ZoO_index_random (void); @*/ ZoO_index ZoO_index_random_up_to (const ZoO_index limit); +int ZoO_index_cmp (const ZoO_index a, const ZoO_index b); + #endif diff --git a/src/core/index_types.h b/src/core/index_types.h index 84a1e20..5514a2a 100644 --- a/src/core/index_types.h +++ b/src/core/index_types.h @@ -1,6 +1,8 @@ #ifndef _ZoO_CORE_INDEX_TYPES_H_ #define _ZoO_CORE_INDEX_TYPES_H_ +#include "../pervasive.h" + /* * ZoO_index is a replacement for size_t. As many indices are stored for every * word learned, having control over which type of variable is used to represent @@ -8,6 +10,7 @@ */ #include +#include /* Must be unsigned. */ typedef unsigned int ZoO_index; @@ -15,9 +18,10 @@ typedef unsigned int ZoO_index; /* Must be > 0. */ #define ZoO_INDEX_MAX UINT_MAX - -#if (ZoO_INDEX_MAX > SIZE_MAX) - #error "ZoO_index should not be able to go higher than a size_t variable." +#ifndef ZoO_RUNNING_FRAMA_C + #if (ZoO_INDEX_MAX > SIZE_MAX) + #error "ZoO_index should not be able to go higher than a size_t variable." + #endif #endif #endif -- cgit v1.2.3-70-g09d2