Skip to content
This repository
Browse code

* common.mk, configure.in, defines.h, eval.c, gc.c, main.c,

  numeric.c, ruby.h, ia64.s: backport IA64 HP-UX support.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit f8e87ab13d54060a94f01e4e12bb9f97d7be512c 1 parent 4d9869f
akr authored September 01, 2006
5  ChangeLog
... ...
@@ -1,3 +1,8 @@
  1
+Sat Sep  2 03:36:22 2006  Tanaka Akira  <akr@fsij.org>
  2
+
  3
+	* common.mk, configure.in, defines.h, eval.c, gc.c, main.c,
  4
+	  numeric.c, ruby.h, ia64.s: backport IA64 HP-UX support.
  5
+
1 6
 Fri Sep  1 13:52:57 2006  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp>
2 7
 
3 8
 	* ext/tk/lib/tk/font.rb: TkFont#current_configinfo() doesn't work
1  common.mk
@@ -189,6 +189,7 @@ nt.$(OBJEXT): {$(VPATH)}nt.c
189 189
 x68.$(OBJEXT): {$(VPATH)}x68.c
190 190
 os2.$(OBJEXT): {$(VPATH)}os2.c
191 191
 dl_os2.$(OBJEXT): {$(VPATH)}dl_os2.c
  192
+ia64.$(OBJEXT): ia64.s
192 193
 
193 194
 # when I use -I., there is confliction at "OpenFile" 
194 195
 # so, set . into environment varible "include"
61  configure.in
@@ -286,16 +286,42 @@ if test "$rb_cv_stdarg" = yes; then
286 286
   AC_DEFINE(HAVE_STDARG_PROTOTYPES)
287 287
 fi
288 288
 
289  
-AC_CACHE_CHECK([for noreturn], rb_cv_noreturn,
290  
-[rb_cv_noreturn=x
291  
-for mac in "x __attribute__ ((noreturn))" "__declspec(noreturn) x" x; do
  289
+AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
  290
+m4_ifval([$2], dnl
  291
+  [AS_VAR_PUSHDEF([attrib],[$2])], dnl
  292
+  [AS_VAR_PUSHDEF([attrib],[FUNC_]AS_TR_CPP($1))] dnl
  293
+)dnl
  294
+m4_ifval([$3], dnl
  295
+  [AS_VAR_PUSHDEF([rbcv],[$3])], dnl
  296
+  [AS_VAR_PUSHDEF([rbcv],[rb_cv_func_][$1])]dnl
  297
+)dnl
  298
+AC_CACHE_CHECK(for [$1] function attribute, rbcv,
  299
+[rbcv=x
  300
+if test "${ac_c_werror_flag+set}"; then
  301
+  rb_c_werror_flag="$ac_c_werror_flag"
  302
+else
  303
+  unset rb_c_werror_flag
  304
+fi
  305
+ac_c_werror_flag=yes
  306
+for mac in "__attribute__ (($1)) x" "x __attribute__ (($1))" "__declspec($1) x" x; do
292 307
   AC_TRY_COMPILE(
293  
-    [#define NORETURN(x) $mac
294  
-NORETURN(void exit(int x));],
295  
-    [],
296  
-    [rb_cv_noreturn="$mac"; break])
297  
-done])
298  
-AC_DEFINE_UNQUOTED([NORETURN(x)], $rb_cv_noreturn)
  308
+    [#define ]attrib[(x) $mac
  309
+    ]attrib[(void conftest_attribute_check(void));], [],
  310
+    [rbcv="$mac"; break])
  311
+done
  312
+if test "${rb_c_werror_flag+set}"; then
  313
+  ac_c_werror_flag="$rb_c_werror_flag"
  314
+else
  315
+  unset ac_c_werror_flag
  316
+fi
  317
+])
  318
+AC_DEFINE_UNQUOTED(attrib[(x)], $rbcv)
  319
+AS_VAR_POPDEF([attrib])
  320
+AS_VAR_POPDEF([rbcv])
  321
+])
  322
+
  323
+RUBY_FUNC_ATTRIBUTE(noreturn, NORETURN)
  324
+RUBY_FUNC_ATTRIBUTE(noinline, NOINLINE)
299 325
 
300 326
 AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
