[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5812 - in flightrecorder: . src/flightrecorderd src/includ
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5812 - in flightrecorder: . src/flightrecorderd src/include src/libflightrecorder |
Date: |
Thu, 6 Dec 2007 13:19:56 -0700 (MST) |
Author: durner
Date: 2007-12-06 13:19:55 -0700 (Thu, 06 Dec 2007)
New Revision: 5812
Modified:
flightrecorder/configure.in
flightrecorder/src/flightrecorderd/Makefile.am
flightrecorder/src/flightrecorderd/flightrecorder.c
flightrecorder/src/include/flightrecorder.h
flightrecorder/src/libflightrecorder/private.h
flightrecorder/src/libflightrecorder/stack_trace.c
flightrecorder/src/libflightrecorder/threads.c
flightrecorder/src/libflightrecorder/xmalloc.c
Log:
fixes
Modified: flightrecorder/configure.in
===================================================================
--- flightrecorder/configure.in 2007-12-06 05:59:42 UTC (rev 5811)
+++ flightrecorder/configure.in 2007-12-06 20:19:55 UTC (rev 5812)
@@ -14,6 +14,23 @@
AC_CANONICAL_HOST
+# Check system type
+case "$host_os" in
+*cygwin*)
+ AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
+ AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
+ AC_DEFINE_UNQUOTED(_WIN32,1,[This is a Windows system])
+ LDFLAGS="$LDFLAGS -Wl,-no-undefined"
+ ;;
+*mingw*)
+ AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
+ AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
+ AC_DEFINE_UNQUOTED(_WIN32,1,[This is a Windows system])
+ LDFLAGS="$LDFLAGS -Wl,-no-undefined -Wl,--export-all-symbols -lkernel32
-lws2_32 -lplibc"
+ AC_PROG_CXX
+ ;;
+esac
+
dnl Checks for programs.
AC_PROG_INSTALL
AC_PROG_CC
@@ -22,7 +39,7 @@
dnl Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS(unistd.h sys/param.h sys/time.h time.h sys/mkdev.h
sys/sysmacros.h string.h memory.h fcntl.h dirent.h sys/ndir.h ndir.h alloca.h
locale.h )
+AC_CHECK_HEADERS(unistd.h sys/param.h sys/time.h time.h sys/mkdev.h
sys/sysmacros.h string.h memory.h fcntl.h dirent.h sys/ndir.h ndir.h alloca.h
locale.h error.h)
jm_CHECK_TYPE_STRUCT_UTIMBUF
Modified: flightrecorder/src/flightrecorderd/Makefile.am
===================================================================
--- flightrecorder/src/flightrecorderd/Makefile.am 2007-12-06 05:59:42 UTC
(rev 5811)
+++ flightrecorder/src/flightrecorderd/Makefile.am 2007-12-06 20:19:55 UTC
(rev 5812)
@@ -1,5 +1,6 @@
bin_PROGRAMS=flightrecorderd
flightrecorderd_SOURCES=flightrecorder.c getopt.c getopt1.c getopt.h
+INCLUDES = -I$(top_srcdir)/src/include
# if you write a self-test script named `chk', uncomment the
# following and add `chk' to the EXTRA_DIST list
Modified: flightrecorder/src/flightrecorderd/flightrecorder.c
===================================================================
--- flightrecorder/src/flightrecorderd/flightrecorder.c 2007-12-06 05:59:42 UTC
(rev 5811)
+++ flightrecorder/src/flightrecorderd/flightrecorder.c 2007-12-06 20:19:55 UTC
(rev 5812)
@@ -1,108 +1,109 @@
-/*
- flightrecorder - A recorder for runtime information gathered by AOP advices
- or other process internal checks
-
- Copyright (C) 2007 Nils Durner
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <getopt.h>
-#include "system.h"
-
-#define EXIT_FAILURE 1
-
-static void usage (int status);
-
-/* The name the program was run with, stripped of any leading path. */
-char *program_name;
-
-/* getopt_long return codes */
-enum {DUMMY_CODE=129
-};
-
-/* Option flags and variables */
-
-
-static struct option const long_options[] =
-{
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'V'},
- {NULL, 0, NULL, 0}
-};
-
-static int decode_switches (int argc, char **argv);
-
-int
-main (int argc, char **argv)
-{
- int i;
-
- program_name = argv[0];
-
- i = decode_switches (argc, argv);
-
- /* do the work */
-
- exit (0);
-}
-
-/* Set all the option flags according to the switches specified.
- Return the index of the first non-option argument. */
-
-static int
-decode_switches (int argc, char **argv)
-{
- int c;
-
-
- while ((c = getopt_long (argc, argv,
- "h" /* help */
- "V", /* version */
- long_options, (int *) 0)) != EOF)
- {
- switch (c)
- {
- case 'V':
- printf ("flightrecorder %s\n", VERSION);
- exit (0);
-
- case 'h':
- usage (0);
-
- default:
- usage (EXIT_FAILURE);
- }
- }
-
- return optind;
-}
-
-
-static void
-usage (int status)
-{
- printf (_("%s - \
-A recorder for runtime information gathered by AOP advices or other process
internal checks\n"), program_name);
- printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
- printf (_("\
-Options:\n\
- -h, --help display this help and exit\n\
- -V, --version output version information and exit\n\
-"));
- exit (status);
-}
+/*
+ flightrecorder - A recorder for runtime information gathered by AOP advices
+ or other process internal checks
+
+ Copyright (C) 2007 Nils Durner
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <getopt.h>
+#include "system.h"
+#include "config.h"
+
+#define EXIT_FAILURE 1
+
+static void usage (int status);
+
+/* The name the program was run with, stripped of any leading path. */
+char *program_name;
+
+/* getopt_long return codes */
+enum {DUMMY_CODE=129
+};
+
+/* Option flags and variables */
+
+
+static struct option const long_options[] =
+{
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'V'},
+ {NULL, 0, NULL, 0}
+};
+
+static int decode_switches (int argc, char **argv);
+
+int
+main (int argc, char **argv)
+{
+ int i;
+
+ program_name = argv[0];
+
+ i = decode_switches (argc, argv);
+
+ /* do the work */
+
+ exit (0);
+}
+
+/* Set all the option flags according to the switches specified.
+ Return the index of the first non-option argument. */
+
+static int
+decode_switches (int argc, char **argv)
+{
+ int c;
+
+
+ while ((c = getopt_long (argc, argv,
+ "h" /* help */
+ "V", /* version */
+ long_options, (int *) 0)) != EOF)
+ {
+ switch (c)
+ {
+ case 'V':
+ printf ("flightrecorder %s\n", VERSION);
+ exit (0);
+
+ case 'h':
+ usage (0);
+
+ default:
+ usage (EXIT_FAILURE);
+ }
+ }
+
+ return optind;
+}
+
+
+static void
+usage (int status)
+{
+ printf (_("%s - \
+A recorder for runtime information gathered by AOP advices or other process
internal checks\n"), program_name);
+ printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
+ printf (_("\
+Options:\n\
+ -h, --help display this help and exit\n\
+ -V, --version output version information and exit\n\
+"));
+ exit (status);
+}
Modified: flightrecorder/src/include/flightrecorder.h
===================================================================
--- flightrecorder/src/include/flightrecorder.h 2007-12-06 05:59:42 UTC (rev
5811)
+++ flightrecorder/src/include/flightrecorder.h 2007-12-06 20:19:55 UTC (rev
5812)
@@ -45,6 +45,7 @@
void *fr_calloc (size_t n, size_t s);
void *fr_realloc (void *p, size_t n);
char *fr_strdup (char *p);
+void fr_free(void *p);
#endif /*FLIGHTRECORDER_H_*/
Modified: flightrecorder/src/libflightrecorder/private.h
===================================================================
--- flightrecorder/src/libflightrecorder/private.h 2007-12-06 05:59:42 UTC
(rev 5811)
+++ flightrecorder/src/libflightrecorder/private.h 2007-12-06 20:19:55 UTC
(rev 5812)
@@ -1,40 +1,36 @@
-/*
- libflightrecorder - Client library for flightrecorder, a recorder for
- runtime information gathered by AOP advices or other process internal
- checks
-
- Copyright (C) 2007 Nils Durner
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
-*/
-
-#ifndef PRIVATE_H_
-#define PRIVATE_H_
-
-#include "config.h"
-
-#ifdef WINDOWS
- #include <windows.h>
-
- #define THREAD_TYPE DWORD
-#elif HAVE_PTHREADS
- #include <pthread.h>
-
- #define THREAD_TYPE pthread_t
-#else
- #error Port threads.h/private.h
-#endif
-
-#endif /*PRIVATE_H_*/
+/*
+ libflightrecorder - Client library for flightrecorder, a recorder for
+ runtime information gathered by AOP advices or other process internal
+ checks
+
+ Copyright (C) 2007 Nils Durner
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#ifndef PRIVATE_H_
+#define PRIVATE_H_
+
+#include "config.h"
+
+#ifdef WINDOWS
+ #include <windows.h>
+#elif HAVE_PTHREADS
+ #include <pthread.h>
+#else
+ #error Port threads.h/private.h
+#endif
+
+#endif /*PRIVATE_H_*/
Modified: flightrecorder/src/libflightrecorder/stack_trace.c
===================================================================
--- flightrecorder/src/libflightrecorder/stack_trace.c 2007-12-06 05:59:42 UTC
(rev 5811)
+++ flightrecorder/src/libflightrecorder/stack_trace.c 2007-12-06 20:19:55 UTC
(rev 5812)
@@ -1,201 +1,190 @@
-/*
- libflightrecorder - Client library for flightrecorder, a recorder for
- runtime information gathered by AOP advices or other process internal
- checks
-
- Copyright (C) 2007 Nils Durner
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
-*/
-
-#include <stddef.h>
-#include "flightrecorder.h"
-#include "private.h"
-
-static StackTrace *traces = NULL;
-static unsigned int threads = 0;
-
-static StackTrace *get_trace(THREAD_TYPE tid)
-{
- StackTrace *trace;
- unsigned idx;
-
- if (!threads)
- {
- traces = (StackTrace *) fr_malloc(sizeof(StackTrace));
- threads++;
-
- return traces;
- }
-
- trace = traces;
- for (idx = 0; idx < threads; idx++)
- {
- if (fr_thread_cmp(trace->tid, tid))
- return trace;
- else
- trace++;
- }
-
- traces = (StackTrace *) fr_realloc(traces, ++threads * sizeof(StackTrace));
-
- if (!traces)
- return NULL;
-
- trace = traces + threads - 1;
- trace->tid = tid;
- trace->depth = 0;
- trace->entries = NULL
- return trace;
-}
-
-static THREAD_TYPE get_tid()
-{
-#if WINDOWS
- return GetThreadID();
-#elif HAVE_PTHREADS
- return pthread_self(); // FIXME
-#else
- #error Port get_tid()
-#endif
-}
-
-/**
- * @brief Add function to the stack trace
- * @param file source file from which the function is called
- * @param line source line from which the function is called
- * @param function name of the function that is called
- * @return 1 on success, 0 otherwise
- */
-int fr_st_enter(char *file, unsigned int line, char *function)
-{
- StrackTrace *trace;
- StackTraceEntry *entry;
-
- trace = get_trace(get_tid());
- if (!trace)
- return 0;
-
- if (trace->depth == 0)
- trace->entries = (StackTraceEntry *) fr_malloc(sizeof(StackTraceEntry));
- else
- trace->entries = (StackTraceEntry *) fr_realloc(trace->entries,
(trace->depth + 1) * sizeof(StrackTraceEntry));
- if (!trace->entries)
- return 0;
-
- trace->depth++;
- entry = trace->entries[trace->depth-1];
- entry->file = file;
- entry->line = line;
- entry->function = function;
- entry->info = NULL;
- entry->info_count = 0;
-
- return 1;
-}
-
-/**
- * @brief Remove function from the stack trace
- * @param file source file from which the function is called
- * @param line source line from which the function is called
- * @param function name of the function that is called
- * @return 1 on success, 0 otherwise
- */
-int fr_st_leave(char *file, unsigned int line, char *function)
-{
- StrackTrace *trace;
-
- trace = get_trace(get_tid());
- if (!trace || trace->depth == 0)
- return 0;
-
- if (trace->depth)
- {
- 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));
- if (!trace->entries)
- return 0;
- }
- else
- {
- fr_free(trace->entries);
- trace->entries = NULL;
- }
-
- return 1;
-}
-
-/**
- * @brief Add a info to the last stack trace entry
- * @param info diagnostics information/log/...
- * @return 1 on success, 0 on error
- */
-int fr_st_add_info(char *info)
-{
- StrackTrace *trace;
- StackTraceEntry *entry;
-
- trace = get_trace(get_tid());
- if (!trace || !trace->depth)
- return 0;
-
- entry = trace->entries + trace->depth - 1;
- if (entry->info_count)
- entry->info = (char **) fr_realloc(entry->info, (entry->info_count + 1) *
sizeof(char *));
- else
- entry->info = (char **) fr_malloc(sizeof(char *));
-
- if (!entry->info)
- return 0;
-
- entry->info[entry->info_count - 1] = strdup(info);
-
- return 1;
-}
-
-/**
- * @brief Return the stack trace for a particular thread
- * @param tid thread ID
- * @return pointer stack trace, NULL on error
- */
-StackTrace *fr_st_get(unsigned int tid)
-{
- return get_trace(tid);
-}
-
-/**
- * @brief Return a list of thread IDs
- * @return array of thread IDs, NULL on error
- */
-unsigned int *fr_st_threads()
-{
- unsigned int idx;
- unsigned int *ret;
-
- ret = fr_malloc(threads * sizeof(unsigned int));
- if (!ret)
- return NULL;
-
- for (idx = 0; idx < threads; idx++)
- ret[idx] = traces[idx]->tid;
-
- return ret;
-}
+/*
+ libflightrecorder - Client library for flightrecorder, a recorder for
+ runtime information gathered by AOP advices or other process internal
+ checks
+
+ Copyright (C) 2007 Nils Durner
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#include <stddef.h>
+#include "flightrecorder.h"
+#include "private.h"
+
+static StackTrace *traces = NULL;
+static unsigned int threads = 0;
+
+static StackTrace *get_trace(unsigned int tid)
+{
+ StackTrace *trace;
+ unsigned idx;
+
+ if (!threads)
+ {
+ traces = (StackTrace *) fr_malloc(sizeof(StackTrace));
+ threads++;
+
+ return traces;
+ }
+
+ trace = traces;
+ for (idx = 0; idx < threads; idx++)
+ {
+ if (fr_thread_cmp(trace->tid, tid))
+ return trace;
+ else
+ trace++;
+ }
+
+ traces = (StackTrace *) fr_realloc(traces, ++threads * sizeof(StackTrace));
+
+ if (!traces)
+ return NULL;
+
+ trace = traces + threads - 1;
+ trace->tid = tid;
+ trace->depth = 0;
+ trace->entries = NULL;
+ return trace;
+}
+
+/**
+ * @brief Add function to the stack trace
+ * @param file source file from which the function is called
+ * @param line source line from which the function is called
+ * @param function name of the function that is called
+ * @return 1 on success, 0 otherwise
+ */
+int fr_st_enter(char *file, unsigned int line, char *function)
+{
+ StackTrace *trace;
+ StackTraceEntry *entry;
+
+ trace = get_trace(fr_thread_get_tid());
+ if (!trace)
+ return 0;
+
+ if (trace->depth == 0)
+ trace->entries = (StackTraceEntry *) fr_malloc(sizeof(StackTraceEntry));
+ else
+ trace->entries = (StackTraceEntry *) fr_realloc(trace->entries,
(trace->depth + 1) * sizeof(StackTraceEntry));
+ if (!trace->entries)
+ return 0;
+
+ trace->depth++;
+ entry = trace->entries + trace->depth - 1;
+ entry->file = file;
+ entry->line = line;
+ entry->function = function;
+ entry->info = NULL;
+ entry->info_count = 0;
+
+ return 1;
+}
+
+/**
+ * @brief Remove function from the stack trace
+ * @param file source file from which the function is called
+ * @param line source line from which the function is called
+ * @param function name of the function that is called
+ * @return 1 on success, 0 otherwise
+ */
+int fr_st_leave(char *file, unsigned int line, char *function)
+{
+ StackTrace *trace;
+
+ trace = get_trace(fr_thread_get_tid());
+ if (!trace || trace->depth == 0)
+ return 0;
+
+ if (trace->depth)
+ {
+ 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));
+ if (!trace->entries)
+ return 0;
+ }
+ else
+ {
+ fr_free(trace->entries);
+ trace->entries = NULL;
+ }
+
+ return 1;
+}
+
+/**
+ * @brief Add a info to the last stack trace entry
+ * @param info diagnostics information/log/...
+ * @return 1 on success, 0 on error
+ */
+int fr_st_add_info(char *info)
+{
+ StackTrace *trace;
+ StackTraceEntry *entry;
+
+ trace = get_trace(fr_thread_get_tid());
+ if (!trace || !trace->depth)
+ return 0;
+
+ entry = trace->entries + trace->depth - 1;
+ if (entry->info_count)
+ entry->info = (char **) fr_realloc(entry->info, (entry->info_count + 1) *
sizeof(char *));
+ else
+ entry->info = (char **) fr_malloc(sizeof(char *));
+
+ if (!entry->info)
+ return 0;
+
+ entry->info[entry->info_count - 1] = strdup(info);
+
+ return 1;
+}
+
+/**
+ * @brief Return the stack trace for a particular thread
+ * @param tid thread ID
+ * @return pointer stack trace, NULL on error
+ */
+StackTrace *fr_st_get(unsigned int tid)
+{
+ return get_trace(tid);
+}
+
+/**
+ * @brief Return a list of thread IDs
+ * @return array of thread IDs, NULL on error
+ */
+unsigned int *fr_st_threads()
+{
+ unsigned int idx;
+ unsigned int *ret;
+
+ ret = fr_malloc(threads * sizeof(unsigned int));
+ if (!ret)
+ return NULL;
+
+ for (idx = 0; idx < threads; idx++)
+ ret[idx] = traces[idx].tid;
+
+ return ret;
+}
Modified: flightrecorder/src/libflightrecorder/threads.c
===================================================================
--- flightrecorder/src/libflightrecorder/threads.c 2007-12-06 05:59:42 UTC
(rev 5811)
+++ flightrecorder/src/libflightrecorder/threads.c 2007-12-06 20:19:55 UTC
(rev 5812)
@@ -1,60 +1,57 @@
-/*
- libflightrecorder - Client library for flightrecorder, a recorder for
- runtime information gathered by AOP advices or other process internal
- checks
-
- Copyright (C) 2007 Nils Durner
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
-*/
-
-#ifdef WINDOWS
- #include <windows.h>
-#elif HAVE_PTHREADS
- #include <pthread.h>
-#else
- #error Port threads.h
-#endif
-
-/**
- * @brief Get the current thread's ID
- * @return thread ID
- */
-THREAD_TYPE fr_thread_get_tid()
-{
-#if WINDOWS
- return GetThreadId();
-#elif HAVE_PTHREADS
- return pthread_self();
-#else
- #error Port fr_util_get_tid()
-#endif
-}
-
-/**
- * @brief Compare two thread IDs
- * @param t1 first thread ID
- * @param t2 second thread ID
- * @return 1 on success, 0 otherwise
- */
-int fr_thread_cmp(THREAD_TYPE t1, THREAD_TYPE t2)
-{
-#if WINDOWS
- return t1 == t2;
-#else
- // FIXME
- return 1;
-#endif
-}
+/*
+ libflightrecorder - Client library for flightrecorder, a recorder for
+ runtime information gathered by AOP advices or other process internal
+ checks
+
+ Copyright (C) 2007 Nils Durner
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#include "private.h"
+
+#ifdef WINDOWS
+ #include <windows.h>
+#elif HAVE_PTHREADS
+ #include <pthread.h>
+#else
+ #error Port threads.h
+#endif
+
+/**
+ * @brief Get the current thread's ID
+ * @return thread ID
+ */
+unsigned int fr_thread_get_tid()
+{
+#if WINDOWS
+ return (unsigned int) GetCurrentThreadId();
+#elif HAVE_PTHREADS
+ return (unsigned int) pthread_self();
+#else
+ #error Port fr_util_get_tid()
+#endif
+}
+
+/**
+ * @brief Compare two thread IDs
+ * @param t1 first thread ID
+ * @param t2 second thread ID
+ * @return 1 on success, 0 otherwise
+ */
+int fr_thread_cmp(unsigned int t1, unsigned int t2)
+{
+ return t1 == t2;
+}
Modified: flightrecorder/src/libflightrecorder/xmalloc.c
===================================================================
--- flightrecorder/src/libflightrecorder/xmalloc.c 2007-12-06 05:59:42 UTC
(rev 5811)
+++ flightrecorder/src/libflightrecorder/xmalloc.c 2007-12-06 20:19:55 UTC
(rev 5812)
@@ -1,135 +1,146 @@
-/* xmalloc.c -- malloc with out of memory checking
- Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 99 Free Software Foundation,
Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h> /* for stderr */
-
-#if STDC_HEADERS
-
-#include <sys/types.h>
-#include <string.h> /* for strlen etc. */
-#include <stdlib.h>
-
-#else /* !STDC_HEADERS */
-
-extern size_t strlen ();
-extern char *strcpy ();
-
-void *calloc ();
-void *malloc ();
-void *realloc ();
-void free ();
-#endif
-
-#if ENABLE_NLS
-# include <libintl.h>
-# define _(Text) gettext (Text)
-#else
-# define textdomain(Domain)
-# define _(Text) Text
-#endif
-
-#include <error.h>
-
-/* Prototypes for functions defined here. */
-#if defined (__STDC__) && __STDC__
-static void *fixup_null_alloc (size_t n);
-void *fr_malloc (size_t n);
-void *fr_calloc (size_t n, size_t s);
-void *fr_realloc (void *p, size_t n);
-char *fr_strdup (char *p);
-#endif
-
-
-static void *
-fixup_null_alloc (n)
- size_t n;
-{
- void *p;
-
- p = 0;
- if (n == 0)
- p = malloc ((size_t) 1);
- if (p == 0)
- {
- /* possible revisions: release some memory and re-try, print
- more information (e.g. line number of input file) */
- fprintf(stderr, _("flightrecorder: Memory exhausted"));
- }
- return p;
-}
-
-/* Allocate N bytes of memory dynamically, with error checking. */
-
-void *
-fr_malloc (n)
- size_t n;
-{
- void *p;
-
- p = malloc (n);
- if (p == 0)
- p = fixup_null_alloc (n);
- return p;
-}
-
-/* Allocate memory for N elements of S bytes, with error checking. */
-
-void *
-fr_calloc (n, s)
- size_t n, s;
-{
- void *p;
-
- p = calloc (n, s);
- if (p == 0)
- p = fixup_null_alloc (n);
- return p;
-}
-
-/* Change the size of an allocated block of memory P to N bytes,
- with error checking.
- If P is NULL, run xmalloc. */
-
-void *
-fr_realloc (p, n)
- void *p;
- size_t n;
-{
- if (p == 0)
- return xmalloc (n);
- p = realloc (p, n);
- if (p == 0)
- p = fixup_null_alloc (n);
- return p;
-}
-
-/* Make a copy of a string in a newly allocated block of memory. */
-
-char *
-fr_strdup (str)
- char *str;
-{
- void *p;
-
- p = xmalloc (strlen (str) + 1);
- strcpy (p, str);
- return p;
-}
+/* xmalloc.c -- malloc with out of memory checking
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 99 Free Software Foundation,
Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h> /* for stderr */
+
+#if STDC_HEADERS
+
+#include <sys/types.h>
+#include <string.h> /* for strlen etc. */
+#include <stdlib.h>
+
+#else /* !STDC_HEADERS */
+
+extern size_t strlen ();
+extern char *strcpy ();
+
+void *calloc ();
+void *malloc ();
+void *realloc ();
+void free ();
+#endif
+
+#if ENABLE_NLS
+# include <libintl.h>
+# define _(Text) gettext (Text)
+#else
+# define textdomain(Domain)
+# define _(Text) Text
+#endif
+
+#if HAVE_ERROR_H
+#include <error.h>
+#endif
+
+/* Prototypes for functions defined here. */
+#if defined (__STDC__) && __STDC__
+static void *fixup_null_alloc (size_t n);
+void *fr_malloc (size_t n);
+void *fr_calloc (size_t n, size_t s);
+void *fr_realloc (void *p, size_t n);
+char *fr_strdup (char *p);
+void fr_free(void *p);
+#endif
+
+
+static void *
+fixup_null_alloc (n)
+ size_t n;
+{
+ void *p;
+
+ p = 0;
+ if (n == 0)
+ p = malloc ((size_t) 1);
+ if (p == 0)
+ {
+ /* possible revisions: release some memory and re-try, print
+ more information (e.g. line number of input file) */
+ fprintf(stderr, _("flightrecorder: Memory exhausted"));
+ }
+ return p;
+}
+
+/* Allocate N bytes of memory dynamically, with error checking. */
+
+void *
+fr_malloc (n)
+ size_t n;
+{
+ void *p;
+
+ p = malloc (n);
+ if (p == 0)
+ p = fixup_null_alloc (n);
+ return p;
+}
+
+/* Allocate memory for N elements of S bytes, with error checking. */
+
+void *
+fr_calloc (n, s)
+ size_t n, s;
+{
+ void *p;
+
+ p = calloc (n, s);
+ if (p == 0)
+ p = fixup_null_alloc (n);
+ return p;
+}
+
+/* Change the size of an allocated block of memory P to N bytes,
+ with error checking.
+ If P is NULL, run xmalloc. */
+
+void *
+fr_realloc (p, n)
+ void *p;
+ size_t n;
+{
+ if (p == 0)
+ return fr_malloc (n);
+ p = realloc (p, n);
+ if (p == 0)
+ p = fixup_null_alloc (n);
+ return p;
+}
+
+/* Make a copy of a string in a newly allocated block of memory. */
+
+char *
+fr_strdup (str)
+ char *str;
+{
+ void *p;
+
+ p = fr_malloc (strlen (str) + 1);
+ strcpy (p, str);
+ return p;
+}
+
+void
+fr_free(p)
+ void *p;
+{
+ if (p != 0)
+ free(p);
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5812 - in flightrecorder: . src/flightrecorderd src/include src/libflightrecorder,
gnunet <=