+2020-09-18  Tom Tromey  <tromey@adacore.com>
+
+       * windows-nat.c (struct windows_nat_target) <wait>: Update.
+       (windows_nat_target::wait): Update.
+       * target/wait.h (enum target_wait_flag): New.  Use
+       DEF_ENUM_FLAGS_TYPE.
+       * target/target.h (target_wait): Change type of options.
+       * target.h (target_options_to_string, default_target_wait):
+       Update.
+       (struct target_ops) <wait>: Change type of options.
+       * target.c (target_wait, default_target_wait, do_option): Change
+       type of "options".
+       (target_options_to_string): Likewise.
+       * target-delegates.c: Rebuild.
+       * target-debug.h (target_debug_print_target_wait_flags): Rename
+       from target_debug_print_options.
+       * sol-thread.c (class sol_thread_target) <wait>: Update.
+       (sol_thread_target::wait): Update.
+       * rs6000-nat.c (class rs6000_nat_target) <wait>: Update.
+       (rs6000_nat_target::wait): Update.
+       * remote.c (class remote_target) <wait, wait_ns, wait_as>:
+       Update.
+       (remote_target::wait_ns, remote_target::wait_as): Change type of
+       "options".
+       (remote_target::wait): Update.
+       * remote-sim.c (struct gdbsim_target) <wait>: Update.
+       (gdbsim_target::wait): Update.
+       * record-full.c (class record_full_base_target) <wait>: Update.
+       (record_full_wait_1): Change type of "options".
+       (record_full_base_target::wait): Update.
+       * record-btrace.c (class record_btrace_target) <wait>: Update.
+       (record_btrace_target::wait): Update.
+       * ravenscar-thread.c (struct ravenscar_thread_target) <wait>:
+       Update.
+       (ravenscar_thread_target::wait): Update.
+       * procfs.c (class procfs_target) <wait>: Update.
+       (procfs_target::wait): Update.
+       * obsd-nat.h (class obsd_nat_target) <wait>: Update.
+       * obsd-nat.c (obsd_nat_target::wait): Update.
+       * nto-procfs.c (struct nto_procfs_target) <wait>: Update.
+       (nto_procfs_target::wait): Update.
+       * nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.
+       * nbsd-nat.c (nbsd_wait): Change type of "options".
+       (nbsd_nat_target::wait): Update.
+       * linux-thread-db.c (class thread_db_target) <wait>: Update.
+       (thread_db_target::wait): Update.
+       * linux-nat.h (class linux_nat_target) <wait>: Update.
+       * linux-nat.c (linux_nat_target::wait): Update.
+       (linux_nat_wait_1): Update.
+       * infrun.c (do_target_wait_1, do_target_wait): Change type of
+       "options".
+       * inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.
+       * inf-ptrace.c (inf_ptrace_target::wait): Update.
+       * go32-nat.c (struct go32_nat_target) <wait>: Update.
+       (go32_nat_target::wait): Update.
+       * gnu-nat.h (struct gnu_nat_target) <wait>: Update.
+       * gnu-nat.c (gnu_nat_target::wait): Update.
+       * fbsd-nat.h (class fbsd_nat_target) <wait>: Update.
+       * fbsd-nat.c (fbsd_nat_target::wait): Update.
+       * darwin-nat.h (class darwin_nat_target) <wait>: Update.
+       * darwin-nat.c (darwin_nat_target::wait): Update.
+       * bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.
+       (bsd_uthread_target::wait): Update.
+       * aix-thread.c (class aix_thread_target) <wait>: Update.
+       (aix_thread_target::wait): Update.
+
 2020-09-18  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * compile/compile-object-run.c (create_copied_type_recursive): New
 
 
   void detach (inferior *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
 ptid_t
 aix_thread_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                        int options)
+                        target_wait_flags options)
 {
   {
     scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
   bool thread_alive (ptid_t ptid) override;
 
 ptid_t
 bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                         int options)
+                         target_wait_flags options)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   CORE_ADDR addr;
 
 
 ptid_t
 darwin_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                        int options)
+                        target_wait_flags options)
 {
   return wait_1 (ptid, status);
 }
 
 
   void detach (inferior *, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void mourn_inferior () override;
 
 
 
 ptid_t
 fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                      int target_options)
+                      target_wait_flags target_options)
 {
   ptid_t wptid;
 
 
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void post_startup_inferior (ptid_t) override;
   void post_attach (int) override;
 
 
 ptid_t
 gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                     int options)
