kbuild/use-alloca.patch

149 lines
4.5 KiB
Diff

--- src/kmk/glob/glob.c.orig 2018-02-20 10:56:04.477559710 +0100
+++ src/kmk/glob/glob.c 2018-02-20 10:56:51.498370508 +0100
@@ -209,8 +209,7 @@
#endif /* __GNU_LIBRARY__ || __DJGPP__ */
-#if !defined __alloca && !defined __GNU_LIBRARY__
-
+#if !defined alloca
# ifdef __GNUC__
# undef alloca
# define alloca(n) __builtin_alloca (n)
@@ -227,9 +226,6 @@
# endif /* Not _AIX. */
# endif /* sparc or HAVE_ALLOCA_H. */
# endif /* GCC. */
-
-# define __alloca alloca
-
#endif
#ifndef __GNU_LIBRARY__
@@ -558,7 +554,7 @@
char *drive_spec;
++dirlen;
- drive_spec = (char *) __alloca (dirlen + 1);
+ drive_spec = (char *) alloca (dirlen + 1);
#ifdef HAVE_MEMPCPY
*((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0';
#else
@@ -574,7 +570,7 @@
from "d:/", since "d:" and "d:/" are not the same.*/
}
#endif
- newp = (char *) __alloca (dirlen + 1);
+ newp = (char *) alloca (dirlen + 1);
#ifdef HAVE_MEMPCPY
*((char *) mempcpy (newp, pattern, dirlen)) = '\0';
#else
@@ -645,7 +641,7 @@
/* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try
a moderate value. */
buflen = 20;
- name = (char *) __alloca (buflen);
+ name = (char *) alloca (buflen);
success = getlogin_r (name, buflen) >= 0;
# else
@@ -664,7 +660,7 @@
/* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.
Try a moderate value. */
pwbuflen = 1024;
- pwtmpbuf = (char *) __alloca (pwbuflen);
+ pwtmpbuf = (char *) alloca (pwbuflen);
while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)
!= 0)
@@ -675,7 +671,7 @@
break;
}
pwbuflen *= 2;
- pwtmpbuf = (char *) __alloca (pwbuflen);
+ pwtmpbuf = (char *) alloca (pwbuflen);
__set_errno (save);
}
# else
@@ -702,7 +698,7 @@
{
char *newp;
size_t home_len = strlen (home_dir);
- newp = (char *) __alloca (home_len + dirlen);
+ newp = (char *) alloca (home_len + dirlen);
# ifdef HAVE_MEMPCPY
mempcpy (mempcpy (newp, home_dir, home_len),
&dirname[1], dirlen);
@@ -725,7 +721,7 @@
else
{
char *newp;
- newp = (char *) __alloca (end_name - dirname);
+ newp = (char *) alloca (end_name - dirname);
# ifdef HAVE_MEMPCPY
*((char *) mempcpy (newp, dirname + 1, end_name - dirname))
= '\0';
@@ -749,7 +745,7 @@
/* `sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a
moderate value. */
buflen = 1024;
- pwtmpbuf = (char *) __alloca (buflen);
+ pwtmpbuf = (char *) alloca (buflen);
while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0)
{
@@ -759,7 +755,7 @@
break;
}
buflen *= 2;
- pwtmpbuf = __alloca (buflen);
+ pwtmpbuf = alloca (buflen);
__set_errno (save);
}
# else
@@ -776,7 +772,7 @@
char *newp;
size_t home_len = strlen (home_dir);
size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
- newp = (char *) __alloca (home_len + rest_len + 1);
+ newp = (char *) alloca (home_len + rest_len + 1);
# ifdef HAVE_MEMPCPY
*((char *) mempcpy (mempcpy (newp, home_dir, home_len),
end_name, rest_len)) = '\0';
@@ -1268,7 +1264,7 @@
struct stat st;
size_t patlen = strlen (pattern);
size_t dirlen = strlen (directory);
- char *fullname = (char *) __alloca (dirlen + 1 + patlen + 1);
+ char *fullname = (char *) alloca (dirlen + 1 + patlen + 1);
# ifdef HAVE_MEMPCPY
mempcpy (mempcpy (mempcpy (fullname, directory, dirlen),
@@ -1299,7 +1295,7 @@
{
/* This is a special case for matching directories like in
"*a/". */
- names = (struct globlink *) __alloca (sizeof (struct globlink));
+ names = (struct globlink *) alloca (sizeof (struct globlink));
names->name = (char *) malloc (1);
if (names->name == NULL)
goto memory_error;
@@ -1358,7 +1354,7 @@
if (fnmatch (pattern, name, fnm_flags) == 0)
{
struct globlink *new = (struct globlink *)
- __alloca (sizeof (struct globlink));
+ alloca (sizeof (struct globlink));
len = NAMLEN (d);
new->name = (char *) malloc (len + 1);
if (new->name == NULL)
@@ -1383,7 +1379,7 @@
{
size_t len = strlen (pattern);
nfound = 1;
- names = (struct globlink *) __alloca (sizeof (struct globlink));
+ names = (struct globlink *) alloca (sizeof (struct globlink));
names->next = NULL;
names->name = (char *) malloc (len + 1);
if (names->name == NULL)