Skip to content
Snippets Groups Projects
Commit d158f8d7 authored by Patrick Baudin's avatar Patrick Baudin
Browse files

Merge branch 'feature/lint/check-indent-of-C-files' into 'master'

linting some more C files

See merge request frama-c/frama-c!4058
parents b1551ab6 c3947158
No related branches found
No related tags found
No related merge requests found
......@@ -47,9 +47,32 @@ Changelog merge=union
# note: "check-syntax" includes already "check-eoleof"
*.ml check-syntax check-indent -check-eoleof
*.mli check-syntax check-indent -check-eoleof
*.py check-indent check-eoleof
*.py check-indent
*.c check-indent
*.h check-indent
## Unset "-check-indent"
# Unchecked C files
tests/**/*.[ch] -check-indent
src/plugins/*/tests/**/*.[ch] -check-indent
doc/aorai/**/*.[ch] -check-indent
doc/developer/**/*.[ch] -check-indent
doc/eva/**/*.[ch] -check-indent
doc/rte/**/*.[ch] -check-indent
share/**/*.[ch] -check-indent
src/plugins/wp/doc/**/*.[ch] -check-indent
src/plugins/e-acsl/doc/**/*.[ch] -check-indent
src/plugins/e-acsl/examples/**/*.[ch] -check-indent
# Don't check it because it takes too much time
src/plugins/e-acsl/contrib/libdlmalloc/dlmalloc.[ch] -check-indent
# Unchecked python files
# linting exceptions
share/analysis-scripts/benchmark_database.py -check-indent
share/analysis-scripts/summary.py -check-indent
share/analysis-scripts/results_display.py -check-indent
......@@ -70,8 +93,6 @@ src/plugins/e-acsl/examples/ensuresec/**/*.py -check-indent
/src/plugins/wp/doc/manual/wp_logicvar.tex -check-utf8
/src/plugins/wp/doc/manual/wp_store.tex -check-utf8
# Don't check symbolic links (that gives an error)
## Unset all: "-check-syntax -check-indent -check-eoleof -check-utf8"
# Don't check symbolic links (that gives an error for check-utf8). Please checks only the linked target.
......
......@@ -20,31 +20,31 @@
/* */
/**************************************************************************/
#ifdef _WIN32
#ifdef _WIN32
/* Must be the first included header */
#include "windows.h"
#endif
#include "caml/mlvalues.h"
#include "caml/alloc.h"
#include "caml/fail.h"
#include "caml/mlvalues.h"
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
// Some BSD flavors do not implement all of C99
#if defined(__NetBSD__)
# include <ieeefp.h>
# define FE_DOWNWARD FP_RM
# define FE_UPWARD FP_RP
# define FE_TONEAREST FP_RN
# define FE_TOWARDZERO FP_RZ
# define fegetround() fpgetround()
# define fesetround(RM) fpsetround(RM)
#else
# include <fenv.h>
#include <ieeefp.h>
#define FE_DOWNWARD FP_RM
#define FE_UPWARD FP_RP
#define FE_TONEAREST FP_RN
#define FE_TOWARDZERO FP_RZ
#define fegetround() fpgetround()
#define fesetround(RM) fpsetround(RM)
#else
#include <fenv.h>
#endif
#include <float.h>
......@@ -52,160 +52,149 @@
// Must be synchronized with Floating_point.c_rounding_mode
typedef enum {
FE_ToNearest, FE_Upward, FE_Downward, FE_TowardZero
FE_ToNearest,
FE_Upward,
FE_Downward,
FE_TowardZero
} c_rounding_mode_t;
value c_round(value d)
{
return caml_copy_double(round(Double_val(d)));
}
value c_round(value d) { return caml_copy_double(round(Double_val(d))); }
value c_trunc(value d)
{
return caml_copy_double(trunc(Double_val(d)));
}
value c_trunc(value d) { return caml_copy_double(trunc(Double_val(d))); }
value c_expf(value d)
{
value c_expf(value d) {
float f = Double_val(d);
float res = expf(f);
return caml_copy_double(res);
}
value c_logf(value d)
{
value c_logf(value d) {
float f = Double_val(d);
float res = logf(f);
return caml_copy_double(res);
}
value c_log10f(value d)
{
value c_log10f(value d) {
float f = Double_val(d);
float res = log10f(f);
return caml_copy_double(res);
}
value c_powf(value x, value y)
{
value c_powf(value x, value y) {
float fx = Double_val(x);
float fy = Double_val(y);
float res = powf(fx, fy);
return caml_copy_double(res);
}
value c_sqrtf(value d)
{
value c_sqrtf(value d) {
float f = Double_val(d);
float res = sqrtf(f);
return caml_copy_double(res);
}
value c_fmodf(value x, value y)
{
value c_fmodf(value x, value y) {
float fx = Double_val(x);
float fy = Double_val(y);
float res = fmodf(fx, fy);
return caml_copy_double(res);
}
value c_cosf(value x)
{
value c_cosf(value x) {
float f = Double_val(x);
float res = cosf(f);
return caml_copy_double(res);
}
value c_sinf(value x)
{
value c_sinf(value x) {
float f = Double_val(x);
float res = sinf(f);
return caml_copy_double(res);
}
value c_acosf(value x)
{
value c_acosf(value x) {
float f = Double_val(x);
float res = acosf(f);
return caml_copy_double(res);
}
value c_asinf(value x)
{
value c_asinf(value x) {
float f = Double_val(x);
float res = asinf(f);
return caml_copy_double(res);
}
value c_atanf(value x)
{
value c_atanf(value x) {
float f = Double_val(x);
float res = atanf(f);
return caml_copy_double(res);
}
value c_atan2f(value x, value y)
{
value c_atan2f(value x, value y) {
float fx = Double_val(x);
float fy = Double_val(y);
float res = atan2f(fx, fy);
return caml_copy_double(res);
}
value address_of_value(value v)
{
return (Val_long(((unsigned long)v)/sizeof(long)));
value address_of_value(value v) {
return (Val_long(((unsigned long)v) / sizeof(long)));
}
value round_to_float(value d)
{
value round_to_float(value d) {
float f = Double_val(d);
return caml_copy_double(f);
}
value set_round_downward(value dummy)
{
value set_round_downward(value dummy) {
fesetround(FE_DOWNWARD);
return Val_unit;
}
value set_round_upward(value dummy)
{
value set_round_upward(value dummy) {
fesetround(FE_UPWARD);
return Val_unit;
}
value set_round_nearest_even(value dummy)
{
value set_round_nearest_even(value dummy) {
fesetround(FE_TONEAREST);
return Val_unit;
}
value set_round_toward_zero(value dummy)
{
value set_round_toward_zero(value dummy) {
fesetround(FE_TOWARDZERO);
return Val_unit;
}
value get_rounding_mode(value dummy)
{
value get_rounding_mode(value dummy) {
switch (fegetround()) {
case FE_TONEAREST: return Val_int(FE_ToNearest);
case FE_DOWNWARD: return Val_int(FE_Downward);
case FE_UPWARD: return Val_int(FE_Upward);
case FE_TOWARDZERO: return Val_int(FE_TowardZero);
case FE_TONEAREST:
return Val_int(FE_ToNearest);
case FE_DOWNWARD:
return Val_int(FE_Downward);
case FE_UPWARD:
return Val_int(FE_Upward);
case FE_TOWARDZERO:
return Val_int(FE_TowardZero);
}
caml_failwith("illegal rounding mode (should never happen)");
}
value set_rounding_mode(value rm)
{
value set_rounding_mode(value rm) {
int new_rm;
switch (Int_val(rm)) {
case FE_ToNearest: new_rm = FE_TONEAREST; break;
case FE_Downward: new_rm = FE_DOWNWARD; break;
case FE_Upward: new_rm = FE_UPWARD; break;
case FE_TowardZero: new_rm = FE_TOWARDZERO; break;
case FE_ToNearest:
new_rm = FE_TONEAREST;
break;
case FE_Downward:
new_rm = FE_DOWNWARD;
break;
case FE_Upward:
new_rm = FE_UPWARD;
break;
case FE_TowardZero:
new_rm = FE_TOWARDZERO;
break;
default:
caml_invalid_argument("set_rounding_mode");
}
......@@ -213,23 +202,31 @@ value set_rounding_mode(value rm)
return Val_unit;
}
value float_compare_total(value x, value y)
{
union { double d; int64_t i; } ux, uy;
value float_compare_total(value x, value y) {
union {
double d;
int64_t i;
} ux, uy;
ux.d = Double_val(x);
uy.d = Double_val(y);
if (ux.i == uy.i) return Val_int(0);
ux.i = ux.i ^ (((uint64_t)(ux.i >> 63))>>1);
uy.i = uy.i ^ (((uint64_t)(uy.i >> 63))>>1);
if (ux.i < uy.i) return Val_int(-1); else return Val_int(1);
if (ux.i == uy.i)
return Val_int(0);
ux.i = ux.i ^ (((uint64_t)(ux.i >> 63)) >> 1);
uy.i = uy.i ^ (((uint64_t)(uy.i >> 63)) >> 1);
if (ux.i < uy.i)
return Val_int(-1);
else
return Val_int(1);
}
value float_is_negative(value v)
{
union { double d; uint64_t i; } uv;
value float_is_negative(value v) {
union {
double d;
uint64_t i;
} uv;
uv.d = Double_val(v);
return (Val_int((int)((uv.i) >> 63)));
}
......@@ -238,8 +235,7 @@ value float_is_negative(value v)
prototype strtof() although it is available in the C library. */
float strtof(const char *, char **);
value single_precision_of_string(value str)
{
value single_precision_of_string(value str) {
const char *s = (const char *)str;
const char *s_end = s + caml_string_length(str);
char *end;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment