Compare commits

...
3 Commits
22 changed files with 3048 additions and 22 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
version: 1.2.0-{build}
version: 1.2.1-{build}
branches:
only:
- master
+4
View File
@@ -12,6 +12,10 @@ mp_err mp_2expt(mp_int *a, int b)
{
mp_err err;
if (b < 0) {
return MP_VAL;
}
/* zero a as per default */
mp_zero(a);
+4
View File
@@ -9,6 +9,10 @@ mp_err mp_grow(mp_int *a, int size)
int i;
mp_digit *tmp;
if (size < 0) {
return MP_VAL;
}
/* if the alloc size is smaller alloc more ram */
if (a->alloc < size) {
/* reallocate the array a->dp
+5
View File
@@ -6,6 +6,11 @@
/* init an mp_init for a given size */
mp_err mp_init_size(mp_int *a, int size)
{
if (size < 0) {
return MP_VAL;
}
size = MP_MAX(MP_MIN_PREC, size);
/* alloc mem */
+4 -4
View File
@@ -6,7 +6,7 @@
/* Compute log_{base}(a) */
static mp_word s_pow(mp_word base, mp_word exponent)
{
mp_word result = 1uLL;
mp_word result = 1u;
while (exponent != 0u) {
if ((exponent & 1u) == 1u) {
result *= base;
@@ -20,8 +20,8 @@ static mp_word s_pow(mp_word base, mp_word exponent)
static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
{
mp_word bracket_low = 1uLL, bracket_mid, bracket_high, N;
mp_digit ret, high = 1uL, low = 0uL, mid;
mp_word bracket_low = 1u, bracket_mid, bracket_high, N;
mp_digit ret, high = 1u, low = 0uL, mid;
if (n < base) {
return 0uL;
@@ -40,7 +40,7 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
bracket_high *= bracket_high;
}
while (((mp_digit)(high - low)) > 1uL) {
while (((mp_digit)(high - low)) > 1u) {
mid = (low + high) >> 1;
bracket_mid = bracket_low * s_pow(base, (mp_word)(mid - low));
+1 -1
View File
@@ -17,7 +17,7 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
* The bigger one needs to be at least about one MP_KARATSUBA_MUL_CUTOFF bigger
* to make some sense, but it depends on architecture, OS, position of the
* stars... so YMMV.
* Using it to cut the input into slices small enough for fast_s_mp_mul_digs
* Using it to cut the input into slices small enough for s_mp_mul_digs_fast
* was actually slower on the author's machine, but YMMV.
*/
(min_len >= MP_KARATSUBA_MUL_CUTOFF) &&
+4
View File
@@ -9,6 +9,10 @@ mp_err mp_mul_2d(const mp_int *a, int b, mp_int *c)
mp_digit d;
mp_err err;
if (b < 0) {
return MP_VAL;
}
/* copy */
if (a != c) {
if ((err = mp_copy(a, c)) != MP_OKAY) {
+2 -2
View File
@@ -16,7 +16,7 @@ mp_err mp_set_double(mp_int *a, double b)
cast.dbl = b;
exp = (int)((unsigned)(cast.bits >> 52) & 0x7FFu);
frac = (cast.bits & ((1uLL << 52) - 1uLL)) | (1uLL << 52);
frac = (cast.bits & (((uint64_t)1 << 52) - (uint64_t)1)) | ((uint64_t)1 << 52);
if (exp == 0x7FF) { /* +-inf, NaN */
return MP_VAL;
@@ -30,7 +30,7 @@ mp_err mp_set_double(mp_int *a, double b)
return err;
}
if (((cast.bits >> 63) != 0uLL) && !MP_IS_ZERO(a)) {
if (((cast.bits >> 63) != 0u) && !MP_IS_ZERO(a)) {
a->sign = MP_NEG;
}
+4
View File
@@ -16,6 +16,10 @@ mp_err s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_word r;
mp_digit tmpx, *tmpt, *tmpy;
if (digs < 0) {
return MP_VAL;
}
/* can we use the fast multiplier? */
if ((digs < MP_WARRAY) &&
(MP_MIN(a->used, b->used) < MP_MAXFAST)) {
+4
View File
@@ -26,6 +26,10 @@ mp_err s_mp_mul_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_digit W[MP_WARRAY];
mp_word _W;
if (digs < 0) {
return MP_VAL;
}
/* grow the destination as required */
if (c->alloc < digs) {
if ((err = mp_grow(c, digs)) != MP_OKAY) {
+4
View File
@@ -15,6 +15,10 @@ mp_err s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_word r;
mp_digit tmpx, *tmpt, *tmpy;
if (digs < 0) {
return MP_VAL;
}
/* can we use the fast multiplier? */
if (MP_HAS(S_MP_MUL_HIGH_DIGS_FAST)
&& ((a->used + b->used + 1) < MP_WARRAY)
+6 -2
View File
@@ -3,8 +3,8 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* this is a modified version of fast_s_mul_digs that only produces
* output digits *above* digs. See the comments for fast_s_mul_digs
/* this is a modified version of s_mp_mul_digs_fast that only produces
* output digits *above* digs. See the comments for s_mp_mul_digs_fast
* to see how it works.
*
* This is used in the Barrett reduction since for one of the multiplications
@@ -19,6 +19,10 @@ mp_err s_mp_mul_high_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int
mp_digit W[MP_WARRAY];
mp_word _W;
if (digs < 0) {
return MP_VAL;
}
/* grow the destination as required */
pa = a->used + b->used;
if (c->alloc < pa) {
+2 -2
View File
@@ -27,10 +27,10 @@ static uint64_t s_rand_jenkins_val(void)
void s_mp_rand_jenkins_init(uint64_t seed)
{
uint64_t i;
int i;
jenkins_x.a = 0xf1ea5eedULL;
jenkins_x.b = jenkins_x.c = jenkins_x.d = seed;
for (i = 0uLL; i < 20uLL; ++i) {
for (i = 0; i < 20; ++i) {
(void)s_rand_jenkins_val();
}
}
+6 -1
View File
@@ -1,4 +1,9 @@
XXX XXth, 2019
Sep 04th, 2023
v1.2.1
-- Bugfix release because of potential integer overflow
c.f. PR #546 resp. CVE-2023-36328
Oct 22nd, 2019
v1.2.0
-- A huge refactoring of the library happened - renaming,
deprecating and replacing existing functions by improved API's.
+42
View File
@@ -0,0 +1,42 @@
#include "shared.h"
void ndraw(mp_int *a, const char *name)
{
char *buf = NULL;
int size;
mp_radix_size(a, 10, &size);
buf = (char *)malloc((size_t) size);
if (buf == NULL) {
fprintf(stderr, "\nndraw: malloc(%d) failed\n", size);
exit(EXIT_FAILURE);
}
printf("%s: ", name);
mp_to_decimal(a, buf, (size_t) size);
printf("%s\n", buf);
mp_to_hex(a, buf, (size_t) size);
printf("0x%s\n", buf);
free(buf);
}
void print_header(void)
{
#ifdef MP_8BIT
printf("Digit size 8 Bit \n");
#endif
#ifdef MP_16BIT
printf("Digit size 16 Bit \n");
#endif
#ifdef MP_32BIT
printf("Digit size 32 Bit \n");
#endif
#ifdef MP_64BIT
printf("Digit size 64 Bit \n");
#endif
printf("Size of mp_digit: %u\n", (unsigned int)sizeof(mp_digit));
printf("Size of mp_word: %u\n", (unsigned int)sizeof(mp_word));
printf("MP_DIGIT_BIT: %d\n", MP_DIGIT_BIT);
printf("MP_PREC: %d\n", MP_PREC);
}
+21
View File
@@ -0,0 +1,21 @@
#include <string.h>
#include <stdlib.h>
#include <time.h>
/*
* Configuration
*/
#ifndef LTM_DEMO_TEST_REDUCE_2K_L
/* This test takes a moment so we disable it by default, but it can be:
* 0 to disable testing
* 1 to make the test with P = 2^1024 - 0x2A434 B9FDEC95 D8F9D550 FFFFFFFF FFFFFFFF
* 2 to make the test with P = 2^2048 - 0x1 00000000 00000000 00000000 00000000 4945DDBF 8EA2A91D 5776399B B83E188F
*/
#define LTM_DEMO_TEST_REDUCE_2K_L 0
#endif
#define MP_WUR /* TODO: result checks disabled for now */
#include "tommath_private.h"
extern void ndraw(mp_int* a, const char* name);
extern void print_header(void);
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -51,7 +51,7 @@ sub check_source {
push @{$troubles->{tab}}, $lineno if $l =~ /\t/ && basename($file) !~ /^makefile/i;
push @{$troubles->{non_ascii_char}}, $lineno if $l =~ /[^[:ascii:]]/;
push @{$troubles->{cpp_comment}}, $lineno if $file =~ /\.(c|h)$/ && ($l =~ /\s\/\// || $l =~ /\/\/\s/);
# we prefer using XMALLOC, XFREE, XREALLOC, XCALLOC ...
# we prefer using MP_MALLOC, MP_FREE, MP_REALLOC, MP_CALLOC ...
push @{$troubles->{unwanted_malloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmalloc\s*\(/;
push @{$troubles->{unwanted_realloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\brealloc\s*\(/;
push @{$troubles->{unwanted_calloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bcalloc\s*\(/;
+1 -1
View File
@@ -21,7 +21,7 @@ RANLIB = ranlib
CFLAGS = -O2
LDFLAGS =
VERSION = 1.2.0
VERSION = 1.2.1
#Compilation flags
LTM_CFLAGS = -I. $(CFLAGS)
+3 -3
View File
@@ -3,9 +3,9 @@
#
#version of library
VERSION=1.2.0
VERSION_PC=1.2.0
VERSION_SO=3:0:2
VERSION=1.2.1
VERSION_PC=1.2.1
VERSION_SO=3:1:2
PLATFORM := $(shell uname | sed -e 's/_.*//')
+394
View File
@@ -0,0 +1,394 @@
#!/bin/bash
#
# return values of this script are:
# 0 success
# 128 a test failed
# >0 the number of timed-out tests
# 255 parsing of parameters failed
set -e
if [ -f /proc/cpuinfo ]
then
MAKE_JOBS=$(( ($(cat /proc/cpuinfo | grep -E '^processor[[:space:]]*:' | tail -n -1 | cut -d':' -f2) + 1) * 2 + 1 ))
else
MAKE_JOBS=8
fi
ret=0
TEST_CFLAGS=""
_help()
{
echo "Usage options for $(basename $0) [--with-cc=arg [other options]]"
echo
echo "Executing this script without any parameter will only run the default"
echo "configuration that has automatically been determined for the"
echo "architecture you're running."
echo
echo " --with-cc=* The compiler(s) to use for the tests"
echo " This is an option that will be iterated."
echo
echo " --test-vs-mtest=* Run test vs. mtest for '*' operations."
echo " Only the first of each options will be"
echo " taken into account."
echo
echo "To be able to specify options a compiler has to be given with"
echo "the option --with-cc=compilername"
echo "All other options will be tested with all MP_xBIT configurations."
echo
echo " --with-{m64,m32,mx32} The architecture(s) to build and test"
echo " for, e.g. --with-mx32."
echo " This is an option that will be iterated,"
echo " multiple selections are possible."
echo " The mx32 architecture is not supported"
echo " by clang and will not be executed."
echo
echo " --cflags=* Give an option to the compiler,"
echo " e.g. --cflags=-g"
echo " This is an option that will always be"
echo " passed as parameter to CC."
echo
echo " --make-option=* Give an option to make,"
echo " e.g. --make-option=\"-f makefile.shared\""
echo " This is an option that will always be"
echo " passed as parameter to make."
echo
echo " --with-low-mp Also build&run tests with -DMP_{8,16,32}BIT."
echo
echo " --mtest-real-rand Use real random data when running mtest."
echo
echo " --with-valgrind"
echo " --with-valgrind=* Run in valgrind (slow!)."
echo
echo " --with-travis-valgrind Run with valgrind on Travis on specific branches."
echo
echo " --valgrind-options Additional Valgrind options"
echo " Some of the options like e.g.:"
echo " --track-origins=yes add a lot of extra"
echo " runtime and may trigger the 30 minutes"
echo " timeout."
echo
echo "Godmode:"
echo
echo " --all Choose all architectures and gcc and clang"
echo " as compilers but does not run valgrind."
echo
echo " --format Runs the various source-code formatters"
echo " and generators and checks if the sources"
echo " are clean."
echo
echo " -h"
echo " --help This message"
echo
echo " -v"
echo " --version Prints the version. It is just the number"
echo " of git commits to this file, no deeper"
echo " meaning attached"
exit 0
}
_die()
{
echo "error $2 while $1"
if [ "$2" != "124" ]
then
exit 128
else
echo "assuming timeout while running test - continue"
local _tail=""
which tail >/dev/null && _tail="tail -n 1 test_${suffix}.log" && \
echo "last line of test_"${suffix}".log was:" && $_tail && echo ""
ret=$(( $ret + 1 ))
fi
}
_make()
{
echo -ne " Compile $1 $2"
suffix=$(echo ${1}${2} | tr ' ' '_')
CC="$1" CFLAGS="$2 $TEST_CFLAGS" make -j$MAKE_JOBS $3 $MAKE_OPTIONS > /dev/null 2>gcc_errors_${suffix}.log
errcnt=$(wc -l < gcc_errors_${suffix}.log)
if [[ ${errcnt} -gt 1 ]]; then
echo " failed"
cat gcc_errors_${suffix}.log
exit 128
fi
}
_runtest()
{
make clean > /dev/null
local _timeout=""
which timeout >/dev/null && _timeout="timeout --foreground 90"
if [[ "$MAKE_OPTIONS" =~ "tune" ]]
then
# "make tune" will run "tune_it.sh" automatically, hence "autotune", but it cannot
# get switched off without some effort, so we just let it run twice for testing purposes
echo -e "\rRun autotune $1 $2"
_make "$1" "$2" ""
$_timeout $TUNE_CMD > test_${suffix}.log || _die "running autotune" $?
else
_make "$1" "$2" "test"
echo -e "\rRun test $1 $2"
$_timeout ./test > test_${suffix}.log || _die "running tests" $?
fi
}
# This is not much more of a C&P of _runtest with a different timeout
# and the additional valgrind call.
# TODO: merge
_runvalgrind()
{
make clean > /dev/null
local _timeout=""
# 30 minutes? Yes. Had it at 20 minutes and the Valgrind run needed over 25 minutes.
# A bit too close for comfort.
which timeout >/dev/null && _timeout="timeout --foreground 1800"
echo "MAKE_OPTIONS = \"$MAKE_OPTIONS\""
if [[ "$MAKE_OPTIONS" =~ "tune" ]]
then
echo "autotune branch"
_make "$1" "$2" ""
# The shell used for /bin/sh is DASH 0.5.7-4ubuntu1 on the author's machine which fails valgrind, so
# we just run on instance of etc/tune with the same options as in etc/tune_it.sh
echo -e "\rRun etc/tune $1 $2 once inside valgrind"
$_timeout $VALGRIND_BIN $VALGRIND_OPTS $TUNE_CMD > test_${suffix}.log || _die "running etc/tune" $?
else
_make "$1" "$2" "test"
echo -e "\rRun test $1 $2 inside valgrind"
$_timeout $VALGRIND_BIN $VALGRIND_OPTS ./test > test_${suffix}.log || _die "running tests" $?
fi
}
_banner()
{
echo "uname="$(uname -a)
[[ "$#" != "0" ]] && (echo $1=$($1 -dumpversion)) || true
}
_exit()
{
if [ "$ret" == "0" ]
then
echo "Tests successful"
else
echo "$ret tests timed out"
fi
exit $ret
}
ARCHFLAGS=""
COMPILERS=""
CFLAGS=""
WITH_LOW_MP=""
TEST_VS_MTEST=""
MTEST_RAND=""
# timed with an AMD A8-6600K
# 25 minutes
#VALGRIND_OPTS=" --track-origins=yes --leak-check=full --show-leak-kinds=all --error-exitcode=1 "
# 9 minutes (14 minutes with --test-vs-mtest=333333 --mtest-real-rand)
VALGRIND_OPTS=" --leak-check=full --show-leak-kinds=all --error-exitcode=1 "
#VALGRIND_OPTS=""
VALGRIND_BIN=""
CHECK_FORMAT=""
TUNE_CMD="./etc/tune -t -r 10 -L 3"
alive_pid=0
function kill_alive() {
disown $alive_pid || true
kill $alive_pid 2>/dev/null
}
function start_alive_printing() {
[ "$alive_pid" == "0" ] || return 0;
for i in `seq 1 10` ; do sleep 300 && echo "Tests still in Progress..."; done &
alive_pid=$!
trap kill_alive EXIT
}
while [ $# -gt 0 ];
do
case $1 in
"--with-m64" | "--with-m32" | "--with-mx32")
ARCHFLAGS="$ARCHFLAGS ${1:6}"
;;
--with-cc=*)
COMPILERS="$COMPILERS ${1#*=}"
;;
--cflags=*)
CFLAGS="$CFLAGS ${1#*=}"
;;
--valgrind-options=*)
VALGRIND_OPTS="$VALGRIND_OPTS ${1#*=}"
;;
--with-valgrind*)
if [[ ${1#*d} != "" ]]
then
VALGRIND_BIN="${1#*=}"
else
VALGRIND_BIN="valgrind"
fi
start_alive_printing
;;
--with-travis-valgrind*)
if [[ ("$TRAVIS_BRANCH" == "develop" && "$TRAVIS_PULL_REQUEST" == "false") || "$TRAVIS_BRANCH" == *"valgrind"* || "$TRAVIS_COMMIT_MESSAGE" == *"valgrind"* ]]
then
if [[ ${1#*d} != "" ]]
then
VALGRIND_BIN="${1#*=}"
else
VALGRIND_BIN="valgrind"
fi
start_alive_printing
fi
;;
--make-option=*)
MAKE_OPTIONS="$MAKE_OPTIONS ${1#*=}"
;;
--with-low-mp)
WITH_LOW_MP="1"
;;
--test-vs-mtest=*)
TEST_VS_MTEST="${1#*=}"
if ! [ "$TEST_VS_MTEST" -eq "$TEST_VS_MTEST" ] 2> /dev/null
then
echo "--test-vs-mtest Parameter has to be int"
exit 255
fi
start_alive_printing
;;
--mtest-real-rand)
MTEST_RAND="-DLTM_MTEST_REAL_RAND"
;;
--format)
CHECK_FORMAT="1"
;;
--all)
COMPILERS="gcc clang"
ARCHFLAGS="-m64 -m32 -mx32"
;;
--help | -h)
_help
;;
--version | -v)
echo $(git rev-list HEAD --count -- testme.sh) || echo "Unknown. Please run in original libtommath git repository."
exit 0
;;
*)
echo "Ignoring option ${1}"
;;
esac
shift
done
function _check_git() {
git update-index --refresh >/dev/null || true
git diff-index --quiet HEAD -- . || ( echo "FAILURE: $*" && exit 1 )
}
if [[ "$CHECK_FORMAT" == "1" ]]
then
make astyle
_check_git "make astyle"
perl helper.pl --update-files
_check_git "helper.pl --update-files"
perl helper.pl --check-all
_check_git "helper.pl --check-all"
exit $?
fi
[[ "$VALGRIND_BIN" == "" ]] && VALGRIND_OPTS=""
# default to CC environment variable if no compiler is defined but some other options
if [[ "$COMPILERS" == "" ]] && [[ "$ARCHFLAGS$MAKE_OPTIONS$CFLAGS" != "" ]]
then
COMPILERS="$CC"
# default to CC environment variable and run only default config if no option is given
elif [[ "$COMPILERS" == "" ]]
then
_banner "$CC"
if [[ "$VALGRIND_BIN" != "" ]]
then
_runvalgrind "$CC" ""
else
_runtest "$CC" ""
fi
_exit
fi
archflags=( $ARCHFLAGS )
compilers=( $COMPILERS )
# choosing a compiler without specifying an architecture will use the default architecture
if [ "${#archflags[@]}" == "0" ]
then
archflags[0]=" "
fi
_banner
if [[ "$TEST_VS_MTEST" != "" ]]
then
make clean > /dev/null
_make "${compilers[0]} ${archflags[0]}" "$CFLAGS" "mtest_opponent"
echo
_make "gcc" "$MTEST_RAND" "mtest"
echo
echo "Run test vs. mtest for $TEST_VS_MTEST iterations"
_timeout=""
which timeout >/dev/null && _timeout="timeout --foreground 1800"
$_timeout ./mtest/mtest $TEST_VS_MTEST | $VALGRIND_BIN $VALGRIND_OPTS ./mtest_opponent > valgrind_test.log 2> test_vs_mtest_err.log
retval=$?
head -n 5 valgrind_test.log
tail -n 2 valgrind_test.log
exit $retval
fi
for i in "${compilers[@]}"
do
if [ -z "$(which $i)" ]
then
echo "Skipped compiler $i, file not found"
continue
fi
compiler_version=$(echo "$i="$($i -dumpversion))
if [ "$compiler_version" == "clang=4.2.1" ]
then
# one of my versions of clang complains about some stuff in stdio.h and stdarg.h ...
TEST_CFLAGS="-Wno-typedef-redefinition"
else
TEST_CFLAGS=""
fi
echo $compiler_version
for a in "${archflags[@]}"
do
if [[ $(expr "$i" : "clang") -ne 0 && "$a" == "-mx32" ]]
then
echo "clang -mx32 tests skipped"
continue
fi
if [[ "$VALGRIND_BIN" != "" ]]
then
_runvalgrind "$i $a" "$CFLAGS"
[ "$WITH_LOW_MP" != "1" ] && continue
_runvalgrind "$i $a" "-DMP_8BIT $CFLAGS"
_runvalgrind "$i $a" "-DMP_16BIT $CFLAGS"
_runvalgrind "$i $a" "-DMP_32BIT $CFLAGS"
else
_runtest "$i $a" "$CFLAGS"
[ "$WITH_LOW_MP" != "1" ] && continue
_runtest "$i $a" "-DMP_8BIT $CFLAGS"
_runtest "$i $a" "-DMP_16BIT $CFLAGS"
_runtest "$i $a" "-DMP_32BIT $CFLAGS"
fi
done
done
_exit
+13 -4
View File
@@ -200,7 +200,7 @@ TOOM_SQR_CUTOFF;
#endif
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
#define PRIVATE_MP_WARRAY (int)(1 << (((CHAR_BIT * (int)sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
#define MP_WARRAY (MP_DEPRECATED_PRAGMA("MP_WARRAY is an internal macro") PRIVATE_MP_WARRAY)
#if defined(__GNUC__) && __GNUC__ >= 4
@@ -234,13 +234,22 @@ TOOM_SQR_CUTOFF;
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 405)
# define MP_DEPRECATED(x) __attribute__((deprecated("replaced by " #x)))
#elif defined(_MSC_VER) && _MSC_VER >= 1500
# define MP_DEPRECATED(x) __declspec(deprecated("replaced by " #x))
#else
# define MP_DEPRECATED(x)
#endif
#ifndef MP_NO_DEPRECATED_PRAGMA
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
# define PRIVATE_MP_DEPRECATED_PRAGMA(s) _Pragma(#s)
# define MP_DEPRECATED_PRAGMA(s) PRIVATE_MP_DEPRECATED_PRAGMA(GCC warning s)
#elif defined(_MSC_VER) && _MSC_VER >= 1500
# define MP_DEPRECATED(x) __declspec(deprecated("replaced by " #x))
# define MP_DEPRECATED_PRAGMA(s) __pragma(message(s))
#else
# define MP_DEPRECATED(s)
#endif
#endif
#ifndef MP_DEPRECATED_PRAGMA
# define MP_DEPRECATED_PRAGMA(s)
#endif