301 327
 [rb_cv_ruby_extern=no
@@ -595,6 +621,21 @@ AC_C_CHAR_UNSIGNED
595 621
 AC_C_INLINE
596 622
 AC_C_VOLATILE
597 623
 
  624
+if test x"$target_cpu" = xia64; then
  625
+    AC_LIBOBJ([ia64])
  626
+    AC_CACHE_CHECK(for __libc_ia64_register_backing_store_base,
  627
+                   rb_cv___libc_ia64_register_backing_store_base,
  628
+    [rb_cv___libc_ia64_register_backing_store_base=no
  629
+    AC_TRY_LINK(
  630
+      [extern unsigned long __libc_ia64_register_backing_store_base;],
  631
+      [unsigned long p = __libc_ia64_register_backing_store_base;
  632
+       printf("%ld\n", p);],
  633
+      [rb_cv___libc_ia64_register_backing_store_base=yes])])
  634
+    if test $rb_cv___libc_ia64_register_backing_store_base = yes; then
  635
+      AC_DEFINE(HAVE___LIBC_IA64_REGISTER_BACKING_STORE_BASE)
  636
+    fi
  637
+fi
  638
+
598 639
 AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
599 640
     [AC_TRY_RUN([
600 641
 int
@@ -827,7 +868,7 @@ if test x"$enable_pthread" = xyes; then
827 868
     fi
828 869
 fi
829 870
 if test x"$ac_cv_header_ucontext_h" = xyes; then
830  
-    if test x"$target_cpu" = xia64 -o x"$rb_with_pthread" = xyes; then
  871
+    if x"$rb_with_pthread" = xyes; then
831 872
 	AC_CHECK_FUNCS(getcontext setcontext)
832 873
     fi
833 874
 fi
11  defines.h
@@ -221,13 +221,10 @@ flush_register_windows(void)
221 221
 	;
222 222
 }
223 223
 #  define FLUSH_REGISTER_WINDOWS flush_register_windows()
224  
-#elif defined(__ia64__)
225  
-void flush_register_windows(void)
226  
-#  if defined(__GNUC__) && (( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3)
227  
-__attribute__ ((noinline))
228  
-#  endif
229  
-  ;
230  
-#  define FLUSH_REGISTER_WINDOWS flush_register_windows()
  224
+#elif defined(__ia64)
  225
+void *rb_ia64_bsp(void);
  226
+void rb_ia64_flushrs(void);
  227
+#  define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
231 228
 #else
232 229
 #  define FLUSH_REGISTER_WINDOWS ((void)0)
233 230
 #endif
198  eval.c
@@ -195,7 +195,8 @@ static int volatile freebsd_clear_carry_flag = 0;
195 195
 #    define POST_GETCONTEXT 0
196 196
 #  endif
197 197
 #  define ruby_longjmp(env, val) rb_jump_context(env, val)
198  
-#  define ruby_setjmp(j) ((j)->status = 0, \
  198
+#  define ruby_setjmp(just_before_setjmp, j) ((j)->status = 0, \
  199
+     (just_before_setjmp), \
199 200
      PRE_GETCONTEXT, \
200 201
      getcontext(&(j)->context), \
201 202
      POST_GETCONTEXT, \
@@ -203,10 +204,12 @@ static int volatile freebsd_clear_carry_flag = 0;
203 204
 #else
204 205
 typedef jmp_buf rb_jmpbuf_t;
205 206
 #  if !defined(setjmp) && defined(HAVE__SETJMP)
206  
-#    define ruby_setjmp(env) _setjmp(env)
  207
+#    define ruby_setjmp(just_before_setjmp, env) \
  208
+       ((just_before_setjmp), _setjmp(env))
207 209
 #    define ruby_longjmp(env,val) _longjmp(env,val)
208 210
 #  else
209  
-#    define ruby_setjmp(env) setjmp(env)
  211
+#    define ruby_setjmp(just_before_setjmp, env) \
  212
+       ((just_before_setjmp), setjmp(env))
210 213
 #    define ruby_longjmp(env,val) longjmp(env,val)
211 214
 #  endif
212 215
 #endif
@@ -1027,7 +1030,7 @@ static struct tag *prot_tag;
1027 1030
 #define PROT_LAMBDA INT2FIX(2)	/* 5 */
1028 1031
 #define PROT_YIELD  INT2FIX(3)	/* 7 */
1029 1032
 
1030  
-#define EXEC_TAG()    (FLUSH_REGISTER_WINDOWS, ruby_setjmp(prot_tag->buf))
  1033
+#define EXEC_TAG()    (FLUSH_REGISTER_WINDOWS, ruby_setjmp(((void)0), prot_tag->buf))
1031 1034
 
1032 1035
 #define JUMP_TAG(st) do {		\
1033 1036
     ruby_frame = prot_tag->frame;	\
@@ -9680,19 +9683,6 @@ Init_Binding()
9680 9683
     rb_define_global_function("binding", rb_f_binding, 0);
9681 9684
 }
9682 9685
 
9683  
-#ifdef __ia64__
9684  
-#if defined(__FreeBSD__)
9685  
-/*
9686  
- * FreeBSD/ia64 currently does not have a way for a process to get the
9687  
- * base address for the RSE backing store, so hardcode it.
9688  
- */
9689  
-#define __libc_ia64_register_backing_store_base (4ULL<<61)
9690  
-#else
9691  
-#pragma weak __libc_ia64_register_backing_store_base
9692  
-extern unsigned long __libc_ia64_register_backing_store_base;
9693  
-#endif
9694  
-#endif
9695  
-
9696 9686
 /* Windows SEH refers data on the stack. */
9697 9687
 #undef SAVE_WIN32_EXCEPTION_LIST
9698 9688
 #if defined _WIN32 || defined __CYGWIN__
@@ -9796,9 +9786,11 @@ struct thread {
9796 9786
     long   stk_max;
9797 9787
     VALUE *stk_ptr;
9798 9788
     VALUE *stk_pos;
9799  
-#ifdef __ia64__
9800  
-    VALUE *bstr_ptr;
  9789
+#ifdef __ia64
9801 9790
     long   bstr_len;
  9791
+    long   bstr_max;
  9792
+    VALUE *bstr_ptr;
  9793
+    VALUE *bstr_pos;
9802 9794
 #endif
9803 9795
 
9804 9796
     struct FRAME *frame;
@@ -10052,9 +10044,9 @@ thread_mark(th)
10052 10044
 #if defined(THINK_C) || defined(__human68k__)
10053 10045
 	rb_gc_mark_locations(th->stk_ptr+2, th->stk_ptr+th->stk_len+2);
10054 10046
 #endif
10055  
-#ifdef __ia64__
  10047
+#ifdef __ia64
10056 10048
 	if (th->bstr_ptr) {
10057  
-	    rb_gc_mark_locations(th->bstr_ptr, th->bstr_ptr+th->bstr_len);
  10049
+            rb_gc_mark_locations(th->bstr_ptr, th->bstr_ptr+th->bstr_len);
10058 10050
 	}
10059 10051
 #endif
10060 10052
     }
@@ -10140,7 +10132,7 @@ thread_free(th)
10140 10132
 {
10141 10133
     if (th->stk_ptr) free(th->stk_ptr);
10142 10134
     th->stk_ptr = 0;
10143  
-#ifdef __ia64__
  10135
+#ifdef __ia64
10144 10136
     if (th->bstr_ptr) free(th->bstr_ptr);
10145 10137
     th->bstr_ptr = 0;
10146 10138
 #endif
@@ -10180,6 +10172,9 @@ static char *th_signm;
10180 10172
 #define RESTORE_EXIT		7
10181 10173
 
10182 10174
 extern VALUE *rb_gc_stack_start;
  10175
+#ifdef __ia64
  10176
+extern VALUE *rb_gc_register_stack_start;
  10177
+#endif
10183 10178
 
10184 10179
 static void
10185 10180
 rb_thread_save_context(th)
@@ -10201,22 +10196,19 @@ rb_thread_save_context(th)
10201 10196
     th->stk_len = len;
10202 10197
     FLUSH_REGISTER_WINDOWS;
10203 10198
     MEMCPY(th->stk_ptr, th->stk_pos, VALUE, th->stk_len);
10204  
-#ifdef __ia64__
10205  
-    {
10206  
-	ucontext_t ctx;
10207  
-	VALUE *top, *bot;
10208  
-
10209  
-	getcontext(&ctx);
10210  
-	bot = (VALUE*)__libc_ia64_register_backing_store_base;
10211  
-#if defined(__FreeBSD__)
10212  
-	top = (VALUE*)ctx.uc_mcontext.mc_special.bspstore;
10213  
-#else
10214  
-	top = (VALUE*)ctx.uc_mcontext.sc_ar_bsp;
10215  
-#endif
10216  
-	th->bstr_len = top - bot;
10217  
-	REALLOC_N(th->bstr_ptr, VALUE, th->bstr_len);
10218  
-	MEMCPY(th->bstr_ptr, (VALUE*)__libc_ia64_register_backing_store_base, VALUE, th->bstr_len);
10219  
-    }
  10199
+#ifdef __ia64
  10200
+    th->bstr_pos = rb_gc_register_stack_start;
  10201
+    len = (VALUE*)rb_ia64_bsp() - th->bstr_pos;
  10202
+    th->bstr_len = 0;
  10203
+    if (len > th->bstr_max) {
  10204
+        VALUE *ptr = realloc(th->bstr_ptr, sizeof(VALUE) * len);
  10205
+        if (!ptr) rb_memerror();
  10206
+        th->bstr_ptr = ptr;
  10207
+        th->bstr_max = len;
  10208
+    }
  10209
+    th->bstr_len = len;
  10210
+    rb_ia64_flushrs();
  10211
+    MEMCPY(th->bstr_ptr, th->bstr_pos, VALUE, th->bstr_len);
10220 10212
 #endif
10221 10213
 #ifdef SAVE_WIN32_EXCEPTION_LIST
10222 10214
     th->win32_exception_list = win32_get_exception_list();
@@ -10289,52 +10281,19 @@ rb_thread_switch(n)
10289 10281
 }
10290 10282
 
10291 10283
 #define THREAD_SAVE_CONTEXT(th) \
10292  
-    (rb_thread_save_context(th),\
10293  
-     rb_thread_switch((FLUSH_REGISTER_WINDOWS, ruby_setjmp((th)->context))))
  10284
+    (rb_thread_switch((FLUSH_REGISTER_WINDOWS, ruby_setjmp(rb_thread_save_context(th), (th)->context))))
10294 10285
 
10295 10286
 NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
10296  
-
10297  
-# if defined(_MSC_VER) && _MSC_VER >= 1300
10298  
-__declspec(noinline) static void stack_extend(rb_thread_t, int);
10299  
-# endif
10300  
-static void
10301  
-stack_extend(th, exit)
10302  
-    rb_thread_t th;
10303  
-    int exit;
10304  
-{
10305  
-    VALUE space[1024];
10306  
-
10307  
-    memset(space, 0, 1);	/* prevent array from optimization */
10308  
-    rb_thread_restore_context(th, exit);
10309  
-}
  10287
+NORETURN(NOINLINE(static void rb_thread_restore_context_0(rb_thread_t,int,void*)));
  10288
+NORETURN(NOINLINE(static void stack_extend(rb_thread_t, int, VALUE *)));
10310 10289
 
10311 10290
 static void
10312  
-rb_thread_restore_context(th, exit)
10313  
-    rb_thread_t th;
10314  
-    int exit;
  10291
+rb_thread_restore_context_0(rb_thread_t th, int exit, void *vp)
10315 10292
 {
10316  
-    VALUE v;
10317 10293
     static rb_thread_t tmp;
10318 10294
     static int ex;
10319 10295
     static VALUE tval;
10320 10296
 
10321  
-    if (!th->stk_ptr) rb_bug("unsaved context");
10322  
-
10323  
-#if STACK_GROW_DIRECTION < 0
10324  
-    if (&v > th->stk_pos) stack_extend(th, exit);
10325  
-#elif STACK_GROW_DIRECTION > 0
10326  
-    if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
10327  
-#else
10328  
-    if (&v < rb_gc_stack_start) {
10329  
-	/* Stack grows downward */
10330  
-	if (&v > th->stk_pos) stack_extend(th, exit);
10331  
-    }
10332  
-    else {
10333  
-	/* Stack grows upward */
10334  
-	if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
10335  
-    }
10336  
-#endif
10337  
-
10338 10297
     rb_trap_immediate = 0;	/* inhibit interrupts from here */
10339 10298
     ruby_frame = th->frame;
10340 10299
     ruby_scope = th->scope;
@@ -10360,8 +10319,8 @@ rb_thread_restore_context(th, exit)
10360 10319
     ex = exit;
10361 10320
     FLUSH_REGISTER_WINDOWS;
10362 10321
     MEMCPY(tmp->stk_pos, tmp->stk_ptr, VALUE, tmp->stk_len);
10363  
-#ifdef __ia64__
10364  
-    MEMCPY((VALUE*)__libc_ia64_register_backing_store_base, tmp->bstr_ptr, VALUE, tmp->bstr_len);
  10322
+#ifdef __ia64
  10323
+    MEMCPY(tmp->bstr_pos, tmp->bstr_ptr, VALUE, tmp->bstr_len);
10365 10324
 #endif
10366 10325
 
10367 10326
     tval = rb_lastline_get();
@@ -10374,6 +10333,78 @@ rb_thread_restore_context(th, exit)
10374 10333
     ruby_longjmp(tmp->context, ex);
10375 10334
 }
10376 10335
 
  10336
+#ifdef __ia64
  10337
+#define C(a) rse_##a##0, rse_##a##1, rse_##a##2, rse_##a##3, rse_##a##4
  10338
+#define E(a) rse_##a##0= rse_##a##1= rse_##a##2= rse_##a##3= rse_##a##4
  10339
+static volatile int C(a), C(b), C(c), C(d), C(e);
  10340
+static volatile int C(f), C(g), C(h), C(i), C(j);
  10341
+static volatile int C(k), C(l), C(m), C(n), C(o);
  10342
+static volatile int C(p), C(q), C(r), C(s), C(t);
  10343
+int rb_dummy_false = 0;
  10344
+NORETURN(NOINLINE(static void register_stack_extend(rb_thread_t, int, void *, VALUE *)));
  10345
+static void
  10346
+register_stack_extend(rb_thread_t th, int exit, void *vp, VALUE *curr_bsp)
  10347
+{
  10348
+    if (rb_dummy_false) {
  10349
+        /* use registers as much as possible */
  10350
+        E(a) = E(b) = E(c) = E(d) = E(e) =
  10351
+        E(f) = E(g) = E(h) = E(i) = E(j) =
  10352
+        E(k) = E(l) = E(m) = E(n) = E(o) =
  10353
+        E(p) = E(q) = E(r) = E(s) = E(t) = 0;
  10354
+        E(a) = E(b) = E(c) = E(d) = E(e) =
  10355
+        E(f) = E(g) = E(h) = E(i) = E(j) =
  10356
+        E(k) = E(l) = E(m) = E(n) = E(o) =
  10357
+        E(p) = E(q) = E(r) = E(s) = E(t) = 0;
  10358
+    }
  10359
+    if (curr_bsp < th->bstr_pos+th->bstr_len) {
  10360
+        register_stack_extend(th, exit, &exit, (VALUE*)rb_ia64_bsp());
  10361
+    }
  10362
+    rb_thread_restore_context_0(th, exit, &exit);
  10363
+}
  10364
+#undef C
  10365
+#undef E
  10366
+#endif
  10367
+
  10368
+# if defined(_MSC_VER) && _MSC_VER >= 1300
  10369
+__declspec(noinline) static void stack_extend(rb_thread_t, int);
  10370
+# endif
  10371
+static void
  10372
+stack_extend(rb_thread_t th, int exit, VALUE *addr_in_prev_frame)
  10373
+{
  10374
+#define STACK_PAD_SIZE 1024
  10375
+    VALUE space[STACK_PAD_SIZE];
  10376
+
  10377
+#if STACK_GROW_DIRECTION < 0
  10378
+    if (addr_in_prev_frame > th->stk_pos) stack_extend(th, exit, &space[0]);
  10379
+#elif STACK_GROW_DIRECTION > 0
  10380
+    if (addr_in_prev_frame < th->stk_pos + th->stk_len) stack_extend(th, exit, &space[STACK_PAD_SIZE-1]);
  10381
+#else
  10382
+    if (addr_in_prev_frame < rb_gc_stack_start) {
  10383
+        /* Stack grows downward */
  10384
+        if (addr_in_prev_frame > th->stk_pos) stack_extend(th, exit, &space[0]);
  10385
+    }
  10386
+    else {
  10387
+        /* Stack grows upward */
  10388
+        if (addr_in_prev_frame < th->stk_pos + th->stk_len) stack_extend(th, exit, &space[STACK_PAD_SIZE-1]);
  10389
+    }
  10390
+#endif
  10391
+#ifdef __ia64
  10392
+    register_stack_extend(th, exit, space, (VALUE*)rb_ia64_bsp());
  10393
+#else
  10394
+    rb_thread_restore_context_0(th, exit, space);
  10395
+#endif
  10396
+}
  10397
+
  10398
+static void
  10399
+rb_thread_restore_context(th, exit)
  10400
+    rb_thread_t th;
  10401
+    int exit;
  10402
+{
  10403
+    VALUE v;
  10404
+    if (!th->stk_ptr) rb_bug("unsaved context");
  10405
+    stack_extend(th, exit, &v);
  10406
+}
  10407
+
10377 10408
 static void
10378 10409
 rb_thread_ready(th)
10379 10410
     rb_thread_t th;
@@ -11579,7 +11610,7 @@ rb_thread_group(thread)
11579 11610
     return group;
11580 11611
 }
11581 11612
 
11582  
-#ifdef __ia64__
  11613
+#ifdef __ia64
11583 11614
 # define IA64_INIT(x) x
11584 11615
 #else
11585 11616
 # define IA64_INIT(x)
@@ -11601,6 +11632,7 @@ rb_thread_group(thread)
11601 11632
     th->wait_for = 0;\
11602 11633
     IA64_INIT(th->bstr_ptr = 0);\
11603 11634
     IA64_INIT(th->bstr_len = 0);\
  11635
+    IA64_INIT(th->bstr_max = 0);\
11604 11636
     FD_ZERO(&th->readfds);\
11605 11637
     FD_ZERO(&th->writefds);\
11606 11638
     FD_ZERO(&th->exceptfds);\
@@ -13054,13 +13086,3 @@ rb_throw(tag, val)
13054 13086
     argv[1] = val;
13055 13087
     rb_f_throw(2, argv);
13056 13088
 }
