Skip to content

Commit

Permalink
Added external interface to start timer server thread (RDOS).
Browse files Browse the repository at this point in the history
  • Loading branch information
rdos314 committed Nov 27, 2024
1 parent cb46ef1 commit ed7019b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 53 deletions.
13 changes: 10 additions & 3 deletions bld/clib/mthread/c/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@

static int __CInitThread( void *p ) { p=p; return( 0 ); }

static beginner *__BeginThread = __CBeginThread;
static ender *__EndThread = __CEndThread;
static initializer *__InitThread = __CInitThread;
static beginner *__BeginThread = __CBeginThread;
static ender *__EndThread = __CEndThread;
static initializer *__InitThread = __CInitThread;
#if defined( __RDOS__ )
static timerbeginner *__BeginTimerThread = __CBeginTimerThread;
#endif

int __initthread( void *p )
{
Expand All @@ -67,6 +70,10 @@ _WCRTLINK int _beginthread( thread_fn *start_addr, int prio,
{
return( __BeginThread( start_addr, prio, thread_name, stack_size, arglist ) );
}
_WCRTLINK void _begintimerthread( thread_fn *start_addr )
{
__BeginTimerThread( start_addr );
}
#elif defined( __RDOSDEV__ )
_WCRTLINK int _beginthread( thread_fn *start_addr, int prio,
const char *thread_name,
Expand Down
11 changes: 11 additions & 0 deletions bld/clib/rdos/c/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,19 @@
#include <stdio.h>
#include <stddef.h>
#include <time.h>
#include <process.h>
#include "rdos.h"

static void TimerThread( void *param )
{
/* unused parameters */ (void)param;
}

void RdosCreateTimerThread( void )
{
_begintimerthread( &TimerThread );
}

_WCRTLINK int timer_create( clockid_t __clk, struct sigevent *__sevp, timer_t *__tmr )
{
/* unused parameters */ (void)__clk; (void)__sevp, (void)__tmr;
Expand Down
3 changes: 3 additions & 0 deletions bld/hdr/watcom/process.mh
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ extern pid_t tfork( char *__stk_addr, unsigned __stk_size, int (*__func)(void*),
const char *__thread_name,
unsigned __stack_size, void *__arglist );
#pragma intrinsic(_beginthread)
_WCRTLINK extern void _begintimerthread(
void (_WCCALLBACK *__start_address)(void *) );
#pragma intrinsic(_begintimerthread)
_WCRTLINK extern void _endthread( void );
:elsesegment LINUX | QNX
#ifdef __386__
Expand Down
30 changes: 6 additions & 24 deletions bld/watcom/h/owflat.h
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,12 @@
__value [__eax] \
__modify [__edx]

#pragma aux RdosGetHandleCount = \
CallGate_get_handle_count \
"jnc ok" \
"mov ecx,256" \
"ok: " \
__value [__ecx]

#pragma aux RdosOpenHandle = \
CallGate_open_handle \
Expand Down Expand Up @@ -2226,30 +2232,6 @@
CarryToBool \
__value [__eax]

#pragma aux RdosStartTimer = \
CallGate_start_user_timer \
__parm [__edi] [__esi] [__ebx] [__edx __eax]

#pragma aux RdosStartTimeout = \
CallGate_start_user_timeout \
__parm [__edi] [__esi] [__ebx] [__eax]

#pragma aux RdosUpdateTimer = \
CallGate_update_user_timer \
CarryToBool \
__parm [__ebx] [__edx __eax] \
__value [__eax]

#pragma aux RdosUpdateTimeout = \
CallGate_update_user_timeout \
CarryToBool \
__parm [__ebx] [__eax] \
__value [__eax]

#pragma aux RdosStopTimer = \
CallGate_stop_user_timer \
__parm [__ebx]

#pragma aux RdosGetActiveCores = \
CallGate_get_active_cores \
__value [__eax]
Expand Down
13 changes: 5 additions & 8 deletions bld/watcom/h/rdos.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ struct RdosDirEntry
{
long long Inode;
long long Size;
long long CreateTime;
long long AccessTime;
long long ModifyTime;
unsigned long long CreateTime;
unsigned long long AccessTime;
unsigned long long ModifyTime;
int Attrib;
int Flags;
int Uid;
Expand Down Expand Up @@ -592,6 +592,7 @@ int RDOSAPI RdosGetCanBridgeVersion(int *MajorVersion, int *MinorVersion, int *S
int RDOSAPI RdosProgramCanBridge(const char *ProgramName);
int RDOSAPI RdosWaitForCanBridgeProgramming(int *ErrorCode, int *Position);

int RDOSAPI RdosGetHandleCount();
int RDOSAPI RdosOpenHandle(const char *Name, int Mode);
int RDOSAPI RdosCloseHandle(int Handle);
int RDOSAPI RdosDeleteHandle(int Handle);
Expand Down Expand Up @@ -723,11 +724,7 @@ void RDOSAPI RdosTerminateThread();
int RDOSAPI RdosGetThreadHandle(void);
int RDOSAPI RdosGetProcessHandle(void);

void RDOSAPI RdosStartTimer(long long (*Callback)(void *Param, long long Expire), void *Param, int ID, long long Expire);
void RDOSAPI RdosStartTimeout(long long (*Callback)(void *Param, long long Expire), void *Param, int ID, int Ms);
int RDOSAPI RdosUpdateTimer(int ID, long long Expire);
int RDOSAPI RdosUpdateTimeout(int ID, int Ms);
void RDOSAPI RdosStopTimer(int ID);
void RDOSAPI RdosCreateTimerThread(void);

int RDOSAPI RdosHasGlobalTimer();
int RDOSAPI RdosGetActiveCores();
Expand Down
24 changes: 6 additions & 18 deletions bld/watcom/h/rdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,8 @@
#define usergate_update_handle 0x00000352
#define usergate_delete_handle 0x00000353

#define usergate_start_user_timer 0x00000354
#define usergate_start_user_timeout 0x00000355
#define usergate_update_user_timer 0x00000356
#define usergate_update_user_timeout 0x00000357
#define usergate_stop_user_timer 0x00000358
#define usergate_init_user_timer 0x00000359
#define usergate_get_handle_count 0x00000354
#define usergate_create_timer_thread 0x00000355



Expand Down Expand Up @@ -2062,12 +2058,8 @@
#define CallGate_update_handle 0x55 0x67 0x9a 82 3 0 0 3 0 0x5d
#define CallGate_delete_handle 0x55 0x67 0x9a 83 3 0 0 3 0 0x5d

#define CallGate_start_user_timer 0x55 0x67 0x9a 84 3 0 0 3 0 0x5d
#define CallGate_start_user_timeout 0x55 0x67 0x9a 85 3 0 0 3 0 0x5d
#define CallGate_update_user_timer 0x55 0x67 0x9a 86 3 0 0 3 0 0x5d
#define CallGate_update_user_timeout 0x55 0x67 0x9a 87 3 0 0 3 0 0x5d
#define CallGate_stop_user_timer 0x55 0x67 0x9a 88 3 0 0 3 0 0x5d
#define CallGate_init_user_timer 0x55 0x67 0x9a 89 3 0 0 3 0 0x5d
#define CallGate_get_handle_count 0x55 0x67 0x9a 84 3 0 0 3 0 0x5d
#define CallGate_create_timer_thread 0x55 0x67 0x9a 85 3 0 0 3 0 0x5d

#else

Expand Down Expand Up @@ -3097,11 +3089,7 @@
#define CallGate_update_handle 0x3e 0x67 0x9a 82 3 0 0 3 0
#define CallGate_delete_handle 0x3e 0x67 0x9a 83 3 0 0 3 0

#define CallGate_start_user_timer 0x3e 0x67 0x9a 84 3 0 0 3 0
#define CallGate_start_user_timeout 0x3e 0x67 0x9a 85 3 0 0 3 0
#define CallGate_update_user_timer 0x3e 0x67 0x9a 86 3 0 0 3 0
#define CallGate_update_user_timeout 0x3e 0x67 0x9a 87 3 0 0 3 0
#define CallGate_stop_user_timer 0x3e 0x67 0x9a 88 3 0 0 3 0
#define CallGate_init_user_timer 0x3e 0x67 0x9a 89 3 0 0 3 0
#define CallGate_get_handle_count 0x3e 0x67 0x9a 84 3 0 0 3 0
#define CallGate_create_timer_thread 0x3e 0x67 0x9a 85 3 0 0 3 0

#endif

0 comments on commit ed7019b

Please sign in to comment.