Splint fiddles.
[platform/upstream/rpm.git] / rpmio / rpmsq.h
index 9e3960e..4223e42 100644 (file)
@@ -6,15 +6,25 @@
  *
  */
 
-#include <pthread.h>
-#include <signal.h>
-#include <sys/signal.h>
-#include <search.h>            /* XXX insque(3)/remque(3) protos. */
+#include <rpmsw.h>
 
+/**
+ */
 typedef struct rpmsig_s * rpmsig;
 
+/**
+ */
 typedef struct rpmsqElem * rpmsq;
 
+/**
+ * Default signal handler prototype.
+ * @param signum       signal number
+ * @param info         (siginfo_t) signal info
+ * @param context      signal context
+ */
+typedef void (*rpmsqAction_t) (int signum, void * info, void * context)
+       /*@*/;
+
 /*@-redecl@*/
 /*@unchecked@*/
 extern int _rpmsq_debug;
@@ -29,14 +39,20 @@ struct rpmsqElem {
     pid_t child;               /*!< Currently running child. */
     volatile pid_t reaped;     /*!< Reaped waitpid(3) return. */
     volatile int status;       /*!< Reaped waitpid(3) status. */
+    struct rpmop_s op;         /*!< Scriptlet operation timestamp; */
+    rpmtime_t ms_scriptlets;   /*!< Accumulated script duration (msecs). */
     int reaper;                        /*!< Register SIGCHLD handler? */
+    int pipes[2];              /*!< Parent/child interlock. */
+/*@shared@*/
     void * id;                 /*!< Blocking thread id (pthread_t). */
-    pthread_mutex_t mutex;
+    pthread_mutex_t mutex;     /*!< Signal delivery to thread condvar. */
     pthread_cond_t cond;
 };
 
+/*@-exportlocal@*/
 /*@unchecked@*/
 extern rpmsq rpmsqQueue;
+/*@=exportlocal@*/
 
 /*@unchecked@*/
 extern sigset_t rpmsqCaught;
@@ -46,31 +62,49 @@ extern sigset_t rpmsqCaught;
 #endif
 
 /**
+ * Insert node into from queue.
+ * @param elem         node to link
+ * @param prev         previous node from queue
+ * @return             0 on success
  */
+/*@-exportlocal@*/
 int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
-       /*@globals rpmsqQueue @*/
-       /*@modifies elem, rpmsqQueue @*/;
+       /*@globals systemState @*/
+       /*@modifies elem, prev, systemState @*/;
+/*@=exportlocal@*/
 
 /**
+ * Remove node from queue.
+ * @param elem         node to link
+ * @return             0 on success
  */
+/*@-exportlocal@*/
 int rpmsqRemove(/*@null@*/ void * elem)
-       /*@modifies elem @*/;
+       /*@globals fileSystem, internalState @*/
+       /*@modifies elem, fileSystem, internalState @*/;
+/*@=exportlocal@*/
 
 /**
+ * Default signal handler.
+ * @param signum       signal number
+ * @param info         (siginfo_t) signal info
+ * @param context      signal context
  */
-void rpmsqHandler(int signum)
-       /*@globals rpmsqCaught, fileSystem @*/
-       /*@modifies rpmsqCaught, fileSystem @*/;
+/*@-exportlocal@*/
+void rpmsqAction(int signum, void * info, void * context)
+       /*@globals rpmsqCaught, rpmsqQueue, errno, fileSystem @*/
+       /*@modifies rpmsqCaught, rpmsqQueue, errno, fileSystem @*/;
+/*@=exportlocal@*/
 
 /**
  * Enable or disable a signal handler.
  * @param signum       signal to enable (or disable if negative)
- * @param handler      signal handler (or NULL to use rpmsqHandler())
+ * @param handler      sa_sigaction handler (or NULL to use rpmsqHandler())
  * @return             no. of refs, -1 on error
  */
-int rpmsqEnable(int signum, /*@null@*/ sighandler_t handler)
-       /*@globals rpmsqCaught, fileSystem, internalState @*/
-       /*@modifies rpmsqCaught, fileSystem, internalState @*/;
+int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
+       /*@globals rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/
+       /*@modifies rpmsqCaught, rpmsqQueue, fileSystem, internalState @*/;
 
 /**
  * Fork a child process.
@@ -91,10 +125,39 @@ pid_t rpmsqWait(rpmsq sq)
        /*@modifies sq, fileSystem, internalState @*/;
 
 /**
+ * Call a function in a thread.
+ * @param start                function
+ * @param arg          function argument
+ * @return             thread pointer (NULL on error)
+ */
+void * rpmsqThread(void * (*start) (void * arg), void * arg)
+       /*@globals internalState @*/
+       /*@modifies internalState @*/;
+
+/**
+ * Wait for thread to terminate.
+ * @param thread       thread
+ * @return             0 on success
+ */
+int rpmsqJoin(/*@null@*/ void * thread)
+       /*@globals internalState @*/
+       /*@modifies internalState @*/;
+
+/**
+ * Compare thread with current thread.
+ * @param thread       thread
+ * @return             0 if not equal
+ */
+int rpmsqThreadEqual(/*@null@*/ void * thread)
+       /*@globals internalState @*/
+       /*@modifies internalState @*/;
+
+/**
  * Execute a command, returning its status.
  */
 int rpmsqExecve (const char ** argv)
-       /*@*/;
+       /*@globals fileSystem, internalState @*/
+       /*@modifies fileSystem, internalState @*/;
 
 #ifdef __cplusplus
 }