Changeset 1edbe2f in git for ppcc


Ignore:
Timestamp:
Feb 15, 2019, 11:51:03 AM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c5facdfddea2addfd91babd8b9019161dea4b695')
Children:
1a8dbfb80bfd40214596b9b7d6461ddaf34bbbb9
Parents:
73bf78cfb1c82e93496a5857586fa0b8ee97ecfa
Message:
format
Location:
ppcc
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • ppcc/.clang-format

    r73bf78 r1edbe2f  
    2121BinPackArguments: true
    2222BinPackParameters: true
    23 BraceWrapping:   
     23BraceWrapping:
    2424  AfterClass:      false
    2525  AfterControlStatement: false
     
    5656ExperimentalAutoDetectBinPacking: false
    5757FixNamespaceComments: false
    58 ForEachMacros:   
     58ForEachMacros:
    5959  - foreach
    6060  - Q_FOREACH
    6161  - BOOST_FOREACH
    62 IncludeCategories: 
     62IncludeCategories:
    6363  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
    6464    Priority:        2
     
    9090PenaltyReturnTypeOnItsOwnLine: 60
    9191PointerAlignment: Right
    92 RawStringFormats: 
     92RawStringFormats:
    9393  - Delimiter:       pb
    9494    Language:        TextProto
  • ppcc/Singular/include.patch

    r73bf78 r1edbe2f  
    44+++ b/Singular/libparse.cc
    55@@ -28,6 +28,8 @@
    6  
     6
    77 #include <stdio.h>
    8  
     8
    99+#include "globaldefs.h"
    1010+
    11  
     11
    1212 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
    1313 #ifdef c_plusplus
     
    1717+++ b/Singular/scanner.cc
    1818@@ -10,6 +10,7 @@
    19  
     19
    2020 #include <stdio.h>
    21  
     21
    2222+#include "globaldefs.h"
    23  
     23
    2424 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
    2525 #ifdef c_plusplus
     
    2929+++ b/Singular/svd_si.h
    3030@@ -13,6 +13,7 @@ See www.alglib.net or alglib.sources.ru for details.
    31  
     31
    3232 #include <stdlib.h>
    3333 #include <math.h>
     
    3535 #include "resources/feFopen.h"
    3636 #include "kernel/mod2.h"
    37  
     37
    3838diff --git a/factory/cf_defs.h b/factory/cf_defs.h
    3939index ba1645515..7ba0ffbd9 100644
     
    4343 #ifndef INCL_CF_DEFS_H
    4444 #define INCL_CF_DEFS_H
    45  
     45
    4646+#include "../Singular/globaldefs.h"
    4747 // #include "config.h"
    48  
     48
    4949 /*BEGINPUBLIC*/
    5050diff --git a/factory/cf_globals.h b/factory/cf_globals.h
     
    5555 #ifndef INCL_CF_GLOBALS_H
    5656 #define INCL_CF_GLOBALS_H
    57  
     57
    5858+#include "../Singular/globaldefs.h"
    5959+
     
    6767@@ -14,8 +14,8 @@
    6868 #include "config.h"
    69  
    70  
     69
     70
    7171-#include "cf_switches.h"
    7272 #include "cf_defs.h"
    7373+#include "cf_switches.h"
    74  
     74
    7575 /** CFSwitches::CFSwitches ()
    7676  *
     
    8181@@ -12,6 +12,7 @@
    8282 **/
    83  
    84  
     83
     84
    8585+#include "../Singular/globaldefs.h"
    8686 #include "config.h"
    87  
    88  
     87
     88
    8989diff --git a/factory/debug.cc b/factory/debug.cc
    9090index 886ee6756..7509b83dc 100644
     
    9494 /* emacs edit mode for this file is -*- C++ -*- */
    9595+#include "../Singular/globaldefs.h"
    96  
     96
    9797 STATIC_VAR int deb_level = -1;
    9898 VAR char * deb_level_msg = (char *)"";
     
    104104 #ifndef GFANLIB_CIRCUITTABLEINT_H_
    105105 #define GFANLIB_CIRCUITTABLEINT_H_
    106  
     106
    107107+#include "../Singular/globaldefs.h"
    108108+
     
    117117 /* please include libpolysconfig.h exclusively via <misc/auxiliary.h> and before any other header */
    118118 #include "libpolysconfig.h"
    119  
     119
    120120+#include "../Singular/globaldefs.h"
    121121+
     
    130130+#include "misc/auxiliary.h"
    131131 #include "sirandom.h"
    132  
     132
    133133 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
    134134diff --git a/resources/feResource.h b/resources/feResource.h
     
    138138@@ -11,6 +11,7 @@
    139139 #endif
    140  
     140
    141141 #ifdef __cplusplus
    142142+#include "../Singular/globaldefs.h"
  • ppcc/Singular/stitch.patch

    r73bf78 r1edbe2f  
    66 #define MAX_BB_TYPES 256
    77 // #define BLACKBOX_DEVEL 1
    8  
     8
    99-static blackbox* blackboxTable[MAX_BB_TYPES];
    1010-static char *    blackboxName[MAX_BB_TYPES];
     
    2222-  int where=-1;
    2323-  if (MAX_BB_TYPES<=blackboxTableCnt)
    24 +  int where = -1;   
    25 +  for (int i=0;i<MAX_BB_TYPES;i++)     
     24+  int where = -1;
     25+  for (int i=0;i<MAX_BB_TYPES;i++)
    2626   {
    2727-    // second try, find empty slot from removed bb:
     
    6969 #endif
    7070@@ -1087,7 +1087,37 @@ int iiAddCprocTop(const char *libname, const char *procname, BOOLEAN pstatic,
    71  
     71
    7272 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
    7373 #ifdef HAVE_DYNAMIC_LOADING
     
    144144+++ b/Singular/tesths.cc
    145145@@ -36,6 +36,9 @@
    146  
    147  
     146
     147
    148148 extern int siInit(char *);
    149149+#ifdef PSINGULAR
    150150+GLOBAL_VAR char *global_argv0;
    151151+#endif
    152  
     152
    153153 int mmInit( void )
    154154 {
     
    156156   omInitRet_2_Info(argv[0]);
    157157   omInitGetBackTrace();
    158  
     158
    159159+#ifdef PSINGULAR
    160160+  global_argv0 = argv[0];
     
    182182+#endif
    183183 }
    184  
     184
    185185 void *dynl_sym(void *handle, const char *symbol)
  • ppcc/auto.def

    r73bf78 r1edbe2f  
    384384}
    385385
    386 make-config-header adlib/config-defs.h -auto USE_* 
     386make-config-header adlib/config-defs.h -auto USE_*
    387387make-template cnf/config.h.in adlib/config.h
    388388make-template cnf/Makefile.in Makefile
  • ppcc/autosetup/adlib.patch

    r73bf78 r1edbe2f  
    6565***************
    6666*** 505,511 ****
    67  
     67
    6868        # Build the command line
    6969        set cmdline {}
     
    7676*** 659,665 ****
    7777  }
    78  
     78
    7979  # Initialise some values from the environment or commandline or default settings
    8080! foreach i {LDFLAGS LIBS CPPFLAGS LINKFLAGS {CFLAGS "-g -O2"}} {
     
    8484--- 661,667 ----
    8585  }
    86  
     86
    8787  # Initialise some values from the environment or commandline or default settings
    8888! foreach i {LDFLAGS LIBS CPPFLAGS LINKFLAGS CFLAGS} {
     
    114114!       define CXX [find-an-executable [get-define cross]c++ [get-define cross]g++ false]
    115115  }
    116  
     116
    117117  # CXXFLAGS default to CFLAGS if not specified
    118118  define CXXFLAGS [get-env CXXFLAGS [get-define CFLAGS]]
    119  
     119
    120120  # May need a CC_FOR_BUILD, so look for one
    121121! define CC_FOR_BUILD [find-an-executable [get-env CC_FOR_BUILD ""] cc gcc false]
    122  
     122
    123123  if {[get-define CC] eq ""} {
    124124        user-error "Could not find a C compiler. Tried: [join $try ", "]"
     
    129129!       define CXX [find-an-executable [get-define cross]g++ [get-define cross]clang++ [get-define cross]c++ false]
    130130  }
    131  
     131
    132132  # CXXFLAGS default to CFLAGS if not specified
    133133  define CXXFLAGS [get-env CXXFLAGS [get-define CFLAGS]]
    134  
     134
    135135  # May need a CC_FOR_BUILD, so look for one
    136136! define CC_FOR_BUILD [find-an-executable [get-env CC_FOR_BUILD ""] gcc clang cc false]
    137  
     137
    138138  if {[get-define CC] eq ""} {
    139139        user-error "Could not find a C compiler. Tried: [join $try ", "]"
     
    142142  cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
    143143  set autosetup(cc-include-deps) {}
    144  
     144
    145145! msg-result "C compiler...[get-define CCACHE] [get-define CC] [get-define CFLAGS]"
    146146  if {[get-define CXX] ne "false"} {
     
    148148  }
    149149  msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
    150  
     150
    151151--- 713,721 ----
    152152  cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
    153153  set autosetup(cc-include-deps) {}
    154  
     154
    155155! msg-result "C compiler...[get-define CC] [get-define CFLAGS]"
    156156  if {[get-define CXX] ne "false"} {
     
    158158  }
    159159  msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
    160  
     160
  • ppcc/gclib/dlmalloc.c

    r73bf78 r1edbe2f  
    8282
    8383  Supported pointer representation:       4 or 8 bytes
    84   Supported size_t  representation:       4 or 8 bytes 
     84  Supported size_t  representation:       4 or 8 bytes
    8585       Note that size_t is allowed to be 4 bytes even if pointers are 8.
    8686       You can adjust this by defining INTERNAL_SIZE_T
     
    114114       minimal mmap unit); typically 4096 or 8192 bytes.
    115115
    116   Maximum allocated size:  4-byte size_t: 2^32 minus about two pages 
     116  Maximum allocated size:  4-byte size_t: 2^32 minus about two pages
    117117                           8-byte size_t: 2^64 minus about two pages
    118118
     
    148148
    149149  Compliance: I believe it is compliant with the 1997 Single Unix Specification
    150        (See http://www.opennc.org). Also SVID/XPG, ANSI C, and probably 
     150       (See http://www.opennc.org). Also SVID/XPG, ANSI C, and probably
    151151       others as well.
    152152
     
    175175    HAVE_MEMCPY                defined
    176176    USE_MEMCPY                 1 if HAVE_MEMCPY is defined
    177     HAVE_MMAP                  defined as 1 
     177    HAVE_MMAP                  defined as 1
    178178    MMAP_CLEARS                1
    179179    HAVE_MREMAP                0 unless linux defined
     
    202202
    203203    MORECORE                   sbrk
    204     MORECORE_CONTIGUOUS        1 
     204    MORECORE_CONTIGUOUS        1
    205205    MORECORE_CANNOT_TRIM       NOT defined
    206     MMAP_AS_MORECORE_SIZE      (1024 * 1024) 
     206    MMAP_AS_MORECORE_SIZE      (1024 * 1024)
    207207
    208208    Tuning options that are also dynamically changeable via mallopt:
     
    281281#else
    282282#define __STD_C     0
    283 #endif 
     283#endif
    284284#endif /*__STD_C*/
    285285
     
    448448/*
    449449  USE_DL_PREFIX will prefix all public routines with the string 'dl'.
    450   This is necessary when you only want to use this malloc in one part 
     450  This is necessary when you only want to use this malloc in one part
    451451  of a program, using your regular system malloc elsewhere.
    452452*/
     
    483483
    484484
    485 /* 
     485/*
    486486   Two-phase name translation.
    487487   All of the actual routines are given mangled names.
     
    552552  have memset and memcpy called. People report that the macro
    553553  versions are faster than libc versions on some systems.
    554  
     554
    555555  Even if USE_MEMCPY is set to 1, loops to copy/clear small chunks
    556556  (of <= 36 bytes) are manually unrolled in realloc and calloc.
     
    587587  malloc fails to be able to return memory, either because memory is
    588588  exhausted or because of illegal arguments.
    589  
    590   By default, sets errno if running on STD_C platform, else does nothing. 
     589
     590  By default, sets errno if running on STD_C platform, else does nothing.
    591591*/
    592592
     
    677677#define HAVE_MMAP 1
    678678
    679 /* 
     679/*
    680680   Standard unix mmap using /dev/zero clears memory so calloc doesn't
    681681   need to.
     
    693693
    694694
    695 /* 
     695/*
    696696   MMAP_AS_MORECORE_SIZE is the minimum mmap size argument to use if
    697697   sbrk fails, and mmap is used as a backup (which is done only if
     
    760760#    else
    761761#      ifdef WIN32 /* use supplied emulation of getpagesize */
    762 #        define malloc_getpagesize getpagesize() 
     762#        define malloc_getpagesize getpagesize()
    763763#      else
    764764#        ifndef LACKS_SYS_PARAM_H
     
    781781#                define malloc_getpagesize PAGESIZE
    782782#              else /* just guess */
    783 #                define malloc_getpagesize (4096) 
     783#                define malloc_getpagesize (4096)
    784784#              endif
    785785#            endif
     
    903903  Returns a pointer to a chunk of size n that contains the same data
    904904  as does chunk p up to the minimum of (n, p's size) bytes, or null
    905   if no space is available. 
     905  if no space is available.
    906906
    907907  The returned pointer may or may not be the same as p. The algorithm
     
    909909  equivalent of a malloc-copy-free sequence.
    910910
    911   If p is null, realloc is equivalent to malloc. 
     911  If p is null, realloc is equivalent to malloc.
    912912
    913913  If space is not available, realloc returns null, errno is set (if on
     
    980980  M_MXFAST          1         64         0-80  (0 disables fastbins)
    981981  M_TRIM_THRESHOLD -1         128*1024   any   (-1U disables trimming)
    982   M_TOP_PAD        -2         0          any 
     982  M_TOP_PAD        -2         0          any
    983983  M_MMAP_THRESHOLD -3         128*1024   any   (or 0 if no MMAP support)
    984984  M_MMAP_MAX       -4         65536      any   (0 disables use of mmap)
     
    995995  Returns (by copy) a struct containing various summary statistics:
    996996
    997   arena:     current total non-mmapped bytes allocated from system 
    998   ordblks:   the number of free chunks 
     997  arena:     current total non-mmapped bytes allocated from system
     998  ordblks:   the number of free chunks
    999999  smblks:    the number of fastbin blocks (i.e., small chunks that
    10001000               have been freed but not use resused or consolidated)
    1001   hblks:     current number of mmapped regions 
    1002   hblkhd:    total bytes held in mmapped regions 
     1001  hblks:     current number of mmapped regions
     1002  hblkhd:    total bytes held in mmapped regions
    10031003  usmblks:   the maximum total allocated space. This will be greater
    10041004                than current total if trimming has occurred.
    1005   fsmblks:   total bytes held in fastbin blocks 
     1005  fsmblks:   total bytes held in fastbin blocks
    10061006  uordblks:  current total allocated space (normal or mmapped)
    1007   fordblks:  total free space 
     1007  fordblks:  total free space
    10081008  keepcost:  the maximum number of bytes that could ideally be released
    10091009               back to system via malloc_trim. ("ideally" means that
     
    10111011
    10121012  Because these fields are ints, but internal bookkeeping may
    1013   be kept as longs, the reported values may wrap around zero and 
     1013  be kept as longs, the reported values may wrap around zero and
    10141014  thus be inaccurate.
    10151015*/
     
    10491049  space to represent elements.  (In this case though, you cannot
    10501050  independently free elements.)
    1051  
     1051
    10521052  independent_calloc simplifies and speeds up implementations of many
    10531053  kinds of pools.  It may also be useful when constructing large data
     
    10571057
    10581058  struct Node { int item; struct Node* next; };
    1059  
     1059
    10601060  struct Node* build_list() {
    10611061    struct Node** pool;
     
    10631063    if (n <= 0) return 0;
    10641064    pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0);
    1065     if (pool == 0) die(); 
    1066     // organize into a linked list... 
     1065    if (pool == 0) die();
     1066    // organize into a linked list...
    10671067    struct Node* first = pool[0];
    1068     for (i = 0; i < n-1; ++i) 
     1068    for (i = 0; i < n-1; ++i)
    10691069      pool[i]->next = pool[i+1];
    10701070    free(pool);     // Can now free the array (or not, if it is needed later)
     
    10991099  null, it returns a chunk representing an array with zero elements
    11001100  (which should be freed if not wanted).
    1101  
     1101
    11021102  Each element must be individually freed when it is no longer
    11031103  needed. If you'd like to instead be able to free all at once, you
    11041104  should instead use a single regular malloc, and assign pointers at
    1105   particular offsets in the aggregate space. (In this case though, you 
     1105  particular offsets in the aggregate space. (In this case though, you
    11061106  cannot independently free elements.)
    11071107
     
    11601160
    11611161  cfree is needed/defined on some systems that pair it with calloc,
    1162   for odd historical reasons (such as: cfree is used in example 
     1162  for odd historical reasons (such as: cfree is used in example
    11631163  code in the first edition of K&R).
    11641164*/
     
    11801180  locked between two used chunks, so they cannot be given back to
    11811181  the system.
    1182  
     1182
    11831183  The `pad' argument to malloc_trim represents the amount of free
    11841184  trailing space to leave untrimmed. If this argument is zero,
     
    11881188  future expected allocations without having to re-obtain memory
    11891189  from the system.
    1190  
     1190
    11911191  Malloc_trim returns 1 if it actually released any memory, else 0.
    11921192  On systems that do not support "negative sbrks", it will always
     
    12761276/* M_MXFAST is a standard SVID/XPG tuning option, usually listed in malloc.h */
    12771277#ifndef M_MXFAST
    1278 #define M_MXFAST            1   
     1278#define M_MXFAST            1
    12791279#endif
    12801280
     
    13261326
    13271327  The trim value It must be greater than page size to have any useful
    1328   effect.  To disable trimming completely, you can set to 
     1328  effect.  To disable trimming completely, you can set to
    13291329  (unsigned long)(-1)
    13301330
     
    13971397  Segregating space in this way has the benefits that:
    13981398
    1399    1. Mmapped space can ALWAYS be individually released back 
    1400       to the system, which helps keep the system level memory 
    1401       demands of a long-lived program low. 
     1399   1. Mmapped space can ALWAYS be individually released back
     1400      to the system, which helps keep the system level memory
     1401      demands of a long-lived program low.
    14021402   2. Mapped memory can never become `locked' between
    14031403      other chunks, as can happen with normally allocated chunks, which
     
    14571457#endif
    14581458
    1459 /* 
     1459/*
    14601460  ========================================================================
    14611461  To make a fully customizable malloc.h header file, cut everything
    1462   above this line, put into file malloc.h, edit to suit, and #include it 
     1462  above this line, put into file malloc.h, edit to suit, and #include it
    14631463  on the next line, as well as in programs that use this malloc.
    14641464  ========================================================================
     
    17121712#if USE_MEMCPY
    17131713
    1714 /* 
     1714/*
    17151715  Note: memcpy is ONLY invoked with non-overlapping regions,
    17161716  so the (usually slower) memmove is not needed.
     
    17771777#endif
    17781778
    1779 /* 
    1780    Nearly all versions of mmap support MAP_ANONYMOUS, 
     1779/*
     1780   Nearly all versions of mmap support MAP_ANONYMOUS,
    17811781   so the following is unlikely to be needed, but is
    17821782   supplied just in case.
     
    19351935
    19361936
    1937 /* 
     1937/*
    19381938   Check if a request is so large that it would wrap around zero when
    19391939   padded and aligned. To simplify some other code, the bound is made
     
    19431943#define REQUEST_OUT_OF_RANGE(req)                                 \
    19441944  ((unsigned long)(req) >=                                        \
    1945    (unsigned long)(INTERNAL_SIZE_T)(-2 * MINSIZE))   
     1945   (unsigned long)(INTERNAL_SIZE_T)(-2 * MINSIZE))
    19461946
    19471947/* pad request bytes into a usable size -- internal version */
     
    19591959    return 0;                                                     \
    19601960  }                                                               \
    1961   (sz) = request2size(req);                                             
     1961  (sz) = request2size(req);
    19621962
    19631963/*
     
    19791979#define chunk_is_mmapped(p) ((p)->size & IS_MMAPPED)
    19801980
    1981 /* 
    1982   Bits to mask off when extracting size 
     1981/*
     1982  Bits to mask off when extracting size
    19831983
    19841984  Note: IS_MMAPPED is intentionally not masked off from size field in
     
    20402040   All internal state is held in an instance of malloc_state defined
    20412041   below. There are no other static variables, except in two optional
    2042    cases: 
    2043    * If USE_MALLOC_LOCK is defined, the mALLOC_MUTEx declared above. 
     2042   cases:
     2043   * If USE_MALLOC_LOCK is defined, the mALLOC_MUTEx declared above.
    20442044   * If HAVE_MMAP is true, but mmap doesn't support
    20452045     MAP_ANONYMOUS, a dummy file descriptor for mmap.
     
    20702070    are just sequential. Keeping them in order almost never requires
    20712071    enough traversal to warrant using fancier ordered data
    2072     structures. 
     2072    structures.
    20732073
    20742074    Chunks of the same size are linked with the most
     
    20832083    But to conserve space and improve locality, we allocate
    20842084    only the fd/bk pointers of bins, and then use repositioning tricks
    2085     to treat these as the fields of a malloc_chunk*. 
     2085    to treat these as the fields of a malloc_chunk*.
    20862086*/
    20872087
     
    22212221    be consolidated with other free chunks. malloc_consolidate
    22222222    releases all chunks in fastbins and consolidates them with
    2223     other free chunks. 
     2223    other free chunks.
    22242224*/
    22252225
     
    22412241  compromise heuristic to only attempt consolidation if it is likely
    22422242  to lead to trimming. However, it is not dynamically tunable, since
    2243   consolidation reduces fragmentation surrounding loarge chunks even 
     2243  consolidation reduces fragmentation surrounding loarge chunks even
    22442244  if trimming is not used.
    22452245*/
     
    22482248
    22492249/*
    2250   Since the lowest 2 bits in max_fast don't matter in size comparisons, 
     2250  Since the lowest 2 bits in max_fast don't matter in size comparisons,
    22512251  they are used as flags.
    22522252*/
     
    22842284#define set_contiguous(M)      ((M)->max_fast &= ~NONCONTIGUOUS_BIT)
    22852285
    2286 /* 
    2287    Set value of max_fast. 
     2286/*
     2287   Set value of max_fast.
    22882288   Use impossibly small value if 0.
    22892289   Precondition: there are no existing fastbin chunks.
     
    23322332
    23332333  /* Cache malloc_getpagesize */
    2334   unsigned int     pagesize;   
     2334  unsigned int     pagesize;
    23352335
    23362336  /* Statistics */
     
    23442344typedef struct malloc_state *mstate;
    23452345
    2346 /* 
     2346/*
    23472347   There is exactly one instance of this struct in this malloc.
    23482348   If you are adapting this malloc in a way that does NOT use a static
     
    23582358   At most one "call" to get_malloc_state is made per invocation of
    23592359   the public versions of malloc and free, but other routines
    2360    that in turn invoke malloc and/or free may call more then once. 
     2360   that in turn invoke malloc and/or free may call more then once.
    23612361   Also, it is called in check* routines if DEBUG is set.
    23622362*/
     
    23822382  int     i;
    23832383  mbinptr bin;
    2384  
     2384
    23852385  /* Establish circular links for normal bins */
    2386   for (i = 1; i < NBINS; ++i) { 
     2386  for (i = 1; i < NBINS; ++i) {
    23872387    bin = bin_at(av,i);
    23882388    bin->fd = bin->bk = bin;
     
    24042404}
    24052405
    2406 /* 
     2406/*
    24072407   Other internal utilities operating on mstates
    24082408*/
     
    24642464
    24652465  if (!chunk_is_mmapped(p)) {
    2466    
     2466
    24672467    /* Has legal address ... */
    24682468    if (p != av->top) {
     
    24782478      assert(prev_inuse(p));
    24792479    }
    2480      
     2480
    24812481  }
    24822482  else {
     
    27202720        assert(idx == i);
    27212721        /* lists are sorted */
    2722         assert(p->bk == b || 
     2722        assert(p->bk == b ||
    27232723               (unsigned long)chunksize(p->bk) >= (unsigned long)chunksize(p));
    27242724      }
    27252725      /* chunk is followed by a legal chain of inuse chunks */
    27262726      for (q = next_chunk(p);
    2727            (q != av->top && inuse(q) && 
     2727           (q != av->top && inuse(q) &&
    27282728             (unsigned long)(chunksize(q)) >= MINSIZE);
    27292729           q = next_chunk(q))
     
    28172817
    28182818      mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
    2819      
     2819
    28202820      if (mm != (char*)(MORECORE_FAILURE)) {
    2821        
     2821
    28222822        /*
    28232823          The offset to the start of the mmapped region is stored
    28242824          in the prev_size field of the chunk. This allows us to adjust
    2825           returned start address to meet alignment requirements here 
     2825          returned start address to meet alignment requirements here
    28262826          and in memalign(), and still be able to compute proper
    28272827          address argument for later munmap in free() and realloc().
    28282828        */
    2829        
     2829
    28302830        front_misalign = (INTERNAL_SIZE_T)chunk2mem(mm) & MALLOC_ALIGN_MASK;
    28312831        if (front_misalign > 0) {
     
    28392839          set_head(p, size|IS_MMAPPED);
    28402840        }
    2841        
     2841
    28422842        /* update statistics */
    2843        
    2844         if (++av->n_mmaps > av->max_n_mmaps) 
     2843
     2844        if (++av->n_mmaps > av->max_n_mmaps)
    28452845          av->max_n_mmaps = av->n_mmaps;
    2846        
     2846
    28472847        sum = av->mmapped_mem += size;
    2848         if (sum > (unsigned long)(av->max_mmapped_mem)) 
     2848        if (sum > (unsigned long)(av->max_mmapped_mem))
    28492849          av->max_mmapped_mem = sum;
    28502850        sum += av->sbrked_mem;
    2851         if (sum > (unsigned long)(av->max_total_mem)) 
     2851        if (sum > (unsigned long)(av->max_total_mem))
    28522852          av->max_total_mem = sum;
    28532853
    28542854        check_chunk(p);
    2855        
     2855
    28562856        return chunk2mem(p);
    28572857      }
     
    28662866  old_end  = (char*)(chunk_at_offset(old_top, old_size));
    28672867
    2868   brk = snd_brk = (char*)(MORECORE_FAILURE); 
    2869 
    2870   /* 
     2868  brk = snd_brk = (char*)(MORECORE_FAILURE);
     2869
     2870  /*
    28712871     If not the first time through, we require old_size to be
    28722872     at least MINSIZE and to have prev_inuse set.
    28732873  */
    28742874
    2875   assert((old_top == initial_top(av) && old_size == 0) || 
     2875  assert((old_top == initial_top(av) && old_size == 0) ||
    28762876         ((unsigned long) (old_size) >= MINSIZE &&
    28772877          prev_inuse(old_top)));
     
    29132913  */
    29142914
    2915   if (size > 0) 
     2915  if (size > 0)
    29162916    brk = (char*)(MORECORE(size));
    29172917
     
    29402940
    29412941      brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
    2942      
     2942
    29432943      if (brk != (char*)(MORECORE_FAILURE)) {
    2944        
     2944
    29452945        /* We do not need, and cannot use, another sbrk call to find end */
    29462946        snd_brk = brk + size;
    2947        
    2948         /* 
    2949            Record that we no longer have a contiguous sbrk region. 
     2947
     2948        /*
     2949           Record that we no longer have a contiguous sbrk region.
    29502950           After the first time mmap is used as backup, we do not
    29512951           ever rely on contiguous space since this could incorrectly
     
    29642964      If MORECORE extends previous space, we can likewise extend top size.
    29652965    */
    2966    
     2966
    29672967    if (brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) {
    29682968      set_head(old_top, (size + old_size) | PREV_INUSE);
    29692969    }
    2970    
     2970
    29712971    /*
    29722972      Otherwise, make adjustments:
    2973      
     2973
    29742974      * If the first time through or noncontiguous, we need to call sbrk
    29752975        just to find out where the end of memory lies.
     
    29872987        which in turn causes future contiguous calls to page-align.
    29882988    */
    2989    
     2989
    29902990    else {
    29912991      front_misalign = 0;
     
    29932993      correction = 0;
    29942994      aligned_brk = brk;
    2995      
     2995
    29962996      /* handle contiguous cases */
    2997       if (contiguous(av)) { 
    2998        
     2997      if (contiguous(av)) {
     2998
    29992999        /* Guarantee alignment of first new chunk made from this space */
    30003000
     
    30133013          aligned_brk += correction;
    30143014        }
    3015        
     3015
    30163016        /*
    30173017          If this isn't adjacent to existing space, then we will not
    30183018          be able to merge with old_top space, so must add to 2nd request.
    30193019        */
    3020        
     3020
    30213021        correction += old_size;
    3022        
     3022
    30233023        /* Extend the end address to hit a page boundary */
    30243024        end_misalign = (INTERNAL_SIZE_T)(brk + size + correction);
    30253025        correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign;
    3026        
     3026
    30273027        assert(correction >= 0);
    30283028        snd_brk = (char*)(MORECORE(correction));
    3029        
     3029
    30303030        /*
    30313031          If can't allocate correction, try to at least find out current
    30323032          brk.  It might be enough to proceed without failing.
    3033          
     3033
    30343034          Note that if second sbrk did NOT fail, we assume that space
    30353035          is contiguous with first sbrk. This is a safe assumption unless
     
    30373037          occurred between our first and second calls.
    30383038        */
    3039        
     3039
    30403040        if (snd_brk == (char*)(MORECORE_FAILURE)) {
    30413041          correction = 0;
     
    30433043        }
    30443044      }
    3045      
     3045
    30463046      /* handle non-contiguous cases */
    3047       else { 
     3047      else {
    30483048        /* MORECORE/mmap must correctly align */
    30493049        assert(((unsigned long)chunk2mem(brk) & MALLOC_ALIGN_MASK) == 0);
    3050        
     3050
    30513051        /* Find out current end of memory */
    30523052        if (snd_brk == (char*)(MORECORE_FAILURE)) {
     
    30543054        }
    30553055      }
    3056      
     3056
    30573057      /* Adjust top based on results of second sbrk */
    30583058      if (snd_brk != (char*)(MORECORE_FAILURE)) {
     
    30603060        set_head(av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE);
    30613061        av->sbrked_mem += correction;
    3062      
     3062
    30633063        /*
    30643064          If not the first time through, we either have a
     
    30693069          two to make sizes and alignments work out.
    30703070        */
    3071    
     3071
    30723072        if (old_size != 0) {
    3073           /* 
     3073          /*
    30743074             Shrink old_top to insert fenceposts, keeping size a
    30753075             multiple of MALLOC_ALIGNMENT. We know there is at least
     
    30783078          old_size = (old_size - 3*SIZE_SZ) & ~MALLOC_ALIGN_MASK;
    30793079          set_head(old_top, old_size | PREV_INUSE);
    3080          
     3080
    30813081          /*
    30823082            Note that the following assignments completely overwrite
     
    30993099      }
    31003100    }
    3101    
     3101
    31023102    /* Update statistics */
    31033103    sum = av->sbrked_mem;
    31043104    if (sum > (unsigned long)(av->max_sbrked_mem))
    31053105      av->max_sbrked_mem = sum;
    3106    
     3106
    31073107    sum += av->mmapped_mem;
    31083108    if (sum > (unsigned long)(av->max_total_mem))
     
    31103110
    31113111    check_malloc_state();
    3112    
     3112
    31133113    /* finally, do the allocation */
    31143114    p = av->top;
    31153115    size = chunksize(p);
    3116    
     3116
    31173117    /* check that one of the above allocation paths succeeded */
    31183118    if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) {
     
    31573157  pagesz = av->pagesize;
    31583158  top_size = chunksize(av->top);
    3159  
     3159
    31603160  /* Release in pagesize units, keeping at least one page */
    31613161  extra = ((top_size - pad - MINSIZE + (pagesz-1)) / pagesz - 1) * pagesz;
    3162  
     3162
    31633163  if (extra > 0) {
    3164    
     3164
    31653165    /*
    31663166      Only proceed if end of memory is where we last set it.
     
    31693169    current_brk = (char*)(MORECORE(0));
    31703170    if (current_brk == (char*)(av->top) + top_size) {
    3171      
     3171
    31723172      /*
    31733173        Attempt to release memory. We ignore MORECORE return value,
     
    31793179        some downstream failure.)
    31803180      */
    3181      
     3181
    31823182      MORECORE(-extra);
    31833183      new_brk = (char*)(MORECORE(0));
    3184      
     3184
    31853185      if (new_brk != (char*)MORECORE_FAILURE) {
    31863186        released = (long)(current_brk - new_brk);
    3187        
     3187
    31883188        if (released != 0) {
    31893189          /* Success. Adjust top. */
     
    32473247  */
    32483248
    3249   if ((unsigned long)(nb) <= (unsigned long)(av->max_fast)) { 
     3249  if ((unsigned long)(nb) <= (unsigned long)(av->max_fast)) {
    32503250    fb = &(av->fastbins[(fastbin_index(nb))]);
    32513251    if ( (victim = *fb) != 0) {
     
    32763276        bin->bk = bck;
    32773277        bck->fd = bin;
    3278        
     3278
    32793279        check_malloced_chunk(victim, nb);
    32803280        return chunk2mem(victim);
     
    32833283  }
    32843284
    3285   /* 
     3285  /*
    32863286     If this is a large request, consolidate fastbins before continuing.
    32873287     While it might look excessive to kill all fastbins before
     
    32893289     fragmentation problems normally associated with fastbins.
    32903290     Also, in practice, programs tend to have runs of either small or
    3291      large requests, but less often mixtures, so consolidation is not 
     3291     large requests, but less often mixtures, so consolidation is not
    32923292     invoked all that often in most programs. And the programs that
    32933293     it is called frequently in otherwise tend to fragment.
     
    32963296  else {
    32973297    idx = largebin_index(nb);
    3298     if (have_fastchunks(av)) 
     3298    if (have_fastchunks(av))
    32993299      malloc_consolidate(av);
    33003300  }
     
    33123312    otherwise need to expand memory to service a "small" request.
    33133313  */
    3314    
    3315   for(;;) {   
    3316    
     3314
     3315  for(;;) {
     3316
    33173317    while ( (victim = unsorted_chunks(av)->bk) != unsorted_chunks(av)) {
    33183318      bck = victim->bk;
    33193319      size = chunksize(victim);
    33203320
    3321       /* 
     3321      /*
    33223322         If a small request, try to use last remainder if it is the
    33233323         only chunk in unsorted bin.  This helps promote locality for
     
    33273327      */
    33283328
    3329       if (in_smallbin_range(nb) && 
     3329      if (in_smallbin_range(nb) &&
    33303330          bck == unsorted_chunks(av) &&
    33313331          victim == av->last_remainder &&
     
    33363336        remainder = chunk_at_offset(victim, nb);
    33373337        unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder;
    3338         av->last_remainder = remainder; 
     3338        av->last_remainder = remainder;
    33393339        remainder->bk = remainder->fd = unsorted_chunks(av);
    3340        
     3340
    33413341        set_head(victim, nb | PREV_INUSE);
    33423342        set_head(remainder, remainder_size | PREV_INUSE);
    33433343        set_foot(remainder, remainder_size);
    3344        
     3344
    33453345        check_malloced_chunk(victim, nb);
    33463346        return chunk2mem(victim);
     
    33503350      unsorted_chunks(av)->bk = bck;
    33513351      bck->fd = unsorted_chunks(av);
    3352      
     3352
    33533353      /* Take now instead of binning if exact fit */
    3354      
     3354
    33553355      if (size == nb) {
    33563356        set_inuse_bit_at_offset(victim, size);
     
    33583358        return chunk2mem(victim);
    33593359      }
    3360      
     3360
    33613361      /* place chunk in bin */
    3362      
     3362
    33633363      if (in_smallbin_range(size)) {
    33643364        victim_index = smallbin_index(size);
     
    33803380          }
    33813381          else {
    3382             while ((unsigned long)(size) < (unsigned long)(fwd->size)) 
     3382            while ((unsigned long)(size) < (unsigned long)(fwd->size))
    33833383              fwd = fwd->fd;
    33843384            bck = fwd->bk;
     
    33863386        }
    33873387      }
    3388      
     3388
    33893389      mark_bin(av, victim_index);
    33903390      victim->bk = bck;
     
    33933393      bck->fd = victim;
    33943394    }
    3395    
     3395
    33963396    /*
    33973397      If a large request, scan through the chunks of current bin in
     
    34003400      anything useful with them. However the lists tend to be short.
    34013401    */
    3402      
     3402
    34033403    if (!in_smallbin_range(nb)) {
    34043404      bin = bin_at(av, idx);
     
    34083408          (unsigned long)(first(bin)->size) >= (unsigned long)(nb)) {
    34093409
    3410         while (((unsigned long)(size = chunksize(victim)) < 
     3410        while (((unsigned long)(size = chunksize(victim)) <
    34113411                (unsigned long)(nb)))
    34123412          victim = victim->bk;
     
    34143414        remainder_size = size - nb;
    34153415        unlink(victim, bck, fwd);
    3416        
     3416
    34173417        /* Exhaust */
    34183418        if (remainder_size < MINSIZE)  {
     
    34313431          check_malloced_chunk(victim, nb);
    34323432          return chunk2mem(victim);
    3433         } 
     3433        }
    34343434      }
    3435     }   
     3435    }
    34363436
    34373437    /*
     
    34403440      (with ties going to approximately the least recently used) chunk
    34413441      that fits is selected.
    3442      
     3442
    34433443      The bitmap avoids needing to check that most blocks are nonempty.
    34443444      The particular case of skipping all bins during warm-up phases
    34453445      when no chunks have been returned yet is faster than it might look.
    34463446    */
    3447    
     3447
    34483448    ++idx;
    34493449    bin = bin_at(av,idx);
     
    34513451    map = av->binmap[block];
    34523452    bit = idx2bit(idx);
    3453    
     3453
    34543454    for (;;) {
    34553455
     
    34643464        bit = 1;
    34653465      }
    3466      
     3466
    34673467      /* Advance to bin with set bit. There must be one. */
    34683468      while ((bit & map) == 0) {
     
    34713471        assert(bit != 0);
    34723472      }
    3473      
     3473
    34743474      /* Inspect the bin. It is likely to be non-empty */
    34753475      victim = last(bin);
    3476      
     3476
    34773477      /*  If a false alarm (empty bin), clear the bit. */
    34783478      if (victim == bin) {
     
    34813481        bit <<= 1;
    34823482      }
    3483      
     3483
    34843484      else {
    34853485        size = chunksize(victim);
     
    34893489
    34903490        remainder_size = size - nb;
    3491        
     3491
    34923492        /* unlink */
    34933493        bck = victim->bk;
    34943494        bin->bk = bck;
    34953495        bck->fd = bin;
    3496        
     3496
    34973497        /* Exhaust */
    34983498        if (remainder_size < MINSIZE) {
     
    35013501          return chunk2mem(victim);
    35023502        }
    3503        
     3503
    35043504        /* Split */
    35053505        else {
    35063506          remainder = chunk_at_offset(victim, nb);
    3507          
     3507
    35083508          unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder;
    35093509          remainder->bk = remainder->fd = unsorted_chunks(av);
    35103510          /* advertise as last remainder */
    3511           if (in_smallbin_range(nb)) 
    3512             av->last_remainder = remainder; 
    3513          
     3511          if (in_smallbin_range(nb))
     3512            av->last_remainder = remainder;
     3513
    35143514          set_head(victim, nb | PREV_INUSE);
    35153515          set_head(remainder, remainder_size | PREV_INUSE);
     
    35213521    }
    35223522
    3523   use_top:   
     3523  use_top:
    35243524    /*
    35253525      If large enough, split off the chunk bordering the end of memory
     
    35393539    victim = av->top;
    35403540    size = chunksize(victim);
    3541    
     3541
    35423542    if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) {
    35433543      remainder_size = size - nb;
     
    35633563    }
    35643564
    3565     /* 
    3566        Otherwise, relay to handle system-dependent cases 
     3565    /*
     3566       Otherwise, relay to handle system-dependent cases
    35673567    */
    3568     else 
    3569       return sYSMALLOc(nb, av);   
     3568    else
     3569      return sYSMALLOc(nb, av);
    35703570  }
    35713571}
     
    36093609
    36103610#if TRIM_FASTBINS
    3611         /* 
     3611        /*
    36123612           If TRIM_FASTBINS set, don't place chunks
    36133613           bordering top into fastbins
     
    36653665        set_head(p, size | PREV_INUSE);
    36663666        set_foot(p, size);
    3667        
     3667
    36683668        check_free_chunk(p);
    36693669      }
     
    36943694      */
    36953695
    3696       if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) { 
    3697         if (have_fastchunks(av)) 
     3696      if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {
     3697        if (have_fastchunks(av))
    36983698          malloc_consolidate(av);
    36993699
    3700 #ifndef MORECORE_CANNOT_TRIM       
    3701         if ((unsigned long)(chunksize(av->top)) >= 
    3702             (unsigned long)(av->trim_threshold)) 
     3700#ifndef MORECORE_CANNOT_TRIM
     3701        if ((unsigned long)(chunksize(av->top)) >=
     3702            (unsigned long)(av->trim_threshold))
    37033703          sYSTRIm(av->top_pad, av);
    37043704#endif
     
    37363736  fastbins.  So, instead, we need to use a minor variant of the same
    37373737  code.
    3738  
     3738
    37393739  Also, because this routine needs to be called the first time through
    37403740  malloc anyway, it turns out to be the perfect place to trigger
     
    37813781      reused anyway.
    37823782    */
    3783    
     3783
    37843784    maxfb = &(av->fastbins[fastbin_index(av->max_fast)]);
    37853785    fb = &(av->fastbins[0]);
     
    37873787      if ( (p = *fb) != 0) {
    37883788        *fb = 0;
    3789        
     3789
    37903790        do {
    37913791          check_inuse_chunk(p);
    37923792          nextp = p->fd;
    3793          
     3793
    37943794          /* Slightly streamlined version of consolidation code in free() */
    37953795          size = p->size & ~PREV_INUSE;
    37963796          nextchunk = chunk_at_offset(p, size);
    37973797          nextsize = chunksize(nextchunk);
    3798          
     3798
    37993799          if (!prev_inuse(p)) {
    38003800            prevsize = p->prev_size;
     
    38033803            unlink(p, bck, fwd);
    38043804          }
    3805          
     3805
    38063806          if (nextchunk != av->top) {
    38073807            nextinuse = inuse_bit_at_offset(nextchunk, nextsize);
    38083808            set_head(nextchunk, nextsize);
    3809            
     3809
    38103810            if (!nextinuse) {
    38113811              size += nextsize;
    38123812              unlink(nextchunk, bck, fwd);
    38133813            }
    3814            
     3814
    38153815            first_unsorted = unsorted_bin->fd;
    38163816            unsorted_bin->fd = p;
    38173817            first_unsorted->bk = p;
    3818            
     3818
    38193819            set_head(p, size | PREV_INUSE);
    38203820            p->bk = unsorted_bin;
     
    38223822            set_foot(p, size);
    38233823          }
    3824          
     3824
    38253825          else {
    38263826            size += nextsize;
     
    38283828            av->top = p;
    38293829          }
    3830          
     3830
    38313831        } while ( (p = nextp) != 0);
    3832        
     3832
    38333833      }
    38343834    } while (fb++ != maxfb);
     
    38723872  unsigned long    copysize;        /* bytes to copy */
    38733873  unsigned int     ncopies;         /* INTERNAL_SIZE_T words to copy */
    3874   INTERNAL_SIZE_T* s;               /* copy source */ 
     3874  INTERNAL_SIZE_T* s;               /* copy source */
    38753875  INTERNAL_SIZE_T* d;               /* copy destination */
    38763876
     
    39133913        return chunk2mem(oldp);
    39143914      }
    3915      
     3915
    39163916      /* Try to expand forward into next chunk;  split off remainder below */
    3917       else if (next != av->top && 
     3917      else if (next != av->top &&
    39183918               !inuse(next) &&
    39193919               (unsigned long)(newsize = oldsize + chunksize(next)) >=
     
    39283928        if (newmem == 0)
    39293929          return 0; /* propagate failure */
    3930      
     3930
    39313931        newp = mem2chunk(newmem);
    39323932        newsize = chunksize(newp);
    3933        
     3933
    39343934        /*
    39353935          Avoid copy if newp is next chunk after oldp.
     
    39453945            INTERNAL_SIZE_T-sized words; minimally 3.
    39463946          */
    3947          
     3947
    39483948          copysize = oldsize - SIZE_SZ;
    39493949          s = (INTERNAL_SIZE_T*)(oldmem);
     
    39513951          ncopies = copysize / sizeof(INTERNAL_SIZE_T);
    39523952          assert(ncopies >= 3);
    3953          
     3953
    39543954          if (ncopies > 9)
    39553955            MALLOC_COPY(d, s, copysize);
    3956          
     3956
    39573957          else {
    39583958            *(d+0) = *(s+0);
     
    39723972            }
    39733973          }
    3974          
     3974
    39753975          fREe(oldmem);
    39763976          check_inuse_chunk(newp);
     
    39963996      /* Mark remainder as inuse so free() won't complain */
    39973997      set_inuse_bit_at_offset(remainder, remainder_size);
    3998       fREe(chunk2mem(remainder)); 
     3998      fREe(chunk2mem(remainder));
    39993999    }
    40004000
     
    40154015    char *cp;
    40164016    unsigned long sum;
    4017    
     4017
    40184018    /* Note the extra SIZE_SZ overhead */
    40194019    newsize = (nb + offset + SIZE_SZ + pagemask) & ~pagemask;
    40204020
    40214021    /* don't need to remap if still within same page */
    4022     if (oldsize == newsize - offset) 
     4022    if (oldsize == newsize - offset)
    40234023      return oldmem;
    40244024
    40254025    cp = (char*)mremap((char*)oldp - offset, oldsize + offset, newsize, 1);
    4026    
     4026
    40274027    if (cp != (char*)MORECORE_FAILURE) {
    40284028
    40294029      newp = (mchunkptr)(cp + offset);
    40304030      set_head(newp, (newsize - offset)|IS_MMAPPED);
    4031      
     4031
    40324032      assert(aligned_OK(chunk2mem(newp)));
    40334033      assert((newp->prev_size == offset));
    4034      
     4034
    40354035      /* update statistics */
    40364036      sum = av->mmapped_mem += newsize - oldsize;
    4037       if (sum > (unsigned long)(av->max_mmapped_mem)) 
     4037      if (sum > (unsigned long)(av->max_mmapped_mem))
    40384038        av->max_mmapped_mem = sum;
    40394039      sum += av->sbrked_mem;
    4040       if (sum > (unsigned long)(av->max_total_mem)) 
     4040      if (sum > (unsigned long)(av->max_total_mem))
    40414041        av->max_total_mem = sum;
    4042      
     4042
    40434043      return chunk2mem(newp);
    40444044    }
     
    40464046
    40474047    /* Note the extra SIZE_SZ overhead. */
    4048     if ((unsigned long)(oldsize) >= (unsigned long)(nb + SIZE_SZ)) 
     4048    if ((unsigned long)(oldsize) >= (unsigned long)(nb + SIZE_SZ))
    40494049      newmem = oldmem; /* do nothing */
    40504050    else {
     
    40584058    return newmem;
    40594059
    4060 #else 
     4060#else
    40614061    /* If !HAVE_MMAP, but chunk_is_mmapped, user must have overwritten mem */
    40624062    check_malloc_state();
     
    41954195    if (!chunk_is_mmapped(p)) /* don't need to clear mmapped space */
    41964196#endif
    4197     { 
     4197    {
    41984198      /*
    41994199        Unroll clear of <= 36 bytes (72 if 8byte sizes)
     
    42864286
    42874287#if __STD_C
    4288 static Void_t** iALLOc(size_t n_elements, 
    4289                        size_t* sizes, 
     4288static Void_t** iALLOc(size_t n_elements,
     4289                       size_t* sizes,
    42904290                       int opts,
    42914291                       Void_t* chunks[])
     
    43044304  mchunkptr       array_chunk;    /* chunk for malloced ptr array */
    43054305  int             mmx;            /* to disable mmap */
    4306   INTERNAL_SIZE_T size;           
     4306  INTERNAL_SIZE_T size;
    43074307  size_t          i;
    43084308
     
    43194319  else {
    43204320    /* if empty req, must still return chunk representing empty array */
    4321     if (n_elements == 0) 
     4321    if (n_elements == 0)
    43224322      return (Void_t**) mALLOc(0);
    43234323    marray = 0;
     
    43334333    element_size = 0;
    43344334    contents_size = 0;
    4335     for (i = 0; i != n_elements; ++i) 
    4336       contents_size += request2size(sizes[i]);     
     4335    for (i = 0; i != n_elements; ++i)
     4336      contents_size += request2size(sizes[i]);
    43374337  }
    43384338
    43394339  /* subtract out alignment bytes from total to minimize overallocation */
    43404340  size = contents_size + array_size - MALLOC_ALIGN_MASK;
    4341  
    4342   /* 
     4341
     4342  /*
    43434343     Allocate the aggregate chunk.
    43444344     But first disable mmap so malloc won't use it, since
     
    43504350  mem = mALLOc(size);
    43514351  av->n_mmaps_max = mmx;   /* reset mmap */
    4352   if (mem == 0) 
     4352  if (mem == 0)
    43534353    return 0;
    43544354
    43554355  p = mem2chunk(mem);
    4356   assert(!chunk_is_mmapped(p)); 
     4356  assert(!chunk_is_mmapped(p));
    43574357  remainder_size = chunksize(p);
    43584358
     
    43734373    marray[i] = chunk2mem(p);
    43744374    if (i != n_elements-1) {
    4375       if (element_size != 0) 
     4375      if (element_size != 0)
    43764376        size = element_size;
    43774377      else
    4378         size = request2size(sizes[i]);         
     4378        size = request2size(sizes[i]);
    43794379      remainder_size -= size;
    43804380      set_head(p, size | PREV_INUSE);
     
    43904390  if (marray != chunks) {
    43914391    /* final element must have exactly exhausted chunk */
    4392     if (element_size != 0) 
     4392    if (element_size != 0)
    43934393      assert(remainder_size == element_size);
    43944394    else
     
    44404440  return mEMALIGn(pagesz, (bytes + pagesz - 1) & ~(pagesz - 1));
    44414441}
    4442    
     4442
    44434443
    44444444/*
     
    44564456  malloc_consolidate(av);
    44574457
    4458 #ifndef MORECORE_CANNOT_TRIM       
     4458#ifndef MORECORE_CANNOT_TRIM
    44594459  return sYSTRIm(pad, av);
    44604460#else
     
    45574557    unsigned long free, reserved, committed;
    45584558    vminfo (&free, &reserved, &committed);
    4559     fprintf(stderr, "free bytes       = %10lu\n", 
     4559    fprintf(stderr, "free bytes       = %10lu\n",
    45604560            free);
    4561     fprintf(stderr, "reserved bytes   = %10lu\n", 
     4561    fprintf(stderr, "reserved bytes   = %10lu\n",
    45624562            reserved);
    4563     fprintf(stderr, "committed bytes  = %10lu\n", 
     4563    fprintf(stderr, "committed bytes  = %10lu\n",
    45644564            committed);
    45654565  }
     
    45754575
    45764576
    4577 #ifdef WIN32 
     4577#ifdef WIN32
    45784578  {
    45794579    unsigned long kernel, user;
    45804580    if (cpuinfo (TRUE, &kernel, &user)) {
    4581       fprintf(stderr, "kernel ms        = %10lu\n", 
     4581      fprintf(stderr, "kernel ms        = %10lu\n",
    45824582              kernel);
    4583       fprintf(stderr, "user ms          = %10lu\n", 
     4583      fprintf(stderr, "user ms          = %10lu\n",
    45844584              user);
    45854585    }
     
    46384638
    46394639
    4640 /* 
     4640/*
    46414641  -------------------- Alternative MORECORE functions --------------------
    46424642*/
     
    46534653      only be called with arguments that are multiples of pagesize.
    46544654
    4655     * MORECORE(0) must return an address that is at least 
     4655    * MORECORE(0) must return an address that is at least
    46564656      MALLOC_ALIGNMENT aligned. (Page-aligning always suffices.)
    46574657
     
    47774777
    47784778
    4779 /* 
    4780   -------------------------------------------------------------- 
    4781 
    4782   Emulation of sbrk for win32. 
     4779/*
     4780  --------------------------------------------------------------
     4781
     4782  Emulation of sbrk for win32.
    47834783  Donated by J. Walter <Walter@GeNeSys-e.de>.
    4784   For additional information about this code, and malloc on Win32, see 
     4784  For additional information about this code, and malloc on Win32, see
    47854785     http://www.genesys-e.de/jwalter/
    47864786*/
     
    47984798/* Wait for spin lock */
    47994799static int slwait (int *sl) {
    4800     while (InterlockedCompareExchange ((void **) sl, (void *) 1, (void *) 0) != 0) 
     4800    while (InterlockedCompareExchange ((void **) sl, (void *) 1, (void *) 0) != 0)
    48014801            Sleep (0);
    48024802    return 0;
     
    48984898    }
    48994899    if (! g_last) {
    4900         if (! region_list_append (&g_last, 0, 0)) 
     4900        if (! region_list_append (&g_last, 0, 0))
    49014901           goto sbrk_exit;
    49024902    }
     
    49654965                            assert ((unsigned) memory_info.BaseAddress % g_pagesize == 0);
    49664966#ifdef TRACE
    4967                             printf ("Query %p %d %s\n", memory_info.BaseAddress, memory_info.RegionSize, 
    4968                                     memory_info.State == MEM_FREE ? "FREE": 
     4967                            printf ("Query %p %d %s\n", memory_info.BaseAddress, memory_info.RegionSize,
     4968                                    memory_info.State == MEM_FREE ? "FREE":
    49694969                                    (memory_info.State == MEM_RESERVE ? "RESERVED":
    49704970                                     (memory_info.State == MEM_COMMIT ? "COMMITTED": "?")));
     
    49874987                        }
    49884988                        /* Search failed? */
    4989                         if (! found) 
     4989                        if (! found)
    49904990                            goto sbrk_exit;
    49914991                        /* Assert preconditions */
     
    49934993                        assert (0 < reserve_size && reserve_size % g_regionsize == 0);
    49944994                        /* Try to reserve this */
    4995                         base_reserved = VirtualAlloc (memory_info.BaseAddress, reserve_size, 
     4995                        base_reserved = VirtualAlloc (memory_info.BaseAddress, reserve_size,
    49964996                                                                          MEM_RESERVE, PAGE_NOACCESS);
    49974997                        if (! base_reserved) {
    49984998                            int rc = GetLastError ();
    4999                             if (rc != ERROR_INVALID_ADDRESS) 
     4999                            if (rc != ERROR_INVALID_ADDRESS)
    50005000                                goto sbrk_exit;
    50015001                        }
     
    50225022                        /* Round size to commit */
    50235023                        commit_size = CEIL (to_commit, g_my_pagesize);
    5024                     } 
     5024                    }
    50255025                    /* Append the new region to the list */
    50265026                    if (! region_list_append (&g_last, base_reserved, reserve_size))
     
    50345034                    }
    50355035                }
    5036             } 
     5036            }
    50375037            /* Assert preconditions */
    50385038            assert ((unsigned) g_last->top_committed % g_pagesize == 0);
    50395039            assert (0 < commit_size && commit_size % g_pagesize == 0); {
    50405040                /* Commit this */
    5041                 void *base_committed = VirtualAlloc (g_last->top_committed, commit_size, 
     5041                void *base_committed = VirtualAlloc (g_last->top_committed, commit_size,
    50425042                                                                             MEM_COMMIT, PAGE_READWRITE);
    50435043                /* Check returned pointer for consistency */
     
    50525052                g_last->top_committed = (char *) base_committed + commit_size;
    50535053            }
    5054         } 
     5054        }
    50555055        /* Adjust the regions allocation top */
    50565056        g_last->top_allocated = (char *) g_last->top_allocated + allocate_size;
     
    50665066            void *base_reserved = (char *) g_last->top_reserved - release_size;
    50675067            /* Assert preconditions */
    5068             assert ((unsigned) base_reserved % g_regionsize == 0); 
     5068            assert ((unsigned) base_reserved % g_regionsize == 0);
    50695069            assert (0 < release_size && release_size % g_regionsize == 0); {
    50705070                /* Release this */
    5071                 int rc = VirtualFree (base_reserved, 0, 
     5071                int rc = VirtualFree (base_reserved, 0,
    50725072                                      MEM_RELEASE);
    50735073                /* Check returned code for consistency */
     
    50955095                assert (0 < decommit_size && decommit_size % g_pagesize == 0); {
    50965096                    /* Decommit this */
    5097                     int rc = VirtualFree ((char *) base_committed, decommit_size, 
     5097                    int rc = VirtualFree ((char *) base_committed, decommit_size,
    50985098                                          MEM_DECOMMIT);
    50995099                    /* Check returned code for consistency */
     
    51515151#endif
    51525152    /* First time initialization */
    5153     if (! g_pagesize) 
     5153    if (! g_pagesize)
    51545154        g_pagesize = getpagesize ();
    5155     if (! g_regionsize) 
     5155    if (! g_regionsize)
    51565156        g_regionsize = getregionsize ();
    51575157    /* Assert preconditions */
     
    51915191#endif
    51925192    /* First time initialization */
    5193     if (! g_pagesize) 
     5193    if (! g_pagesize)
    51945194        g_pagesize = getpagesize ();
    5195     if (! g_regionsize) 
     5195    if (! g_regionsize)
    51965196        g_regionsize = getregionsize ();
    51975197    /* Assert preconditions */
     
    51995199    assert (size % g_pagesize == 0);
    52005200    /* Free this */
    5201     if (! VirtualFree (ptr, 0, 
     5201    if (! VirtualFree (ptr, 0,
    52025202                       MEM_RELEASE))
    52035203        goto munmap_exit;
     
    52375237    if (whole) {
    52385238        __int64 creation64, exit64, kernel64, user64;
    5239         int rc = GetProcessTimes (GetCurrentProcess (), 
    5240                                   (FILETIME *) &creation64, 
    5241                                   (FILETIME *) &exit64, 
    5242                                   (FILETIME *) &kernel64, 
     5239        int rc = GetProcessTimes (GetCurrentProcess (),
     5240                                  (FILETIME *) &creation64,
     5241                                  (FILETIME *) &exit64,
     5242                                  (FILETIME *) &kernel64,
    52435243                                  (FILETIME *) &user64);
    52445244        if (! rc) {
     
    52465246            *user = 0;
    52475247            return FALSE;
    5248         } 
     5248        }
    52495249        *kernel = (unsigned long) (kernel64 / 10000);
    52505250        *user = (unsigned long) (user64 / 10000);
     
    52525252    } else {
    52535253        __int64 creation64, exit64, kernel64, user64;
    5254         int rc = GetThreadTimes (GetCurrentThread (), 
    5255                                  (FILETIME *) &creation64, 
    5256                                  (FILETIME *) &exit64, 
    5257                                  (FILETIME *) &kernel64, 
     5254        int rc = GetThreadTimes (GetCurrentThread (),
     5255                                 (FILETIME *) &creation64,
     5256                                 (FILETIME *) &exit64,
     5257                                 (FILETIME *) &kernel64,
    52585258                                 (FILETIME *) &user64);
    52595259        if (! rc) {
     
    52615261            *user = 0;
    52625262            return FALSE;
    5263         } 
     5263        }
    52645264        *kernel = (unsigned long) (kernel64 / 10000);
    52655265        *user = (unsigned long) (user64 / 10000);
     
    52815281        Thanks also to Andreas Mueller <a.mueller at paradatec.de>,
    52825282        and Anonymous.
    5283       * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for 
     5283      * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for
    52845284        helping test this.)
    52855285      * memalign: check alignment arg
     
    52925292      * Introduce fastbins (although similar to 2.5.1)
    52935293      * Many minor tunings and cosmetic improvements
    5294       * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK 
     5294      * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK
    52955295      * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS
    52965296        Thanks to Tony E. Bennett <tbennett@nvidia.com> and others.
  • ppcc/src/Makefile.extra

    r73bf78 r1edbe2f  
    22TCLSH=`autosetup/autosetup-find-tclsh`
    33PREPROC_TCL=$(TCLSH) src/script/preproc.tcl
    4 src/pplex.h: src/pplex.h.in 
     4src/pplex.h: src/pplex.h.in
    55        $(PREPROC_TCL) src/pplex.h.in
    6 src/pplex.re: src/pplex.re.in 
     6src/pplex.re: src/pplex.re.in
    77        $(PREPROC_TCL) src/pplex.re.in
    88CONFIGITEMS += src/pplex.h src/pplex.re
  • ppcc/src/pplex.cc

    r73bf78 r1edbe2f  
    8888  while (!done) {
    8989    const char *last = cursor;
    90    
     90
    9191#line 92 "src/pplex.cc"
    9292{
     
    21242124
    21252125    comment:
    2126    
     2126
    21272127#line 2128 "src/pplex.cc"
    21282128{
Note: See TracChangeset for help on using the changeset viewer.