summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeder Andersen2011-06-23 14:39:22 (EDT)
committer Eugene Tarassov2011-11-21 12:56:40 (EST)
commitb7a76d5c2e04197a05f52d99a2401457b77ca83b (patch)
treeb781efc290cbb4c7dc465f2bfaa939634127d88e
parent45c739a72bc2f3943aed89e4912137dc2afe8f8f (diff)
downloadorg.eclipse.tcf.agent-b7a76d5c2e04197a05f52d99a2401457b77ca83b.zip
org.eclipse.tcf.agent-b7a76d5c2e04197a05f52d99a2401457b77ca83b.tar.gz
org.eclipse.tcf.agent-b7a76d5c2e04197a05f52d99a2401457b77ca83b.tar.bz2
TCF Agent: leverage static initialization of lists
In addition to improving size and performance, this allows certain service capabilites to function to some extent before their initializer routines are invoked.
-rw-r--r--framework/asyncreq.c5
-rw-r--r--framework/cache.c5
-rw-r--r--framework/channel_pipe.c5
-rw-r--r--framework/context.c5
-rw-r--r--framework/link.h5
-rw-r--r--server/services/context-proxy.c3
-rw-r--r--services/breakpoints.c12
-rw-r--r--services/expressions.c3
-rw-r--r--services/filesystem.c5
-rw-r--r--services/linenumbers_proxy.c5
-rw-r--r--services/memorymap.c5
-rw-r--r--services/pathmap.c3
-rw-r--r--services/processes.c3
-rw-r--r--services/runctrl.c2
-rw-r--r--services/streamsservice.c11
-rw-r--r--services/symbols_proxy.c3
-rw-r--r--services/terminals.c4
-rw-r--r--system/Darwin/context-darwin.c5
-rw-r--r--system/FreeBSD/context-freebsd.c5
-rw-r--r--system/GNU/Linux/context-linux.c6
20 files changed, 39 insertions, 61 deletions
diff --git a/framework/asyncreq.c b/framework/asyncreq.c
index 733d6f2..a6a0359 100644
--- a/framework/asyncreq.c
+++ b/framework/asyncreq.c
@@ -37,7 +37,7 @@
#define MAX_WORKER_THREADS 32
-static LINK wtlist;
+static LINK wtlist = TCF_LIST_INIT(wtlist);
static int wtlist_size = 0;
static pthread_mutex_t wtlock;
@@ -270,7 +270,6 @@ void async_req_post(AsyncReqInfo * req) {
}
void ini_asyncreq(void) {
- list_init(&wtlist);
wtlist_size = 0;
check_error(pthread_mutex_init(&wtlock, NULL));
-} \ No newline at end of file
+}
diff --git a/framework/cache.c b/framework/cache.c
index c2b7ebe..32ae2f4 100644
--- a/framework/cache.c
+++ b/framework/cache.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -44,7 +44,7 @@ static int client_exited = 0;
static int cache_miss_cnt = 0;
static WaitingCacheClient * wait_list_buf;
static unsigned wait_list_max;
-static LINK cache_list;
+static LINK cache_list = TCF_LIST_INIT(cache_list);
static void run_cache_client(void) {
Trap trap;
@@ -96,7 +96,6 @@ void cache_wait_dbg(const char * file, int line, AbstractCache * cache) {
assert(is_dispatch_thread());
assert(client_exited == 0);
if (current_client.client != NULL && cache_miss_cnt == 0) {
- if (cache_list.next == NULL) list_init(&cache_list);
if (cache->wait_list_cnt >= cache->wait_list_max) {
cache->wait_list_max += 8;
cache->wait_list_buf = (WaitingCacheClient *)loc_realloc(cache->wait_list_buf, cache->wait_list_max * sizeof(WaitingCacheClient));
diff --git a/framework/channel_pipe.c b/framework/channel_pipe.c
index 1a74d9e..e2d3189 100644
--- a/framework/channel_pipe.c
+++ b/framework/channel_pipe.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2010, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -99,7 +99,7 @@ struct ServerPIPE {
#define ibuf2pipe(A) ((ChannelPIPE *)((char *)(A) - offsetof(ChannelPIPE, ibuf)))
#define obuf2pipe(A) ((ChannelPIPE *)((char *)(A) - offsetof(ChannelPIPE, out_queue)))
-static LINK server_list;
+static LINK server_list = TCF_LIST_INIT(server_list);
static void pipe_read_done(void * x);
static void handle_channel_msg(void * x);
@@ -712,7 +712,6 @@ static void server_close(ChannelServer * serv) {
ChannelServer * channel_pipe_server(PeerServer * ps) {
ServerPIPE * s = (ServerPIPE *)loc_alloc_zero(sizeof(ServerPIPE));
- if (server_list.next == NULL) list_init(&server_list);
#if defined(WIN32) && !defined(__CYGWIN__)
{
int i;
diff --git a/framework/context.c b/framework/context.c
index 9722166..e90d7f2 100644
--- a/framework/context.c
+++ b/framework/context.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -35,7 +35,7 @@ static unsigned listener_max = 0;
static size_t extension_size = 0;
static int context_created = 0;
-LINK context_root = { NULL, NULL };
+LINK context_root = TCF_LIST_INIT(context_root);
const char * REASON_USER_REQUEST = "Suspended";
const char * REASON_STEP = "Step";
@@ -289,7 +289,6 @@ void send_context_exited_event(Context * ctx) {
}
void ini_contexts(void) {
- list_init(&context_root);
init_contexts_sys_dep();
}
diff --git a/framework/link.h b/framework/link.h
index 7a5c851..5d60da6 100644
--- a/framework/link.h
+++ b/framework/link.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -29,6 +29,9 @@ struct LINK {
LINK * prev;
};
+
+#define TCF_LIST_INIT(list) {&(list), &(list)}
+
#define list_init(list) { \
(list)->next = (list)->prev = (list); \
}
diff --git a/server/services/context-proxy.c b/server/services/context-proxy.c
index 3aea652..04c1827 100644
--- a/server/services/context-proxy.c
+++ b/server/services/context-proxy.c
@@ -152,7 +152,7 @@ struct PeerCache {
#define ctx2stk(A) ((StackFrameCache *)((char *)(A) - offsetof(StackFrameCache, link_ctx)))
#define idhashl2ctx(A) ((ContextCache *)((char *)(A) - offsetof(ContextCache, id_hash_link)))
-static LINK peers;
+static LINK peers = TCF_LIST_INIT(peers);
static MemoryRegion * mem_buf = NULL;
static unsigned mem_buf_max = 0;
@@ -1540,7 +1540,6 @@ void init_contexts_sys_dep(void) {
add_context_event_listener(&listener, NULL);
add_channel_close_listener(channel_close_listener);
context_extension_offset = context_extension(sizeof(ContextCache *));
- list_init(&peers);
}
#endif /* ENABLE_DebugContext && ENABLE_ContextProxy */
diff --git a/services/breakpoints.c b/services/breakpoints.c
index 28cde4f..b7d158d 100644
--- a/services/breakpoints.c
+++ b/services/breakpoints.c
@@ -188,16 +188,16 @@ static unsigned listener_max = 0;
#define link_active2erl(A) ((EvaluationRequest *)((char *)(A) - offsetof(EvaluationRequest, link_active)))
#define link_bcg2chnl(A) ((Channel *)((char *)(A) - offsetof(Channel, bclink)))
-static LINK breakpoints;
+static LINK breakpoints = TCF_LIST_INIT(breakpoints);
static LINK id2bp[ID2BP_HASH_SIZE];
-static LINK instructions;
+static LINK instructions = TCF_LIST_INIT(instructions);
static LINK addr2instr[ADDR2INSTR_HASH_SIZE];
static LINK inp2br[INP2BR_HASH_SIZE];
-static LINK evaluations_posted;
-static LINK evaluations_active;
+static LINK evaluations_posted = TCF_LIST_INIT(evaluations_posted);
+static LINK evaluations_active = TCF_LIST_INIT(evaluations_active);
static uintptr_t generation_posted = 0;
static uintptr_t generation_active = 0;
static uintptr_t generation_done = 0;
@@ -2549,10 +2549,6 @@ void ini_breakpoints_service(Protocol * proto, TCFBroadcastGroup * bcg) {
add_path_map_event_listener(&listener, NULL);
}
#endif
- list_init(&breakpoints);
- list_init(&instructions);
- list_init(&evaluations_posted);
- list_init(&evaluations_active);
for (i = 0; i < ADDR2INSTR_HASH_SIZE; i++) list_init(addr2instr + i);
for (i = 0; i < ID2BP_HASH_SIZE; i++) list_init(id2bp + i);
for (i = 0; i < INP2BR_HASH_SIZE; i++) list_init(inp2br + i);
diff --git a/services/expressions.c b/services/expressions.c
index c58757b..a9e3aad 100644
--- a/services/expressions.c
+++ b/services/expressions.c
@@ -2216,7 +2216,7 @@ typedef struct Expression {
#define ID2EXP_HASH_SIZE (32 * MEM_USAGE_FACTOR - 1)
-static LINK expressions;
+static LINK expressions = TCF_LIST_INIT(expressions);
static LINK id2exp[ID2EXP_HASH_SIZE];
#define MAX_SYM_NAME 1024
@@ -2793,7 +2793,6 @@ void add_identifier_callback(ExpressionIdentifierCallBack * callback) {
void ini_expressions_service(Protocol * proto) {
unsigned i;
- list_init(&expressions);
for (i = 0; i < ID2EXP_HASH_SIZE; i++) list_init(id2exp + i);
add_channel_close_listener(on_channel_close);
add_command_handler(proto, EXPRESSIONS, "getContext", command_get_context);
diff --git a/services/filesystem.c b/services/filesystem.c
index 174a8bb..5c912e4 100644
--- a/services/filesystem.c
+++ b/services/filesystem.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -132,7 +132,7 @@ static unsigned long handle_cnt = 0;
#define HANDLE_HASH_SIZE (4 * MEM_USAGE_FACTOR - 1)
static LINK handle_hash[HANDLE_HASH_SIZE];
-static LINK file_info_ring = { NULL, NULL };
+static LINK file_info_ring = TCF_LIST_INIT(file_info_ring);
static OpenFileInfo * create_open_file_info(Channel * ch, char * path, int file, DIR * dir) {
LINK * list_head = NULL;
@@ -1366,7 +1366,6 @@ void ini_file_system_service(Protocol * proto) {
int i;
add_channel_close_listener(channel_close_listener);
- list_init(&file_info_ring);
for (i = 0; i < HANDLE_HASH_SIZE; i++) {
list_init(&handle_hash[i]);
}
diff --git a/services/linenumbers_proxy.c b/services/linenumbers_proxy.c
index 3f92072..88f6f88 100644
--- a/services/linenumbers_proxy.c
+++ b/services/linenumbers_proxy.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -65,7 +65,7 @@ typedef struct LineAddressCache {
#define root2cache(A) ((LineNumbersCache *)((char *)(A) - offsetof(LineNumbersCache, link_root)))
#define cache2addr(A) ((LineAddressCache *)((char *)(A) - offsetof(LineAddressCache, link_cache)))
-static LINK root;
+static LINK root = TCF_LIST_INIT(root);
static int code_area_cnt = 0;
static int code_area_max = 0;
@@ -308,7 +308,6 @@ void ini_line_numbers_lib(void) {
NULL,
event_context_changed
};
- list_init(&root);
add_context_event_listener(&listener, NULL);
add_channel_close_listener(channel_close_listener);
}
diff --git a/services/memorymap.c b/services/memorymap.c
index 55ecded..71f89cd 100644
--- a/services/memorymap.c
+++ b/services/memorymap.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -67,7 +67,7 @@ static unsigned listener_max = 0;
#define ctx2map(A) ((ClientMap *)((char *)(A) - offsetof(ClientMap, link_ctx)))
#define MAP_HASH_SIZE (4 * MEM_USAGE_FACTOR - 1)
-static LINK client_map_list;
+static LINK client_map_list = TCF_LIST_INIT(client_map_list);
static LINK client_map_hash[MAP_HASH_SIZE];
static TCFBroadcastGroup * broadcast_group = NULL;
@@ -529,7 +529,6 @@ void ini_memory_map_service(Protocol * proto, TCFBroadcastGroup * bcg) {
};
broadcast_group = bcg;
add_channel_close_listener(channel_close_listener);
- list_init(&client_map_list);
for (i = 0; i < MAP_HASH_SIZE; i++) {
list_init(&client_map_hash[i]);
}
diff --git a/services/pathmap.c b/services/pathmap.c
index 8322930..e48a8a4 100644
--- a/services/pathmap.c
+++ b/services/pathmap.c
@@ -102,7 +102,7 @@ struct PathMap {
static const char PATH_MAP[] = "PathMap";
static int ini_done = 0;
-static LINK maps;
+static LINK maps = TCF_LIST_INIT(maps);
static char host_name[256];
static Listener * listeners = NULL;
@@ -523,7 +523,6 @@ static void channel_close_listener(Channel * c) {
void ini_path_map_service(Protocol * proto, TCFBroadcastGroup * bcg) {
if (!ini_done) {
ini_done = 1;
- list_init(&maps);
add_channel_close_listener(channel_close_listener);
}
broadcast_group = bcg;
diff --git a/services/processes.c b/services/processes.c
index 78a2a56..23f5e6a 100644
--- a/services/processes.c
+++ b/services/processes.c
@@ -133,7 +133,7 @@ typedef struct ProcessInput {
#define link2prs(A) ((ChildProcess *)((char *)(A) - offsetof(ChildProcess, link)))
static int init_done = 0;
-static LINK prs_list;
+static LINK prs_list = TCF_LIST_INIT(prs_list);
#if defined(_WRS_KERNEL)
static SEM_ID prs_list_lock = NULL;
#endif
@@ -1335,7 +1335,6 @@ static void init(void) {
if (taskCreateHookAdd((FUNCPTR)task_create_hook) != OK) check_error(errno);
if (taskDeleteHookAdd((FUNCPTR)task_delete_hook) != OK) check_error(errno);
#endif /* defined(_WRS_KERNEL) */
- list_init(&prs_list);
add_waitpid_listener(waitpid_listener, NULL);
}
diff --git a/services/runctrl.c b/services/runctrl.c
index f781231..57b9236 100644
--- a/services/runctrl.c
+++ b/services/runctrl.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
diff --git a/services/streamsservice.c b/services/streamsservice.c
index 0414e5d..34dca53 100644
--- a/services/streamsservice.c
+++ b/services/streamsservice.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -107,9 +107,9 @@ struct Subscription {
#define HANDLE_HASH_SIZE (4 * MEM_USAGE_FACTOR - 1)
static LINK handle_hash[HANDLE_HASH_SIZE];
-static LINK clients;
-static LINK streams;
-static LINK subscriptions;
+static LINK clients = TCF_LIST_INIT(clients);
+static LINK streams = TCF_LIST_INIT(streams);
+static LINK subscriptions = TCF_LIST_INIT(subscriptions);
static unsigned id_cnt = 0;
static unsigned get_client_hash(unsigned id, Channel * c) {
@@ -835,9 +835,6 @@ static void channel_close_listener(Channel * c) {
void ini_streams_service(Protocol * proto) {
int i;
- list_init(&clients);
- list_init(&streams);
- list_init(&subscriptions);
for (i = 0; i < HANDLE_HASH_SIZE; i++) {
list_init(&handle_hash[i]);
}
diff --git a/services/symbols_proxy.c b/services/symbols_proxy.c
index d145de9..539fd59 100644
--- a/services/symbols_proxy.c
+++ b/services/symbols_proxy.c
@@ -168,7 +168,7 @@ struct Symbol {
#include <services/symbols_alloc.h>
-static LINK root;
+static LINK root = TCF_LIST_INIT(root);
static const char * SYMBOLS = "Symbols";
@@ -1348,7 +1348,6 @@ void ini_symbols_lib(void) {
event_context_started,
event_context_changed
};
- list_init(&root);
add_context_event_listener(&listener, NULL);
add_channel_close_listener(channel_close_listener);
}
diff --git a/services/terminals.c b/services/terminals.c
index fb9932e..47c158d 100644
--- a/services/terminals.c
+++ b/services/terminals.c
@@ -105,7 +105,7 @@ typedef struct Terminal {
#define link2term(A) ((Terminal *)((char *)(A) - offsetof(Terminal, link)))
-static LINK terms_list;
+static LINK terms_list = TCF_LIST_INIT(terms_list);
static Terminal * find_terminal(int pid) {
LINK * qhp = &terms_list;
@@ -571,8 +571,6 @@ static void channel_close_listener(Channel * c) {
}
void ini_terminals_service(Protocol * proto) {
- list_init(&terms_list);
-
add_channel_close_listener(channel_close_listener);
add_command_handler(proto, TERMINALS, "getContext", command_get_context);
diff --git a/system/Darwin/context-darwin.c b/system/Darwin/context-darwin.c
index 1ed3271..5436129 100644
--- a/system/Darwin/context-darwin.c
+++ b/system/Darwin/context-darwin.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -67,7 +67,7 @@ static size_t context_extension_offset = 0;
#include <system/pid-hash.h>
-static LINK pending_list;
+static LINK pending_list = TCF_LIST_INIT(pending_list);
static MemoryErrorInfo mem_err_info;
@@ -654,7 +654,6 @@ static void waitpid_listener(int pid, int exited, int exit_code, int signal, int
}
void init_contexts_sys_dep(void) {
- list_init(&pending_list);
context_extension_offset = context_extension(sizeof(ContextExtensionDarwin));
add_waitpid_listener(waitpid_listener, NULL);
ini_context_pid_hash();
diff --git a/system/FreeBSD/context-freebsd.c b/system/FreeBSD/context-freebsd.c
index d01f108..50b8799 100644
--- a/system/FreeBSD/context-freebsd.c
+++ b/system/FreeBSD/context-freebsd.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -74,7 +74,7 @@ static size_t context_extension_offset = 0;
#include <system/pid-hash.h>
-static LINK pending_list;
+static LINK pending_list = TCF_LIST_INIT(pending_list);
static MemoryErrorInfo mem_err_info;
@@ -650,7 +650,6 @@ static void waitpid_listener(int pid, int exited, int exit_code, int signal, int
}
void init_contexts_sys_dep(void) {
- list_init(&pending_list);
context_extension_offset = context_extension(sizeof(ContextExtensionBSD));
add_waitpid_listener(waitpid_listener, NULL);
ini_context_pid_hash();
diff --git a/system/GNU/Linux/context-linux.c b/system/GNU/Linux/context-linux.c
index 569d9ec..b2cdd64 100644
--- a/system/GNU/Linux/context-linux.c
+++ b/system/GNU/Linux/context-linux.c
@@ -107,8 +107,8 @@ static size_t context_extension_offset = 0;
#include <system/pid-hash.h>
-static LINK pending_list;
-static LINK detach_list;
+static LINK pending_list = TCF_LIST_INIT(pending_list);
+static LINK detach_list = TCF_LIST_INIT(detach_list);
static MemoryErrorInfo mem_err_info;
@@ -1173,8 +1173,6 @@ static void eventpoint_at_main(Context * ctx, void * args) {
}
void init_contexts_sys_dep(void) {
- list_init(&pending_list);
- list_init(&detach_list);
context_extension_offset = context_extension(sizeof(ContextExtensionLinux));
add_waitpid_listener(waitpid_listener, NULL);
ini_context_pid_hash();