[rtems-libbsd commit] Fix curthread so it returns a valid value.

Jennifer Averett jennifer at rtems.org
Tue Jul 17 13:17:10 UTC 2012


Module:    rtems-libbsd
Branch:    master
Commit:    325120c8755aa974a03fc85f020857fbec9cc071
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=325120c8755aa974a03fc85f020857fbec9cc071

Author:    Jennifer Averett <jennifer.averett at oarcorp.com>
Date:      Tue Jul 17 08:20:46 2012 -0500

Fix curthread so it returns a valid value.

---

 freebsd/sys/pcpu.h                |    5 +++++
 rtemsbsd/src/rtems-bsd-syscalls.c |    4 ++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/freebsd/sys/pcpu.h b/freebsd/sys/pcpu.h
index 8c93f2a..ce84f15 100644
--- a/freebsd/sys/pcpu.h
+++ b/freebsd/sys/pcpu.h
@@ -199,6 +199,11 @@ SLIST_HEAD(cpuhead, pcpu);
 extern struct cpuhead cpuhead;
 extern struct pcpu *cpuid_to_pcpu[MAXCPU];
 
+#ifdef __rtems__
+struct thread *rtems_get_curthread(void);
+#define	curthread	rtems_get_curthread()
+#endif
+
 #define	curcpu		PCPU_GET(cpuid)
 #define	curproc		(curthread->td_proc)
 #ifndef curthread
diff --git a/rtemsbsd/src/rtems-bsd-syscalls.c b/rtemsbsd/src/rtems-bsd-syscalls.c
index aad2e92..eb00ef5 100644
--- a/rtemsbsd/src/rtems-bsd-syscalls.c
+++ b/rtemsbsd/src/rtems-bsd-syscalls.c
@@ -202,6 +202,10 @@ socket (int domain, int type, int protocol)
 	int fd, error;
 
 	td = curthread;
+        if (!td) { 
+          printf("Current thread NULL\n");
+          exit(0);
+        }
 #ifdef MAC
 	error = mac_socket_check_create(td->td_ucred, domain, type, protocol);
 	if (error == 0 )




More information about the vc mailing list