/* More subroutines needed by GCC output code on some machines. */
/* Compile this one with gcc. */
/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+ 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
GCC 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, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
version.
-In addition to the permissions in the GNU General Public License, the
-Free Software Foundation gives you unlimited permission to link the
-compiled version of this file into combinations with other programs,
-and to distribute those combinations without any restriction coming
-from the use of this file. (The General Public License restrictions
-do apply in other respects; for example, they cover modification of
-the file, and distribution when not linked into a combine
-executable.)
-
GCC 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 GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA. */
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
#include "tconfig.h"
#include "tsystem.h"
#define ATTRIBUTE_HIDDEN
#endif
-#ifndef MIN_UNITS_PER_WORD
-#define MIN_UNITS_PER_WORD UNITS_PER_WORD
-#endif
-
/* Work out the largest "word" size that we can deal with on this target. */
#if MIN_UNITS_PER_WORD > 4
# define LIBGCC2_MAX_UNITS_PER_WORD 8
#elif (MIN_UNITS_PER_WORD > 2 \
- || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32))
+ || (MIN_UNITS_PER_WORD > 1 && __SIZEOF_LONG_LONG__ > 4))
# define LIBGCC2_MAX_UNITS_PER_WORD 4
#else
# define LIBGCC2_MAX_UNITS_PER_WORD MIN_UNITS_PER_WORD
return u;
const DWunion uu = {.ll = u};
- const shift_count_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+ const shift_count_type bm = W_TYPE_SIZE - b;
DWunion w;
if (bm <= 0)
return u;
const DWunion uu = {.ll = u};
- const shift_count_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+ const shift_count_type bm = W_TYPE_SIZE - b;
DWunion w;
if (bm <= 0)
return u;
const DWunion uu = {.ll = u};
- const shift_count_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+ const shift_count_type bm = W_TYPE_SIZE - b;
DWunion w;
if (bm <= 0)
{
/* w.s.high = 1..1 or 0..0 */
- w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
+ w.s.high = uu.s.high >> (W_TYPE_SIZE - 1);
w.s.low = uu.s.high >> -bm;
}
else
if (uu.s.low != 0)
word = uu.s.low, add = 0;
else if (uu.s.high != 0)
- word = uu.s.high, add = BITS_PER_UNIT * sizeof (Wtype);
+ word = uu.s.high, add = W_TYPE_SIZE;
else
return 0;
return ret + add;
}
#endif
+\f
+#ifdef L_clrsbsi2
+#undef int
+int
+__clrsbSI2 (Wtype x)
+{
+ Wtype ret;
+ if (x < 0)
+ x = ~x;
+ if (x == 0)
+ return W_TYPE_SIZE - 1;
+ count_leading_zeros (ret, x);
+ return ret - 1;
+}
+#endif
+\f
+#ifdef L_clrsbdi2
+#undef int
+int
+__clrsbDI2 (DWtype x)
+{
+ const DWunion uu = {.ll = x};
+ UWtype word;
+ Wtype ret, add;
+
+ if (uu.s.high == 0)
+ word = uu.s.low, add = W_TYPE_SIZE;
+ else if (uu.s.high == -1)
+ word = ~uu.s.low, add = W_TYPE_SIZE;
+ else if (uu.s.high >= 0)
+ word = uu.s.high, add = 0;
+ else
+ word = ~uu.s.high, add = 0;
+
+ if (word == 0)
+ ret = W_TYPE_SIZE;
+ else
+ count_leading_zeros (ret, word);
+
+ return ret + add - 1;
+}
+#endif
+\f
#ifdef L_popcount_tab
const UQItype __popcount_tab[256] =
{
#define isfinite(x) __builtin_expect (!isnan((x) - (x)), 1)
#define isinf(x) __builtin_expect (!isnan(x) & !isfinite(x), 0)
-#define INFINITY CONCAT2(__builtin_inf, CEXT) ()
+#define INFINITY CONCAT2(__builtin_huge_val, CEXT) ()
#define I 1i
/* Helpers to make the following code slightly less gross. */
#endif /* L_clear_cache */
\f
-#ifdef L_enable_execute_stack
-/* Attempt to turn on execute permission for the stack. */
-
-#ifdef ENABLE_EXECUTE_STACK
- ENABLE_EXECUTE_STACK
-#else
-void
-__enable_execute_stack (void *addr __attribute__((__unused__)))
-{}
-#endif /* ENABLE_EXECUTE_STACK */
-
-#endif /* L_enable_execute_stack */
-\f
#ifdef L_trampoline
/* Jump to a trampoline, loading the static chain address. */
#if defined(WINNT) && ! defined(__CYGWIN__)
+#include <windows.h>
+int getpagesize (void);
+int mprotect (char *,int, int);
int
getpagesize (void)
int
mprotect (char *addr, int len, int prot)
{
- int np, op;
+ DWORD np, op;
if (prot == 7)
np = 0x40;
np = 0x02;
else if (prot == 0)
np = 0x01;
+ else
+ return -1;
if (VirtualProtect (addr, len, np, &op))
return 0;