Ver código fonte

Added new bb_thread_t type. (#339)

Fixed DebugDeclNext pointer addition.
Brucey 8 meses atrás
pai
commit
120dc1f3ff

+ 1 - 1
appstub.mod/debugger.stdio.glue.c

@@ -30,7 +30,7 @@ unsigned int bmx_debugger_DebugDeclKind(struct BBDebugDecl * decl) {
 }
 }
 
 
 struct BBDebugDecl * bmx_debugger_DebugDeclNext( struct BBDebugDecl * decl ) {
 struct BBDebugDecl * bmx_debugger_DebugDeclNext( struct BBDebugDecl * decl ) {
-	return ((char *)decl) + sizeof(struct BBDebugDecl);
+	return decl + 1;
 }
 }
 
 
 void * bmx_debugger_DebugDecl_VarAddress( struct BBDebugDecl * decl ) {
 void * bmx_debugger_DebugDecl_VarAddress( struct BBDebugDecl * decl ) {

+ 4 - 4
blitz.mod/blitz_thread.c

@@ -186,7 +186,7 @@ int bbThreadResume( BBThread *thread ){
 	return ResumeThread( thread->handle );
 	return ResumeThread( thread->handle );
 }
 }
 
 
-BBThread *bbThreadRegister( DWORD id ) {
+BBThread *bbThreadRegister( bb_thread_t id ) {
 
 
 	GC_call_with_stack_base(bbRegisterGCThread, NULL);
 	GC_call_with_stack_base(bbRegisterGCThread, NULL);
 
 
@@ -364,7 +364,7 @@ static void *threadProc( void *p ){
 
 
 	GC_call_with_stack_base(bbRegisterGCThread, NULL);
 	GC_call_with_stack_base(bbRegisterGCThread, NULL);
 
 
-	BBThread *thread=p;
+	BBThread *thread=(BBThread *)p;
 	
 	
 	pthread_setspecific( curThreadTls,thread );
 	pthread_setspecific( curThreadTls,thread );
 	
 	
@@ -406,7 +406,7 @@ BBThread *bbThreadCreate( BBThreadProc proc,BBObject *data ){
 	return 0;
 	return 0;
 }
 }
 
 
-BBThread *bbThreadRegister( void * thd ) {
+BBThread *bbThreadRegister( bb_thread_t thd ) {
 
 
 	GC_call_with_stack_base(bbRegisterGCThread, NULL);
 	GC_call_with_stack_base(bbRegisterGCThread, NULL);
 
 
@@ -444,7 +444,7 @@ void bbThreadDetach( BBThread *thread ){
 BBObject *bbThreadWait( BBThread *thread ){
 BBObject *bbThreadWait( BBThread *thread ){
 	BBObject *p=0;
 	BBObject *p=0;
 	thread->detached=1;
 	thread->detached=1;
-	pthread_join( thread->handle,&p );
+	pthread_join( thread->handle,(void**)&p );
 	return p;
 	return p;
 }
 }
 
 

+ 6 - 9
blitz.mod/blitz_thread.h

@@ -9,6 +9,7 @@ extern "C"{
 #ifdef _WIN32
 #ifdef _WIN32
 
 
 #include <windows.h>
 #include <windows.h>
+typedef DWORD bb_thread_t;
 typedef CRITICAL_SECTION bb_mutex_t;
 typedef CRITICAL_SECTION bb_mutex_t;
 #define bb_mutex_init(MUTPTR) (InitializeCriticalSection(MUTPTR),1)
 #define bb_mutex_init(MUTPTR) (InitializeCriticalSection(MUTPTR),1)
 #define bb_mutex_destroy(MUTPTR) DeleteCriticalSection(MUTPTR)
 #define bb_mutex_destroy(MUTPTR) DeleteCriticalSection(MUTPTR)
@@ -37,6 +38,7 @@ typedef HANDLE bb_sem_t;
 #include<switch/kernel/semaphore.h>
 #include<switch/kernel/semaphore.h>
 #include <threads.h>
 #include <threads.h>
 
 
+typedef thrd_t bb_thread_t;
 typedef mtx_t bb_mutex_t;
 typedef mtx_t bb_mutex_t;
 #define bb_mutex_init(MUTPTR) (mtx_init(MUTPTR,mtx_recursive),1)
 #define bb_mutex_init(MUTPTR) (mtx_init(MUTPTR,mtx_recursive),1)
 #define bb_mutex_destroy(MUTPTR)
 #define bb_mutex_destroy(MUTPTR)
@@ -53,6 +55,7 @@ typedef Semaphore bb_sem_t;
 #else
 #else
 
 
 #include <pthread.h>
 #include <pthread.h>
+typedef pthread_t bb_thread_t;
 typedef pthread_mutex_t bb_mutex_t;
 typedef pthread_mutex_t bb_mutex_t;
 extern pthread_mutexattr_t _bb_mutexattr;
 extern pthread_mutexattr_t _bb_mutexattr;
 #define bb_mutex_init(MUTPTR) (pthread_mutex_init((MUTPTR),&_bb_mutexattr)>=0)
 #define bb_mutex_init(MUTPTR) (pthread_mutex_init((MUTPTR),&_bb_mutexattr)>=0)
@@ -107,11 +110,9 @@ struct BBThread{
 #ifdef _WIN32
 #ifdef _WIN32
 	BBObject * result;
 	BBObject * result;
 	HANDLE handle;
 	HANDLE handle;
-	DWORD id;
-#elif __SWITCH__
-	thrd_t handle;
+	bb_thread_t id;
 #else
 #else
-	pthread_t handle;
+	bb_thread_t handle;
 #endif
 #endif
 };
 };
 
 
@@ -134,11 +135,7 @@ BBObject*		bbThreadGetData( int index );
 int			bbAtomicCAS( volatile int *target,int oldVal,int newVal );
 int			bbAtomicCAS( volatile int *target,int oldVal,int newVal );
 int			bbAtomicAdd( volatile int *target,int incr );
 int			bbAtomicAdd( volatile int *target,int incr );
 
 
-#ifdef _WIN32
-BBThread *bbThreadRegister( DWORD id );
-#else
-BBThread *bbThreadRegister( void * thd );
-#endif
+BBThread *bbThreadRegister( bb_thread_t id );
 void bbThreadUnregister( BBThread * thread );
 void bbThreadUnregister( BBThread * thread );