Skip to content

Commit 136f29a

Browse files
committed
patch 7.4.1437
Problem: Old system doesn't have isinf() and NAN. (Ben Fritz) Solution: Adjust #ifdefs. Detect isnan() and isinf() functions with configure. Use a replacement when missing. (Kazunobu Kuriyama)
1 parent e98991b commit 136f29a

8 files changed

Lines changed: 85 additions & 34 deletions

File tree

src/auto/configure

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10978,6 +10978,48 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
1097810978
presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
1097910979
esac
1098010980

10981+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
10982+
$as_echo_n "checking for inline... " >&6; }
10983+
if ${ac_cv_c_inline+:} false; then :
10984+
$as_echo_n "(cached) " >&6
10985+
else
10986+
ac_cv_c_inline=no
10987+
for ac_kw in inline __inline__ __inline; do
10988+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10989+
/* end confdefs.h. */
10990+
#ifndef __cplusplus
10991+
typedef int foo_t;
10992+
static $ac_kw foo_t static_foo () {return 0; }
10993+
$ac_kw foo_t foo () {return 0; }
10994+
#endif
10995+
10996+
_ACEOF
10997+
if ac_fn_c_try_compile "$LINENO"; then :
10998+
ac_cv_c_inline=$ac_kw
10999+
fi
11000+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11001+
test "$ac_cv_c_inline" != no && break
11002+
done
11003+
11004+
fi
11005+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
11006+
$as_echo "$ac_cv_c_inline" >&6; }
11007+
11008+
case $ac_cv_c_inline in
11009+
inline | yes) ;;
11010+
*)
11011+
case $ac_cv_c_inline in
11012+
no) ac_val=;;
11013+
*) ac_val=$ac_cv_c_inline;;
11014+
esac
11015+
cat >>confdefs.h <<_ACEOF
11016+
#ifndef __cplusplus
11017+
#define inline $ac_val
11018+
#endif
11019+
_ACEOF
11020+
;;
11021+
esac
11022+
1098111023

1098211024
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rlim_t" >&5
1098311025
$as_echo_n "checking for rlim_t... " >&6; }
@@ -11816,7 +11858,7 @@ for ac_func in bcmp fchdir fchown fsync getcwd getpseudotty \
1181611858
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
1181711859
sigvec strcasecmp strerror strftime stricmp strncasecmp \
1181811860
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
11819-
usleep utime utimes
11861+
usleep utime utimes isnan isinf
1182011862
do :
1182111863
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1182211864
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

src/config.h.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,12 @@
460460

461461
/* Define if GTK+ GUI is to be linked against GTK+ 3 */
462462
#undef USE_GTK3
463+
464+
/* Define if we have isinf() */
465+
#undef HAVE_ISINF
466+
467+
/* Define if we have isnan() */
468+
#undef HAVE_ISNAN
469+
470+
/* Define to inline symbol or empty */
471+
#undef inline

src/configure.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3146,6 +3146,7 @@ AC_HEADER_TIME
31463146
AC_CHECK_TYPE(ino_t, long)
31473147
AC_CHECK_TYPE(dev_t, unsigned)
31483148
AC_C_BIGENDIAN(,,,)
3149+
AC_C_INLINE
31493150

31503151
AC_MSG_CHECKING(for rlim_t)
31513152
if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
@@ -3564,7 +3565,7 @@ AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
35643565
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
35653566
sigvec strcasecmp strerror strftime stricmp strncasecmp \
35663567
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
3567-
usleep utime utimes)
3568+
usleep utime utimes isnan isinf)
35683569
AC_FUNC_FSEEKO
35693570

35703571
dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when

src/eval.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@
2727
# include <time.h> /* for time_t */
2828
#endif
2929

30-
#if defined(FEAT_FLOAT)
31-
# include <float.h>
32-
# if defined(HAVE_MATH_H)
33-
# include <math.h>
34-
# endif
35-
# if defined(WIN32) && !defined(isnan)
36-
# define isnan(x) _isnan(x)
37-
# endif
38-
#endif
39-
4030
#define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */
4131

4232
#define DO_NOT_FREE_CNT 99999 /* refcount for dict or list that should not

src/json.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,6 @@
1717

1818
#if defined(FEAT_EVAL) || defined(PROTO)
1919

20-
#if defined(FEAT_FLOAT)
21-
# include <float.h>
22-
# if defined(HAVE_MATH_H)
23-
/* for isnan() and isinf() */
24-
# include <math.h>
25-
# endif
26-
# if defined(WIN32) && !defined(isnan)
27-
# define isnan(x) _isnan(x)
28-
# define isinf(x) (!_finite(x) && !_isnan(x))
29-
# endif
30-
# if !defined(INFINITY) && defined(DBL_MAX)
31-
# define INFINITY (DBL_MAX+DBL_MAX)
32-
# endif
33-
# if !defined(NAN) && defined(INFINITY)
34-
# define NAN (INFINITY-INFINITY)
35-
# endif
36-
#endif
37-
3820
static int json_encode_item(garray_T *gap, typval_T *val, int copyID, int options);
3921
static int json_decode_item(js_read_T *reader, typval_T *res, int options);
4022

src/macros.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,32 @@
320320
#if defined(FEAT_CHANNEL) || defined(FEAT_JOB) || defined(FEAT_CLIENTSERVER)
321321
# define MESSAGE_QUEUE
322322
#endif
323+
324+
#if defined(FEAT_EVAL) && defined(FEAT_FLOAT)
325+
# include <float.h>
326+
# if defined(HAVE_MATH_H)
327+
/* for isnan() and isinf() */
328+
# include <math.h>
329+
# endif
330+
# if defined(WIN32) && !defined(isnan)
331+
# define isnan(x) _isnan(x)
332+
# define isinf(x) (!_finite(x) && !_isnan(x))
333+
# else
334+
# ifndef HAVE_ISNAN
335+
static inline int isnan(double x) { return x != x; }
336+
# endif
337+
# ifndef HAVE_ISINF
338+
static inline int isinf(double x) { return !isnan(x) && isnan(x - x); }
339+
# endif
340+
# endif
341+
# if !defined(INFINITY)
342+
# if defined(DBL_MAX)
343+
# define INFINITY (DBL_MAX+DBL_MAX)
344+
# else
345+
# define INFINITY (1.0 / 0.0)
346+
# endif
347+
# endif
348+
# if !defined(NAN)
349+
# define NAN (INFINITY-INFINITY)
350+
# endif
351+
#endif

src/message.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
#include "vim.h"
1717

18-
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
19-
# include <math.h>
20-
#endif
21-
2218
static int other_sourcing_name(void);
2319
static char_u *get_emsg_source(void);
2420
static char_u *get_emsg_lnum(void);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1437,
746748
/**/
747749
1436,
748750
/**/

0 commit comments

Comments
 (0)