home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / os2msg.h < prev    next >
C/C++ Source or Header  |  1999-01-02  |  7KB  |  196 lines

  1. /* -*-C-*-
  2.  
  3. $Id: os2msg.h,v 1.15 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1994-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. #ifndef SCM_OS2MSG_H
  23. #define SCM_OS2MSG_H
  24.  
  25. typedef enum
  26. {
  27.   /* This is sent to acknowledge that the other end of a qid pair has
  28.      been opened.  Sometimes it is necessary to wait until the
  29.      connection is established before proceeding.  */
  30.   mt_init,
  31.  
  32.   /* This is sent by a "readahead" thread whenever it has some data to
  33.      give to the other end of the connection.  These messages are
  34.      generated asynchronously whenever the readahead is available.  */
  35.   mt_readahead,
  36.  
  37.   /* This is sent by the receiver of a readahead message.  It is used
  38.      to regulate the amount of readahead in the connection.
  39.      Typically, the readahead thread won't generate any more readahead
  40.      messages until the readahead_ack is received.  */
  41.   mt_readahead_ack,
  42.  
  43.   /* This is a console interrupt event.  It is generated automatically
  44.      by the console readahead thread, and causes a Scheme character
  45.      interrupt to be signalled in the interrupt-code register.  */
  46.   mt_console_interrupt,
  47.  
  48.   /* This is a timer interrupt event.  It is generated automatically
  49.      by the timer thread when the timer is active.  */
  50.   mt_timer_event,
  51.   
  52.   /* This event signals the termination of a child process.  It is
  53.      generated automatically by the thread that monitors child
  54.      processes.  */
  55.   mt_child_death,
  56.  
  57.   /* These are error messages.  They are sent as a reply to a request
  58.      when an error is generated during the processing of the request.  */
  59.   mt_error,
  60.   mt_syscall_error,
  61.  
  62.   /* This is a generic reply that is used to acknowledge requests that
  63.      return no meaningful data other than that they have completed.  */
  64.   mt_generic_reply,
  65.  
  66.   /* This machine-generated file contains most of the PM message types.  */
  67. #include "os2pm-mt.h"
  68.  
  69.   /* These are messages that command the PM thread to perform specific
  70.      actions.  A command that does not have a specific reply type will
  71.      receive a generic reply when the PM code is configured to do
  72.      handshaking; normally such a command has no reply.  */
  73.   mt_window_pos_request,    /* request position of window's frame */
  74.   mt_window_pos_reply,
  75.   mt_window_size_request,    /* request size of window's client area */
  76.   mt_window_size_reply,
  77.   mt_window_frame_size_request,    /* request size of window's frame */
  78.   mt_window_frame_size_reply,
  79.  
  80.   /* These are also PM thread commands, but they operate on
  81.      presentation spaces rather than on windows.  */
  82.   mt_ps_set_bitmap_request,    /* associate a bitmap with a memory PS */
  83.   mt_ps_set_bitmap_reply,
  84.  
  85.   /* These are messages that are automatically generated by the PM
  86.      thread when the corresponding events occur.  */
  87.   mt_pm_event,            /* undecoded PM input event */
  88.   mt_paint_event,        /* window needs painting */
  89.  
  90.   /* This requests the thread on the other end of the connection to
  91.      kill itself.  At present this request is not used.  */
  92.   mt_kill_request,
  93.   mt_supremum
  94. } msg_type_t;
  95. #define MSG_TYPE_SUP ((unsigned int) mt_supremum)
  96. #define MSG_TYPE_MAX (MSG_TYPE_SUP - 1)
  97.  
  98. typedef unsigned char qid_t;
  99. #define QID_MAX (UCHAR_MAX - 1)
  100. #define QID_NONE UCHAR_MAX
  101.  
  102. typedef unsigned short msg_length_t;
  103. #define MSG_LENGTH_MAX USHRT_MAX
  104.  
  105. /* Fields of message header:
  106.    type: msg_type_t identifying the type of message
  107.    sender: qid identifying the message sender (used for replies)
  108.    */
  109.  
  110. #define DECLARE_MSG_HEADER_FIELDS                    \
  111.   msg_type_t _msg_type;                            \
  112.   qid_t _msg_sender
  113.  
  114. typedef struct
  115. {
  116.   DECLARE_MSG_HEADER_FIELDS;
  117. } msg_t;
  118.  
  119. #define _MSG(m) ((msg_t *) (m))
  120. #define MSG_TYPE(m) ((_MSG (m)) -> _msg_type)
  121. #define MSG_SENDER(m) ((_MSG (m)) -> _msg_sender)
  122.  
  123. typedef enum
  124. {
  125.   tqt_std,
  126.   tqt_scm,
  127.   tqt_pm
  128. } tqueue_type_t;
  129.  
  130. typedef struct
  131. {
  132.   tqueue_type_t type;
  133. } tqueue_t;
  134. #define TQUEUE_TYPE(q) (((tqueue_t *) (q)) -> type)
  135.  
  136. typedef msg_t * (* qid_receive_filter_t) (msg_t *);
  137.  
  138. typedef enum { mat_not_available, mat_available, mat_interrupt } msg_avail_t;
  139.  
  140. extern tqueue_t * OS2_scheme_tqueue;
  141. extern qid_t OS2_interrupt_qid;
  142. extern char OS2_scheme_tqueue_avail_map [QID_MAX + 1];
  143.  
  144. extern void OS2_make_qid_pair (qid_t *, qid_t *);
  145. extern void OS2_open_qid (qid_t, tqueue_t *);
  146. extern int OS2_qid_openp (qid_t);
  147. extern void OS2_close_qid (qid_t);
  148. extern tqueue_t * OS2_qid_tqueue (qid_t);
  149. extern qid_t OS2_qid_twin (qid_t);
  150. extern void OS2_close_qid_pair (qid_t);
  151. extern void OS2_set_qid_receive_filter (qid_t, qid_receive_filter_t);
  152. extern msg_length_t OS2_message_type_length (msg_type_t);
  153. extern void OS2_set_message_type_length (msg_type_t, msg_length_t);
  154. extern msg_t * OS2_create_message_1 (msg_type_t, msg_length_t);
  155. extern void OS2_destroy_message (msg_t *);
  156. extern void OS2_send_message (qid_t, msg_t *);
  157. extern msg_t * OS2_receive_message (qid_t, int, int);
  158. extern msg_avail_t OS2_message_availablep (qid_t, int);
  159. extern msg_t * OS2_wait_for_message (qid_t, msg_type_t);
  160. extern msg_t * OS2_message_transaction (qid_t, msg_t *, msg_type_t);
  161. extern void OS2_unread_message (qid_t, msg_t *);
  162. extern int OS2_tqueue_select (tqueue_t *, int);
  163. extern tqueue_t * OS2_make_std_tqueue (void);
  164. extern void OS2_close_std_tqueue (tqueue_t *);
  165.  
  166. extern void * OS2_create_msg_fifo (void);
  167. void OS2_destroy_msg_fifo (void *);
  168. extern void OS2_msg_fifo_insert (void *, void *);
  169. extern void OS2_msg_fifo_insert_front (void *, void *);
  170. extern void * OS2_msg_fifo_remove (void *);
  171. extern void * OS2_msg_fifo_remove_last (void *);
  172. extern void ** OS2_msg_fifo_remove_all (void *);
  173. extern int OS2_msg_fifo_emptyp (void *);
  174. extern unsigned int OS2_msg_fifo_count (void *);
  175. extern void * OS2_msg_fifo_last (void *);
  176.  
  177. #define MSG_LENGTH(m) (OS2_message_type_length (MSG_TYPE (m)))
  178.  
  179. #define SET_MSG_TYPE_LENGTH(t, s)                    \
  180.   OS2_set_message_type_length ((t), (sizeof (s)))
  181.  
  182. #define OS2_create_message(type) OS2_create_message_1 ((type), 0)
  183.  
  184. typedef struct
  185. {
  186.   DECLARE_MSG_HEADER_FIELDS;
  187.   int code;
  188. } sm_console_interrupt_t;
  189. #define SM_CONSOLE_INTERRUPT_CODE(m) (((sm_console_interrupt_t *) (m)) -> code)
  190.  
  191. typedef msg_t sm_timer_event_t;
  192. typedef msg_t sm_init_t;
  193. typedef msg_t sm_generic_reply_t;
  194.  
  195. #endif /* SCM_OS2MSG_H */
  196.