mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Tweaked platform support, disabled some tests based on platform
This commit is contained in:
@@ -5,27 +5,37 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
||||||
//TOY_API is platform-dependant, and marks publicly usable API functions
|
//TOY_API is platform-dependant, and marks publicly usable API functions
|
||||||
#if defined(__linux__) || defined(__MINGW32__) || defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
#define TOY_API extern
|
||||||
//GCC support
|
|
||||||
#define TOY_API extern
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
#ifndef TOY_EXPORT
|
||||||
//MSVC support
|
#define TOY_API __declspec(dllimport)
|
||||||
#ifndef TOY_EXPORT
|
#else
|
||||||
#define TOY_API __declspec(dllimport)
|
#define TOY_API __declspec(dllexport)
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define TOY_API __declspec(dllexport)
|
//generic solution
|
||||||
|
#define TOY_API extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//TOY_BITNESS is used to encourage memory-cache friendliness
|
||||||
|
//source: https://www.linuxquestions.org/questions/programming-9/c-preprocessor-define-for-32-vs-64-bit-long-int-4175658579/
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#if defined(__x86_64)
|
||||||
|
#define TOY_BITNESS 64
|
||||||
|
#else
|
||||||
|
#define TOY_BITNESS 32
|
||||||
|
#endif
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#if defined(_M_X64)
|
||||||
|
#define TOY_BITNESS 64
|
||||||
|
#else
|
||||||
|
#define TOY_BITNESS 32
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
|
//generic solution
|
||||||
//generic
|
#define TOY_BITNESS -1
|
||||||
#define TOY_API extern
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//bytecode version specifiers, embedded as the header
|
//bytecode version specifiers, embedded as the header
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int test_sizeof_ast() {
|
int test_sizeof_ast_32bit() {
|
||||||
#define TEST_SIZEOF(type, size) \
|
#define TEST_SIZEOF(type, size) \
|
||||||
if (sizeof(type) != size) { \
|
if (sizeof(type) != size) { \
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: sizeof(" #type ") is %d, expected %d\n" TOY_CC_RESET, (int)sizeof(type), size); \
|
fprintf(stderr, TOY_CC_ERROR "ERROR: sizeof(" #type ") is %d, expected %d\n" TOY_CC_RESET, (int)sizeof(type), size); \
|
||||||
@@ -223,12 +223,16 @@ int main() {
|
|||||||
//run each test set, returning the total errors given
|
//run each test set, returning the total errors given
|
||||||
int total = 0, res = 0;
|
int total = 0, res = 0;
|
||||||
|
|
||||||
res = test_sizeof_ast();
|
#if TOY_BITNESS == 32
|
||||||
|
res = test_sizeof_ast_32bit();
|
||||||
total += res;
|
total += res;
|
||||||
|
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
fprintf(stderr, TOY_CC_WARN "WARNING: Skipping test_sizeof_ast_32bit(); Can't determine the 'bitness' of this platform\n" TOY_CC_RESET);
|
||||||
|
#endif
|
||||||
|
|
||||||
res = test_type_emission();
|
res = test_type_emission();
|
||||||
total += res;
|
total += res;
|
||||||
|
|||||||
Reference in New Issue
Block a user