ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.xs
(Generate patch)

Comparing Coro/Coro/State.xs (file contents):
Revision 1.77 by root, Tue Oct 31 23:55:33 2006 UTC vs.
Revision 1.78 by root, Wed Nov 1 01:21:21 2006 UTC

29# endif 29# endif
30#endif 30#endif
31 31
32#include <errno.h> 32#include <errno.h>
33 33
34#if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64
35# undef STACKGUARD
36#endif
37
38#ifndef STACKGUARD
39# define STACKGUARD 0
40#endif
41
34#ifdef HAVE_MMAP 42#ifdef HAVE_MMAP
35# include <unistd.h> 43# include <unistd.h>
36# include <sys/mman.h> 44# include <sys/mman.h>
37# ifndef MAP_ANONYMOUS 45# ifndef MAP_ANONYMOUS
38# ifdef MAP_ANON 46# ifdef MAP_ANON
39# define MAP_ANONYMOUS MAP_ANON 47# define MAP_ANONYMOUS MAP_ANON
40# else 48# else
41# undef HAVE_MMAP 49# undef HAVE_MMAP
42# endif 50# endif
51# endif
52# include <limits.h>
53# ifndef PAGESIZE
54# define PAGESIZE pagesize
55# define BOOT_PAGESIZE pagesize = sysconf (_SC_PAGESIZE)
56static long pagesize;
57# else
58# define BOOT_PAGESIZE
43# endif 59# endif
44#endif 60#endif
45 61
46#define SUB_INIT "Coro::State::initialize" 62#define SUB_INIT "Coro::State::initialize"
47#define UCORO_STATE "_coro_state" 63#define UCORO_STATE "_coro_state"
527 stack->gencnt = ctx->gencnt = 0; 543 stack->gencnt = ctx->gencnt = 0;
528 544
529 if (alloc) 545 if (alloc)
530 { 546 {
531#if HAVE_MMAP 547#if HAVE_MMAP
532 stack->ssize = STACKSIZE * sizeof (long); /* mmap should do allocate-on-write for us */ 548 stack->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE; /* mmap should do allocate-on-write for us */
533 stack->sptr = mmap (0, stack->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); 549 stack->sptr = mmap (0, stack->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
534 if (stack->sptr == (void *)-1) 550 if (stack->sptr != (void *)-1)
551 {
552# if STACKGUARD
553 mprotect (stack->sptr, STACKGUARD * PAGESIZE, PROT_NONE);
554# endif
555 }
556 else
535#endif 557#endif
536 { 558 {
537 stack->ssize = - (STACKSIZE * (long)sizeof (long)); 559 stack->ssize = - (STACKSIZE * (long)sizeof (long));
538 New (0, stack->sptr, STACKSIZE, long); 560 New (0, stack->sptr, STACKSIZE, long);
539 } 561 }
893BOOT: 915BOOT:
894{ /* {} necessary for stoopid perl-5.6.x */ 916{ /* {} necessary for stoopid perl-5.6.x */
895#ifdef USE_ITHREADS 917#ifdef USE_ITHREADS
896 MUTEX_INIT (&coro_mutex); 918 MUTEX_INIT (&coro_mutex);
897#endif 919#endif
920 BOOT_PAGESIZE;
898 921
899 ucoro_state_sv = newSVpv (UCORO_STATE, sizeof(UCORO_STATE) - 1); 922 ucoro_state_sv = newSVpv (UCORO_STATE, sizeof(UCORO_STATE) - 1);
900 PERL_HASH(ucoro_state_hash, UCORO_STATE, sizeof(UCORO_STATE) - 1); 923 PERL_HASH(ucoro_state_hash, UCORO_STATE, sizeof(UCORO_STATE) - 1);
901 coro_state_stash = gv_stashpv ("Coro::State", TRUE); 924 coro_state_stash = gv_stashpv ("Coro::State", TRUE);
902 925

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines