chiark / gitweb /
hostside: more length for bavarian
[trains.git] / hostside / realtime.h
index ca8d239ef637e80d37b26fd5bf6884e46ddc5f05..d644ca21de773bdee6b1dc719fdb6551227b35e9 100644 (file)
 
 #include <fcntl.h>
 #include <dirent.h>
+#include <inttypes.h>
 
 #include <sys/types.h>
 #include <sys/time.h>
 
+#include "../.git-revid-autoversion.h"
 #include "../layout/layout-data.h"
 #include "realtime+dflags.h"
 
-typedef struct Segment Segment;
-typedef struct Train Train;
+typedef struct Segment Segment; /* from safety.h */
+typedef struct Train Train; /* from safety.h */
 typedef struct TimeoutEvent TimeoutEvent;
 
 /*---------- from retransmit.c ----------*/
@@ -36,7 +38,8 @@ typedef unsigned Retransmit__Time;
    * retransmit.c only; as a special exception, caller may edit pi
    * directly.  Normally, though, pi is set by supplying an NMRA
    * command to one of the _queue functions; iff the Nmra* is
-   * non-null, _queue will add an NMRA checksum and update pi.
+   * non-null, _queue will add an NMRA checksum (modifying *n)
+   * and update pi (which always results in a nonzero pi.l).
    */
 struct RetransmitRelaxedNode {
   PicInsn pi;
@@ -67,46 +70,47 @@ void retransmit_relaxed_cancel(RetransmitRelaxedNode *rn);
    * urgent_requeue if it's queued and has changed and must get a new
    * quota of urgency; _requeue is just _cancel followed by queue. */
 
-/*---------- features, filled in by record, used by features.c ----------*/
+/*---------- adjuncts, filled in by record, used by adjuncts.c ----------*/
 
-#define FEATURESADDR_TRANSMITS 4
+#define ADJUNCTSADDR_TRANSMITS 4
   /* 0..2 are func0to4 func5to8 func9to12 and speed cmd
    * pi.l is 0 if not transmitting */
 
-#define FEATS_SPEEDSTEP_BIT     0x4000u /* a->{current,all,permit}, f->bits */
-#define FEATS_SPEEDSTEP_REVERSE 0x8000u /* in a->all */
+#define ADJS_SPEEDSTEP_BIT     0x4000u /* a->{current,all,permit}, f->bits */
+#define ADJS_SPEEDSTEP_REVERSE 0x8000u /* in a->all */
 
-typedef struct FeaturesAddr {
-  struct FeaturesAddr *next;
+typedef struct AdjunctsAddr {
+  struct AdjunctsAddr *next;
   int addr, speedstep;
   unsigned current, permit, all;
-  RetransmitRelaxedNode rn[FEATURESADDR_TRANSMITS];
-} FeaturesAddr;
+  RetransmitRelaxedNode rn[ADJUNCTSADDR_TRANSMITS];
+} AdjunctsAddr;
 
 typedef struct {
   char *pname; /* first, for pname1st_compar */
-  FeaturesAddr *a;
+  AdjunctsAddr *a;
   unsigned bits; /* may have no or several bits set */
-} FeaturesFeature;
+} AdjunctsAdjunct;
 
-typedef struct FeaturesTarget {
+typedef struct AdjunctsTarget {
   char *pname; /* first, for pname1st_compar */
-  int n_feats;
-  FeaturesFeature *feats;
-} FeaturesTarget;
+  int n_adjs;
+  AdjunctsAdjunct *adjs;
+} AdjunctsTarget;
 
 extern int n_trains;
 extern Train *trains;
 extern Segment *segments;
 
-extern int n_feattargs, n_feataddrs;
-extern FeaturesTarget *feattargs;
-extern FeaturesAddr **feataddrs;
+extern int n_adjtargs, n_adjaddrs;
+extern AdjunctsTarget *adjtargs;
+extern AdjunctsAddr **adjaddrs;
 
 /*---------- global variables, in realtime.c ----------*/
 
 extern CommandInput cmdi;
 extern int picio_send_noise;
+extern int disable_watchdog;
 
 #define CIXF_U                 0x0000ffffu
 #define CIXF_FORCE             0x00010000u
