aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-01-29 15:36:26 +0000
committerUlrich Drepper <drepper@redhat.com>2009-01-29 15:36:26 +0000
commit647925b260ed00034b0ca8c7598c92f6d28a3e99 (patch)
treeceb837592a955c2f101fa56bcf9fbf417ab969f5
parentfd537e535fe9f4d2b0286cf7a7242ef1e6775e67 (diff)
downloadglibc-647925b260ed00034b0ca8c7598c92f6d28a3e99.tar
glibc-647925b260ed00034b0ca8c7598c92f6d28a3e99.tar.gz
glibc-647925b260ed00034b0ca8c7598c92f6d28a3e99.tar.bz2
glibc-647925b260ed00034b0ca8c7598c92f6d28a3e99.zip
* sysdeps/i386/stackinfo.h (stackinfo_get_sp): Define.
(stackinfo_sub_sp): Define.
-rw-r--r--ChangeLog5
-rw-r--r--include/alloca.h4
-rw-r--r--sysdeps/i386/stackinfo.h12
3 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 36d09f734c..eada0c52a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/stackinfo.h (stackinfo_get_sp): Define.
+ (stackinfo_sub_sp): Define.
+
2009-01-28 Ulrich Drepper <drepper@redhat.com>
[BZ #9750]
diff --git a/include/alloca.h b/include/alloca.h
index 7d243fd4ac..9a4b5c7da0 100644
--- a/include/alloca.h
+++ b/include/alloca.h
@@ -55,8 +55,8 @@ extern int __libc_alloca_cutoff (size_t size) __attribute__ ((const));
#else
# define alloca_account(size, avar) \
({ size_t s__ = (size); \
- avar += size__; \
- __alloca (size__); })
+ avar += s__; \
+ __alloca (s__); })
#endif
#endif
diff --git a/sysdeps/i386/stackinfo.h b/sysdeps/i386/stackinfo.h
index a9a6745aaf..2530ea7234 100644
--- a/sysdeps/i386/stackinfo.h
+++ b/sysdeps/i386/stackinfo.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,4 +25,14 @@
/* On x86 the stack grows down. */
#define _STACK_GROWS_DOWN 1
+/* Access to the stack pointer. The macros are used in alloca_account
+ for which they need to act as barriers as well, hence the additional
+ (unnecessary) parameters. */
+#define stackinfo_get_sp() \
+ ({ void *p__; asm volatile ("mov %%esp, %0" : "=r" (p__)); p__; })
+#define stackinfo_sub_sp(ptr) \
+ ({ ptrdiff_t d__; \
+ asm volatile ("sub %%esp, %0" : "=r" (d__) : "0" (ptr)); \
+ d__; })
+
#endif /* stackinfo.h */