[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7695 - in flightrecorder/src: include libflightrecorder
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7695 - in flightrecorder/src: include libflightrecorder |
Date: |
Thu, 11 Sep 2008 14:45:10 -0600 (MDT) |
Author: durner
Date: 2008-09-11 14:45:10 -0600 (Thu, 11 Sep 2008)
New Revision: 7695
Modified:
flightrecorder/src/include/flightrecorder.h
flightrecorder/src/libflightrecorder/clientapi.c
flightrecorder/src/libflightrecorder/func.c
flightrecorder/src/libflightrecorder/main.c
flightrecorder/src/libflightrecorder/opt.c
flightrecorder/src/libflightrecorder/private.h
flightrecorder/src/libflightrecorder/session.c
flightrecorder/src/libflightrecorder/stack_trace.c
Log:
opaque types
Modified: flightrecorder/src/include/flightrecorder.h
===================================================================
--- flightrecorder/src/include/flightrecorder.h 2008-09-11 19:53:30 UTC (rev
7694)
+++ flightrecorder/src/include/flightrecorder.h 2008-09-11 20:45:10 UTC (rev
7695)
@@ -25,37 +25,22 @@
#include <sys/types.h>
-typedef struct
+struct StackTraceEntry
{
char *file;
unsigned int line;
char *function;
char **info;
unsigned int info_count;
-} StackTraceEntry;
+};
-typedef struct
-{
- StackTraceEntry *entries;
- unsigned int depth;
- unsigned int tid;
-} StackTrace;
+struct StackTrace;
-typedef struct
-{
- unsigned int opt;
- void *val;
-} FR_Option_Entry;
+struct FR_Option_Entry;
-typedef struct
-{
- FR_Option_Entry *options;
- unsigned long option_count;
- StackTrace *traces;
- unsigned int trace_count;
-} FR_Session;
+struct FR_Session;
-typedef int (*StackTraceIterator)(StackTraceEntry *entry);
+typedef int (*StackTraceIterator)(struct StackTraceEntry *entry);
typedef enum {FR_OPT_RECORD_STACK_TRACE} FR_Option;
@@ -66,9 +51,9 @@
void fr_free(void *p);
/* --- Sessions --- */
-FR_Session *fr_session_create();
-void fr_session_destroy(FR_Session *ses);
-FR_Session *fr_session_get_local();
+struct FR_Session *fr_session_create();
+void fr_session_destroy(struct FR_Session *ses);
+struct FR_Session *fr_session_get_local();
/* --- Options - Simple API --- */
int fr_opt_set(const FR_Option opt, const void *val, const unsigned int len);
@@ -80,13 +65,13 @@
void fr_opt_cleanup();
/* --- Options - C/S API --- */
-int fr_srv_opt_set(FR_Session *ses, const FR_Option opt, const void *val,
const unsigned int len);
-int fr_srv_opt_set_int(FR_Session *ses, const FR_Option opt, const unsigned
int val);
-int fr_srv_opt_set_str(FR_Session *ses, const FR_Option opt, const char *val);
-const void *fr_srv_opt_get(FR_Session *ses, const FR_Option opt);
-const char *fr_srv_opt_get_str(FR_Session *ses, const FR_Option opt);
-unsigned int fr_srv_opt_get_int(FR_Session *ses, const FR_Option opt);
-void fr_srv_opt_cleanup(FR_Session *ses);
+int fr_srv_opt_set(struct FR_Session *ses, const FR_Option opt, const void
*val, const unsigned int len);
+int fr_srv_opt_set_int(struct FR_Session *ses, const FR_Option opt, const
unsigned int val);
+int fr_srv_opt_set_str(struct FR_Session *ses, const FR_Option opt, const char
*val);
+const void *fr_srv_opt_get(struct FR_Session *ses, const FR_Option opt);
+const char *fr_srv_opt_get_str(struct FR_Session *ses, const FR_Option opt);
+unsigned int fr_srv_opt_get_int(struct FR_Session *ses, const FR_Option opt);
+void fr_srv_opt_cleanup(struct FR_Session *ses);
/**
* @brief Add function to the stack trace
@@ -118,7 +103,7 @@
* @param tid thread ID
* @return pointer stack trace, NULL on error
*/
-StackTrace *fr_st_get(unsigned int tid);
+struct StackTrace *fr_st_get(unsigned int tid);
/**
* @brief Return a list of thread IDs
@@ -131,7 +116,7 @@
* @param trace stack trace
* @param iter callback function
*/
-void fr_st_iterate(StackTrace *trace, StackTraceIterator iter);
+void fr_st_iterate(struct StackTrace *trace, StackTraceIterator iter);
/* --- Stack traces - C/S API --- */
@@ -143,7 +128,7 @@
* @param function name of the function that is called
* @return 1 on success, 0 otherwise
*/
-int fr_srv_st_enter(FR_Session *ses, char *file, unsigned int line, char
*function);
+int fr_srv_st_enter(struct FR_Session *ses, char *file, unsigned int line,
char *function);
/**
* @brief Remove function from the stack trace
@@ -153,7 +138,7 @@
* @param function name of the function that is called
* @return 1 on success, 0 otherwise
*/
-int fr_srv_st_leave(FR_Session *ses, char *file, unsigned int line, char
*function);
+int fr_srv_st_leave(struct FR_Session *ses, char *file, unsigned int line,
char *function);
/**
* @brief Add a info to the last stack trace entry
@@ -161,7 +146,7 @@
* @param info diagnostics information/log/...
* @return 1 on success, 0 on error
*/
-int fr_srv_st_add_info(FR_Session *ses, char *info);
+int fr_srv_st_add_info(struct FR_Session *ses, char *info);
/**
* @brief Return the stack trace for a particular thread
@@ -169,13 +154,13 @@
* @param tid thread ID
* @return pointer stack trace, NULL on error
*/
-StackTrace *fr_srv_st_get(FR_Session *ses, unsigned int tid);
+struct StackTrace *fr_srv_st_get(struct FR_Session *ses, unsigned int tid);
/**
* @brief Return a list of thread IDs
* @param ses C/S session
* @return array of thread IDs, NULL on error
*/
-unsigned int *fr_srv_st_threads(FR_Session *ses);
+unsigned int *fr_srv_st_threads(struct FR_Session *ses);
#endif /*FLIGHTRECORDER_H_*/
Modified: flightrecorder/src/libflightrecorder/clientapi.c
===================================================================
--- flightrecorder/src/libflightrecorder/clientapi.c 2008-09-11 19:53:30 UTC
(rev 7694)
+++ flightrecorder/src/libflightrecorder/clientapi.c 2008-09-11 20:45:10 UTC
(rev 7695)
@@ -1,4 +1,4 @@
-/*
+/*
libflightrecorder - Client library for flightrecorder, a recorder for
runtime information gathered by AOP advices or other process internal
checks
@@ -67,13 +67,13 @@
* @param tid thread ID
* @return pointer stack trace, NULL on error
*/
-StackTrace *fr_st_get(unsigned int tid)
+struct StackTrace *fr_st_get(unsigned int tid)
{
return fr_srv_st_get(fr_session_get_local(), tid);
}
/**
- * @brief Return a list of thread IDs
+ * @brief Return a list of thread IDs
* @return array of thread IDs, NULL on error
*/
unsigned int *fr_st_threads()
Modified: flightrecorder/src/libflightrecorder/func.c
===================================================================
--- flightrecorder/src/libflightrecorder/func.c 2008-09-11 19:53:30 UTC (rev
7694)
+++ flightrecorder/src/libflightrecorder/func.c 2008-09-11 20:45:10 UTC (rev
7695)
@@ -1,4 +1,4 @@
-/*
+/*
libflightrecorder - Client library for flightrecorder, a recorder for
runtime information gathered by AOP advices or other process internal
checks
@@ -22,35 +22,35 @@
#include "flightrecorder.h"
-int fr_srv_func_enter(FR_Session *ses, char *file, unsigned int line, char
*function)
+int fr_srv_func_enter(struct FR_Session *ses, char *file, unsigned int line,
char *function)
{
if (fr_srv_opt_get_int(ses, FR_OPT_RECORD_STACK_TRACE))
{
if (!fr_srv_st_enter(ses, file, line, function))
return 0;
}
-
+
return 1;
}
-int fr_srv_func_leave(FR_Session *ses, char *file, unsigned int line, char
*function)
+int fr_srv_func_leave(struct FR_Session *ses, char *file, unsigned int line,
char *function)
{
if (fr_srv_opt_get_int(ses, FR_OPT_RECORD_STACK_TRACE))
{
if (!fr_srv_st_leave(ses, file, line, function))
return 0;
}
-
+
return 1;
}
-int fr_srv_func_add_info(FR_Session *ses, char *info)
+int fr_srv_func_add_info(struct FR_Session *ses, char *info)
{
if (fr_srv_opt_get_int(ses, FR_OPT_RECORD_STACK_TRACE))
{
if (!fr_srv_st_add_info(ses, info))
return 0;
}
-
+
return 1;
}
Modified: flightrecorder/src/libflightrecorder/main.c
===================================================================
--- flightrecorder/src/libflightrecorder/main.c 2008-09-11 19:53:30 UTC (rev
7694)
+++ flightrecorder/src/libflightrecorder/main.c 2008-09-11 20:45:10 UTC (rev
7695)
@@ -1,4 +1,4 @@
-/*
+/*
libflightrecorder - Client library for flightrecorder, a recorder for
runtime information gathered by AOP advices or other process internal
checks
@@ -22,6 +22,7 @@
#include <stddef.h>
#include "flightrecorder.h"
+#include "private.h"
static int remote_operation;
@@ -45,12 +46,12 @@
else
{
remote_operation = 0;
-
- memset(fr_session_get_local(), 0, sizeof(FR_Session));
+
+ memset(fr_session_get_local(), 0, sizeof(struct FR_Session));
}
-
+
// FIXME
// ...
-
+
return 1;
}
Modified: flightrecorder/src/libflightrecorder/opt.c
===================================================================
--- flightrecorder/src/libflightrecorder/opt.c 2008-09-11 19:53:30 UTC (rev
7694)
+++ flightrecorder/src/libflightrecorder/opt.c 2008-09-11 20:45:10 UTC (rev
7695)
@@ -1,4 +1,4 @@
-/*
+/*
libflightrecorder - Client library for flightrecorder, a recorder for
runtime information gathered by AOP advices or other process internal
checks
@@ -24,11 +24,11 @@
#include "flightrecorder.h"
#include "private.h"
-int fr_srv_opt_set(FR_Session *ses, const FR_Option opt, const void *val,
const unsigned int len)
+int fr_srv_opt_set(struct FR_Session *ses, const FR_Option opt, const void
*val, const unsigned int len)
{
- FR_Option_Entry *option;
+ struct FR_Option_Entry *option;
unsigned int idx, found;
-
+
found = 0;
option = ses->options;
for (idx = 0; idx <= ses->option_count; idx++)
@@ -43,71 +43,71 @@
if (!found)
{
if (ses->option_count == 0)
- ses->options = (FR_Option_Entry *)
fr_malloc(sizeof(FR_Option_Entry));
+ ses->options = (struct FR_Option_Entry *)
fr_malloc(sizeof(struct FR_Option_Entry));
else
- ses->options = (FR_Option_Entry *)
fr_realloc(ses->options, (ses->option_count + 1) * sizeof(FR_Option_Entry));
+ ses->options = (struct FR_Option_Entry *)
fr_realloc(ses->options, (ses->option_count + 1) * sizeof(struct
FR_Option_Entry));
}
-
+
if (!ses->options)
return 0;
-
+
option = ses->options + ses->option_count;
-
+
option->opt = opt;
option->val = fr_malloc(len);
memcpy(option->val, val, len);
ses->option_count++;
-
+
return 1;
}
-int fr_srv_opt_set_int(FR_Session *ses, const FR_Option opt, const unsigned
int val)
+int fr_srv_opt_set_int(struct FR_Session *ses, const FR_Option opt, const
unsigned int val)
{
return fr_srv_opt_set(ses, opt, &val, sizeof(val));
}
-int fr_srv_opt_set_str(FR_Session *ses, const FR_Option opt, const char *val)
+int fr_srv_opt_set_str(struct FR_Session *ses, const FR_Option opt, const char
*val)
{
return fr_srv_opt_set(ses, opt, val, strlen(val));
}
-const void *fr_srv_opt_get(FR_Session *ses, const FR_Option opt)
+const void *fr_srv_opt_get(struct FR_Session *ses, const FR_Option opt)
{
- FR_Option_Entry *option;
+ struct FR_Option_Entry *option;
unsigned int idx;
-
+
option = ses->options;
for (idx = 0; idx <= ses->option_count; idx++)
{
if (opt == option->opt)
return option->val;
}
-
+
return NULL;
}
-const char *fr_srv_opt_get_str(FR_Session *ses, const FR_Option opt)
+const char *fr_srv_opt_get_str(struct FR_Session *ses, const FR_Option opt)
{
return (const char *) fr_srv_opt_get(ses, opt);
}
-unsigned int fr_srv_opt_get_int(FR_Session *ses, const FR_Option opt)
+unsigned int fr_srv_opt_get_int(struct FR_Session *ses, const FR_Option opt)
{
return *((unsigned int *) fr_srv_opt_get(ses, opt));
}
-void fr_srv_opt_cleanup(FR_Session *ses)
+void fr_srv_opt_cleanup(struct FR_Session *ses)
{
- FR_Option_Entry *opt;
+ struct FR_Option_Entry *opt;
unsigned int idx;
-
+
opt = ses->options;
for (idx = 0; idx <= ses->option_count; idx++)
{
fr_free(opt->val);
opt++;
}
-
+
fr_free(ses->options);
ses->options = NULL;
}
Modified: flightrecorder/src/libflightrecorder/private.h
===================================================================
--- flightrecorder/src/libflightrecorder/private.h 2008-09-11 19:53:30 UTC
(rev 7694)
+++ flightrecorder/src/libflightrecorder/private.h 2008-09-11 20:45:10 UTC
(rev 7695)
@@ -1,4 +1,4 @@
-/*
+/*
libflightrecorder - Client library for flightrecorder, a recorder for
runtime information gathered by AOP advices or other process internal
checks
@@ -26,11 +26,33 @@
#include "config.h"
#ifdef WINDOWS
- #include <windows.h>
+ #include <windows.h>
#elif HAVE_PTHREADS
#include <pthread.h>
#else
#error Port threads.h/private.h
#endif
+struct StackTrace
+{
+ struct StackTraceEntry *entries;
+ unsigned int depth;
+ unsigned int tid;
+};
+
+struct FR_Option_Entry
+{
+ unsigned int opt;
+ void *val;
+};
+
+struct FR_Session
+{
+ struct FR_Option_Entry *options;
+ unsigned long option_count;
+ struct StackTrace *traces;
+ unsigned int trace_count;
+};
+
+
#endif /*PRIVATE_H_*/
Modified: flightrecorder/src/libflightrecorder/session.c
===================================================================
--- flightrecorder/src/libflightrecorder/session.c 2008-09-11 19:53:30 UTC
(rev 7694)
+++ flightrecorder/src/libflightrecorder/session.c 2008-09-11 20:45:10 UTC
(rev 7695)
@@ -1,4 +1,4 @@
-/*
+/*
libflightrecorder - Client library for flightrecorder, a recorder for
runtime information gathered by AOP advices or other process internal
checks
@@ -21,25 +21,26 @@
*/
#include "flightrecorder.h"
+#include "private.h"
-static FR_Session local_session;
+static struct FR_Session local_session;
-FR_Session *fr_session_create()
+struct FR_Session *fr_session_create()
{
- FR_Session *ret;
-
- ret = (FR_Session *) fr_malloc(sizeof(FR_Session));
- memset(ret, 0, sizeof(FR_Session));
-
+ struct FR_Session *ret;
+
+ ret = (struct FR_Session *) fr_malloc(sizeof(struct FR_Session));
+ memset(ret, 0, sizeof(struct FR_Session));
+
return ret;
}
-void fr_session_destroy(FR_Session *ses)
+void fr_session_destroy(struct FR_Session *ses)
{
fr_free(ses);
}
-FR_Session *fr_session_get_local()
+struct FR_Session *fr_session_get_local()
{
return &local_session;
}
Modified: flightrecorder/src/libflightrecorder/stack_trace.c
===================================================================
--- flightrecorder/src/libflightrecorder/stack_trace.c 2008-09-11 19:53:30 UTC
(rev 7694)
+++ flightrecorder/src/libflightrecorder/stack_trace.c 2008-09-11 20:45:10 UTC
(rev 7695)
@@ -24,14 +24,14 @@
#include "flightrecorder.h"
#include "private.h"
-static StackTrace *get_trace(FR_Session *ses, unsigned int tid)
+static struct StackTrace *get_trace(struct FR_Session *ses, unsigned int tid)
{
- StackTrace *trace;
+ struct StackTrace *trace;
unsigned idx;
if (!ses->trace_count)
{
- ses->traces = (StackTrace *) fr_malloc(sizeof(StackTrace));
+ ses->traces = (struct StackTrace *) fr_malloc(sizeof(struct StackTrace));
ses->trace_count++;
return ses->traces;
@@ -46,7 +46,7 @@
trace++;
}
- ses->traces = (StackTrace *) fr_realloc(ses->traces, ++ses->trace_count *
sizeof(StackTrace));
+ ses->traces = (struct StackTrace *) fr_realloc(ses->traces,
++ses->trace_count * sizeof(struct StackTrace));
if (!ses->traces)
return NULL;
@@ -66,19 +66,19 @@
* @param function name of the function that is called
* @return 1 on success, 0 otherwise
*/
-int fr_srv_st_enter(FR_Session *ses, char *file, unsigned int line, char
*function)
+int fr_srv_st_enter(struct FR_Session *ses, char *file, unsigned int line,
char *function)
{
- StackTrace *trace;
- StackTraceEntry *entry;
+ struct StackTrace *trace;
+ struct StackTraceEntry *entry;
trace = get_trace(ses, fr_thread_get_tid());
if (!trace)
return 0;
if (trace->depth == 0)
- trace->entries = (StackTraceEntry *) fr_malloc(sizeof(StackTraceEntry));
+ trace->entries = (struct StackTraceEntry *) fr_malloc(sizeof(struct
StackTraceEntry));
else
- trace->entries = (StackTraceEntry *) fr_realloc(trace->entries,
(trace->depth + 1) * sizeof(StackTraceEntry));
+ trace->entries = (struct StackTraceEntry *) fr_realloc(trace->entries,
(trace->depth + 1) * sizeof(struct StackTraceEntry));
if (!trace->entries)
return 0;
@@ -101,9 +101,9 @@
* @param function name of the function that is called
* @return 1 on success, 0 otherwise
*/
-int fr_srv_st_leave(FR_Session *ses, char *file, unsigned int line, char
*function)
+int fr_srv_st_leave(struct FR_Session *ses, char *file, unsigned int line,
char *function)
{
- StackTrace *trace;
+ struct StackTrace *trace;
trace = get_trace(ses, fr_thread_get_tid());
if (!trace || trace->depth == 0)
@@ -111,14 +111,14 @@
if (trace->depth)
{
- StackTraceEntry *entry;
+ struct StackTraceEntry *entry;
unsigned int idx;
entry = trace->entries + trace->depth - 1;
for(idx = 0; idx < entry->info_count; idx++)
fr_free(entry->info[idx]);
- trace->entries = (StackTraceEntry *) fr_realloc(trace->entries,
--trace->depth * sizeof(StackTraceEntry));
+ trace->entries = (struct StackTraceEntry *) fr_realloc(trace->entries,
--trace->depth * sizeof(struct StackTraceEntry));
if (!trace->entries)
return 0;
}
@@ -137,10 +137,10 @@
* @param info diagnostics information/log/...
* @return 1 on success, 0 on error
*/
-int fr_srv_st_add_info(FR_Session *ses, char *info)
+int fr_srv_st_add_info(struct FR_Session *ses, char *info)
{
- StackTrace *trace;
- StackTraceEntry *entry;
+ struct StackTrace *trace;
+ struct StackTraceEntry *entry;
trace = get_trace(ses, fr_thread_get_tid());
if (!trace || !trace->depth)
@@ -166,7 +166,7 @@
* @param tid thread ID
* @return pointer stack trace, NULL on error
*/
-StackTrace *fr_srv_st_get(FR_Session *ses, unsigned int tid)
+struct StackTrace *fr_srv_st_get(struct FR_Session *ses, unsigned int tid)
{
return get_trace(ses, tid);
}
@@ -176,7 +176,7 @@
* @param ses C/S session
* @return array of thread IDs, NULL on error
*/
-unsigned int *fr_srv_st_threads(FR_Session *ses)
+unsigned int *fr_srv_st_threads(struct FR_Session *ses)
{
unsigned int idx;
unsigned int *ret;
@@ -196,9 +196,9 @@
* @param trace stack trace
* @param iter callback function
*/
-void fr_st_iterate(StackTrace *trace, StackTraceIterator iter)
+void fr_st_iterate(struct StackTrace *trace, StackTraceIterator iter)
{
- StackTraceEntry *entry;
+ struct StackTraceEntry *entry;
unsigned idx;
entry = trace->entries;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7695 - in flightrecorder/src: include libflightrecorder,
gnunet <=