diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-17 18:48:45 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-17 18:48:45 +0000 |
commit | add62f6afea7118bc01b8ca9dfabf1062fb65031 (patch) | |
tree | d0168824c3517b671ef6a4c4bbf09f335edd2800 /include | |
parent | 10b4496ae30845cc3fd784538f35424af952ee8b (diff) | |
download | gcc-add62f6afea7118bc01b8ca9dfabf1062fb65031.tar.gz |
include:
* libiberty.h (ASTRDUP): New macro.
libiberty_optr, libiberty_nptr, libiberty_len): Declare.
libiberty:
* alloca.c (libiberty_optr, libiberty_nptr, libiberty_len):
Define.
gcc:
* c-aux-info.c (affix_data_type): Use ASTRDUP in lieu of
alloca/strcpy.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45657 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'include')
-rw-r--r-- | include/ChangeLog | 5 | ||||
-rw-r--r-- | include/libiberty.h | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog index 81d2cc2c7b5..d745a289647 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2001-09-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * libiberty.h (ASTRDUP): New macro. + libiberty_optr, libiberty_nptr, libiberty_len): Declare. + 2001-08-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * ansidecl.h: Update comments reflecting previous change. diff --git a/include/libiberty.h b/include/libiberty.h index 8d46e375e3a..7220ec0643c 100644 --- a/include/libiberty.h +++ b/include/libiberty.h @@ -246,12 +246,25 @@ extern PTR C_alloca PARAMS((size_t)); #if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA # define alloca(x) __builtin_alloca(x) # undef C_ALLOCA +# define ASTRDUP(X) \ + (__extension__ ({ const char *const libiberty_optr = (X); \ + const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \ + char *const libiberty_nptr = alloca (libiberty_len); \ + (char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); })) #else # define alloca(x) C_alloca(x) # undef USE_C_ALLOCA # define USE_C_ALLOCA 1 # undef C_ALLOCA # define C_ALLOCA 1 +extern const char *libiberty_optr; +extern char *libiberty_nptr; +extern unsigned long libiberty_len; +# define ASTRDUP(X) \ + (libiberty_optr = (X), \ + libiberty_len = strlen (libiberty_optr) + 1, \ + libiberty_nptr = alloca (libiberty_len), \ + (char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len)) #endif #ifdef __cplusplus |