Artifact 3b844e4f49c7960f4d458451460008eba2dd2249:


0000: 2f 2a 20 54 68 69 73 20 66 69 6c 65 20 69 73 20  /* This file is 
0010: 64 65 72 69 76 65 64 20 66 72 6f 6d 20 67 63 63  derived from gcc
0020: 2d 32 2e 36 2e 33 2f 6c 69 62 67 63 63 32 2e 63  -2.6.3/libgcc2.c
0030: 2c 20 73 65 63 74 69 6f 6e 20 4c 5f 74 72 61 6d  , section L_tram
0040: 70 6f 6c 69 6e 65 20 2a 2f 0a 0a 2f 2a 20 43 6f  poline */../* Co
0050: 70 79 72 69 67 68 74 20 28 43 29 20 31 39 38 39  pyright (C) 1989
0060: 2c 20 31 39 39 32 2c 20 31 39 39 33 2c 20 31 39  , 1992, 1993, 19
0070: 39 34 20 46 72 65 65 20 53 6f 66 74 77 61 72 65  94 Free Software
0080: 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20 49 6e 63   Foundation, Inc
0090: 2e 0a 0a 54 68 69 73 20 66 69 6c 65 20 69 73 20  ...This file is 
00a0: 70 61 72 74 20 6f 66 20 47 4e 55 20 43 43 2e 0a  part of GNU CC..
00b0: 0a 47 4e 55 20 43 43 20 69 73 20 66 72 65 65 20  .GNU CC is free 
00c0: 73 6f 66 74 77 61 72 65 3b 20 79 6f 75 20 63 61  software; you ca
00d0: 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 20 69  n redistribute i
00e0: 74 20 61 6e 64 2f 6f 72 20 6d 6f 64 69 66 79 0a  t and/or modify.
00f0: 69 74 20 75 6e 64 65 72 20 74 68 65 20 74 65 72  it under the ter
0100: 6d 73 20 6f 66 20 74 68 65 20 47 4e 55 20 47 65  ms of the GNU Ge
0110: 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63  neral Public Lic
0120: 65 6e 73 65 20 61 73 20 70 75 62 6c 69 73 68 65  ense as publishe
0130: 64 20 62 79 0a 74 68 65 20 46 72 65 65 20 53 6f  d by.the Free So
0140: 66 74 77 61 72 65 20 46 6f 75 6e 64 61 74 69 6f  ftware Foundatio
0150: 6e 3b 20 65 69 74 68 65 72 20 76 65 72 73 69 6f  n; either versio
0160: 6e 20 32 2c 20 6f 72 20 28 61 74 20 79 6f 75 72  n 2, or (at your
0170: 20 6f 70 74 69 6f 6e 29 0a 61 6e 79 20 6c 61 74   option).any lat
0180: 65 72 20 76 65 72 73 69 6f 6e 2e 0a 0a 47 4e 55  er version...GNU
0190: 20 43 43 20 69 73 20 64 69 73 74 72 69 62 75 74   CC is distribut
01a0: 65 64 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74  ed in the hope t
01b0: 68 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75  hat it will be u
01c0: 73 65 66 75 6c 2c 0a 62 75 74 20 57 49 54 48 4f  seful,.but WITHO
01d0: 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 59 3b  UT ANY WARRANTY;
01e0: 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74 68   without even th
01f0: 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61 6e  e implied warran
0200: 74 79 20 6f 66 0a 4d 45 52 43 48 41 4e 54 41 42  ty of.MERCHANTAB
0210: 49 4c 49 54 59 20 6f 72 20 46 49 54 4e 45 53 53  ILITY or FITNESS
0220: 20 46 4f 52 20 41 20 50 41 52 54 49 43 55 4c 41   FOR A PARTICULA
0230: 52 20 50 55 52 50 4f 53 45 2e 20 20 53 65 65 20  R PURPOSE.  See 
0240: 74 68 65 0a 47 4e 55 20 47 65 6e 65 72 61 6c 20  the.GNU General 
0250: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66  Public License f
0260: 6f 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e  or more details.
0270: 0a 0a 59 6f 75 20 73 68 6f 75 6c 64 20 68 61 76  ..You should hav
0280: 65 20 72 65 63 65 69 76 65 64 20 61 20 63 6f 70  e received a cop
0290: 79 20 6f 66 20 74 68 65 20 47 4e 55 20 47 65 6e  y of the GNU Gen
02a0: 65 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65  eral Public Lice
02b0: 6e 73 65 0a 61 6c 6f 6e 67 20 77 69 74 68 20 47  nse.along with G
02c0: 4e 55 20 43 43 3b 20 73 65 65 20 74 68 65 20 66  NU CC; see the f
02d0: 69 6c 65 20 43 4f 50 59 49 4e 47 2e 20 20 49 66  ile COPYING.  If
02e0: 20 6e 6f 74 2c 20 77 72 69 74 65 20 74 6f 0a 74   not, write to.t
02f0: 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 72 65  he Free Software
0300: 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20 36 37 35   Foundation, 675
0310: 20 4d 61 73 73 20 41 76 65 2c 20 43 61 6d 62 72   Mass Ave, Cambr
0320: 69 64 67 65 2c 20 4d 41 20 30 32 31 33 39 2c 20  idge, MA 02139, 
0330: 55 53 41 2e 20 20 2a 2f 0a 0a 0a 2f 2a 20 4a 75  USA.  */.../* Ju
0340: 6d 70 20 74 6f 20 61 20 74 72 61 6d 70 6f 6c 69  mp to a trampoli
0350: 6e 65 2c 20 6c 6f 61 64 69 6e 67 20 74 68 65 20  ne, loading the 
0360: 73 74 61 74 69 63 20 63 68 61 69 6e 20 61 64 64  static chain add
0370: 72 65 73 73 2e 20 20 2a 2f 0a 0a 23 69 66 20 64  ress.  */..#if d
0380: 65 66 69 6e 65 64 20 28 5f 5f 61 6c 70 68 61 5f  efined (__alpha_
0390: 5f 29 0a 0a 76 6f 69 64 0a 5f 5f 65 6e 61 62 6c  _)..void.__enabl
03a0: 65 5f 65 78 65 63 75 74 65 5f 73 74 61 63 6b 20  e_execute_stack 
03b0: 28 61 64 64 72 29 0a 20 20 20 20 20 76 6f 69 64  (addr).     void
03c0: 20 2a 61 64 64 72 3b 0a 7b 0a 20 20 6c 6f 6e 67   *addr;.{.  long
03d0: 20 73 69 7a 65 20 3d 20 67 65 74 70 61 67 65 73   size = getpages
03e0: 69 7a 65 20 28 29 3b 0a 20 20 6c 6f 6e 67 20 6d  ize ();.  long m
03f0: 61 73 6b 20 3d 20 7e 28 73 69 7a 65 2d 31 29 3b  ask = ~(size-1);
0400: 0a 20 20 63 68 61 72 20 2a 70 61 67 65 20 3d 20  .  char *page = 
0410: 28 63 68 61 72 20 2a 29 20 28 28 28 6c 6f 6e 67  (char *) (((long
0420: 29 20 61 64 64 72 29 20 26 20 6d 61 73 6b 29 3b  ) addr) & mask);
0430: 0a 20 20 63 68 61 72 20 2a 65 6e 64 20 20 3d 20  .  char *end  = 
0440: 28 63 68 61 72 20 2a 29 20 28 28 28 28 6c 6f 6e  (char *) ((((lon
0450: 67 29 20 28 61 64 64 72 20 2b 20 54 52 41 4d 50  g) (addr + TRAMP
0460: 4f 4c 49 4e 45 5f 53 49 5a 45 29 29 20 26 20 6d  OLINE_SIZE)) & m
0470: 61 73 6b 29 20 2b 20 73 69 7a 65 29 3b 0a 0a 20  ask) + size);.. 
0480: 20 2f 2a 20 37 20 69 73 20 50 52 4f 54 5f 52 45   /* 7 is PROT_RE
0490: 41 44 20 7c 20 50 52 4f 54 5f 57 52 49 54 45 20  AD | PROT_WRITE 
04a0: 7c 20 50 52 4f 54 5f 45 58 45 43 20 2a 2f 0a 20  | PROT_EXEC */. 
04b0: 20 69 66 20 28 6d 70 72 6f 74 65 63 74 20 28 70   if (mprotect (p
04c0: 61 67 65 2c 20 65 6e 64 20 2d 20 70 61 67 65 2c  age, end - page,
04d0: 20 37 29 20 3c 20 30 29 0a 20 20 20 20 70 65 72   7) < 0).    per
04e0: 72 6f 72 20 28 22 6d 70 72 6f 74 65 63 74 20 6f  ror ("mprotect o
04f0: 66 20 74 72 61 6d 70 6f 6c 69 6e 65 20 63 6f 64  f trampoline cod
0500: 65 22 29 3b 0a 7d 0a 0a 23 65 6e 64 69 66 0a 0a  e");.}..#endif..
0510: 23 69 66 20 64 65 66 69 6e 65 64 20 28 4e 65 58  #if defined (NeX
0520: 54 29 20 26 26 20 64 65 66 69 6e 65 64 20 28 5f  T) && defined (_
0530: 5f 4d 41 43 48 5f 5f 29 0a 0a 2f 2a 20 4d 61 6b  _MACH__)../* Mak
0540: 65 20 73 74 61 63 6b 20 65 78 65 63 75 74 61 62  e stack executab
0550: 6c 65 20 73 6f 20 77 65 20 63 61 6e 20 63 61 6c  le so we can cal
0560: 6c 20 74 72 61 6d 70 6f 6c 69 6e 65 73 20 6f 6e  l trampolines on
0570: 20 73 74 61 63 6b 2e 0a 20 20 20 54 68 69 73 20   stack..   This 
0580: 69 73 20 63 61 6c 6c 65 64 20 66 72 6f 6d 20 49  is called from I
0590: 4e 49 54 49 41 4c 49 5a 45 5f 54 52 41 4d 50 4f  NITIALIZE_TRAMPO
05a0: 4c 49 4e 45 20 69 6e 20 6e 65 78 74 2e 68 2e 20  LINE in next.h. 
05b0: 20 2a 2f 0a 23 69 66 64 65 66 20 4e 65 58 54 53   */.#ifdef NeXTS
05c0: 74 65 70 32 31 0a 20 23 69 6e 63 6c 75 64 65 20  tep21. #include 
05d0: 3c 6d 61 63 68 2e 68 3e 0a 23 65 6c 73 65 0a 20  <mach.h>.#else. 
05e0: 23 69 6e 63 6c 75 64 65 20 3c 6d 61 63 68 2f 6d  #include <mach/m
05f0: 61 63 68 2e 68 3e 0a 23 65 6e 64 69 66 0a 0a 76  ach.h>.#endif..v
0600: 6f 69 64 0a 5f 5f 65 6e 61 62 6c 65 5f 65 78 65  oid.__enable_exe
0610: 63 75 74 65 5f 73 74 61 63 6b 20 28 61 64 64 72  cute_stack (addr
0620: 29 0a 20 20 20 20 20 63 68 61 72 20 2a 61 64 64  ).     char *add
0630: 72 3b 0a 7b 0a 20 20 6b 65 72 6e 5f 72 65 74 75  r;.{.  kern_retu
0640: 72 6e 5f 74 20 72 3b 0a 20 20 63 68 61 72 20 2a  rn_t r;.  char *
0650: 65 61 64 64 72 20 3d 20 61 64 64 72 20 2b 20 54  eaddr = addr + T
0660: 52 41 4d 50 4f 4c 49 4e 45 5f 53 49 5a 45 3b 0a  RAMPOLINE_SIZE;.
0670: 20 20 76 6d 5f 61 64 64 72 65 73 73 5f 74 20 61    vm_address_t a
0680: 20 3d 20 28 76 6d 5f 61 64 64 72 65 73 73 5f 74   = (vm_address_t
0690: 29 20 61 64 64 72 3b 0a 0a 20 20 2f 2a 20 74 75  ) addr;..  /* tu
06a0: 72 6e 20 6f 6e 20 65 78 65 63 75 74 65 20 61 63  rn on execute ac
06b0: 63 65 73 73 20 6f 6e 20 73 74 61 63 6b 20 2a 2f  cess on stack */
06c0: 0a 20 20 72 20 3d 20 76 6d 5f 70 72 6f 74 65 63  .  r = vm_protec
06d0: 74 20 28 74 61 73 6b 5f 73 65 6c 66 20 28 29 2c  t (task_self (),
06e0: 20 61 2c 20 54 52 41 4d 50 4f 4c 49 4e 45 5f 53   a, TRAMPOLINE_S
06f0: 49 5a 45 2c 20 46 41 4c 53 45 2c 20 56 4d 5f 50  IZE, FALSE, VM_P
0700: 52 4f 54 5f 41 4c 4c 29 3b 0a 20 20 69 66 20 28  ROT_ALL);.  if (
0710: 72 20 21 3d 20 4b 45 52 4e 5f 53 55 43 43 45 53  r != KERN_SUCCES
0720: 53 29 0a 20 20 20 20 7b 0a 20 20 20 20 20 20 6d  S).    {.      m
0730: 61 63 68 5f 65 72 72 6f 72 28 22 76 6d 5f 70 72  ach_error("vm_pr
0740: 6f 74 65 63 74 20 56 4d 5f 50 52 4f 54 5f 41 4c  otect VM_PROT_AL
0750: 4c 22 2c 20 72 29 3b 0a 20 20 20 20 20 20 65 78  L", r);.      ex
0760: 69 74 28 31 29 3b 0a 20 20 20 20 7d 0a 7d 20 0a  it(1);.    }.} .
0770: 0a 23 65 6e 64 69 66 20 2f 2a 20 64 65 66 69 6e  .#endif /* defin
0780: 65 64 20 28 4e 65 58 54 29 20 26 26 20 64 65 66  ed (NeXT) && def
0790: 69 6e 65 64 20 28 5f 5f 4d 41 43 48 5f 5f 29 20  ined (__MACH__) 
07a0: 2a 2f 0a 0a 23 69 66 64 65 66 20 5f 5f 63 6f 6e  */..#ifdef __con
07b0: 76 65 78 5f 5f 0a 0a 2f 2a 20 4d 61 6b 65 20 73  vex__../* Make s
07c0: 74 61 63 6b 20 65 78 65 63 75 74 61 62 6c 65 20  tack executable 
07d0: 73 6f 20 77 65 20 63 61 6e 20 63 61 6c 6c 20 74  so we can call t
07e0: 72 61 6d 70 6f 6c 69 6e 65 73 20 6f 6e 20 73 74  rampolines on st
07f0: 61 63 6b 2e 0a 20 20 20 54 68 69 73 20 69 73 20  ack..   This is 
0800: 63 61 6c 6c 65 64 20 66 72 6f 6d 20 49 4e 49 54  called from INIT
0810: 49 41 4c 49 5a 45 5f 54 52 41 4d 50 4f 4c 49 4e  IALIZE_TRAMPOLIN
0820: 45 20 69 6e 20 63 6f 6e 76 65 78 2e 68 2e 20 20  E in convex.h.  
0830: 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 73 79  */..#include <sy
0840: 73 2f 6d 6d 61 6e 2e 68 3e 0a 23 69 6e 63 6c 75  s/mman.h>.#inclu
0850: 64 65 20 3c 73 79 73 2f 76 6d 70 61 72 61 6d 2e  de <sys/vmparam.
0860: 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 6d 61 63  h>.#include <mac
0870: 68 69 6e 65 2f 6d 61 63 68 70 61 72 61 6d 2e 68  hine/machparam.h
0880: 3e 0a 0a 76 6f 69 64 0a 5f 5f 65 6e 61 62 6c 65  >..void.__enable
0890: 5f 65 78 65 63 75 74 65 5f 73 74 61 63 6b 20 28  _execute_stack (
08a0: 29 0a 7b 0a 20 20 69 6e 74 20 66 70 3b 0a 20 20  ).{.  int fp;.  
08b0: 73 74 61 74 69 63 20 75 6e 73 69 67 6e 65 64 20  static unsigned 
08c0: 6c 6f 77 65 73 74 20 3d 20 55 53 52 53 54 41 43  lowest = USRSTAC
08d0: 4b 3b 0a 20 20 75 6e 73 69 67 6e 65 64 20 63 75  K;.  unsigned cu
08e0: 72 72 65 6e 74 20 3d 20 28 75 6e 73 69 67 6e 65  rrent = (unsigne
08f0: 64 29 20 26 66 70 20 26 20 2d 4e 42 50 47 3b 0a  d) &fp & -NBPG;.
0900: 0a 20 20 69 66 20 28 6c 6f 77 65 73 74 20 3e 20  .  if (lowest > 
0910: 63 75 72 72 65 6e 74 29 0a 20 20 20 20 7b 0a 20  current).    {. 
0920: 20 20 20 20 20 75 6e 73 69 67 6e 65 64 20 6c 65       unsigned le
0930: 6e 20 3d 20 6c 6f 77 65 73 74 20 2d 20 63 75 72  n = lowest - cur
0940: 72 65 6e 74 3b 0a 20 20 20 20 20 20 6d 72 65 6d  rent;.      mrem
0950: 61 70 20 28 63 75 72 72 65 6e 74 2c 20 26 6c 65  ap (current, &le
0960: 6e 2c 20 50 52 4f 54 5f 52 45 41 44 20 7c 20 50  n, PROT_READ | P
0970: 52 4f 54 5f 57 52 49 54 45 20 7c 20 50 52 4f 54  ROT_WRITE | PROT
0980: 5f 45 58 45 43 2c 20 4d 41 50 5f 50 52 49 56 41  _EXEC, MAP_PRIVA
0990: 54 45 29 3b 0a 20 20 20 20 20 20 6c 6f 77 65 73  TE);.      lowes
09a0: 74 20 3d 20 63 75 72 72 65 6e 74 3b 0a 20 20 20  t = current;.   
09b0: 20 7d 0a 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 5f   }.}.#endif /* _
09c0: 5f 63 6f 6e 76 65 78 5f 5f 20 2a 2f 0a 0a 23 69  _convex__ */..#i
09d0: 66 64 65 66 20 5f 5f 44 4f 4c 50 48 49 4e 5f 5f  fdef __DOLPHIN__
09e0: 0a 0a 2f 2a 20 4d 6f 64 69 66 69 65 64 20 66 72  ../* Modified fr
09f0: 6f 6d 20 74 68 65 20 63 6f 6e 76 65 78 20 2d 63  om the convex -c
0a00: 6f 64 65 20 61 62 6f 76 65 2e 20 2a 2f 0a 0a 23  ode above. */..#
0a10: 69 6e 63 6c 75 64 65 20 3c 73 79 73 2f 70 61 72  include <sys/par
0a20: 61 6d 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c  am.h>.#include <
0a30: 65 72 72 6e 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64  errno.h>.#includ
0a40: 65 20 3c 73 79 73 2f 6d 38 38 6b 62 63 73 2e 68  e <sys/m88kbcs.h
0a50: 3e 0a 0a 76 6f 69 64 0a 5f 5f 65 6e 61 62 6c 65  >..void.__enable
0a60: 5f 65 78 65 63 75 74 65 5f 73 74 61 63 6b 20 28  _execute_stack (
0a70: 29 0a 7b 0a 20 20 69 6e 74 20 73 61 76 65 5f 65  ).{.  int save_e
0a80: 72 72 6e 6f 3b 0a 20 20 73 74 61 74 69 63 20 75  rrno;.  static u
0a90: 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 6c 6f 77  nsigned long low
0aa0: 65 73 74 20 3d 20 55 53 52 53 54 41 43 4b 3b 0a  est = USRSTACK;.
0ab0: 20 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20    unsigned long 
0ac0: 63 75 72 72 65 6e 74 20 3d 20 28 75 6e 73 69 67  current = (unsig
0ad0: 6e 65 64 20 6c 6f 6e 67 29 20 26 73 61 76 65 5f  ned long) &save_
0ae0: 65 72 72 6e 6f 20 26 20 2d 4e 42 50 43 3b 0a 20  errno & -NBPC;. 
0af0: 20 0a 20 20 2f 2a 20 49 67 6e 6f 72 65 20 65 72   .  /* Ignore er
0b00: 72 6e 6f 20 62 65 69 6e 67 20 73 65 74 2e 20 6d  rno being set. m
0b10: 65 6d 63 74 6c 20 73 65 74 73 20 65 72 72 6e 6f  emctl sets errno
0b20: 20 74 6f 20 45 49 4e 56 41 4c 20 77 68 65 6e 65   to EINVAL whene
0b30: 76 65 72 20 74 68 65 0a 20 20 20 20 20 61 64 64  ver the.     add
0b40: 72 65 73 73 20 69 73 20 73 65 65 6e 20 61 73 20  ress is seen as 
0b50: 27 6e 65 67 61 74 69 76 65 27 2e 20 54 68 61 74  'negative'. That
0b60: 20 69 73 20 74 68 65 20 63 61 73 65 20 77 69 74   is the case wit
0b70: 68 20 74 68 65 20 73 74 61 63 6b 2e 20 20 20 2a  h the stack.   *
0b80: 2f 0a 0a 20 20 73 61 76 65 5f 65 72 72 6e 6f 3d  /..  save_errno=
0b90: 65 72 72 6e 6f 3b 0a 20 20 69 66 20 28 6c 6f 77  errno;.  if (low
0ba0: 65 73 74 20 3e 20 63 75 72 72 65 6e 74 29 0a 20  est > current). 
0bb0: 20 20 20 7b 0a 20 20 20 20 20 20 75 6e 73 69 67     {.      unsig
0bc0: 6e 65 64 20 6c 65 6e 3d 6c 6f 77 65 73 74 2d 63  ned len=lowest-c
0bd0: 75 72 72 65 6e 74 3b 0a 20 20 20 20 20 20 6d 65  urrent;.      me
0be0: 6d 63 74 6c 28 63 75 72 72 65 6e 74 2c 6c 65 6e  mctl(current,len
0bf0: 2c 4d 43 54 5f 54 45 58 54 29 3b 0a 20 20 20 20  ,MCT_TEXT);.    
0c00: 20 20 6c 6f 77 65 73 74 20 3d 20 63 75 72 72 65    lowest = curre
0c10: 6e 74 3b 0a 20 20 20 20 7d 0a 20 20 65 6c 73 65  nt;.    }.  else
0c20: 0a 20 20 20 20 6d 65 6d 63 74 6c 28 63 75 72 72  .    memctl(curr
0c30: 65 6e 74 2c 4e 42 50 43 2c 4d 43 54 5f 54 45 58  ent,NBPC,MCT_TEX
0c40: 54 29 3b 0a 20 20 65 72 72 6e 6f 3d 73 61 76 65  T);.  errno=save
0c50: 5f 65 72 72 6e 6f 3b 0a 7d 0a 0a 23 65 6e 64 69  _errno;.}..#endi
0c60: 66 20 2f 2a 20 5f 5f 44 4f 4c 50 48 49 4e 5f 5f  f /* __DOLPHIN__
0c70: 20 2a 2f 0a 0a 23 69 66 64 65 66 20 5f 5f 70 79   */..#ifdef __py
0c80: 72 5f 5f 0a 0a 23 75 6e 64 65 66 20 4e 55 4c 4c  r__..#undef NULL
0c90: 20 2f 2a 20 41 76 6f 69 64 20 65 72 72 6f 72 73   /* Avoid errors
0ca0: 20 69 66 20 73 74 64 69 6f 2e 68 20 61 6e 64 20   if stdio.h and 
0cb0: 6f 75 72 20 73 74 64 64 65 66 2e 68 20 6d 69 73  our stddef.h mis
0cc0: 6d 61 74 63 68 2e 20 20 2a 2f 0a 23 69 6e 63 6c  match.  */.#incl
0cd0: 75 64 65 20 3c 73 74 64 69 6f 2e 68 3e 0a 23 69  ude <stdio.h>.#i
0ce0: 6e 63 6c 75 64 65 20 3c 73 79 73 2f 6d 6d 61 6e  nclude <sys/mman
0cf0: 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 79  .h>.#include <sy
0d00: 73 2f 74 79 70 65 73 2e 68 3e 0a 23 69 6e 63 6c  s/types.h>.#incl
0d10: 75 64 65 20 3c 73 79 73 2f 70 61 72 61 6d 2e 68  ude <sys/param.h
0d20: 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 79 73 2f  >.#include <sys/
0d30: 76 6d 6d 61 63 2e 68 3e 0a 0a 2f 2a 20 4d 6f 64  vmmac.h>../* Mod
0d40: 69 66 69 65 64 20 66 72 6f 6d 20 74 68 65 20 63  ified from the c
0d50: 6f 6e 76 65 78 20 2d 63 6f 64 65 20 61 62 6f 76  onvex -code abov
0d60: 65 2e 0a 20 20 20 6d 72 65 6d 61 70 20 70 72 6f  e..   mremap pro
0d70: 6d 69 73 65 73 20 74 6f 20 63 6c 65 61 72 20 74  mises to clear t
0d80: 68 65 20 69 2d 63 61 63 68 65 2e 20 2a 2f 0a 0a  he i-cache. */..
0d90: 76 6f 69 64 0a 5f 5f 65 6e 61 62 6c 65 5f 65 78  void.__enable_ex
0da0: 65 63 75 74 65 5f 73 74 61 63 6b 20 28 29 0a 7b  ecute_stack ().{
0db0: 0a 20 20 69 6e 74 20 66 70 3b 0a 20 20 69 66 20  .  int fp;.  if 
0dc0: 28 6d 70 72 6f 74 65 63 74 20 28 28 28 75 6e 73  (mprotect (((uns
0dd0: 69 67 6e 65 64 20 69 6e 74 29 26 66 70 2f 50 41  igned int)&fp/PA
0de0: 47 53 49 5a 29 2a 50 41 47 53 49 5a 2c 20 50 41  GSIZ)*PAGSIZ, PA
0df0: 47 53 49 5a 2c 0a 09 09 50 52 4f 54 5f 52 45 41  GSIZ,...PROT_REA
0e00: 44 7c 50 52 4f 54 5f 57 52 49 54 45 7c 50 52 4f  D|PROT_WRITE|PRO
0e10: 54 5f 45 58 45 43 29 29 0a 20 20 20 20 7b 0a 20  T_EXEC)).    {. 
0e20: 20 20 20 20 20 70 65 72 72 6f 72 20 28 22 6d 70       perror ("mp
0e30: 72 6f 74 65 63 74 20 69 6e 20 5f 5f 65 6e 61 62  rotect in __enab
0e40: 6c 65 5f 65 78 65 63 75 74 65 5f 73 74 61 63 6b  le_execute_stack
0e50: 22 29 3b 0a 20 20 20 20 20 20 66 66 6c 75 73 68  ");.      fflush
0e60: 20 28 73 74 64 65 72 72 29 3b 0a 20 20 20 20 20   (stderr);.     
0e70: 20 61 62 6f 72 74 20 28 29 3b 0a 20 20 20 20 7d   abort ();.    }
0e80: 0a 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 5f 5f 70  .}.#endif /* __p
0e90: 79 72 5f 5f 20 2a 2f 0a                          yr__ */.