Skip to content

Commit

Permalink
* fix for build on solaris 10.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jun 16, 2011
1 parent ef38cb7 commit 6854445
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 32 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Thu Jun 16 09:12:38 2011 Nobuyoshi Nakada <[email protected]>

* fix for build on solaris 10.

Thu Jun 16 09:08:39 2011 Nobuyoshi Nakada <[email protected]>

* test/io/console/test_io_console.rb (TestIO_Console#test_sync):
Expand Down
5 changes: 3 additions & 2 deletions cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,14 @@ fiber_machine_stack_alloc(size_t size)
}
}
else {
void *page;
STACK_GROW_DIR_DETECTION;
ptr = (VALUE*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
if (ptr == (VALUE*)(SIGNED_VALUE)-1) {
rb_raise(rb_eFiberError, "can't alloc machine stack to fiber");
}
if (mprotect(ptr + STACK_DIR_UPPER((size - RB_PAGE_SIZE) / sizeof(VALUE), 0),
RB_PAGE_SIZE, PROT_READ | PROT_WRITE) < 0) {
page = ptr + STACK_DIR_UPPER((size - RB_PAGE_SIZE) / sizeof(VALUE), 0);
if (mprotect(page, RB_PAGE_SIZE, PROT_READ | PROT_WRITE) < 0) {
rb_raise(rb_eFiberError, "mprotect failed");
}
}
Expand Down
1 change: 1 addition & 0 deletions eval_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ NORETURN(void _longjmp(jmp_buf, int));
*/
#ifdef HAVE_SELECT_LARGE_FDSET
#define select(n, r, w, e, t) select_large_fdset((n), (r), (w), (e), (t))
extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval *);
#endif

#ifdef HAVE_SYS_PARAM_H
Expand Down
3 changes: 2 additions & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -5007,7 +5007,8 @@ path_check_0(VALUE path, int execpath)
&& !(p && execpath && (st.st_mode & S_ISVTX))
#endif
&& !access(p0, W_OK)) {
rb_warn("Insecure world writable dir %s in %sPATH, mode 0%o",
rb_warn("Insecure world writable dir %s in %sPATH, mode 0%"
PRI_MODET_PREFIX"o",
p0, (execpath ? "" : "LOAD_"), st.st_mode);
if (p) *p = '/';
RB_GC_GUARD(path);
Expand Down
3 changes: 3 additions & 0 deletions include/ruby/missing.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ RUBY_EXTERN const unsigned char rb_nan[];
#ifndef isinf
# ifndef HAVE_ISINF
# if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
# ifdef HAVE_IEEEFP_H
# include <ieeefp.h>
# endif
# define isinf(x) (!finite(x) && !isnan(x))
# else
RUBY_EXTERN int isinf(double);
Expand Down
58 changes: 29 additions & 29 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ typedef struct rb_mutex_struct
struct rb_thread_struct volatile *th;
int cond_waiting;
struct rb_mutex_struct *next_mutex;
} mutex_t;
} rb_mutex_t;

static void rb_mutex_unlock_all(mutex_t *mutex, rb_thread_t *th);
static void rb_mutex_abandon_all(mutex_t *mutexes);
static void rb_mutex_unlock_all(rb_mutex_t *mutex, rb_thread_t *th);
static void rb_mutex_abandon_all(rb_mutex_t *mutexes);

void
rb_thread_terminate_all(void)
Expand Down Expand Up @@ -3322,20 +3322,20 @@ thgroup_add(VALUE group, VALUE thread)
*/

#define GetMutexPtr(obj, tobj) \
TypedData_Get_Struct((obj), mutex_t, &mutex_data_type, (tobj))
TypedData_Get_Struct((obj), rb_mutex_t, &mutex_data_type, (tobj))

static const char *mutex_unlock(mutex_t *mutex, rb_thread_t volatile *th);
static const char *rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t volatile *th);

#define mutex_mark NULL

