Protoization.
[deliverable/binutils-gdb.git] / gdb / lin-thread.c
index a4f388dedb411073a46f7a34e99ce4ef96189cc5..dd06e5d21897d26ef9b0ea9f00a072ce3c4836f7 100644 (file)
 
 #include <dlfcn.h>             /* dynamic library interface */
 
+/* Prototypes for supply_gregset etc. */
+#include "gregset.h"
+
 #ifndef TIDGET
 #define TIDGET(PID)            (((PID) & 0x7fffffff) >> 16)
 #define PIDGET(PID)            (((PID) & 0xffff))
@@ -170,6 +173,16 @@ typedef const void *gdb_ps_write_buf_t;
 typedef size_t gdb_ps_size_t;
 #endif
 
+/* Unfortunately glibc 2.1.3 was released with a broken prfpregset_t
+   type.  We let configure check for this lossage, and make
+   appropriate typedefs here.  */
+
+#ifdef PRFPREGSET_T_BROKEN
+typedef elf_fpregset_t gdb_prfpregset_t;
+#else
+typedef prfpregset_t gdb_prfpregset_t;
+#endif
+
 /* 
  * proc_service callback functions, called by thread_db.
  */
@@ -392,7 +405,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph,                /* Set LWP general regs */
 ps_err_e
 ps_lgetfpregs (gdb_ps_prochandle_t ph,         /* Get LWP float regs */
               lwpid_t       lwpid,
-              prfpregset_t *fpregset)
+              gdb_prfpregset_t *fpregset)
 {
   struct cleanup *old_chain = save_inferior_pid ();
 
@@ -406,7 +419,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph,              /* Get LWP float regs */
 ps_err_e
 ps_lsetfpregs (gdb_ps_prochandle_t ph,         /* Set LWP float regs */
               lwpid_t             lwpid,
-              const prfpregset_t *fpregset)
+              const gdb_prfpregset_t *fpregset)
 {
   struct cleanup *old_chain = save_inferior_pid ();
 
@@ -508,10 +521,10 @@ static td_err_e (*p_td_thr_setgregs)      (const td_thrhandle_t *th_p,
                                           const prgregset_t regset);
 
 static td_err_e (*p_td_thr_getfpregs)     (const td_thrhandle_t *th_p,
-                                          prfpregset_t *fpregset);
+                                          gdb_prfpregset_t *fpregset);
 
 static td_err_e (*p_td_thr_setfpregs)     (const td_thrhandle_t *th_p,
-                                          const prfpregset_t *fpregset);
+                                          const gdb_prfpregset_t *fpregset);
 
 static td_err_e (*p_td_ta_map_id2thr)     (const td_thragent_t *ta_p,
                                           thread_t tid,
@@ -542,7 +555,7 @@ static td_err_e (*p_td_ta_map_lwp2thr)    (const td_thragent_t *ta_p,
  */
 
 static int
-init_thread_db_library ()
+init_thread_db_library (void)
 {
   void *dlhandle;
   td_err_e ret;
@@ -658,21 +671,19 @@ init_thread_db_library ()
 static struct cleanup *
 save_inferior_pid (void)
 {
-#if TARGET_PTR_BIT > TARGET_INT_BIT
-  return make_cleanup (restore_inferior_pid, (void *) ((long) inferior_pid));
-#else
-  return make_cleanup (restore_inferior_pid, (void *) inferior_pid);
-#endif
+  int *saved_pid_ptr;
+  
+  saved_pid_ptr = xmalloc (sizeof (int));
+  *saved_pid_ptr = inferior_pid;
+  return make_cleanup (restore_inferior_pid, saved_pid_ptr);
 }
 
 static void
-restore_inferior_pid (void *saved_pid)
+restore_inferior_pid (void *arg)
 {
-#if TARGET_PTR_BIT > TARGET_INT_BIT
-  inferior_pid = (int) ((long) saved_pid);
-#else
-  inferior_pid = (int) saved_pid;
-#endif
+  int *saved_pid_ptr = arg;
+  inferior_pid = *saved_pid_ptr;
+  free (arg);
 }
 
 /*
@@ -693,8 +704,7 @@ restore_inferior_pid (void *saved_pid)
  */
 
 static char *
-thr_err_string (errcode)
-     td_err_e errcode;
+thr_err_string (td_err_e errcode)
 {
   static char buf[50];
 
@@ -744,8 +754,7 @@ thr_err_string (errcode)
  */
 
 static char *
-thr_state_string (statecode)
-     td_thr_state_e statecode;
+thr_state_string (td_thr_state_e statecode)
 {
   static char buf[50];
 
@@ -783,11 +792,7 @@ int threadlist_top = 0;            /* number of threads now in table */
 #define THREADLIST_ALLOC 100   /* chunk size by which to expand table */
 
 static threadinfo *
-insert_thread (tid, lid, state, type)
-     int            tid;
-     int            lid;
-     td_thr_state_e state;
-     td_thr_type_e  type;
+insert_thread (int tid, int lid, td_thr_state_e state, td_thr_type_e type)
 {
   if (threadlist_top >= threadlist_max)
     {
@@ -808,13 +813,13 @@ insert_thread (tid, lid, state, type)
 }
 
 static void
-empty_threadlist ()
+empty_threadlist (void)
 {
   threadlist_top = 0;
 }
 
 static threadinfo *
-next_pending_event ()
+next_pending_event (void)
 {
   int i;
 
@@ -899,8 +904,7 @@ static CORE_ADDR thread_death_bkpt_address;
    The thread-specific enabling is handled per-thread elsewhere.  */
 
 static void
-enable_thread_event_reporting (ta)
-     td_thragent_t *ta;
+enable_thread_event_reporting (td_thragent_t *ta)
 {
   td_thr_events_t events;
   td_notify_t     notify;
@@ -959,8 +963,7 @@ enable_thread_event_reporting (ta)
    The thread-specific enabling is handled per-thread elsewhere.  */
 
 static void
-disable_thread_event_reporting (ta)
-     td_thragent_t *ta;
+disable_thread_event_reporting (td_thragent_t *ta)
 {
   td_thr_events_t events;
 
@@ -1122,8 +1125,7 @@ quit:
  */
 
 static int
-thread_db_alive (pid)
-     int pid;
+thread_db_alive (int pid)
 {
   if (is_thread (pid))         /* user-space (non-kernel) thread */
     {
@@ -1148,8 +1150,7 @@ thread_db_alive (pid)
  */
 
 static int     /* lwpid_t or pid_t */
-get_lwp_from_thread_handle (th)
-     td_thrhandle_t *th;
+get_lwp_from_thread_handle (td_thrhandle_t *th)
 {
   td_thrinfo_t ti;
   td_err_e     ret;
@@ -1268,11 +1269,10 @@ thread_db_xfer_memory (memaddr, myaddr, len, dowrite, target)
  */
 
 static void
-thread_db_fetch_registers (regno)
-     int regno;
+thread_db_fetch_registers (int regno)
 {
   td_thrhandle_t thandle;
-  prfpregset_t fpregset;
+  gdb_prfpregset_t fpregset;
   prgregset_t gregset;
   thread_t thread;
   td_err_e ret;
@@ -1319,11 +1319,10 @@ thread_db_fetch_registers (regno)
  */
 
 static void
-thread_db_store_registers (regno)
-     int regno;
+thread_db_store_registers (int regno)
 {
   td_thrhandle_t thandle;
-  prfpregset_t fpregset;
+  gdb_prfpregset_t fpregset;
   prgregset_t  gregset;
   thread_t thread;
   td_err_e ret;
@@ -1371,10 +1370,9 @@ thread_db_store_registers (regno)
 }
 
 static void
-handle_new_thread (tid, lid, verbose)
-     int tid;  /* user thread id */
-     int lid;  /* kernel thread id */
-     int verbose;
+handle_new_thread (int tid,    /* user thread id */
+                  int lid,     /* kernel thread id */
+                  int verbose)
 {
   int gdb_pid = BUILD_THREAD (tid, main_prochandle.pid);
   int wait_pid, wait_status;
@@ -1394,10 +1392,7 @@ handle_new_thread (tid, lid, verbose)
 }
 
 static void
-test_for_new_thread (tid, lid, verbose)
-     int tid;
-     int lid;
-     int verbose;
+test_for_new_thread (int tid, int lid, int verbose)
 {
   if (!in_thread_list (BUILD_THREAD (tid, main_prochandle.pid)))
     handle_new_thread (tid, lid, verbose);
@@ -1409,9 +1404,7 @@ test_for_new_thread (tid, lid, verbose)
  */
 
 static int
-find_new_threads_callback (th, ignored)
-     const td_thrhandle_t *th;
-     void *ignored;
+find_new_threads_callback (const td_thrhandle_t *th, void *ignored)
 {
   td_thrinfo_t ti;
   td_err_e     ret;
@@ -1437,7 +1430,7 @@ find_new_threads_callback (th, ignored)
  */
 
 static void
-thread_db_find_new_threads ()
+thread_db_find_new_threads (void)
 {
   if (inferior_pid == -1)      /* FIXME: still necessary? */
     {
@@ -1476,9 +1469,7 @@ thread_db_find_new_threads ()
  */
 
 static int
-resume_thread_callback (th, data)
-     const td_thrhandle_t *th;
-     void *data;
+resume_thread_callback (const td_thrhandle_t *th, void *data)
 {
   td_thrinfo_t ti;
   td_err_e     ret;
@@ -1506,9 +1497,7 @@ resume_thread_callback (th, data)
 }
 
 static int
-new_resume_thread_callback (thread, data)
-     threadinfo *thread;
-     void *data;
+new_resume_thread_callback (threadinfo *thread, void *data)
 {
   if (thread->lid != event_pid &&
       thread->lid != main_prochandle.pid)
@@ -1525,10 +1514,7 @@ static int last_resume_step;
 static int last_resume_signo;
 
 static void
-thread_db_resume (pid, step, signo)
-     int pid;
-     int step;
-     enum target_signal signo;
+thread_db_resume (int pid, int step, enum target_signal signo)
 {
   last_resume_pid   = pid;
   last_resume_step  = step;
@@ -1621,8 +1607,7 @@ stop_or_attach_thread_callback (const td_thrhandle_t *th, void *data)
  */
 
 static void
-wait_for_stop (pid)
-     int pid;
+wait_for_stop (int pid)
 {
   int i;
   int retpid;
@@ -1752,9 +1737,7 @@ wait_thread_callback (const td_thrhandle_t *th, void *data)
 }
 
 static int
-new_wait_thread_callback (thread, data)
-     threadinfo *thread;
-     void *data;
+new_wait_thread_callback (threadinfo *thread, void *data)
 {
   /* don't wait on the event thread -- it's already stopped and waited.  
      Ditto the main thread.  */
@@ -1887,9 +1870,7 @@ thread_db_wait (int pid, struct target_waitstatus *ourstatus)
  */
 
 static int
-kill_thread_callback (th, data)
-     td_thrhandle_t *th;
-     void *data;
+kill_thread_callback (td_thrhandle_t *th, void *data)
 {
   td_thrinfo_t ti;
   td_err_e     ret;
@@ -1979,9 +1960,7 @@ static void thread_db_mourn_inferior (void)
  */
 
 static int
-detach_thread_callback (th, data)
-     td_thrhandle_t *th;
-     void *data;
+detach_thread_callback (td_thrhandle_t *th, void *data)
 {
   /* Called once per thread.  */
   td_thrinfo_t ti;
@@ -2064,10 +2043,7 @@ thread_db_detach (char *args, int from_tty)
  */
 
 static void
-thread_db_create_inferior (exec_file, allargs, env)
-     char *exec_file;
-     char *allargs;
-     char **env;
+thread_db_create_inferior (char *exec_file, char *allargs, char **env)
 {
   thread_db_unpush_target ();
   find_default_create_inferior (exec_file, allargs, env);
@@ -2078,7 +2054,7 @@ thread_db_create_inferior (exec_file, allargs, env)
  */
 
 void
-init_thread_db_ops ()
+init_thread_db_ops (void)
 {
   thread_db_ops.to_shortname        = "multi-thread";
   thread_db_ops.to_longname         = "multi-threaded child process.";
@@ -2111,7 +2087,7 @@ init_thread_db_ops ()
 
 
 void
-_initialize_thread_db ()
+_initialize_thread_db (void)
 {
 #ifdef HAVE_STDINT_H   /* stub out entire module, leave initializer empty */
   if (init_thread_db_library ())
This page took 0.030687 seconds and 4 git commands to generate.