[patch, libgfortran] Some more transformational intrinsic speedups
FX
fxcoudert@gmail.com
Tue Apr 8 15:11:00 GMT 2008
> This can probably be adapted.
Index: configure.ac
===================================================================
--- configure.ac (revision 132845)
+++ configure.ac (working copy)
@@ -210,7 +210,7 @@ AC_CHECK_FUNCS(gettimeofday stat fstat l
AC_CHECK_FUNCS(backtrace backtrace_symbols)
# Check for types
-AC_CHECK_TYPES([intptr_t])
+AC_CHECK_TYPES([intptr_t uintptr_t])
# Check libc for getgid, getpid, getuid
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes
getgid])])
Index: libgfortran.h
===================================================================
--- libgfortran.h (revision 132845)
+++ libgfortran.h (working copy)
@@ -70,6 +70,38 @@ typedef off_t gfc_offset;
#endif
+/* We use intptr_t and uintptr_t, which may not be always defined in
+ system headers. */
+
+#ifndef HAVE_INTPTR_T
+#if __SIZEOF_POINTER__ == __SIZEOF_LONG__
+#define intptr_t long;
+#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
+#define intptr_t long long;
+#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
+#define intptr_t int;
+#elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
+#define intptr_t short;
+#else
+#error "Pointer type with unexpected size"
+#endif
+#endif
+
+#ifndef HAVE_UINTPTR_T
+#if __SIZEOF_POINTER__ == __SIZEOF_LONG__
+#define uintptr_t unsigned long;
+#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
+#define uintptr_t unsigned long long;
+#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
+#define uintptr_t unsigned int;
+#elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
+#define uintptr_t unsigned short;
+#else
+#error "Pointer type with unexpected size"
+#endif
+#endif
+
+
/* On mingw, work around the buggy Windows snprintf() by using the one
mingw provides, __mingw_snprintf(). We also provide a prototype for
__mingw_snprintf(), because the mingw headers currently don't have one. */
Index: runtime/backtrace.c
===================================================================
--- runtime/backtrace.c (revision 132845)
+++ runtime/backtrace.c (working copy)
@@ -43,12 +43,6 @@ Boston, MA 02110-1301, USA. */
#include <unistd.h>
#endif
-#ifdef HAVE_INTPTR_T
-# define INTPTR_T intptr_t
-#else
-# define INTPTR_T int
-#endif
-
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
@@ -158,7 +152,7 @@ show_backtrace (void)
/* Write the list of addresses in hexadecimal format. */
for (i = 0; i < depth; i++)
- addr[i] = xtoa ((GFC_UINTEGER_LARGEST) (INTPTR_T) trace[i], addr_buf[i],
+ addr[i] = xtoa ((GFC_UINTEGER_LARGEST) (intptr_t) trace[i], addr_buf[i],
sizeof (addr_buf[i]));
/* Don't output an error message if something goes wrong, we'll simply
Index: intrinsics/signal.c
===================================================================
--- intrinsics/signal.c (revision 132845)
+++ intrinsics/signal.c (working copy)
@@ -44,12 +44,6 @@ Boston, MA 02110-1301, USA. */
#include <errno.h>
-#ifdef HAVE_INTPTR_T
-# define INTPTR_T intptr_t
-#else
-# define INTPTR_T int
-#endif
-
/* SIGNAL subroutine with PROCEDURE as handler */
extern void signal_sub (int *, void (*)(int), int *);
iexport_proto(signal_sub);
@@ -58,11 +52,11 @@ void
signal_sub (int *number, void (*handler)(int), int *status)
{
#ifdef HAVE_SIGNAL
- INTPTR_T ret;
+ intptr_t ret;
if (status != NULL)
{
- ret = (INTPTR_T) signal (*number, handler);
+ ret = (intptr_t) signal (*number, handler);
*status = (int) ret;
}
else
@@ -84,11 +78,11 @@ void
signal_sub_int (int *number, int *handler, int *status)
{
#ifdef HAVE_SIGNAL
- INTPTR_T ptr = *handler, ret;
+ intptr_t ptr = *handler, ret;
if (status != NULL)
{
- ret = (INTPTR_T) signal (*number, (void (*)(int)) ptr);
+ ret = (intptr_t) signal (*number, (void (*)(int)) ptr);
*status = (int) ret;
}
else
@@ -204,14 +198,14 @@ alarm_sub_int_i4 (int *seconds __attribu
#if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
if (status != NULL)
{
- if (signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler) == SIG_ERR)
+ if (signal (SIGALRM, (void (*)(int)) (intptr_t) *handler) == SIG_ERR)
*status = -1;
else
*status = alarm (*seconds);
}
else
{
- signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler);
+ signal (SIGALRM, (void (*)(int)) (intptr_t) *handler);
alarm (*seconds);
}
#else
@@ -234,14 +228,14 @@ alarm_sub_int_i8 (int *seconds __attribu
#if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
if (status != NULL)
{
- if (signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler) == SIG_ERR)
+ if (signal (SIGALRM, (void (*)(int)) (intptr_t) *handler) == SIG_ERR)
*status = -1;
else
*status = alarm (*seconds);
}
else
{
- signal (SIGALRM, (void (*)(int)) (INTPTR_T) *handler);
+ signal (SIGALRM, (void (*)(int)) (intptr_t) *handler);
alarm (*seconds);
}
#else
--
FX Coudert
http://www.homepages.ucl.ac.uk/~uccafco/
More information about the Fortran
mailing list