diff options
author | Simon Josefsson <simon@josefsson.org> | 2011-08-03 01:16:03 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2011-08-03 01:54:47 +0200 |
commit | ae155d81b9b0282e1fe2fdfc18f3bfa3ec6a5074 (patch) | |
tree | e66003dc5af9746fbe3b652414362cc704bc6de8 /gl/alloca.c | |
parent | 5ca16d756ababb14e31d09ac4f1c1514de2ff5b9 (diff) | |
download | gnutls-ae155d81b9b0282e1fe2fdfc18f3bfa3ec6a5074.tar.gz |
Update gnulib files. Fix syntax-check usage.
Diffstat (limited to 'gl/alloca.c')
-rw-r--r-- | gl/alloca.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/gl/alloca.c b/gl/alloca.c index 771c2faa34..06b12a7bff 100644 --- a/gl/alloca.c +++ b/gl/alloca.c @@ -93,25 +93,15 @@ long i00afunc (); static int stack_dir; /* 1 or -1 once known. */ # define STACK_DIR stack_dir -static void -find_stack_direction (char **ptr) +static int +find_stack_direction (int *addr, int depth) { - auto char dummy; /* To get stack address. */ - - if (*ptr == NULL) - { /* Initial entry. */ - *ptr = ADDRESS_FUNCTION (dummy); - - find_stack_direction (ptr); /* Recurse once. */ - } - else - { - /* Second entry. */ - if (ADDRESS_FUNCTION (dummy) > *ptr) - stack_dir = 1; /* Stack grew upward. */ - else - stack_dir = -1; /* Stack grew downward. */ - } + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; } # endif /* STACK_DIRECTION == 0 */ @@ -154,10 +144,7 @@ alloca (size_t size) # if STACK_DIRECTION == 0 if (STACK_DIR == 0) /* Unknown growth direction. */ - { - char *addr = NULL; /* Address of first `dummy', once known. */ - find_stack_direction (&addr); - } + STACK_DIR = find_stack_direction (NULL, (size & 1) + 20); # endif /* Reclaim garbage, defined as all alloca'd storage that |