From 28feb623687b5cfc026912a951a9985c79a8163b Mon Sep 17 00:00:00 2001 From: Joshua Saxby Date: Sun, 23 Oct 2016 21:29:53 +0100 Subject: [PATCH 1/2] Improve 64-bit detection CMake now responsible for this, removed non-standard #warning directives in source files for 64-bit detection. CMake issues a warning only as there is no guarantee that every 64-bit system has a void-pointer size of at least 8 bytes Also, amended incorrect data size test case to set size field to UINT_64_MAX, so that way the build is broken if attempted on a 32-bit system that truncates the 64-bit uints. --- CMakeLists.txt | 8 ++++++++ README.md | 2 ++ saxbospiral/render.c | 6 ------ saxbospiral/render.h | 5 ----- saxbospiral/saxbospiral.h | 5 ----- saxbospiral/serialise.c | 6 ------ saxbospiral/solve.c | 6 ------ tests.c | 4 ++-- 8 files changed, 12 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 994adcb..26408e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,14 @@ set( set(SAXBOSPIRAL_ESCAPED_VERSION_STRING "\"${SAXBOSPIRAL_VERSION_STRING}\"") # end basic metadata +# this is a 64-bit project, so check now to make sure we're 64-bit, issue warning if not +if(CMAKE_SIZEOF_VOID_P LESS 8) + message( + WARNING + "It looks like this system's architecture is not at least 64-bit.\n" + "libsaxbospiral requires a system with an architecture of at least 64 bits!") +endif() + # pass in version of library as preprocessor definitions add_definitions(-DSAXBOSPIRAL_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}) add_definitions(-DSAXBOSPIRAL_VERSION_MINOR=${PROJECT_VERSION_MINOR}) diff --git a/README.md b/README.md index 54a9e5e..816c79a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Although this project doesn't work in sprints, there is a [*sprint board*](https ## Please Note +- This software only works on systems capable of running 64-bit code. + - This is a library only. If you're looking for something that is immediately usable for the end-user, you probably want to look at [sxbp](https://github.com/saxbophone/sxbp) instead, which is a command-line program I wrote which uses libsaxbospiral to render input binary files to PNG images. - As libsaxbospiral is currently at major version 0, expect the library API to be unstable. I will endeavour as much as possible to make sure breaking changes increment the minor version number whilst in the version 0.x.x series and bugfixes increment the patch version number, but no heavy reliance should be placed on this. diff --git a/saxbospiral/render.c b/saxbospiral/render.c index 9cda20f..34adf45 100644 --- a/saxbospiral/render.c +++ b/saxbospiral/render.c @@ -20,12 +20,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - -// sanity check for support of 64-bit integers -#if __SIZEOF_SIZE_T__ < 8 -#warning "Please compile this code for a target with 64-bit words or greater." -#endif - #include #include #include diff --git a/saxbospiral/render.h b/saxbospiral/render.h index f180af3..8b422eb 100644 --- a/saxbospiral/render.h +++ b/saxbospiral/render.h @@ -23,11 +23,6 @@ #ifndef SAXBOPHONE_SAXBOSPIRAL_RENDER_H #define SAXBOPHONE_SAXBOSPIRAL_RENDER_H -// sanity check for support of 64-bit integers -#if __SIZEOF_SIZE_T__ < 8 -#warning "Please compile this code for a target with 64-bit words or greater." -#endif - #include #include diff --git a/saxbospiral/saxbospiral.h b/saxbospiral/saxbospiral.h index a2bf3ff..54cc8aa 100644 --- a/saxbospiral/saxbospiral.h +++ b/saxbospiral/saxbospiral.h @@ -24,11 +24,6 @@ #ifndef SAXBOPHONE_SAXBOSPIRAL_SAXBOSPIRAL_H #define SAXBOPHONE_SAXBOSPIRAL_SAXBOSPIRAL_H -// sanity check for support of 64-bit integers -#if __SIZEOF_SIZE_T__ < 8 -#warning "Please compile this code for a target with 64-bit words or greater." -#endif - #include #include #include diff --git a/saxbospiral/serialise.c b/saxbospiral/serialise.c index 04495b6..e01a6ec 100644 --- a/saxbospiral/serialise.c +++ b/saxbospiral/serialise.c @@ -21,12 +21,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - -// sanity check for support of 64-bit integers -#if __SIZEOF_SIZE_T__ < 8 -#warning "Please compile this code for a target with 64-bit words or greater." -#endif - #include #include #include diff --git a/saxbospiral/solve.c b/saxbospiral/solve.c index bdbbd92..a260e58 100644 --- a/saxbospiral/solve.c +++ b/saxbospiral/solve.c @@ -22,12 +22,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - -// sanity check for support of 64-bit integers -#if __SIZEOF_SIZE_T__ < 8 -#warning "Please compile this code for a target with 64-bit words or greater." -#endif - #include #include #include diff --git a/tests.c b/tests.c index 6ee706d..9650e53 100644 --- a/tests.c +++ b/tests.c @@ -483,8 +483,8 @@ bool test_sxbp_load_spiral_rejects_too_small_data_section() { // success / failure variable bool result = true; // build buffer of bytes for input data - sxbp_buffer_t buffer = { .size = 41, }; - buffer.bytes = calloc(1, buffer.size); + sxbp_buffer_t buffer = { .size = 0xffffffffffffffffu, }; // max 64-bit uint + buffer.bytes = calloc(1, 41); // set allocation size to actual data size // construct data header sprintf( (char*)buffer.bytes, From 5db3ccec7a47703baa22384676c3eae95b0018d9 Mon Sep 17 00:00:00 2001 From: Joshua Saxby Date: Sun, 23 Oct 2016 22:15:23 +0100 Subject: [PATCH 2/2] Bump version to v0.19.2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26408e7..4cdb721 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ # begin basic metadata cmake_minimum_required(VERSION 3.0) -project(libsaxbospiral VERSION 0.19.1 LANGUAGES C) +project(libsaxbospiral VERSION 0.19.2 LANGUAGES C) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) set(