2
0

Fix ANSI C11 support.

This commit is contained in:
Maarten Billemont 2021-02-11 14:11:09 -05:00
parent 83fa6c39bc
commit 2e9c79f6b3
4 changed files with 26 additions and 15 deletions

View File

@ -74,7 +74,7 @@ library {
link.linkerArgs = ['-lc', '-nodefaultlibs', '-flto'] link.linkerArgs = ['-lc', '-nodefaultlibs', '-flto']
} else if (toolChain in VisualCpp) { } else if (toolChain in VisualCpp) {
// TODO: Should this be shared instead of static? // TODO: Should this be shared instead of static?
compile.compilerArgs = ['/TC', '/MT', '/Ox', '/DSODIUM_STATIC', '/DSODIUM_EXPORT='] compile.compilerArgs = ['/TC', '/MT', '/Ox', '/DSODIUM_STATIC', '/DSODIUM_EXPORT=', '/std:c11']
} }
} }
} }

View File

@ -250,7 +250,7 @@ void mpw_marshal_file_free(
MPMarshalledData *mpw_marshal_data_new() { MPMarshalledData *mpw_marshal_data_new() {
MPMarshalledData *data = malloc( sizeof( MPMarshalledData ) ); MPMarshalledData *data = malloc( sizeof( MPMarshalledData ) );
*data = (MPMarshalledData){}; *data = (MPMarshalledData){ 0 };
mpw_marshal_data_set_null( data, NULL ); mpw_marshal_data_set_null( data, NULL );
data->is_null = false; data->is_null = false;
return data; return data;

View File

@ -22,7 +22,6 @@ MP_LIBS_BEGIN
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <libgen.h>
#if MPW_CPERCIVA #if MPW_CPERCIVA
#include <scrypt/crypto_scrypt.h> #include <scrypt/crypto_scrypt.h>

View File

@ -86,6 +86,21 @@ void mpw_log_ssink(LogLevel level, const char *file, int line, const char *funct
//// Utilities //// Utilities
#ifndef OK
#define OK 0
#endif
#ifndef ERR
#define ERR -1
#endif
#ifndef stringify
#define stringify(s) #s
#endif
#ifndef stringify_def
#define stringify_def(s) stringify(s)
#endif
#if !__STRICT_ANSI__ && __GNUC__ >= 3
#ifndef min #ifndef min
#define min(a, b) ({ \ #define min(a, b) ({ \
__typeof__ (a) _a = (a); \ __typeof__ (a) _a = (a); \
@ -98,21 +113,18 @@ void mpw_log_ssink(LogLevel level, const char *file, int line, const char *funct
__typeof__ (b) _b = (b); \ __typeof__ (b) _b = (b); \
_a > _b ? _a : _b; }) _a > _b ? _a : _b; })
#endif #endif
#ifndef ERR #define mpw_default(__default, __value) ({ __typeof__ (__value) _v = (__value); _v? _v: (__default); })
#define ERR -1 #define mpw_default_n(__default, __num) ({ __typeof__ (__num) _n = (__num); !isnan( _n )? (__typeof__ (__default))_n: (__default); })
#else
#ifndef min
#define min(a, b) ( (a) < (b) ? (a) : (b) )
#endif #endif
#ifndef OK #ifndef max
#define OK 0 #define max(a, b) ( (a) > (b) ? (a) : (b) )
#endif #endif
#ifndef stringify #define mpw_default(__default, __value) ( (__value)? (__value): (__default) )
#define stringify(s) #s #define mpw_default_n(__default, __num) ( !isnan( (__num) )? (__num): (__default) )
#endif #endif
#ifndef stringify_def
#define stringify_def(s) stringify(s)
#endif
#define mpw_default(__default, __value) ({ __typeof__ (__value) _v = __value; _v? _v: __default; })
#define mpw_default_n(__default, __num) ({ __typeof__ (__num) _n = (__num); !isnan( _n )? (__typeof__ (__default))_n: __default; })
//// Buffers and memory. //// Buffers and memory.