Ticket #13731: sage_trac_13731.patch

File sage_trac_13731.patch, 3.7 KB (added by SimonKing, 7 years ago)

A patch for the singular spkg to produce a libsingular that uses malloc

  • omalloc/omAllocDecl.h

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1353802196 -3600
    # Node ID 08f6b06d6b20d85bcfd3ed4771ec890d019d32e9
    # Parent  e8203d071281594049b3d4ece666599d83db5d59
    #13731: Add some definitions to omAllocDecl that are needed to use malloc
    
    diff --git a/omalloc/omAllocDecl.h b/omalloc/omAllocDecl.h
    a b  
    290290extern void* omEmulateCalloc(size_t size);
    291291extern void* omEmulateRealloc0Size(void* o_addr, size_t o_size, size_t n_size);
    292292extern void* omEmulateRealloc0(void* o_addr, size_t n_size);
     293extern void* omEmulateAlloc0(size_t size);
    293294
    294295#define omTypeAllocBin(type,addr,bin)           addr=(type) OM_MALLOC_MALLOC(bin->sizeW << LOG_SIZEOF_LONG)
    295296#define omTypeAlloc0Bin(type,addr,bin)          addr=(type) omEmulateAlloc0(bin->sizeW << LOG_SIZEOF_LONG)
     
    316317#define omRealloc(addr,size)                                    OM_MALLOC_REALLOC(addr,size)
    317318#define omRealloc0(addr,size)                                   omEmulateRealloc0(addr,size)
    318319
     320#define omalloc(size)   omAlloc(size)
     321#define omalloc0(size)  omAlloc0(size)
     322
     323#define omFreeBinAddr(addr)     OM_MALLOC_FREE(addr)
    319324#define omFreeBin(addr,bin)     OM_MALLOC_FREE(addr)
    320325#define omFreeSize(addr,size)   OM_MALLOC_FREE(addr)
    321326#define omFree(addr)            OM_MALLOC_FREE(addr)
     327#define omfreeSize(addr,size)   do {if (addr && size) omFreeSize(addr, size);} while (0)
     328#define omfree(addr)            do {if (addr) omFree(addr);} while (0)
     329
     330#define omreallocSize(addr,o_size,size)  omReallocSize(addr,o_size,size)
     331#define omrealloc0Size(addr,o_size,size) omRealloc0Size(addr,o_size,size)
     332#define omrealloc(addr,size)            omRealloc(addr, size)
     333#define omrealloc0(addr,size)           omRealloc0(addr, size)
     334
     335#define omStrDup(s)             OM_MALLOC_STRDUP(s)
     336#define omMemDup(s)             OM_MALLOC_MEMDUP(s)
     337
    322338#endif /* ! debug && ! the real thing */
    323339
    324340
  • omalloc/omAllocFunc.h

    diff --git a/omalloc/omAllocFunc.h b/omalloc/omAllocFunc.h
    a b  
    1818#if (defined(__sun) && (defined(__sparc) || defined(__i386) || defined(__x86_64)) || defined(__CYGWIN__))
    1919extern void* omMemalignFunc(size_t, size_t);
    2020#else
    21 void* omMemalignFunc(void* alignment, size_t size);
     21void* omMemalignFunc(size_t alignment, size_t size);
    2222#endif
    2323#endif
    2424void* omReallocFunc(void* old_addr, size_t new_size);
  • omalloc/omMallocSystem.h

    diff --git a/omalloc/omMallocSystem.h b/omalloc/omMallocSystem.h
    a b  
    88#ifndef OM_MALLOC_SYSTEM_H
    99#define OM_MALLOC_SYSTEM_H
    1010
     11#include <malloc.h>
     12
    1113/* this is the minimal set of OM_MALLOC_* macros which must be defined */
    1214#define OM_MALLOC_MALLOC   malloc
    1315#define OM_MALLOC_REALLOC  realloc
    1416#define OM_MALLOC_FREE     free
    1517#define OM_MALLOC_VALLOC   valloc
    1618#define OM_MALLOC_VFREE(addr, size) OM_MALLOC_FREE(addr)
     19#define OM_MALLOC_STRDUP        strdup
     20
     21#if defined(ix86Mac_darwin) || defined(x86_64Mac_darwin) || defined(ppcMac_darwin)
     22#define OM_MALLOC_MEMDUP(ptr)   memcpy(malloc(malloc_size(ptr)),ptr,malloc_size(ptr))
     23#else
     24#define OM_MALLOC_MEMDUP(ptr)   memcpy(malloc(malloc_usable_size(ptr)),ptr,malloc_usable_size(ptr))
     25#endif /* darwin or not darwin */
    1726
    1827#endif /* OM_MALLOC_SYSTEM_H */
  • omalloc/omalloc.c

    diff --git a/omalloc/omalloc.c b/omalloc/omalloc.c
    a b  
    6060#elif (defined(__sun) && (defined(__sparc) || defined(__i386) || defined(__x86_64)) || defined(__CYGWIN__))
    6161void* memalign(size_t size_1, size_t size_2)
    6262#else
    63 void* memalign(void* alignment, size_t size)
     63void* memalign(size_t alignment, size_t size)
    6464#endif
    6565{
    6666  fprintf(stderr, "omalloc Warning: memalign not yet implemented\n");