From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24848 invoked by alias); 24 Jan 2013 01:15:11 -0000 Received: (qmail 24769 invoked by uid 22791); 24 Jan 2013 01:15:09 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Jan 2013 01:14:56 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1TyBP5-00017S-UH from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 23 Jan 2013 17:14:55 -0800 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 23 Jan 2013 17:14:55 -0800 Received: from qiyao.dyndns.org.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Wed, 23 Jan 2013 17:14:55 -0800 From: Yao Qi To: Subject: [PATCH 2/3] Remove queue_position. Date: Thu, 24 Jan 2013 01:15:00 -0000 Message-ID: <1358990040-10962-2-git-send-email-yao@codesourcery.com> In-Reply-To: <1358990040-10962-1-git-send-email-yao@codesourcery.com> References: <1358990040-10962-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain 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: 2013-01/txt/msg00580.txt.bz2 enum HEAD is never used and AFAICS, we don't need to insert element to event_queue in different places of the queue, so 'enum queue_position' is not needed. This patch is to remove it and simplify 'async_queue_event'. gdb: 2013-01-24 Yao Qi * event-loop.c (async_queue_event): Remove one parameter 'position'. Remove code handling 'position' == TAIL. (gdb_wait_for_event): Caller update. (check_async_event_handlers): Caller update. (poll_timers): Caller update. * event-loop.h (enum queue_position): Remove. --- gdb/event-loop.c | 40 +++++++++++++--------------------------- gdb/event-loop.h | 12 ------------ 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/gdb/event-loop.c b/gdb/event-loop.c index be485c9..aea3b5e 100644 --- a/gdb/event-loop.c +++ b/gdb/event-loop.c @@ -274,9 +274,7 @@ static int gdb_wait_for_event (int); static void poll_timers (void); -/* Insert an event object into the gdb event queue at - the specified position. - POSITION can be head or tail, with values TAIL, HEAD. +/* Insert an event object into the gdb event queue. EVENT_PTR points to the event to be inserted into the queue. The caller must allocate memory for the event. It is freed after the event has ben handled. @@ -285,28 +283,16 @@ static void poll_timers (void); as last in first out. Event appended at the tail of the queue will be processed first in first out. */ static void -async_queue_event (gdb_event * event_ptr, queue_position position) +async_queue_event (gdb_event * event_ptr) { - if (position == TAIL) - { - /* The event will become the new last_event. */ + /* The event will become the new last_event. */ - event_ptr->next_event = NULL; - if (event_queue.first_event == NULL) - event_queue.first_event = event_ptr; - else - event_queue.last_event->next_event = event_ptr; - event_queue.last_event = event_ptr; - } - else if (position == HEAD) - { - /* The event becomes the new first_event. */ - - event_ptr->next_event = event_queue.first_event; - if (event_queue.first_event == NULL) - event_queue.last_event = event_ptr; - event_queue.first_event = event_ptr; - } + event_ptr->next_event = NULL; + if (event_queue.first_event == NULL) + event_queue.first_event = event_ptr; + else + event_queue.last_event->next_event = event_ptr; + event_queue.last_event = event_ptr; } /* Create a generic event, to be enqueued in the event queue for @@ -936,7 +922,7 @@ gdb_wait_for_event (int block) if (file_ptr->ready_mask == 0) { file_event_ptr = create_file_event (file_ptr->fd); - async_queue_event (file_event_ptr, TAIL); + async_queue_event (file_event_ptr); } file_ptr->ready_mask = (gdb_notifier.poll_fds + i)->revents; } @@ -972,7 +958,7 @@ gdb_wait_for_event (int block) if (file_ptr->ready_mask == 0) { file_event_ptr = create_file_event (file_ptr->fd); - async_queue_event (file_event_ptr, TAIL); + async_queue_event (file_event_ptr); } file_ptr->ready_mask = mask; } @@ -1158,7 +1144,7 @@ check_async_event_handlers (void) data.ptr = hdata; event_ptr = create_event (invoke_async_event_handler, data); - async_queue_event (event_ptr, TAIL); + async_queue_event (event_ptr); } } } @@ -1365,7 +1351,7 @@ poll_timers (void) event_ptr = (gdb_event *) xmalloc (sizeof (gdb_event)); event_ptr->proc = handle_timer_event; event_ptr->data.integer = timer_list.first_timer->timer_id; - async_queue_event (event_ptr, TAIL); + async_queue_event (event_ptr); } /* Now we need to update the timeout for select/ poll, because diff --git a/gdb/event-loop.h b/gdb/event-loop.h index 16c2286..fc95cf1 100644 --- a/gdb/event-loop.h +++ b/gdb/event-loop.h @@ -75,18 +75,6 @@ typedef void (sig_handler_func) (gdb_client_data); typedef void (async_event_handler_func) (gdb_client_data); typedef void (timer_handler_func) (gdb_client_data); -/* Where to add an event onto the event queue, by queue_event. */ -typedef enum - { - /* Add at tail of queue. It will be processed in first in first - out order. */ - TAIL, - /* Add at head of queue. It will be processed in last in first - out order. */ - HEAD - } -queue_position; - /* Exported functions from event-loop.c */ extern void start_event_loop (void); -- 1.7.7.6