13057  
-
13058  
-/* flush_register_windows must not be inlined because flushrs doesn't flush
13059  
- * current frame in register stack. */
13060  
-#ifdef __ia64__
13061  
-void flush_register_windows(void)
13062  
-{
13063  
-    __asm__ ("flushrs");
13064  
-}
13065  
-#endif
13066  
-
95  gc.c
@@ -30,20 +30,6 @@
30 30
 #include <sys/resource.h>
31 31
 #endif
32 32
 
33  
-#ifdef __ia64__
34  
-#include <ucontext.h>
35  
-#if defined(__FreeBSD__)
36  
-/*
37  
- * FreeBSD/ia64 currently does not have a way for a process to get the
38  
- * base address for the RSE backing store, so hardcode it.
39  
- */
40  
-#define __libc_ia64_register_backing_store_base (4ULL<<61)
41  
-#else
42  
-#pragma weak __libc_ia64_register_backing_store_base
43  
-extern unsigned long __libc_ia64_register_backing_store_base;
44  
-#endif
45  
-#endif
46  
-
47 33
 #if defined _WIN32 || defined __CYGWIN__
48 34
 #include <windows.h>
49 35
 #endif
@@ -423,6 +409,9 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
423 409
 
424 410
 extern st_table *rb_class_tbl;
