From: solar Date: Sun, 4 Dec 2005 08:47:22 +0000 (+0000) Subject: Initial checkin. X-Git-Tag: v0.4~48 X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=bf2467f8b7d21570e11985421f2359a24a739134 Initial checkin. --- diff --git a/functions/stdlib/abs.c b/functions/stdlib/abs.c new file mode 100644 index 0000000..1bd965d --- /dev/null +++ b/functions/stdlib/abs.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* abs( int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +int abs( int j ) +{ + return ( j >= 0 ) ? j : -j; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> +#include + +int main() +{ + BEGIN_TESTS; + TESTCASE( abs( 0 ) == 0 ); + TESTCASE( abs( INT_MAX ) == INT_MAX ); + TESTCASE( abs( INT_MIN + 1 ) == -( INT_MIN + 1 ) ); + return TEST_RESULTS; +} + +#endif diff --git a/functions/stdlib/labs.c b/functions/stdlib/labs.c new file mode 100644 index 0000000..09d15a6 --- /dev/null +++ b/functions/stdlib/labs.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* labs( long int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +long int labs( long int j ) +{ + return ( j >= 0 ) ? j : -j; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> +#include + +int main() +{ + BEGIN_TESTS; + TESTCASE( labs( 0 ) == 0 ); + TESTCASE( labs( LONG_MAX ) == LONG_MAX ); + TESTCASE( labs( LONG_MIN + 1 ) == -( LONG_MIN + 1 ) ); + return TEST_RESULTS; +} + +#endif diff --git a/functions/stdlib/llabs.c b/functions/stdlib/llabs.c new file mode 100644 index 0000000..ab9aca1 --- /dev/null +++ b/functions/stdlib/llabs.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* llabs( long int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +long long int llabs( long long int j ) +{ + return ( j >= 0 ) ? j : -j; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> +#include + +int main() +{ + BEGIN_TESTS; + TESTCASE( llabs( 0 ) == 0 ); + TESTCASE( llabs( LLONG_MAX ) == LLONG_MAX ); + TESTCASE( llabs( LLONG_MIN + 1 ) == -( LLONG_MIN + 1 ) ); + return TEST_RESULTS; +} + +#endif