This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Support for long long type for C99 and C++11 compliant compilers
- From: Thomas Uhle <thomas dot uhle at eas dot iis dot fraunhofer dot de>
- To: Newlib Mailing List <newlib at sourceware dot org>
- Date: Tue, 9 Sep 2014 20:05:46 +0200
- Subject: Support for long long type for C99 and C++11 compliant compilers
- Authentication-results: sourceware.org; auth=none
Hello,
the attached patch fixes some issues with long long type support for
compilers that have C99 or C++11 compliance. For instance, llabs(),
lldiv() and atoll() have been missing if g++ was invoked with option
'-std=c++11'.
Regards,
Thomas Uhle
--
Thomas Uhle
System Specification Mixed-Signal Systems
Fraunhofer Institute for Integrated Circuits IIS
Design Automation Division EAS
Zeunerstr. 38, 01069 Dresden, Germany
phone: +49 (0) 351 4640-786
mailto:thomas.uhle@eas.iis.fraunhofer.de
http://www.eas.iis.fraunhofer.de/
--- newlib/libc/include/math.h 27 Aug 2014 19:27:03 -0000 1.52
+++ newlib/libc/include/math.h 9 Sep 2014 17:37:27 -0000
@@ -136,7 +136,8 @@
#endif /* ! defined (__math_68881) */
#endif /* ! defined (_REENT_ONLY) */
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
+#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || \
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
/* ISO C99 types and macros. */
@@ -276,7 +277,7 @@
extern _LONG_LONG_TYPE int llrint _PARAMS((double));
extern double round _PARAMS((double));
extern long int lround _PARAMS((double));
-extern long long int llround _PARAMS((double));
+extern _LONG_LONG_TYPE int llround _PARAMS((double));
extern double trunc _PARAMS((double));
extern double remquo _PARAMS((double, double, int *));
extern double fdim _PARAMS((double, double));
@@ -343,10 +344,10 @@
extern float tgammaf _PARAMS((float));
extern float nearbyintf _PARAMS((float));
extern long int lrintf _PARAMS((float));
-extern _LONG_LONG_TYPE llrintf _PARAMS((float));
+extern _LONG_LONG_TYPE int llrintf _PARAMS((float));
extern float roundf _PARAMS((float));
extern long int lroundf _PARAMS((float));
-extern long long int llroundf _PARAMS((float));
+extern _LONG_LONG_TYPE int llroundf _PARAMS((float));
extern float truncf _PARAMS((float));
extern float remquof _PARAMS((float, float, int *));
extern float fdimf _PARAMS((float, float));
@@ -429,7 +430,7 @@
extern long double tgammal _PARAMS((long double));
extern long double nearbyintl _PARAMS((long double));
extern long int lrintl _PARAMS((long double));
-extern long long int llrintl _PARAMS((long double));
+extern _LONG_LONG_TYPE int llrintl _PARAMS((long double));
extern long double roundl _PARAMS((long double));
extern long lroundl _PARAMS((long double));
extern _LONG_LONG_TYPE int llroundl _PARAMS((long double));
@@ -452,11 +453,11 @@
/* Other long double precision functions. */
extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
extern long int lrintl _PARAMS((_LONG_DOUBLE));
-extern _LONG_LONG_TYPE llrintl _PARAMS((_LONG_DOUBLE));
+extern _LONG_LONG_TYPE int llrintl _PARAMS((_LONG_DOUBLE));
#endif /* __i386__ */
#endif /* !_LDBL_EQ_DBL */
-#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */
+#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) */
#if !defined (__STRICT_ANSI__) || defined(__cplusplus)
--- newlib/libc/include/stdlib.h 1 Aug 2014 15:44:50 -0000 1.51
+++ newlib/libc/include/stdlib.h 9 Sep 2014 17:37:27 -0000
@@ -130,7 +130,9 @@
_VOID _EXFUN(srand,(unsigned __seed));
double _EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR));
double _EXFUN(_strtod_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR));
-#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
+#if !defined(__STRICT_ANSI__) || \
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+ (defined(__cplusplus) && __cplusplus >= 201103L)
float _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR));
#endif
#ifndef __STRICT_ANSI__
@@ -189,18 +191,28 @@
_EXFUN(_seed48_r,(struct _reent *, unsigned short [3]));
_VOID _EXFUN(srand48,(long));
_VOID _EXFUN(_srand48_r,(struct _reent *, long));
+#endif /* ! __STRICT_ANSI__ */
+#if !defined(__STRICT_ANSI__) || \
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+ (defined(__cplusplus) && __cplusplus >= 201103L)
long long _EXFUN(atoll,(const char *__nptr));
+#endif
+#ifndef __STRICT_ANSI__
long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr));
+#endif /* ! __STRICT_ANSI__ */
+#if !defined(__STRICT_ANSI__) || \
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+ (defined(__cplusplus) && __cplusplus >= 201103L)
long long _EXFUN(llabs,(long long));
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
-#endif /* ! __STRICT_ANSI__ */
-#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
#ifndef __STRICT_ANSI__
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif /* ! __STRICT_ANSI__ */
-#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
+#if !defined(__STRICT_ANSI__) || \
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+ (defined(__cplusplus) && __cplusplus >= 201103L)
unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
#ifndef __STRICT_ANSI__
@@ -232,7 +244,9 @@
/* On platforms where long double equals double. */
#ifdef _HAVE_LONG_DOUBLE
-#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
+#if !defined(__STRICT_ANSI__) || \
+ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+ (defined(__cplusplus) && __cplusplus >= 201103L)
extern long double strtold (const char *__restrict, char **__restrict);
#endif
#endif /* _HAVE_LONG_DOUBLE */