425 411
 VALUE *rb_gc_stack_start = 0;
  412
+#ifdef __ia64
  413
+VALUE *rb_gc_register_stack_start = 0;
  414
+#endif
426 415
 
427 416
 #ifdef DJGPP
428 417
 /* set stack size (http://www.delorie.com/djgpp/v2faq/faq15_9.html) */
@@ -445,7 +434,7 @@ static unsigned int STACK_LEVEL_MAX = 655300;
445 434
 # define SET_STACK_END VALUE stack_end; alloca(0);
446 435
 # define STACK_END (&stack_end)
447 436
 #else
448  
-# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS) && !defined(__ia64__)
  437
+# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS) && !defined(__ia64)
449 438
 #  if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
450 439
 __attribute__ ((noinline))
451 440
 #  endif
@@ -1385,23 +1374,10 @@ garbage_collect()
1385 1374
     else
1386 1375
 	rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END + 1);
1387 1376
 #endif
1388  
-#ifdef __ia64__
  1377
+#ifdef __ia64
1389 1378
     /* mark backing store (flushed register window on the stack) */
1390 1379
     /* the basic idea from guile GC code                         */
1391  
-    {
1392  
-	ucontext_t ctx;
1393  
-	VALUE *top, *bot;
1394  
-	getcontext(&ctx);
1395  
-	mark_locations_array((VALUE*)&ctx.uc_mcontext,
1396  
-			     ((size_t)(sizeof(VALUE)-1 + sizeof ctx.uc_mcontext)/sizeof(VALUE)));
1397  
-	bot = (VALUE*)__libc_ia64_register_backing_store_base;
1398  
-#if defined(__FreeBSD__)
1399  
-	top = (VALUE*)ctx.uc_mcontext.mc_special.bspstore;
1400  
-#else
1401  
-	top = (VALUE*)ctx.uc_mcontext.sc_ar_bsp;
1402  
-#endif
1403  
-	rb_gc_mark_locations(bot, top);
1404  
-    }
  1380
