creloc.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % File: PXK:CRELOC.C
  5. % Description: A simple modifier/relocation for PSL items after a Savesystem.
  6. % It is needed for the image model in newer Linuxes, after say 2008.
  7. % Heaplowerbound can be very far away then.
  8. % Author: Winfried Neun, ZIB
  9. % Created:
  10. % Modified:
  11. % Mode: Text
  12. % Package:
  13. % Status: Open Source: BSD License
  14. %
  15. % (c) Copyright 1983, Hewlett-Packard Company, see the file
  16. % HP_disclaimer at the root of the PSL file tree
  17. %
  18. % (c) Copyright 1982, University of Utah
  19. %
  20. % Redistribution and use in source and binary forms, with or without
  21. % modification, are permitted provided that the following conditions are met:
  22. %
  23. % * Redistributions of source code must retain the relevant copyright
  24. % notice, this list of conditions and the following disclaimer.
  25. % * Redistributions in binary form must reproduce the above copyright
  26. % notice, this list of conditions and the following disclaimer in the
  27. % documentation and/or other materials provided with the distribution.
  28. %
  29. % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  30. % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  31. % THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  32. % PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
  33. % CONTRIBUTORS
  34. % BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. % CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  36. % SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  37. % INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  38. % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  39. % ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. % POSSIBILITY OF SUCH DAMAGE.
  41. %
  42. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  43. */
  44. #include <inttypes.h>
  45. #include "psl.h"
  46. void creloc (int64_t array[], long len, int64_t diff, int64_t lowb)
  47. { long i;
  48. long skip;
  49. long tag;
  50. int64_t inf;
  51. for (i=0; i< len; i += skip)
  52. { tag = (array[i] >> 56) ;
  53. if (tag < 0)
  54. { tag += 256;
  55. }
  56. inf = (array[i] << 8) >> 8;
  57. skip = 1;
  58. if ( tag == 0 ) continue; // posint
  59. if ( tag > 250 ) continue; // negint to forward
  60. // printf(" %d before %d %lx",tag,i,array[i]);
  61. if ( tag < 31 && (inf > lowb ))
  62. { array[i] += diff;
  63. }
  64. if (tag == 247)
  65. { skip = (inf +9) /8 +1 ; //strpack
  66. }
  67. else if (tag==249)
  68. { skip = inf + 2;
  69. }
  70. else if (tag==250)
  71. { skip = 1; // work on the vect contents
  72. }
  73. // One has to make sure that bignums are *NOT* vectors in gc, but WORD-VECT.
  74. // printf(" %d after %lx\n",skip, array[i]);
  75. }
  76. }
  77. /* end of creloc.c */