project_files/hwc/rtl/pmath.c
author vittorio.giovara@gmail.com
Mon, 27 Apr 2015 17:21:58 +0000
changeset 10911 5e3f42553ebc
parent 8047 25a4daa6473c
child 14185 801dc57371c3
permissions -rw-r--r--
Do not set rpath when binaries are installed in the standard search path $ rpmlint hedgewars hedgewars.i686: E: binary-or-shlib-defines-rpath /usr/bin/hwengine ['$ORIGIN/../lib/', '$ORIGIN/', '/usr/lib/'] hedgewars.i686: E: binary-or-shlib-defines-rpath /usr/lib/libphyslayer.so ['$ORIGIN/../lib/', '$ORIGIN/', '/usr/lib/'] hedgewars.i686: E: binary-or-shlib-defines-rpath /usr/bin/hedgewars ['$ORIGIN/../lib/', '$ORIGIN/', '/usr/lib/']

#include "pmath.h"
#include <stdlib.h>
#include <math.h>

/*
 * power raises base to the power power.
 * This is equivalent to exp(power*ln(base)). Therefore base should be non-negative.
 */
float fpcrtl_power(float base, float exponent)
{
    return exp(exponent * log(base));
}

/* Currently the games only uses sign of an integer */
int fpcrtl_signi(int x)
{
    if(x > 0){
        return 1;
    }
    else if(x < 0){
        return -1;
    }
    else{
        return 0;
    }
}

float fpcrtl_csc(float x)
{
    return 1 / sin(x);
}

float __attribute__((overloadable)) fpcrtl_abs(float x)
{
    return fabs(x);
}
double __attribute__((overloadable)) fpcrtl_abs(double x)
{
    return fabs(x);
}
int __attribute__((overloadable)) fpcrtl_abs(int x)
{
    return abs(x);
}

int64_t __attribute__((overloadable)) fpcrtl_abs(int64_t x)
{
    return x < 0 ? -x : x;
}