+    rb_gc_mark_locations(rb_gc_register_stack_start, (VALUE*)rb_ia64_bsp());
1405 1381
 #endif
1406 1382
 #if defined(__human68k__) || defined(__mc68000__)
1407 1383
     rb_gc_mark_locations((VALUE*)((char*)STACK_END + 2),
@@ -1477,6 +1453,28 @@ void
1477 1453
 Init_stack(addr)
1478 1454
     VALUE *addr;
1479 1455
 {
  1456
+#ifdef __ia64
  1457
+    if (rb_gc_register_stack_start == 0) {
  1458
+# if defined(__FreeBSD__)
  1459
+        /*
  1460
+         * FreeBSD/ia64 currently does not have a way for a process to get the
  1461
+         * base address for the RSE backing store, so hardcode it.
  1462
+         */
  1463
+        rb_gc_register_stack_start = (4ULL<<61);
  1464
+# elif defined(HAVE___LIBC_IA64_REGISTER_BACKING_STORE_BASE)
  1465
+#  pragma weak __libc_ia64_register_backing_store_base
  1466
+        extern unsigned long __libc_ia64_register_backing_store_base;
  1467
+        rb_gc_register_stack_start = (VALUE*)__libc_ia64_register_backing_store_base;
  1468
+# endif
  1469
+    }
  1470
+    {
  1471
+        VALUE *bsp = (VALUE*)rb_ia64_bsp();
  1472
+        if (rb_gc_register_stack_start == 0 ||
  1473
+            bsp < rb_gc_register_stack_start) {
  1474
+            rb_gc_register_stack_start = bsp;
  1475
+        }
  1476
+    }
  1477
+#endif
1480 1478
 #if defined(_WIN32) || defined(__CYGWIN__)
1481 1479
     MEMORY_BASIC_INFORMATION m;
1482 1480
     memset(&m, 0, sizeof(m));
@@ -1485,8 +1483,10 @@ Init_stack(addr)
1485 1483
 	STACK_UPPER((VALUE *)&m, (VALUE *)m.BaseAddress,
1486 1484
 		    (VALUE *)((char *)m.BaseAddress + m.RegionSize) - 1);
1487 1485
 #elif defined(STACK_END_ADDRESS)
1488  
-    extern void *STACK_END_ADDRESS;
1489  
-    rb_gc_stack_start = STACK_END_ADDRESS;
  1486
+    {
  1487
+        extern void *STACK_END_ADDRESS;
  1488
+        rb_gc_stack_start = STACK_END_ADDRESS;
  1489
+    }
1490 1490
 #else
1491 1491
     if (!addr) addr = (VALUE *)&addr;
1492 1492
     STACK_UPPER(&addr, addr, ++addr);
@@ -1513,6 +1513,37 @@ Init_stack(addr)
1513 1513
 #endif
1514 1514
 }
1515 1515
 
  1516
+void ruby_init_stack(VALUE *addr
  1517
+#ifdef __ia64
  1518
+    , void *bsp
  1519
+#endif
  1520
+    )
  1521
+{
  1522
+    if (!rb_gc_stack_start ||
  1523
+        STACK_UPPER(&addr,
  1524
+                    rb_gc_stack_start > addr,
  1525
+                    rb_gc_stack_start < addr)) {
  1526
+        rb_gc_stack_start = addr;
  1527
+    }
  1528
+#ifdef __ia64
  1529
+    if (!rb_gc_register_stack_start ||
  1530
+        (VALUE*)bsp < rb_gc_register_stack_start) {
  1531
+        rb_gc_register_stack_start = (VALUE*)bsp;
  1532
+    }
  1533
+#endif
  1534
+#ifdef HAVE_GETRLIMIT
  1535
+    {
  1536
+        struct rlimit rlim;
  1537
+
  1538
+        if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
  1539
+            unsigned int space = rlim.rlim_cur/5;
  1540
+
  1541
+            if (space > 1024*1024) space = 1024*1024;
  1542
+            STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
  1543
+        }
  1544
+    }
  1545
+#endif
  1546
+}
1516 1547
 