+                     target_wait_flags options)
 {
   struct msg
     {
 
   void detach (inferior *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   enum target_xfer_status xfer_partial (enum target_object object,
                                        const char *annex,
                                        gdb_byte *readbuf,
 
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
 ptid_t
 go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                      int options)
+                      target_wait_flags options)
 {
   int i;
   unsigned char saved_opcode;
 
 
 ptid_t
 inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                        int options)
+                        target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
 
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void files_info () override;
 
 
 
 static ptid_t
 do_target_wait_1 (inferior *inf, ptid_t ptid,
-                 target_waitstatus *status, int options)
+                 target_waitstatus *status, target_wait_flags options)
 {
   ptid_t event_ptid;
   struct thread_info *tp;
    more events.  Polls for events from all inferiors/targets.  */
 
 static bool
-do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, int options)
+do_target_wait (ptid_t wait_ptid, execution_control_state *ecs,
+               target_wait_flags options)
 {
   int num_inferiors = 0;
   int random_selector;
 
 
 static ptid_t
 linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
-                 int target_options)
+                 target_wait_flags target_options)
 {
   sigset_t prev_mask;
   enum resume_kind last_resume_kind;
 
 ptid_t
 linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                       int target_options)
+                       target_wait_flags target_options)
 {
   ptid_t event_ptid;
 
 
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void pass_signals (gdb::array_view<const unsigned char>) override;
 
 
   strata stratum () const override { return thread_stratum; }
 
   void detach (inferior *, int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
   void update_thread_list () override;
 
 ptid_t
 thread_db_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                       int options)
+                       target_wait_flags options)
 {
   struct thread_db_info *info;
 
 
 /* Implement a safe wrapper around waitpid().  */
 
 static pid_t
-nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
+nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
+          target_wait_flags options)
 {
   pid_t pid;
   int status;
 
 ptid_t
 nbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                      int target_options)
+                      target_wait_flags target_options)
 {
   pid_t pid = nbsd_wait (ptid, ourstatus, target_options);
   ptid_t wptid = ptid_t (pid);
 
   bool info_proc (const char *, enum info_proc_what) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   int insert_exec_catchpoint (int pid) override;
   int remove_exec_catchpoint (int pid) override;
   int set_syscall_catchpoint (int pid, bool needed, int any_count,
 
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
 sptid_t
 nto_procfs_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                        int options)
+                        target_wait_flags options)
 {
   sigset_t set;
   siginfo_t info;
 
 
 ptid_t
 obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                      int options)
+                      target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
 
   /* Override some methods to support threads.  */
   std::string pid_to_str (ptid_t) override;
   void update_thread_list () override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
 #ifdef PT_GET_PROCESS_STATE
   bool follow_fork (bool, bool) override;
 
   void detach (inferior *inf, int) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
 ptid_t
 procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                    int options)
+                    target_wait_flags options)
 {
   /* First cut: loosely based on original version 2.1.  */
   procinfo *pi;
 
 
   strata stratum () const override { return thread_stratum; }
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
   void fetch_registers (struct regcache *, int) override;
 ptid_t
 ravenscar_thread_target::wait (ptid_t ptid,
                               struct target_waitstatus *status,
-                              int options)
+                              target_wait_flags options)
 {
   process_stratum_target *beneath
     = as_process_stratum_target (this->beneath ());
 
 
   void commit_resume () override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void stop (ptid_t) override;
   void update_thread_list () override;
 
 ptid_t
 record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                           int options)
+                           target_wait_flags options)
 {
   std::vector<thread_info *> moving;
   std::vector<thread_info *> no_history;
 
-  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (), options);
+  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (),
+        (unsigned) options);
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
 
 
   void close () override;
   void async (int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   bool stopped_by_watchpoint () override;
   bool stopped_data_address (CORE_ADDR *) override;
 
 static ptid_t
 record_full_wait_1 (struct target_ops *ops,
                    ptid_t ptid, struct target_waitstatus *status,
-                   int options)
+                   target_wait_flags options)
 {
   scoped_restore restore_operation_disable
     = record_full_gdb_operation_disable_set ();
 
 ptid_t
 record_full_base_target::wait (ptid_t ptid, struct target_waitstatus *status,
-                              int options)
+                              target_wait_flags options)
 {
   ptid_t return_ptid;
 
 
   void detach (inferior *inf, int) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 }
 
 ptid_t
-gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)
+gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status,
+                    target_wait_flags options)
 {
   struct sim_inferior_data *sim_data;
   static sighandler_t prev_sigint;
 
 
   void commit_resume () override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
   void add_current_inferior_and_thread (char *wait_status);
 
   ptid_t wait_ns (ptid_t ptid, struct target_waitstatus *status,
-                 int options);
+                 target_wait_flags options);
   ptid_t wait_as (ptid_t ptid, target_waitstatus *status,
-                 int options);
+                 target_wait_flags options);
 
   ptid_t process_stop_reply (struct stop_reply *stop_reply,
                             target_waitstatus *status);
 /* The non-stop mode version of target_wait.  */
 
 ptid_t
-remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
+remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status,
+                       target_wait_flags options)
 {
   struct remote_state *rs = get_remote_state ();
   struct stop_reply *stop_reply;
    STATUS just as `wait' would.  */
 
 ptid_t
-remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options)
+remote_target::wait_as (ptid_t ptid, target_waitstatus *status,
+                       target_wait_flags options)
 {
   struct remote_state *rs = get_remote_state ();
   ptid_t event_ptid = null_ptid;
    STATUS just as `wait' would.  */
 
 ptid_t
-remote_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)
+remote_target::wait (ptid_t ptid, struct target_waitstatus *status,
+                    target_wait_flags options)
 {
   ptid_t event_ptid;
 
 
   void create_inferior (const char *, const std::string &,
                        char **, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
 private:
   enum target_xfer_status
 
 ptid_t
 rs6000_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                        int options)
+                        target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
 
   strata stratum () const override { return thread_stratum; }
 
   void detach (inferior *, int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
   std::string pid_to_str (ptid_t) override;
 
 ptid_t
 sol_thread_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                        int options)
+                        target_wait_flags options)
 {
   if (ptid.pid () != -1)
     {
 
   target_debug_do_print ((X) ? "step" : "continue")
 
 static void
-target_debug_print_options (int options)
+target_debug_print_target_wait_flags (target_wait_flags options)
 {
   std::string str = target_options_to_string (options);
 
 
   void disconnect (const char *arg0, int arg1) override;
   void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;
   void commit_resume () override;
-  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;
+  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;
   void fetch_registers (struct regcache *arg0, int arg1) override;
   void store_registers (struct regcache *arg0, int arg1) override;
   void prepare_to_store (struct regcache *arg0) override;
   void disconnect (const char *arg0, int arg1) override;
   void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;
   void commit_resume () override;
-  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;
+  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;
   void fetch_registers (struct regcache *arg0, int arg1) override;
   void store_registers (struct regcache *arg0, int arg1) override;
   void prepare_to_store (struct regcache *arg0) override;
 }
 
 ptid_t
-target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   return this->beneath ()->wait (arg0, arg1, arg2);
 }
 
 ptid_t
-dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   return default_target_wait (this, arg0, arg1, arg2);
 }
 
 ptid_t
-debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   ptid_t result;
   fprintf_unfiltered (gdb_stdlog, "-> %s->wait (...)\n", this->beneath ()->shortname ());
   fputs_unfiltered (", ", gdb_stdlog);
   target_debug_print_struct_target_waitstatus_p (arg1);
   fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_options (arg2);
+  target_debug_print_target_wait_flags (arg2);
   fputs_unfiltered (") = ", gdb_stdlog);
   target_debug_print_ptid_t (result);
   fputs_unfiltered ("\n", gdb_stdlog);
 
 /* See target/target.h.  */
 
 ptid_t
-target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+target_wait (ptid_t ptid, struct target_waitstatus *status,
+            target_wait_flags options)
 {
   return current_top_target ()->wait (ptid, status, options);
 }
 ptid_t
 default_target_wait (struct target_ops *ops,
                     ptid_t ptid, struct target_waitstatus *status,
-                    int options)
+                    target_wait_flags options)
 {
   status->kind = TARGET_WAITKIND_IGNORE;
   return minus_one_ptid;
    OPT is removed from TARGET_OPTIONS.  */
 
 static void
-do_option (int *target_options, std::string *ret,
-          int opt, const char *opt_str)
+do_option (target_wait_flags *target_options, std::string *ret,
+          target_wait_flag opt, const char *opt_str)
 {
   if ((*target_options & opt) != 0)
     {
 /* See target.h.  */
 
 std::string
-target_options_to_string (int target_options)
+target_options_to_string (target_wait_flags target_options)
 {
   std::string ret;
 
 
   };
 
 /* Return a pretty printed form of TARGET_OPTIONS.  */
-extern std::string target_options_to_string (int target_options);
+extern std::string target_options_to_string (target_wait_flags target_options);
 
 /* Possible types of events that the inferior handler will have to
    deal with.  */
        current target.  inferior_ptid may also be null_ptid on
        entry.  */
     virtual ptid_t wait (ptid_t, struct target_waitstatus *,
-                        int TARGET_DEBUG_PRINTER (target_debug_print_options))
+                        target_wait_flags options)
       TARGET_DEFAULT_FUNC (default_target_wait);
     virtual void fetch_registers (struct regcache *, int)
       TARGET_DEFAULT_IGNORE ();
 extern ptid_t default_target_wait (struct target_ops *ops,
                                   ptid_t ptid,
                                   struct target_waitstatus *status,
-                                  int options);
+                                  target_wait_flags options);
 
 /* Fetch at least register REGNO, or all regs if regno == -1.  No result.  */
 
 
 #define TARGET_TARGET_H
 
 #include "target/waitstatus.h"
+#include "target/wait.h"
+
 /* This header is a stopgap until more code is shared.  */
 
 /* Read LEN bytes of target memory at address MEMADDR, placing the
    options.  */
 
 extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
-                          int options);
+                          target_wait_flags options);
 
 /* The inferior process has died.  Do what is right.  */
 
 
 #ifndef TARGET_WAIT_H
 #define TARGET_WAIT_H
 
