diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-12-19 19:44:03 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-20 03:44:34 +0000 |
commit | b445b3da44d66704022012bc39f884b3ad0177b7 (patch) | |
tree | a746c222cfe5015134714acf7057fb9d5674977e /wsutil/floorl.c | |
parent | b925c350d9bab35e5e389d3452199e6f8e6fbcb0 (diff) | |
download | wireshark-b445b3da44d66704022012bc39f884b3ad0177b7.tar.gz |
Rename wsutil/floor.[ch] to wsutil/floorl.[ch].
That better indicates what they do - they don't supply floor(), as
that's a standard math.h feature dating back before C89, they supply
floorl().
Change-Id: Ib1278c51cdfc57680c28c51de87eafb2cb50c8eb
Reviewed-on: https://code.wireshark.org/review/5905
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/floorl.c')
-rw-r--r-- | wsutil/floorl.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/wsutil/floorl.c b/wsutil/floorl.c new file mode 100644 index 0000000000..5ca7354441 --- /dev/null +++ b/wsutil/floorl.c @@ -0,0 +1,47 @@ +/* floorl.c + * + * Provides floorl function for systems that do not provide it + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include "wsutil/floorl.h" + +#ifndef HAVE_FLOORL +long double +floorl(long double x) +{ +#ifdef (__GNUC__) + /* + * Handle platforms where GCC has the builtin but the platform's + * headers (including the headers used with GCC!) don't define + * floorl() to use it. + * + * XXX - are there any such platforms? + */ + __builtin_floorl(x); +#else + /* Not perfect, but probably the best workaround available */ + return floor((double)x); +#endif +} + +#endif /* !HAVE_FLOORL */ |