~ubuntu-branches/debian/sid/pari/sid

« back to all changes in this revision

Viewing changes to src/language/init.c

  • Committer: Package Import Robot
  • Author(s): Bill Allombert
  • Date: 2013-09-24 20:49:44 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20130924204944-3ddctn0k2mk1rpov
Tags: 2.5.5-1
* New upstream release
  - Fix detection of multiarch GMP.
* debian/control:
  - Bump Standards-Version to 3.9.4.
* debian/rules:
  - Add CPU mapping for s390x, sparc64 and ppc64

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
  ghalf  = (GEN)readonly_ghalf;
460
460
}
461
461
 
 
462
static const size_t MIN_STACK = 500032;
462
463
static size_t
463
464
fix_size(size_t a)
464
465
{
465
 
  size_t b = (a / sizeof(long)) * sizeof(long); /* Align */
466
 
  if (b < 1024) b = 1024;
 
466
  size_t b = a & (~0x3fUL); /* Align */
 
467
  if (b < MIN_STACK) b = MIN_STACK;
467
468
  return b;
468
469
}
469
470
/* old = current stack size (0 = unallocated), size = new size */
472
473
{
473
474
  size_t s = fix_size(size);
474
475
  if (old != s) {
 
476
    BLOCK_SIGINT_START;
475
477
    if (old) pari_free((void*)bot);
476
 
    BLOCK_SIGINT_START;
477
478
    for (;; s>>=1)
478
479
    {
479
480
      char buf[128];
 
481
      if (s < MIN_STACK) pari_err(memer); /* no way out. Die */
 
482
      s = fix_size(s);
480
483
      bot = (pari_sp)malloc(s); /* NOT pari_malloc, memer would be deadly */
481
484
      if (bot) break;
482
 
      if (!s) pari_err(memer); /* no way out. Die */
483
485
      /* must use sprintf: pari stack is currently dead */
484
486
      sprintf(buf, "not enough memory, new stack %lu", (ulong)s);
485
487
      pari_warn(warner, buf, s);