static void
mutex_free(void *ptr)
{
if (ptr) {
mutex_t *mutex = ptr;
rb_mutex_t *mutex = ptr;
if (mutex->th) {
/* rb_warn("free locked mutex"); */
const char *err = mutex_unlock(mutex, mutex->th);
const char *err = rb_mutex_unlock_th(mutex, mutex->th);
if (err) rb_bug("%s", err);
}
native_mutex_destroy(&mutex->lock);
Expand All @@ -3347,7 +3347,7 @@ mutex_free(void *ptr)
static size_t
mutex_memsize(const void *ptr)
{
return ptr ? sizeof(mutex_t) : 0;
return ptr ? sizeof(rb_mutex_t) : 0;
}

static const rb_data_type_t mutex_data_type = {
Expand All @@ -3370,9 +3370,9 @@ static VALUE
mutex_alloc(VALUE klass)
{
VALUE volatile obj;
mutex_t *mutex;
rb_mutex_t *mutex;

obj = TypedData_Make_Struct(klass, mutex_t, &mutex_data_type, mutex);
obj = TypedData_Make_Struct(klass, rb_mutex_t, &mutex_data_type, mutex);
native_mutex_initialize(&mutex->lock);
native_cond_initialize(&mutex->cond, RB_CONDATTR_CLOCK_MONOTONIC);
return obj;
Expand Down Expand Up @@ -3405,15 +3405,15 @@ rb_mutex_new(void)
VALUE
rb_mutex_locked_p(VALUE self)
{
mutex_t *mutex;
rb_mutex_t *mutex;
GetMutexPtr(self, mutex);
return mutex->th ? Qtrue : Qfalse;
}

static void
mutex_locked(rb_thread_t *th, VALUE self)
{
mutex_t *mutex;
rb_mutex_t *mutex;
GetMutexPtr(self, mutex);

if (th->keeping_mutexes) {
Expand All @@ -3432,7 +3432,7 @@ mutex_locked(rb_thread_t *th, VALUE self)
VALUE
rb_mutex_trylock(VALUE self)
{
mutex_t *mutex;
rb_mutex_t *mutex;
VALUE locked = Qfalse;
GetMutexPtr(self, mutex);

Expand All @@ -3449,7 +3449,7 @@ rb_mutex_trylock(VALUE self)
}

static int
lock_func(rb_thread_t *th, mutex_t *mutex, int timeout_ms)
lock_func(rb_thread_t *th, rb_mutex_t *mutex, int timeout_ms)
{
int interrupted = 0;
int err = 0;
Expand Down Expand Up @@ -3491,7 +3491,7 @@ lock_func(rb_thread_t *th, mutex_t *mutex, int timeout_ms)
static void
lock_interrupt(void *ptr)
{
mutex_t *mutex = (mutex_t *)ptr;
rb_mutex_t *mutex = (rb_mutex_t *)ptr;
native_mutex_lock(&mutex->lock);
if (mutex->cond_waiting > 0)
native_cond_broadcast(&mutex->cond);
Expand All @@ -3510,7 +3510,7 @@ rb_mutex_lock(VALUE self)
{

if (rb_mutex_trylock(self) == Qfalse) {
mutex_t *mutex;
rb_mutex_t *mutex;
rb_thread_t *th = GET_THREAD();
GetMutexPtr(self, mutex);

Expand Down Expand Up @@ -3565,10 +3565,10 @@ rb_mutex_lock(VALUE self)
}

static const char *
mutex_unlock(mutex_t *mutex, rb_thread_t volatile *th)
rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t volatile *th)
{
const char *err = NULL;
mutex_t *th_mutex;
rb_mutex_t *th_mutex;

native_mutex_lock(&mutex->lock);

Expand All @@ -3593,7 +3593,7 @@ mutex_unlock(mutex_t *mutex, rb_thread_t volatile *th)
}
else {
while (1) {
mutex_t *tmp_mutex;
rb_mutex_t *tmp_mutex;
tmp_mutex = th_mutex->next_mutex;
if (tmp_mutex == mutex) {
th_mutex->next_mutex = tmp_mutex->next_mutex;
Expand All @@ -3619,35 +3619,35 @@ VALUE
rb_mutex_unlock(VALUE self)
{
const char *err;
mutex_t *mutex;
rb_mutex_t *mutex;
GetMutexPtr(self, mutex);

err = mutex_unlock(mutex, GET_THREAD());
err = rb_mutex_unlock_th(mutex, GET_THREAD());
if (err) rb_raise(rb_eThreadError, "%s", err);

return self;
}

static void
rb_mutex_unlock_all(mutex_t *mutexes, rb_thread_t *th)
rb_mutex_unlock_all(rb_mutex_t *mutexes, rb_thread_t *th)
{
const char *err;
mutex_t *mutex;
rb_mutex_t *mutex;

while (mutexes) {
mutex = mutexes;
/* rb_warn("mutex #<%p> remains to be locked by terminated thread",
mutexes); */
mutexes = mutex->next_mutex;
err = mutex_unlock(mutex, th);
err = rb_mutex_unlock_th(mutex, th);
if (err) rb_bug("invalid keeping_mutexes: %s", err);
}
}

static void
rb_mutex_abandon_all(mutex_t *mutexes)
rb_mutex_abandon_all(rb_mutex_t *mutexes)
{
mutex_t *mutex;
rb_mutex_t *mutex;

while (mutexes) {
mutex = mutexes;
Expand Down Expand Up @@ -3759,7 +3759,7 @@ VALUE
rb_barrier_wait(VALUE self)
{
VALUE mutex = GetBarrierPtr(self);
mutex_t *m;
rb_mutex_t *m;

if (!mutex) return Qfalse;
GetMutexPtr(mutex, m);
Expand Down Expand Up @@ -4721,7 +4721,7 @@ check_deadlock_i(st_data_t key, st_data_t val, int *found)
*found = 1;
}
else if (th->locking_mutex) {
mutex_t *mutex;
rb_mutex_t *mutex;
GetMutexPtr(th->locking_mutex, mutex);

native_mutex_lock(&mutex->lock);
Expand All @@ -4744,7 +4744,7 @@ debug_i(st_data_t key, st_data_t val, int *found)

printf("th:%p %d %d", th, th->status, th->interrupt_flag);
if (th->locking_mutex) {
mutex_t *mutex;
rb_mutex_t *mutex;
GetMutexPtr(th->locking_mutex, mutex);

native_mutex_lock(&mutex->lock);
Expand Down
3 changes: 3 additions & 0 deletions thread_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifdef HAVE_THR_STKSEGMENT
#include <thread.h>
#endif

static void native_mutex_lock(pthread_mutex_t *lock);
static void native_mutex_unlock(pthread_mutex_t *lock);
Expand Down

0 comments on commit 6854445

Please sign in to comment.