gc.c raw

   1  /*
   2   * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
   3   * Copyright (c) 1996 by Silicon Graphics.  All rights reserved.
   4   * Copyright (c) 1998 by Fergus Henderson.  All rights reserved.
   5   * Copyright (c) 2000-2009 by Hewlett-Packard Development Company.
   6   * All rights reserved.
   7   * Copyright (c) 2009-2018 Ivan Maidanski
   8   *
   9   * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  10   * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
  11   *
  12   * Permission is hereby granted to use or copy this program
  13   * for any purpose, provided the above notices are retained on all copies.
  14   * Permission to modify the code and to distribute modified code is granted,
  15   * provided the above notices are retained, and a notice that the code was
  16   * modified is included with the above copyright notice.
  17   */
  18  
  19  /*
  20   * This file could be used for the following purposes:
  21   *   - get the complete collector as a single link object file (module);
  22   *   - enable more compiler optimizations.
  23   *
  24   * Tip: to get the highest level of compiler optimizations, the typical
  25   * compiler options to use (assuming gcc) are:
  26   * `-O3 -march=native -fprofile-generate`
  27   *
  28   * Warning: gcc for Linux (for C++ clients only): use `-fexceptions` both for
  29   * the collector library and the client as otherwise `GC_thread_exit_proc()`
  30   * is not guaranteed to be invoked (see the comments in `pthread_start.c`
  31   * file).
  32   */
  33  
  34  #define GC_SINGLE_OBJ_BUILD
  35  
  36  #ifndef __cplusplus
  37  /* `static` is desirable here for more efficient linkage. */
  38  /* TODO: Enable this in case of the compilation as C++ code. */
  39  #  define GC_INNER STATIC
  40  #  define GC_EXTERN GC_INNER
  41  /* Note: `STATIC` macro is defined in `gcconfig.h` file. */
  42  #endif
  43  
  44  /* Small files go first... */
  45  #include "../backgraph.c"
  46  #include "../blacklst.c"
  47  #include "../checksums.c"
  48  #include "../gcj_mlc.c"
  49  #include "../headers.c"
  50  #include "../new_hblk.c"
  51  #include "../ptr_chck.c"
  52  
  53  #include "../allchblk.c"
  54  #include "../alloc.c"
  55  #include "../dbg_mlc.c"
  56  #include "../finalize.c"
  57  #include "../fnlz_mlc.c"
  58  #include "../malloc.c"
  59  #include "../mallocx.c"
  60  #include "../mark.c"
  61  #include "../mark_rts.c"
  62  #include "../reclaim.c"
  63  #include "../typd_mlc.c"
  64  
  65  #include "../misc.c"
  66  #include "../os_dep.c"
  67  #include "../thread_local_alloc.c"
  68  
  69  /* Most platform-specific files go here... */
  70  #include "../darwin_stop_world.c"
  71  #include "../dyn_load.c"
  72  #include "../gc_dlopen.c"
  73  #if !defined(PLATFORM_MACH_DEP)
  74  #  include "../mach_dep.c"
  75  #endif
  76  #if !defined(PLATFORM_STOP_WORLD)
  77  #  include "../pthread_stop_world.c"
  78  #endif
  79  #include "../pthread_support.c"
  80  #include "../specific.c"
  81  #include "../win32_threads.c"
  82  
  83  #ifndef GC_PTHREAD_START_STANDALONE
  84  #  include "../pthread_start.c"
  85  #endif
  86  
  87  /*
  88   * Restore `pthreads` calls redirection (if altered in `pthread_stop_world.c`
  89   * or `pthread_support.c` file).  This is only useful if directly included
  90   * from client code (instead of linking with `gc.o` file).
  91   */
  92  #if !defined(GC_NO_THREAD_REDIRECTS) && defined(GC_PTHREADS)
  93  #  define GC_PTHREAD_REDIRECTS_ONLY
  94  #  include "gc/gc_pthread_redirects.h"
  95  #endif
  96  
  97  /* Note: the files from `extra` folder are not included. */
  98