+#include "gdbsupport/enum-flags.h"
+
 /* Options that can be passed to target_wait.  */
 
-/* Return immediately if there's no event already queued.  If this
-   options is not requested, target_wait blocks waiting for an
-   event.  */
-#define TARGET_WNOHANG 1
+enum target_wait_flag : unsigned
+{
+  /* Return immediately if there's no event already queued.  If this
+     options is not requested, target_wait blocks waiting for an
+     event.  */
+  TARGET_WNOHANG = 1,
+};
+
+DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);
 
 #endif /* TARGET_WAIT_H */
 
 
   void resume (ptid_t, int , enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 /* Wait for interesting events to occur in the target process.  */
 ptid_t
 windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                         int options)
+                         target_wait_flags options)
 {
   int pid = -1;
 
 
+2020-09-18  Tom Tromey  <tromey@adacore.com>
+
+       * netbsd-low.h (class netbsd_process_target) <wait>: Update.
+       * netbsd-low.cc (netbsd_waitpid, netbsd_wait)
+       (netbsd_process_target::wait): Change type of target_options.
+       * win32-low.h (class win32_process_target) <wait>: Update.
+       * win32-low.cc (win32_process_target::wait): Update.
+       * target.h (class process_stratum_target) <wait>: Update.
+       (mywait): Update.
+       * target.cc (mywait, target_wait): Change type of "options".
+       * linux-low.h (class linux_process_target) <wait, wait_1>:
+       Update.
+       * linux-low.cc (linux_process_target::wait)
+       (linux_process_target::wait_1): Update.
+
 2020-09-15  Tom Tromey  <tromey@adacore.com>
 
        * linux-x86-low.cc (xmltarget_i386_linux_no_xml)
 
 
 ptid_t
 linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
-                             int target_options)
+                             target_wait_flags target_options)
 {
   client_state &cs = get_client_state ();
   int w;
 ptid_t
 linux_process_target::wait (ptid_t ptid,
                            target_waitstatus *ourstatus,
-                           int target_options)
+                           target_wait_flags target_options)
 {
   ptid_t event_ptid;
 
 
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-              int options) override;
+              target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;
 
 
   /* Wait for process, returns status.  */
   ptid_t wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
-                int target_options);
+                target_wait_flags target_options);
 
   /* Stop all lwps that aren't stopped yet, except EXCEPT, if not NULL.
      If SUSPEND, then also increase the suspend count of every LWP,
 
 /* Implement a safe wrapper around waitpid().  */
 
 static pid_t
-netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
+netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus,
+               target_wait_flags target_options)
 {
   int status;
+  int options = (target_options & TARGET_WNOHANG) ? WNOHANG : 0;
 
   pid_t pid
     = gdb::handle_eintr<int> (-1, ::waitpid, ptid.pid (), &status, options);
 
 static ptid_t
 netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-            int target_options)
+            target_wait_flags target_options)
 {
   pid_t pid = netbsd_waitpid (ptid, ourstatus, target_options);
   ptid_t wptid = ptid_t (pid);
 
 ptid_t
 netbsd_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-                            int target_options)
+                            target_wait_flags target_options)
 {
   while (true)
     {
 
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-              int options) override;
+              target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;
 
 
 }
 
 ptid_t
-mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
-       int connected_wait)
+mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
+       target_wait_flags options, int connected_wait)
 {
   ptid_t ret;
 
 /* See target/target.h.  */
 
 ptid_t
-target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+target_wait (ptid_t ptid, struct target_waitstatus *status,
+            target_wait_flags options)
 {
   return the_target->wait (ptid, status, options);
 }
 
      no child stop to report, return is
      null_ptid/TARGET_WAITKIND_IGNORE.  */
   virtual ptid_t wait (ptid_t ptid, target_waitstatus *status,
-                      int options) = 0;
+                      target_wait_flags options) = 0;
 
   /* Fetch registers from the inferior process.
 
 #define target_supports_software_single_step() \
   the_target->supports_software_single_step ()
 
-ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
-              int connected_wait);
+ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
+              target_wait_flags options, int connected_wait);
 
 /* Prepare to read or write memory from the inferior process.  See the
    corresponding process_stratum_target methods for more details.  */
 
    Returns the signal which caused the process to stop. */
 ptid_t
 win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
-                           int options)
+                           target_wait_flags options)
 {
   if (cached_status.kind != TARGET_WAITKIND_IGNORE)
     {
 
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-              int options) override;
+              target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;