From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15048 invoked by alias); 27 May 2011 14:58:15 -0000 Received: (qmail 15033 invoked by uid 22791); 27 May 2011 14:58:13 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 May 2011 14:57:36 +0000 Received: (qmail 19098 invoked from network); 27 May 2011 14:57:35 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 May 2011 14:57:35 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: simplify continuations a bit more. Date: Fri, 27 May 2011 14:58:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-8-generic; KDE/4.6.2; x86_64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201105271557.33330.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00638.txt.bz2 Yes more continuations love, replacing the hard to read prototypes with function pointer typedefs ... Applied. Pedro Alves 2011-05-27 Pedro Alves gdb/ * defs.h (continuation_ftype, continuation_free_arg_ftype): New typedefs. (add_continuation, add_intermediate_continuation) (add_inferior_continuation): Use them. * continuations.c (struct continuation): Use them. (make_continuation_ftype): Delete. (make_continuation, add_inferior_continuation, add_continuation) (add_intermediate_continuation): Use continuation_ftype and continuation_free_arg_ftype. Rename parameters to shorter names. --- gdb/continuations.c | 32 ++++++++++++++------------------ gdb/defs.h | 22 +++++++++++++++------- 2 files changed, 29 insertions(+), 25 deletions(-) Index: src/gdb/defs.h =================================================================== --- src.orig/gdb/defs.h 2011-05-27 15:07:35.000000000 +0100 +++ src/gdb/defs.h 2011-05-27 15:45:20.320787876 +0100 @@ -740,21 +740,29 @@ struct continuation; struct thread_info; struct inferior; -/* From utils.c */ +/* From continuations.c */ + +/* Prototype of the continuation callback functions. */ +typedef void (continuation_ftype) (void *); + +/* Prototype of the function responsible for releasing the argument + passed to the continuation callback functions, either when the + continuation is called, or discarded. */ +typedef void (continuation_free_arg_ftype) (void *); /* Thread specific continuations. */ extern void add_continuation (struct thread_info *, - void (*)(void *), void *, - void (*)(void *)); + continuation_ftype *, void *, + continuation_free_arg_ftype *); extern void do_all_continuations (void); extern void do_all_continuations_thread (struct thread_info *); extern void discard_all_continuations (void); extern void discard_all_continuations_thread (struct thread_info *); extern void add_intermediate_continuation (struct thread_info *, - void (*)(void *), void *, - void (*)(void *)); + continuation_ftype *, void *, + continuation_free_arg_ftype *); extern void do_all_intermediate_continuations (void); extern void do_all_intermediate_continuations_thread (struct thread_info *); extern void discard_all_intermediate_continuations (void); @@ -762,9 +770,9 @@ extern void discard_all_intermediate_con /* Inferior specific (any thread) continuations. */ -extern void add_inferior_continuation (void (*) (void *), +extern void add_inferior_continuation (continuation_ftype *, void *, - void (*) (void *)); + continuation_free_arg_ftype *); extern void do_all_inferior_continuations (void); extern void discard_all_inferior_continuations (struct inferior *inf); Index: src/gdb/continuations.c =================================================================== --- src.orig/gdb/continuations.c 2011-05-27 15:43:35.000000000 +0100 +++ src/gdb/continuations.c 2011-05-27 15:43:28.060787856 +0100 @@ -26,20 +26,18 @@ struct continuation { struct continuation *next; - void (*function) (void *); - void (*free_arg) (void *); + continuation_ftype *function; + continuation_free_arg_ftype *free_arg; void *arg; }; -typedef void (make_continuation_ftype) (void *); - /* Add a new continuation to the continuation chain. Args are FUNCTION to run the continuation up with, and ARG to pass to it. */ static void make_continuation (struct continuation **pmy_chain, - make_continuation_ftype *function, + continuation_ftype *function, void *arg, void (*free_arg) (void *)) { struct continuation *new = XNEW (struct continuation); @@ -113,13 +111,12 @@ discard_my_continuations (struct continu continuation will be added at the front. */ void -add_inferior_continuation (void (*continuation_hook) (void *), void *args, - void (*continuation_free_args) (void *)) +add_inferior_continuation (continuation_ftype *hook, void *args, + continuation_free_arg_ftype *free_arg) { struct inferior *inf = current_inferior (); - make_continuation (&inf->continuations, continuation_hook, - args, continuation_free_args); + make_continuation (&inf->continuations, hook, args, free_arg); } /* Do all continuations of the current inferior. */ @@ -144,11 +141,10 @@ discard_all_inferior_continuations (stru void add_continuation (struct thread_info *thread, - void (*continuation_hook) (void *), void *args, - void (*continuation_free_args) (void *)) + continuation_ftype *hook, void *args, + continuation_free_arg_ftype *free_arg) { - make_continuation (&thread->continuations, continuation_hook, - args, continuation_free_args); + make_continuation (&thread->continuations, hook, args, free_arg); } static void @@ -256,12 +252,12 @@ discard_all_continuations (void) void add_intermediate_continuation (struct thread_info *thread, - void (*continuation_hook) - (void *), void *args, - void (*continuation_free_args) (void *)) + continuation_ftype *hook, + void *args, + continuation_free_arg_ftype *free_arg) { - make_continuation (&thread->intermediate_continuations, continuation_hook, - args, continuation_free_args); + make_continuation (&thread->intermediate_continuations, hook, + args, free_arg); } /* Walk down the cmd_continuation list, and execute all the