@@ -122,6 +126,7 @@ void serial_moredata(PicInsn *buf);
 
 extern StartupState sta_state;
 extern const char *const stastatelist[];
+void cmdi_output_bufferempty(OutBufferChain *obc);
 
 void resolve_begin(void); /* from resolve.c */
 int resolve_complete(void);
@@ -150,10 +155,12 @@ void ouhex(const char *word, const Byte *command, int length);
 void ouhex_nosim(const char *word, const Byte *command, int length);
 
 void serial_transmit(const PicInsn *pi);
-void serial_transmit_maybenosim(const PicInsn *pi, int nosim);
 void command_doline(ParseState *ps, CommandInput *cmdi_arg);
 const CmdInfo *current_cmd;
 
+void check_rusage_baseline(void);
+void check_rusage_check(int always_report);
+
 /*---------- for/from simulate.c ----------*/
 
 void serial_indata_process(int buf_used);
@@ -186,13 +193,14 @@ int picinsn_polarity_testbit(const PicInsn *pi, const SegmentInfo *segi);
   /* this belongs in {au,skel}proto-pic.[ch] really but it's
    * more convenient here. */
 
-void features_start_xmit(void);
-void features_updated(FeaturesAddr *a);
+void adjuncts_start_xmit(void);
+void adjuncts_updated(AdjunctsAddr *a);
 
 /*---------- from movpos.c ----------*/
 
 void points_turning_on(void);
 void motions_all_abandon(void);
+void movpos_reportall(void);
 
 /*---------- from eventhelp.c ----------*/
 
@@ -221,9 +229,10 @@ void toev_stop(TimeoutEvent*);    /* IR -> I */
 
 void realtime_priority(void);
 
-#define RTFEAT_DEFAULTS  0100u /* turns on MLOCK and SCHEDPRIO iff not sim */
+#define RTFEAT_DEFAULTS  0100u /* turns things on iff not sim */
 #define RTFEAT_MEM       0001u /* mlock */
 #define RTFEAT_CPU       0002u /* hard CPU scheduling priority */
+#define RTFEAT_RUSAGE    0004u /* check up on faults etc. in getrusage */
 
 #define RTFEAT_ALL_SHIFT 16
 #define RTFEAT_ALL(x) (RTFEAT_##x << RTFEAT_ALL_SHIFT)
@@ -232,22 +241,29 @@ void realtime_priority(void);
 
 extern unsigned rtfeats_use;
 
-void ouvprintf(const char *fmt, va_list al);
-void ouprintf(const char *fmt, ...);
+void ouvprintf(const char *fmt, va_list al)
+     __attribute__((format(printf,1,0)));
+void ouprintf(const char *fmt, ...)
+     __attribute__((format(printf,1,2)));
 
-void ouvprintf_only(const char *fmt, va_list al);
-void ouprintf_only(const char *fmt, ...);
+void ouvprintf_only(const char *fmt, va_list al)
+     __attribute__((format(printf,1,0)));
+void ouprintf_only(const char *fmt, ...)
+     __attribute__((format(printf,1,2)));
 
+extern unsigned long eventcounter; /* for debugging use only ! */
 void debug_count_event(const char *what);
 
 #define DEBUGP(a,k) (dflags_##a & DBIT_##a##_##k)
 
+#define DPRINTFA ouprintf_only
+
 #define COND_DPRINTF(cond, a,k, fmt, ...) \
- ((cond) ? ouprintf_only("debug " #a "/" #k " : " fmt,##__VA_ARGS__) : (void)0)
+ ((cond) ? DPRINTFA("debug " #a "/" #k " : " fmt,##__VA_ARGS__) : (void)0)
 
 #define DPRINTF(a,k,f,...) COND_DPRINTF(DEBUGP(a,k),a,k,f,##__VA_ARGS__)
 #define DPRINTF1(a,k,f,...) COND_DPRINTF((DP)=DEBUGP(a,k), a,k,f,##__VA_ARGS__)
-#define DPRINTF2(f,...) ((DP) ? ouprintf_only(f,##__VA_ARGS__) : (void)0)
+#define DPRINTF2(f,...) ((DP) ? DPRINTFA(f,##__VA_ARGS__) : (void)0)
 
 /*---------- tbi ----------*/