1517 1548
 /*
1518 1549
  * Document-class: ObjectSpace
9  main.c
@@ -41,8 +41,11 @@ main(argc, argv, envp)
41 41
     argc = ccommand(&argv);
42 42
 #endif
43 43
 
44  
-    ruby_init();
45  
-    ruby_options(argc, argv);
46  
-    ruby_run();
  44
+    {
  45
+        RUBY_INIT_STACK
  46
+        ruby_init();
  47
+        ruby_options(argc, argv);
  48
+        ruby_run();
  49
+    }
47 50
     return 0;
48 51
 }
4  numeric.c
@@ -2042,6 +2042,10 @@ fix_mul(x, y)
2042 2042
     VALUE x, y;
2043 2043
 {
2044 2044
     if (FIXNUM_P(y)) {
  2045
+#ifdef __HP_cc
  2046
+        /* avoids an optimization bug of HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005] */
  2047
+        volatile
  2048
+#endif
2045 2049
 	long a, b, c;
2046 2050
 	VALUE r;
2047 2051
 
25  ruby.h
@@ -25,6 +25,15 @@ extern "C" {
25 25
 #ifdef RUBY_EXTCONF_H
26 26
 #include RUBY_EXTCONF_H
27 27
 #endif
  28
+
  29
+#define NORETURN_STYLE_NEW 1
  30
+#ifndef NORETURN
  31
+# define NORETURN(x) x
  32
+#endif
  33
+#ifndef NOINLINE
  34
+# define NOINLINE(x) x
  35
+#endif
  36
+
28 37
 #include "defines.h"
29 38
 
30 39
 #ifdef HAVE_STDLIB_H
@@ -58,11 +67,6 @@ extern "C" {
58 67
 #define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c)))
59 68
 #endif
60 69
 
61  
-#define NORETURN_STYLE_NEW 1
62  
-#ifndef NORETURN
63  
-# define NORETURN(x) x
64  
-#endif
65  
-
66 70
 #if defined(HAVE_ALLOCA_H)
67 71
 #include <alloca.h>
68 72
 #else
@@ -565,6 +569,17 @@ NORETURN(void rb_throw _((const char*,VALUE)));
565 569
 
566 570
 VALUE rb_require _((const char*));
567 571
 
  572
+#ifdef __ia64
  573
+void ruby_init_stack(VALUE*, void*);
  574
+#define RUBY_INIT_STACK \
  575
+    VALUE variable_in_this_stack_frame; \
  576
+    ruby_init_stack(&variable_in_this_stack_frame, rb_ia64_bsp());
  577
+#else
  578
+void ruby_init_stack(VALUE*);
  579
+#define RUBY_INIT_STACK \
  580
+    VALUE variable_in_this_stack_frame; \
  581
+    ruby_init_stack(&variable_in_this_stack_frame);
  582
+#endif
568 583
 void ruby_init _((void));
569 584
 void ruby_options _((int, char**));
570 585
 NORETURN(void ruby_run _((void)));

0 notes on commit f8e87ab

Please sign in to comment.
Something went wrong with that request. Please try again.