📄 tsk.h
字号:
#if (TSK_TURBO)
/*
*** NOTE *** The following definitions are missing from the
TC++ 1.0 DOS.H file. If you're still using this compiler,
please enable the lines by replacing "if (0)" with "if (1)".
*/
#if (0)
unsigned char _Cdecl __inportb__(int __portid);
void _Cdecl __outportb__ (int __portid, unsigned char __value);
#define inportb __inportb__
#define outportb __outportb__
#endif
#define tsk_cli() disable()
#define tsk_sti() enable()
#define tsk_outp(p,b) outportb(p,b)
#define tsk_inp(p) ((byte) inportb(p))
extern word Globalfunc tsk_inpw (word port);
#elif TSK_MSC
#pragma intrinsic(_disable,_enable,outp,inp,inpw)
#define tsk_cli() _disable()
#define tsk_sti() _enable()
#define tsk_outp(p,b) outp(p,b)
#define tsk_inp(p) ((byte) inp(p))
#define tsk_inpw(p) ((byte) inpw(p))
#else
extern int Globalfunc tsk_dis_int (void);
extern void Globalfunc tsk_ena_int (int);
extern void Globalfunc tsk_cli (void);
extern void Globalfunc tsk_sti (void);
#endif
#define TMK_FP(seg,ofs) ((farptr)(((dword)(seg) << 16) | (word)(ofs)))
#define TFP_SEG(ptr) ((word)((dword)ptr >> 16))
#define TFP_OFF(ptr) ((word)((dword)ptr))
#define TSK_OFFSETOF(struc,elem) ((word)(&((struc near *)0)->elem))
#define TSK_STRUCTOP(struc,ptr,elem) ((struc far *)((byteptr)ptr - TSK_OFFSETOF(struc, elem)))
#define LNULL ((void far *)0L)
/* module tsktask */
extern int tsk_use_ndp;
extern tcbptr Globalfunc create_task (tcbptr task, funcptr func, byteptr stack,
word stksz, word prior, farptr arg
TN(byteptr name));
extern void Globalfunc kill_task (tcbptr task);
extern int Globalfunc start_task (tcbptr task);
/* module tsktutl */
extern int Globalfunc wake_task (tcbptr task);
extern int Globalfunc stop_task (tcbptr task);
extern word Globalfunc get_priority (tcbptr task);
extern void Globalfunc set_priority (tcbptr task, word prior);
extern void Globalfunc set_task_flags (tcbptr task, byte flags);
extern void Globalfunc set_funcs (tcbptr task, funcptr save, funcptr rest);
extern farptr Globalfunc set_user_ptr (tcbptr task, farptr uptr);
extern farptr Globalfunc get_user_ptr (tcbptr task);
extern tcbptr Globalfunc curr_task (void);
/* module tsktops */
extern tlinkptr CGlobalfunc create_timer_elem (tlinkptr elem, dword tout,
farptr strucp, byte kind,
int rept, ...);
extern tlinkptr CGlobalfunc create_timer (tlinkptr elem, dword tout, farptr strucp,
byte kind, int rept, ...);
extern void Globalfunc enable_timer (tlinkptr elem);
extern void Globalfunc disable_timer (tlinkptr elem);
extern void Globalfunc delete_timer (tlinkptr elem);
extern void CGlobalfunc change_timer (tlinkptr elem, dword tout, int rept, ...);
/* module tsktsub */
extern void Globalfunc enable_watch (tlinkptr elem);
#if (CHECKING)
extern void Globalfunc disable_hwatch (tlinkptr elem, byte typ);
extern void Globalfunc delete_hwatch (tlinkptr elem, byte typ);
#define disable_watch(elem) disable_hwatch(elem,TYP_WATCH);
#define delete_watch(elem) delete_hwatch(elem,TYP_WATCH);
#define disable_hotkey(elem) disable_hwatch(elem,TYP_HOTKEY);
#define delete_hotkey(elem) delete_hwatch(elem,TYP_HOTKEY);
#else
extern void Globalfunc disable_watch (tlinkptr elem);
extern void Globalfunc delete_watch (tlinkptr elem);
#define disable_hotkey(elem) disable_watch(elem);
#define delete_hotkey(elem) delete_watch(elem);
#endif
/* module tskmemw */
extern tlinkptr CGlobalfunc create_memory_watch_elem (tlinkptr elem, farptr address,
word mask, word compare,
byte cmpkind, farptr strucp,
byte kind, int rept, ...);
extern tlinkptr CGlobalfunc create_memory_watch (tlinkptr elem, farptr address,
word mask, word compare,
byte cmpkind, farptr strucp,
byte kind, int rept, ...);
extern int Globalfunc wait_memory (farptr address,
word mask, word compare, byte cmpkind);
/* module tskporw */
extern tlinkptr CGlobalfunc create_port_watch_elem (tlinkptr elem,
word port, byte in_word,
word mask, word compare,
byte cmpkind, farptr strucp,
byte kind, int rept, ...);
extern tlinkptr CGlobalfunc create_port_watch (tlinkptr elem,
word port, byte in_word,
word mask, word compare,
byte cmpkind, farptr strucp,
byte kind, int rept, ...);
extern int Globalfunc wait_port (word port, byte in_word,
word mask, word compare, byte cmpkind);
/* module tskhot */
#if (HOTKEYS)
extern tlinkptr CGlobalfunc create_hotkey_elem (tlinkptr elem, byte scancode,
byte mask1, byte flag1,
byte mask2, byte flag2,
byte mask3, byte flag3,
farptr strucp, byte kind,
int rept, ...);
extern tlinkptr CGlobalfunc create_hotkey_entry (tlinkptr elem, byte scancode,
byte mask1, byte flag1,
byte mask2, byte flag2,
byte mask3, byte flag3,
farptr strucp, byte kind,
int rept, ...);
extern int Globalfunc wait_hotkey (byte scancode,
byte mask1, byte flag1,
byte mask2, byte flag2,
byte mask3, byte flag3);
extern void Globalfunc enable_hotkey (tlinkptr elem);
#endif
/* module tskrsc */
extern resourceptr Globalfunc create_resource (resourceptr rsc TN(byteptr name));
extern void Globalfunc delete_resource (resourceptr rsc);
extern int Globalfunc request_resource (resourceptr rsc, dword timeout);
extern int Globalfunc c_request_resource (resourceptr rsc);
extern int Globalfunc request_cresource (resourceptr rsc, dword timeout);
extern int Globalfunc c_request_cresource (resourceptr rsc);
extern void Globalfunc release_resource (resourceptr rsc);
extern int Globalfunc check_resource (resourceptr rsc);
/* module tskflg */
extern flagptr Globalfunc create_flag (flagptr flg TN(byteptr name));
extern void Globalfunc delete_flag (flagptr flg);
extern int Globalfunc wait_flag_set (flagptr flg, dword timeout);
extern int Globalfunc wait_flag_clear (flagptr flg, dword timeout);
extern void Globalfunc set_flag (flagptr flg);
extern void Globalfunc clear_flag (flagptr flg);
extern int Globalfunc clear_flag_wait_set (flagptr flg, dword timeout);
extern int Globalfunc check_flag (flagptr flg);
/* module tskcnt */
extern counterptr Globalfunc create_counter (counterptr cnt TN(byteptr name));
extern void Globalfunc delete_counter (counterptr cnt);
extern void Globalfunc clear_counter (counterptr cnt);
extern int Globalfunc wait_counter_set (counterptr cnt, dword timeout);
extern int Globalfunc wait_counter_clear (counterptr cnt, dword timeout);
extern dword Globalfunc inc_counter (counterptr cnt);
extern dword Globalfunc dec_counter (counterptr cnt);
extern dword Globalfunc check_counter (counterptr cnt);
extern void Globalfunc set_counter (counterptr cnt, dword val);
/* module tskmsg */
extern mailboxptr Globalfunc create_mailbox (mailboxptr box TN(byteptr name));
extern void Globalfunc delete_mailbox (mailboxptr box);
extern farptr Globalfunc wait_mail (mailboxptr box, dword timeout);
extern farptr Globalfunc c_wait_mail (mailboxptr box);
extern void Globalfunc send_mail (mailboxptr box, farptr msg);
extern int Globalfunc check_mailbox (mailboxptr box);
/* module tskpip */
extern pipeptr Globalfunc create_pipe (pipeptr pip, farptr buf, word bufsize
TN(byteptr name));
extern void Globalfunc delete_pipe (pipeptr pip);
extern int Globalfunc read_pipe (pipeptr pip, dword timeout);
extern int Globalfunc c_read_pipe (pipeptr pip);
extern int Globalfunc write_pipe (pipeptr pip, byte ch, dword timeout);
extern int Globalfunc c_write_pipe (pipeptr pip, byte ch);
extern int Globalfunc wait_pipe_empty (pipeptr pip, dword timeout);
extern int Globalfunc check_pipe (pipeptr pip);
extern word Globalfunc pipe_free (pipeptr pip);
extern void Globalfunc flush_pipe (pipeptr pip);
/* module tskwpip */
extern wpipeptr Globalfunc create_wpipe (wpipeptr pip, farptr buf, word bufsize
TN(byteptr name));
extern void Globalfunc delete_wpipe (wpipeptr pip);
extern word Globalfunc read_wpipe (wpipeptr pip, dword timeout);
extern word Globalfunc c_read_wpipe (wpipeptr pip);
extern int Globalfunc write_wpipe (wpipeptr pip, word ch, dword timeout);
extern int Globalfunc c_write_wpipe (wpipeptr pip, word ch);
extern int Globalfunc wait_wpipe_empty (wpipeptr pip, dword timeout);
extern word Globalfunc check_wpipe (wpipeptr pip);
extern word Globalfunc wpipe_free (wpipeptr pip);
extern void Globalfunc flush_wpipe (wpipeptr pip);
/* module tskbuf */
extern bufferptr Globalfunc create_buffer (bufferptr buf, farptr pbuf,
word bufsize TN(byteptr name));
extern void Globalfunc delete_buffer (bufferptr buf);
extern int Globalfunc read_buffer (bufferptr buf, farptr msg, int size, dword timeout);
extern int Globalfunc c_read_buffer (bufferptr buf, farptr msg, int size);
extern int Globalfunc write_buffer (bufferptr buf, farptr msg, int size, dword timeout);
extern int Globalfunc c_write_buffer (bufferptr buf, farptr msg, int size);
extern word Globalfunc check_buffer (bufferptr buf);
/* module tsksec */
extern word Globalfunc t_read_key (void);
extern word Globalfunc t_wait_key (dword timeout);
extern word Globalfunc t_keyhit (void);
/* module tskalloc (model dependent) */
#if (TSK_DYNAMIC && TSK_DYNLOAD)
extern farptr Globalfunc tsk_alloc (word size);
extern farptr Globalfunc tsk_calloc (word item, word size);
extern farptr Globalfunc tsk_free (farptr item);
extern farptr Globalfunc tsk_realloc (farptr item, word size);
extern resource Neardata alloc_resource;
#endif
/* module tskname */
#if (TSK_NAMED)
extern farptr Globalfunc find_group_name (gcbptr group, byteptr name, int kind);
extern farptr Globalfunc find_name (byteptr name, int kind);
extern void Globalfunc add_event_name (nameptr elem);
#else
#define add_event_name(x)
#endif
/* module tsktick */
extern tick_ptr Globalfunc create_ticker (tick_ptr elem, dword val);
extern void Globalfunc delete_ticker (tick_ptr elem);
extern void Globalfunc set_ticker (tick_ptr elem, dword val);
extern dword Globalfunc get_ticker (tick_ptr elem);
/* module tskres */
extern int Globalfunc ctask_resident (void);
extern int Globalfunc link_ctask (void);
/* --------------------------------------------------------------------- */
/*
Macros to define and initialize static control structures.
General usage is:
DEF_xxx (variable, name [other params]);
Example:
DEF_FLAG (my_flag, "MyFlag");
*/
#define TQH(var,typ) {(queptr)&var, (queptr)&var, Q_HEAD | typ}
#if (TSK_NAMED)
#define TNR(var,nam,typ) ,{{LNULL, LNULL, typ}, &var, nam}
#else
#define TNR(var,nam,typ)
#endif
#if (TSK_DYNAMIC)
#define TFLG ,0
#else
#define TFLG
#endif
#define DEF_FLAG(var,nam) flag var = { TQH(var.wait_set,TYP_FLAG), TQH(var.wait_clear,TYP_FLAG), 0 TFLG TNR(var,nam,TYP_FLAG) }
#define DEF_COUNTER(var,nam) counter var = { TQH(var.wait_set,TYP_COUNTER), TQH(var.wait_clear,TYP_COUNTER), 0L TFLG TNR(var,nam,TYP_COUNTER) }
#define DEF_RESOURCE(var,nam) resource var = { TQH(var.waiting,TYP_RESOURCE), LNULL, 0 TFLG TNR(var,nam,TYP_RESOURCE) }
#define DEF_MAILBOX(var,nam) mailbox var = { TQH(var.waiting,TYP_RESOURCE), LNULL, LNULL TFLG TNR(var,nam,TYP_MAILBOX) }
#define DEF_PIPE(var,nam,buf,len) pipe var = { TQH(var.wait_read,TYP_PIPE), TQH(var.wait_write,TYP_PIPE), TQH(var.wait_clear,TYP_PIPE), \
len, 0, 0, 0, (byteptr)buf TFLG TNR(var,nam,TYP_PIPE) }
#define DEF_WPIPE(var,nam,buf,len) wpipe var = { TQH(var.wait_read,TYP_WPIPE), TQH(var.wait_write,TYP_WPIPE), TQH(var.wait_clear,TYP_WPIPE), \
len / 2, 0, 0, 0, (wordptr)buf TFLG TNR(var,nam,TYP_WPIPE) }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -