handle sizeof(pid_t) != sizeof(void*) gracefully
authorAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>
Fri, 28 Oct 2011 12:20:27 +0000 (05:20 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 01:28:05 +0000 (18:28 -0700)
kern/arch/riscv/types.h
kern/src/process.c

index 305210d..99b795f 100644 (file)
@@ -28,10 +28,10 @@ typedef unsigned int uint32_t;
 typedef long long int64_t;
 typedef unsigned long long uint64_t;
 
 typedef long long int64_t;
 typedef unsigned long long uint64_t;
 
-typedef long ssize_t;
-typedef long pid_t;
-typedef long uid_t;
-typedef long gid_t;
+typedef int64_t ssize_t;
+typedef int32_t pid_t;
+typedef int32_t uid_t;
+typedef int32_t gid_t;
 
 typedef unsigned long uintptr_t;
 
 
 typedef unsigned long uintptr_t;
 
index 6d89c7b..19f8016 100644 (file)
@@ -172,7 +172,7 @@ int __proc_set_state(struct proc *p, uint32_t state)
 struct proc *pid2proc(pid_t pid)
 {
        spin_lock(&pid_hash_lock);
 struct proc *pid2proc(pid_t pid)
 {
        spin_lock(&pid_hash_lock);
-       struct proc *p = hashtable_search(pid_hash, (void*)pid);
+       struct proc *p = hashtable_search(pid_hash, (void*)(long)pid);
        if (p)
                if (!kref_get_not_zero(&p->p_kref, 1))
                        p = 0;
        if (p)
                if (!kref_get_not_zero(&p->p_kref, 1))
                        p = 0;
@@ -368,7 +368,7 @@ error_t proc_alloc(struct proc **pp, struct proc *parent)
 void __proc_ready(struct proc *p)
 {
        spin_lock(&pid_hash_lock);
 void __proc_ready(struct proc *p)
 {
        spin_lock(&pid_hash_lock);
-       hashtable_insert(pid_hash, (void*)p->pid, p);
+       hashtable_insert(pid_hash, (void*)(long)p->pid, p);
        spin_unlock(&pid_hash_lock);
 }
 
        spin_unlock(&pid_hash_lock);
 }
 
@@ -414,7 +414,7 @@ static void __proc_free(struct kref *kref)
        }
        /* Remove us from the pid_hash and give our PID back (in that order). */
        spin_lock(&pid_hash_lock);
        }
        /* Remove us from the pid_hash and give our PID back (in that order). */
        spin_lock(&pid_hash_lock);
-       if (!hashtable_remove(pid_hash, (void*)p->pid))
+       if (!hashtable_remove(pid_hash, (void*)(long)p->pid))
                panic("Proc not in the pid table in %s", __FUNCTION__);
        spin_unlock(&pid_hash_lock);
        put_free_pid(p->pid);
                panic("Proc not in the pid table in %s", __FUNCTION__);
        spin_unlock(&pid_hash_lock);
        put_free_pid(p->pid);