From b66ee2ed22754dd44b20c06e573072e328d9a3dd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 16 Feb 2008 18:38:02 +0100 Subject: Move responsibilities of build.h to makefile. (This used to be commit a43f6d37bce85748e9cf2675e5beced5db26f1c3) --- source4/lib/events/events.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c index 555a5092cc..969abeae46 100644 --- a/source4/lib/events/events.c +++ b/source4/lib/events/events.c @@ -58,9 +58,6 @@ #include "lib/events/events_internal.h" #include "lib/util/dlinklist.h" #include "param/param.h" -#if _SAMBA_BUILD_ -#include "build.h" -#endif struct event_ops_list { struct event_ops_list *next, *prev; @@ -102,6 +99,9 @@ void event_set_default_backend(const char *backend) static void event_backend_init(void) { #if _SAMBA_BUILD_ + NTSTATUS s4_events_standard_init(void); + NTSTATUS s4_events_select_init(void); + NTSTATUS s4_events_epoll_init(void); init_module_fn static_init[] = { STATIC_LIBEVENTS_MODULES }; if (event_backends) return; run_init_functions(static_init); -- cgit From c5d77a1c2414d930ccbedbe05e124df69242a144 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 26 Feb 2008 17:17:52 +0100 Subject: Move public header accumulation out of the perl code. (This used to be commit 89f7c74924965071981bbe7e05ff69847b0a3a03) --- source4/lib/events/config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 910cf3738f..225a23c634 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -32,11 +32,12 @@ INIT_FUNCTION = s4_events_standard_init # Start SUBSYSTEM LIBEVENTS [SUBSYSTEM::LIBEVENTS] OBJ_FILES = events.o events_timed.o events_signal.o -PUBLIC_HEADERS = events.h events_internal.h PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL # End SUBSYSTEM LIBEVENTS ############################## +PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) + [PYTHON::swig_events] SWIG_FILE = events.i PRIVATE_DEPENDENCIES = LIBEVENTS -- cgit From b29d47edcf2767d7f9e9f63332079c6e8e89946c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Mar 2008 18:25:28 +0100 Subject: Move object file lists to the Makefile. (This used to be commit a7e6d2a1832db388fdafa1279f84c9a8bbfc87d6) --- source4/lib/events/config.mk | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 225a23c634..ba06c2f673 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -1,41 +1,45 @@ ############################## [MODULE::EVENTS_AIO] -OBJ_FILES = events_aio.o PRIVATE_DEPENDENCIES = LIBAIO_LINUX SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_aio_init ############################## +EVENTS_AIO_OBJ_FILES = lib/events/events_aio.o + ############################## [MODULE::EVENTS_EPOLL] -OBJ_FILES = events_epoll.o SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_epoll_init ############################## +EVENTS_EPOLL_OBJ_FILES = lib/events/events_epoll.o + ############################## [MODULE::EVENTS_SELECT] -OBJ_FILES = events_select.o SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_select_init ############################## +EVENTS_SELECT_OBJ_FILES = lib/events/events_select.o + ############################## [MODULE::EVENTS_STANDARD] -OBJ_FILES = events_standard.o SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_standard_init ############################## +EVENTS_STANDARD_OBJ_FILES = lib/events/events_standard.o ############################## # Start SUBSYSTEM LIBEVENTS [SUBSYSTEM::LIBEVENTS] -OBJ_FILES = events.o events_timed.o events_signal.o PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL # End SUBSYSTEM LIBEVENTS ############################## +LIBEVENTS_OBJ_FILES = $(addprefix lib/events/, events.o events_timed.o events_signal.o) + PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) [PYTHON::swig_events] -- cgit From 2d1c06c5781600a0efcf9becd3e2773dbbbf2cc7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Mar 2008 00:43:24 +0100 Subject: Fix includes. (This used to be commit 99e61dade2bd9ae2a5dfe17f766528012c09e46c) --- source4/lib/events/config.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index ba06c2f673..e5a1316c47 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -45,3 +45,5 @@ PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) [PYTHON::swig_events] SWIG_FILE = events.i PRIVATE_DEPENDENCIES = LIBEVENTS + +swig_events_OBJ_FILES = lib/events/events_wrap.o -- cgit From 4e83011f72ba3df387512755a17760b42a7bf2f2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 21 Apr 2008 17:58:23 -0400 Subject: Remove more event_context_init() uses from function calls within deep down the code. Make sure we pass around the event_context where we need it instead. All test but a few python ones fail. Jelmer promised to fix them. (This used to be commit 3045d391626fba169aa26be52174883e18d323e9) --- source4/lib/events/events.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/events') diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c index 568aadc31e..252af4443d 100644 --- a/source4/lib/events/events.c +++ b/source4/lib/events/events.c @@ -207,6 +207,8 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char */ struct event_context *event_context_init(TALLOC_CTX *mem_ctx) { + DEBUG(0, ("New event context requested. Parent: [%s:%p]\n", + mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx)); return event_context_init_byname(mem_ctx, NULL); } -- cgit From 89cac520d047581fc11c7d4a20e0508a2005c154 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 22 Apr 2008 16:37:27 -0400 Subject: Remove temporary debug statement (This used to be commit 10780e638af8afc3ffa261255200779aea732694) --- source4/lib/events/events.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c index 252af4443d..568aadc31e 100644 --- a/source4/lib/events/events.c +++ b/source4/lib/events/events.c @@ -207,8 +207,6 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char */ struct event_context *event_context_init(TALLOC_CTX *mem_ctx) { - DEBUG(0, ("New event context requested. Parent: [%s:%p]\n", - mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx)); return event_context_init_byname(mem_ctx, NULL); } -- cgit From 348109e6887865cf9d58bcd5aa8be5974abe33fd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 03:31:38 +0200 Subject: Fix dependency on loadparm. (This used to be commit 018ee187ffbfd77aa0d5f5da6c3512ea6b37a746) --- source4/lib/events/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index e5a1316c47..058ce7f793 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -44,6 +44,6 @@ PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) [PYTHON::swig_events] SWIG_FILE = events.i -PRIVATE_DEPENDENCIES = LIBEVENTS +PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG swig_events_OBJ_FILES = lib/events/events_wrap.o -- cgit From 136f369b23946698c9fcfd217444ddc0614cde85 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 24 Apr 2008 17:28:30 -0400 Subject: Make it possible to build libevents standalone. (This used to be commit 10415bb738d51afdebbfeae976923e086805ae84) --- source4/lib/events/Makefile.in | 66 ++++++++++++++++++ source4/lib/events/autogen.sh | 17 +++++ source4/lib/events/config.mk | 11 ++- source4/lib/events/configure.ac | 35 ++++++++++ source4/lib/events/events.c | 14 ++-- source4/lib/events/events.i | 2 +- source4/lib/events/events.mk | 59 ++++++++++++++++ source4/lib/events/events.pc.in | 11 +++ source4/lib/events/events_epoll.c | 15 ++-- source4/lib/events/events_select.c | 13 +++- source4/lib/events/events_signal.c | 13 ++-- source4/lib/events/events_standard.c | 11 ++- source4/lib/events/events_timed.c | 11 ++- source4/lib/events/events_util.c | 129 +++++++++++++++++++++++++++++++++++ source4/lib/events/events_util.h | 123 +++++++++++++++++++++++++++++++++ source4/lib/events/events_wrap.c | 2 +- source4/lib/events/libevents.m4 | 21 +++++- 17 files changed, 527 insertions(+), 26 deletions(-) create mode 100644 source4/lib/events/Makefile.in create mode 100755 source4/lib/events/autogen.sh create mode 100644 source4/lib/events/configure.ac create mode 100644 source4/lib/events/events.mk create mode 100644 source4/lib/events/events.pc.in create mode 100644 source4/lib/events/events_util.c create mode 100644 source4/lib/events/events_util.h (limited to 'source4/lib/events') diff --git a/source4/lib/events/Makefile.in b/source4/lib/events/Makefile.in new file mode 100644 index 0000000000..0a0df9bef9 --- /dev/null +++ b/source4/lib/events/Makefile.in @@ -0,0 +1,66 @@ +#!gmake +# +# Makefile for tdb directory +# + +CC = @CC@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +includedir = @includedir@ +libdir = @libdir@ +VPATH = @srcdir@:@tallocdir@:@libreplacedir@ +srcdir = @srcdir@ +builddir = @builddir@ +CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I. +LDFLAGS = @LDFLAGS@ +EXEEXT = @EXEEXT@ +SHLD = @SHLD@ +SHLD_FLAGS = @SHLD_FLAGS@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PICFLAG = @PICFLAG@ +SHLIBEXT = @SHLIBEXT@ +SWIG = swig +PYTHON = @PYTHON@ +PYTHON_CONFIG = @PYTHON_CONFIG@ +PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@ +PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@ +PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@ +LIB_PATH_VAR = @LIB_PATH_VAR@ +eventsdir = @eventsdir@ +tallocdir = @tallocdir@ + +TALLOC_LIBS = @TALLOC_LIBS@ +TALLOC_CFLAGS = @TALLOC_CFLAGS@ +TALLOC_OBJ = @TALLOC_OBJ@ + +CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) @CFLAGS@ + +EVENTS_OBJ = @EVENTS_OBJ@ $(TALLOC_OBJ) @LIBREPLACEOBJ@ + +default: all + +include $(eventsdir)/events.mk +include $(eventsdir)/rules.mk + +all:: showflags dirs $(PROGS) $(LIBEVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET) + +install:: all +$(LIBEVENTS_SOLIB): $(EVENTS_OBJ) + $(SHLD) $(SHLD_FLAGS) -o $@ $(EVENTS_OBJ) $(TALLOC_LIBS) @SONAMEFLAG@$(LIBEVENTS_SONAME) + +check: test + +test:: $(PYTHON_CHECK_TARGET) +installcheck:: test install + +clean:: + rm -f *.o *.a */*.o + rm -f $(TALLOC_OBJ) + +distclean:: clean + rm -f config.log config.status include/config.h config.cache + rm -f Makefile + +realdistclean:: distclean + rm -f configure include/config.h.in diff --git a/source4/lib/events/autogen.sh b/source4/lib/events/autogen.sh new file mode 100755 index 0000000000..b13a4b685d --- /dev/null +++ b/source4/lib/events/autogen.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +rm -rf autom4te.cache +rm -f configure config.h.in + +IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace" +IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc" +autoconf $IPATHS || exit 1 +autoheader $IPATHS || exit 1 + +rm -rf autom4te.cache + +swig -O -Wall -python -keyword events.i # Ignore errors for now + +echo "Now run ./configure and then make." +exit 0 + diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 058ce7f793..34c24f76f5 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -1,3 +1,13 @@ +################################################ +# Start SUBSYSTEM LIBEVENTS +[LIBRARY::LIBEVENTS] +PUBLIC_DEPENDENCIES = LIBTALLOC +OUTPUT_TYPE = STATIC_LIBRARY +CFLAGS = -Ilib/events +# +# End SUBSYSTEM LIBEVENTS +################################################ + ############################## [MODULE::EVENTS_AIO] PRIVATE_DEPENDENCIES = LIBAIO_LINUX @@ -34,7 +44,6 @@ EVENTS_STANDARD_OBJ_FILES = lib/events/events_standard.o ############################## # Start SUBSYSTEM LIBEVENTS [SUBSYSTEM::LIBEVENTS] -PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL # End SUBSYSTEM LIBEVENTS ############################## diff --git a/source4/lib/events/configure.ac b/source4/lib/events/configure.ac new file mode 100644 index 0000000000..4eb3575aac --- /dev/null +++ b/source4/lib/events/configure.ac @@ -0,0 +1,35 @@ +AC_PREREQ(2.50) +AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""]) +AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""]) +AC_DEFUN([SMB_ENABLE], [echo -n ""]) +AC_INIT(events, 1.0.0) +AC_CONFIG_SRCDIR([events.c]) +AC_CONFIG_HEADER(config.h) +AC_LIBREPLACE_ALL_CHECKS +AC_LIBREPLACE_NETWORK_CHECKS + +m4_include(libtalloc.m4) + +AC_LD_EXPORT_DYNAMIC +AC_LD_SONAMEFLAG +AC_LD_PICFLAG +AC_LD_SHLIBEXT +AC_LIBREPLACE_SHLD +AC_LIBREPLACE_SHLD_FLAGS +AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR +m4_include(libevents.m4) +AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) +AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python]) + +PYTHON_BUILD_TARGET="build-python" +PYTHON_INSTALL_TARGET="install-python" +PYTHON_CHECK_TARGET="check-python" +AC_SUBST(PYTHON_BUILD_TARGET) +AC_SUBST(PYTHON_INSTALL_TARGET) +AC_SUBST(PYTHON_CHECK_TARGET) +if test -z "$PYTHON_CONFIG"; then + PYTHON_BUILD_TARGET="" + PYTHON_INSTALL_TARGET="" + PYTHON_CHECK_TARGET="" +fi +AC_OUTPUT(Makefile events.pc) diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c index 6f45db512a..ccc62b4c83 100644 --- a/source4/lib/events/events.c +++ b/source4/lib/events/events.c @@ -52,12 +52,16 @@ forever. */ - +#if _SAMBA_BUILD_ #include "includes.h" -#include "lib/events/events.h" -#include "lib/events/events_internal.h" #include "lib/util/dlinklist.h" #include "param/param.h" +#else +#include "replace.h" +#include "events_util.h" +#endif +#include "events.h" +#include "events_internal.h" struct event_ops_list { struct event_ops_list *next, *prev; @@ -204,6 +208,8 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char */ struct event_context *event_context_init(TALLOC_CTX *mem_ctx) { + DEBUG(0, ("New event context requested. Parent: [%s:%p]\n", + mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx)); return event_context_init_byname(mem_ctx, NULL); } @@ -283,7 +289,7 @@ struct signal_event *event_add_signal(struct event_context *ev, TALLOC_CTX *mem_ /* do a single event loop using the events defined in ev */ -_PUBLIC_ int event_loop_once(struct event_context *ev) +int event_loop_once(struct event_context *ev) { return ev->ops->loop_once(ev); } diff --git a/source4/lib/events/events.i b/source4/lib/events/events.i index 263605b176..c16d482efc 100644 --- a/source4/lib/events/events.i +++ b/source4/lib/events/events.i @@ -21,7 +21,7 @@ %import "../talloc/talloc.i"; %{ -#include "lib/events/events.h" +#include "events.h" typedef struct event_context event; %} diff --git a/source4/lib/events/events.mk b/source4/lib/events/events.mk new file mode 100644 index 0000000000..64d3fcb9fd --- /dev/null +++ b/source4/lib/events/events.mk @@ -0,0 +1,59 @@ +dirs:: + @mkdir -p lib + +LIBEVENTS_SONAME = libevents.$(SHLIBEXT).0 +LIBEVENTS_SOLIB = libevents.$(SHLIBEXT).$(PACKAGE_VERSION) + +LIBEVENTS = libevents.a + +clean:: + rm -f $(LIBEVENTS_SONAME) $(LIBEVENTS_SOLIB) libevents.a libevents.$(SHLIBEXT) + rm -f events.pc + +build-python:: _libevents.$(SHLIBEXT) + +events_wrap.o: $(eventsdir)/events_wrap.c + $(CC) $(PICFLAG) -c $(eventsdir)/events_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` + +_libevents.$(SHLIBEXT): libevents.$(SHLIBEXT) events_wrap.o + $(SHLD) $(SHLD_FLAGS) -o $@ events_wrap.o -L. -levents `$(PYTHON_CONFIG) --libs` + +install:: installdirs installbin installheaders installlibs \ + $(PYTHON_INSTALL_TARGET) + +install-python:: build-python + mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \ + $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` + cp $(eventsdir)/events.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` + cp _libevents.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` + +check-python:: build-python + $(LIB_PATH_VAR)=. PYTHONPATH=".:$(eventsdir)" $(PYTHON) $(eventsdir)/python/tests/simple.py + +install-swig:: + mkdir -p $(DESTDIR)`$(SWIG) -swiglib` + cp events.i $(DESTDIR)`$(SWIG) -swiglib` + +clean:: + rm -f _libevents.$(SHLIBEXT) + +installdirs:: + mkdir -p $(DESTDIR)$(includedir) + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(libdir)/pkgconfig + +installheaders:: installdirs + cp $(srcdir)/events.h $(DESTDIR)$(includedir) + +installlibs:: all installdirs + cp events.pc $(DESTDIR)$(libdir)/pkgconfig + cp libevents.a $(LIBEVENTS_SOLIB) $(DESTDIR)$(libdir) + +libevents.a: $(EVENTS_OBJ) + ar -rv libevents.a $(EVENTS_OBJ) + +libevents.$(SHLIBEXT): $(LIBEVENTS_SOLIB) + ln -fs $< $@ + +$(LIBEVENTS_SONAME): $(LIBEVENTS_SOLIB) + ln -fs $< $@ diff --git a/source4/lib/events/events.pc.in b/source4/lib/events/events.pc.in new file mode 100644 index 0000000000..4a4c012d73 --- /dev/null +++ b/source4/lib/events/events.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: events +Description: An event system library +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -levents +Cflags: -I${includedir} +URL: http://samba.org/ diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c index 109027eb1a..07e66154fc 100644 --- a/source4/lib/events/events_epoll.c +++ b/source4/lib/events/events_epoll.c @@ -20,12 +20,17 @@ along with this program. If not, see . */ +#if _SAMBA_BUILD_ #include "includes.h" +#include "lib/util/dlinklist.h" +#else +#include "replace.h" +#include "events_util.h" +#endif #include "system/filesys.h" #include "system/network.h" -#include "lib/util/dlinklist.h" -#include "lib/events/events.h" -#include "lib/events/events_internal.h" +#include "events.h" +#include "events_internal.h" #include struct epoll_event_context { @@ -56,9 +61,11 @@ struct epoll_event_context { called when a epoll call fails, and we should fallback to using select */ -_NORETURN_ static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason) +static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason) { +#if _SAMBA_BUILD_ DEBUG(0,("%s (%s) - calling abort()\n", reason, strerror(errno))); +#endif abort(); } diff --git a/source4/lib/events/events_select.c b/source4/lib/events/events_select.c index f4b7e4e5eb..16fff71e4a 100644 --- a/source4/lib/events/events_select.c +++ b/source4/lib/events/events_select.c @@ -23,12 +23,17 @@ */ +#if _SAMBA_BUILD_ #include "includes.h" +#include "lib/util/dlinklist.h" +#else +#include "replace.h" +#include "events_util.h" +#endif #include "system/filesys.h" #include "system/select.h" -#include "lib/util/dlinklist.h" -#include "lib/events/events.h" -#include "lib/events/events_internal.h" +#include "events.h" +#include "events_internal.h" struct select_event_context { /* a pointer back to the generic event_context */ @@ -216,7 +221,9 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru made readable and that should have removed the event, so this must be a bug. This is a fatal error. */ +#if _SAMBA_BUILD_ DEBUG(0,("ERROR: EBADF on select_event_loop_once\n")); +#endif select_ev->exit_code = EBADF; return -1; } diff --git a/source4/lib/events/events_signal.c b/source4/lib/events/events_signal.c index c0771cbe01..7128612fb0 100644 --- a/source4/lib/events/events_signal.c +++ b/source4/lib/events/events_signal.c @@ -19,13 +19,18 @@ along with this program. If not, see . */ +#if _SAMBA_BUILD_ #include "includes.h" +#include "lib/util/dlinklist.h" +#else +#include +#include "replace.h" +#include "events_util.h" +#endif #include "system/filesys.h" #include "system/select.h" -#include "system/wait.h" -#include "lib/util/dlinklist.h" -#include "lib/events/events.h" -#include "lib/events/events_internal.h" +#include "events.h" +#include "events_internal.h" #define NUM_SIGNALS 64 diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c index 7b945b154d..4e41c42206 100644 --- a/source4/lib/events/events_standard.c +++ b/source4/lib/events/events_standard.c @@ -27,13 +27,18 @@ at runtime we fallback to select() */ +#if _SAMBA_BUILD_ #include "includes.h" +#include "lib/util/dlinklist.h" +#else +#include "replace.h" +#include "events_util.h" +#endif #include "system/filesys.h" #include "system/network.h" #include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */ -#include "lib/util/dlinklist.h" -#include "lib/events/events.h" -#include "lib/events/events_internal.h" +#include "events.h" +#include "events_internal.h" struct std_event_context { /* a pointer back to the generic event_context */ diff --git a/source4/lib/events/events_timed.c b/source4/lib/events/events_timed.c index 389c2cbbb7..79e4cde795 100644 --- a/source4/lib/events/events_timed.c +++ b/source4/lib/events/events_timed.c @@ -20,12 +20,17 @@ along with this program. If not, see . */ +#if _SAMBA_BUILD_ #include "includes.h" +#include "lib/util/dlinklist.h" +#else +#include "replace.h" +#include "events_util.h" +#endif #include "system/filesys.h" #include "system/select.h" -#include "lib/util/dlinklist.h" -#include "lib/events/events.h" -#include "lib/events/events_internal.h" +#include "events.h" +#include "events_internal.h" /* destroy a timed event diff --git a/source4/lib/events/events_util.c b/source4/lib/events/events_util.c new file mode 100644 index 0000000000..74e11473f3 --- /dev/null +++ b/source4/lib/events/events_util.c @@ -0,0 +1,129 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2005 + Copyright (C) Jelmer Vernooij 2005 + + 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 3 of the License, 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, see . +*/ + +#include "replace.h" +#include "talloc.h" + +/** + return the number of elements in a string list +*/ +static size_t str_list_length(const char **list) +{ + size_t ret; + for (ret=0;list && list[ret];ret++) /* noop */ ; + return ret; +} + +/** + add an entry to a string list +*/ +const char **str_list_add(const char **list, const char *s) +{ + size_t len = str_list_length(list); + const char **ret; + + ret = talloc_realloc(NULL, list, const char *, len+2); + if (ret == NULL) return NULL; + + ret[len] = talloc_strdup(ret, s); + if (ret[len] == NULL) return NULL; + + ret[len+1] = NULL; + + return ret; +} + +/** + compare two timeval structures. + Return -1 if tv1 < tv2 + Return 0 if tv1 == tv2 + Return 1 if tv1 > tv2 +*/ +static int timeval_compare(const struct timeval *tv1, const struct timeval *tv2) +{ + if (tv1->tv_sec > tv2->tv_sec) return 1; + if (tv1->tv_sec < tv2->tv_sec) return -1; + if (tv1->tv_usec > tv2->tv_usec) return 1; + if (tv1->tv_usec < tv2->tv_usec) return -1; + return 0; +} + +/** + return a zero timeval +*/ +struct timeval timeval_zero(void) +{ + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + return tv; +} + +/** + return true if a timeval is zero +*/ +bool timeval_is_zero(const struct timeval *tv) +{ + return tv->tv_sec == 0 && tv->tv_usec == 0; +} + +/** + return a timeval for the current time +*/ +struct timeval timeval_current(void) +{ + struct timeval tv; + GetTimeOfDay(&tv); + return tv; +} + +/** + return a timeval struct with the given elements +*/ +struct timeval timeval_set(uint32_t secs, uint32_t usecs) +{ + struct timeval tv; + tv.tv_sec = secs; + tv.tv_usec = usecs; + return tv; +} + +/** + return the difference between two timevals as a timeval + if tv1 comes after tv2, then return a zero timeval + (this is *tv2 - *tv1) +*/ +struct timeval timeval_until(const struct timeval *tv1, + const struct timeval *tv2) +{ + struct timeval t; + if (timeval_compare(tv1, tv2) >= 0) { + return timeval_zero(); + } + t.tv_sec = tv2->tv_sec - tv1->tv_sec; + if (tv1->tv_usec > tv2->tv_usec) { + t.tv_sec--; + t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec); + } else { + t.tv_usec = tv2->tv_usec - tv1->tv_usec; + } + return t; +} + diff --git a/source4/lib/events/events_util.h b/source4/lib/events/events_util.h new file mode 100644 index 0000000000..401df891a5 --- /dev/null +++ b/source4/lib/events/events_util.h @@ -0,0 +1,123 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 1998-2005 + Copyright (C) Jelmer Vernooij 2005 + + 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 3 of the License, 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, see . +*/ + +/* To use these macros you must have a structure containing a next and + prev pointer */ + +#ifndef _DLINKLIST_H +#define _DLINKLIST_H + + +/* hook into the front of the list */ +#define DLIST_ADD(list, p) \ +do { \ + if (!(list)) { \ + (list) = (p); \ + (p)->next = (p)->prev = NULL; \ + } else { \ + (list)->prev = (p); \ + (p)->next = (list); \ + (p)->prev = NULL; \ + (list) = (p); \ + }\ +} while (0) + +/* remove an element from a list - element doesn't have to be in list. */ +#define DLIST_REMOVE(list, p) \ +do { \ + if ((p) == (list)) { \ + (list) = (p)->next; \ + if (list) (list)->prev = NULL; \ + } else { \ + if ((p)->prev) (p)->prev->next = (p)->next; \ + if ((p)->next) (p)->next->prev = (p)->prev; \ + } \ + if ((p) != (list)) (p)->next = (p)->prev = NULL; \ +} while (0) + +/* promote an element to the top of the list */ +#define DLIST_PROMOTE(list, p) \ +do { \ + DLIST_REMOVE(list, p); \ + DLIST_ADD(list, p); \ +} while (0) + +/* hook into the end of the list - needs a tmp pointer */ +#define DLIST_ADD_END(list, p, type) \ +do { \ + if (!(list)) { \ + (list) = (p); \ + (p)->next = (p)->prev = NULL; \ + } else { \ + type tmp; \ + for (tmp = (list); tmp->next; tmp = tmp->next) ; \ + tmp->next = (p); \ + (p)->next = NULL; \ + (p)->prev = tmp; \ + } \ +} while (0) + +/* insert 'p' after the given element 'el' in a list. If el is NULL then + this is the same as a DLIST_ADD() */ +#define DLIST_ADD_AFTER(list, p, el) \ +do { \ + if (!(list) || !(el)) { \ + DLIST_ADD(list, p); \ + } else { \ + p->prev = el; \ + p->next = el->next; \ + el->next = p; \ + if (p->next) p->next->prev = p; \ + }\ +} while (0) + +/* demote an element to the end of the list, needs a tmp pointer */ +#define DLIST_DEMOTE(list, p, tmp) \ +do { \ + DLIST_REMOVE(list, p); \ + DLIST_ADD_END(list, p, tmp); \ +} while (0) + +/* concatenate two lists - putting all elements of the 2nd list at the + end of the first list */ +#define DLIST_CONCATENATE(list1, list2, type) \ +do { \ + if (!(list1)) { \ + (list1) = (list2); \ + } else { \ + type tmp; \ + for (tmp = (list1); tmp->next; tmp = tmp->next) ; \ + tmp->next = (list2); \ + if (list2) { \ + (list2)->prev = tmp; \ + } \ + } \ +} while (0) + +#endif /* _DLINKLIST_H */ + +const char **str_list_add(const char **list, const char *s); +struct timeval timeval_zero(void); +bool timeval_is_zero(const struct timeval *tv); +struct timeval timeval_current(void); +struct timeval timeval_set(uint32_t secs, uint32_t usecs); +struct timeval timeval_until(const struct timeval *tv1, + const struct timeval *tv2); + diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c index b220d320cf..9dbbb08734 100644 --- a/source4/lib/events/events_wrap.c +++ b/source4/lib/events/events_wrap.c @@ -2501,7 +2501,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0}; #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) -#include "lib/events/events.h" +#include "events.h" typedef struct event_context event; SWIGINTERN event *new_event(TALLOC_CTX *mem_ctx){ return event_context_init(mem_ctx); } diff --git a/source4/lib/events/libevents.m4 b/source4/lib/events/libevents.m4 index 99a47dcc54..483ab861fb 100644 --- a/source4/lib/events/libevents.m4 +++ b/source4/lib/events/libevents.m4 @@ -1,11 +1,28 @@ -EVENTS_OBJ="lib/events/events.o lib/events/events_select.o lib/events/events_signal.o lib/events/events_timed.o lib/events/events_standard.o" +dnl find the events sources. This is meant to work both for +dnl standalone builds, and builds of packages using libevents +eventsdir="" +eventspaths="$srcdir $srcdir/lib/events $srcdir/events $srcdir/../events" +for d in $eventspaths; do + if test -f "$d/events.c"; then + eventsdir="$d" + AC_SUBST(eventsdir) + break; + fi +done +if test x"$eventsdir" = "x"; then + AC_MSG_ERROR([cannot find libevents source in $eventspaths]) +fi + +EVENTS_OBJ="events.o events_select.o events_signal.o events_timed.o events_standard.o events_util.o" +AC_SUBST(LIBREPLACEOBJ) AC_CHECK_HEADERS(sys/epoll.h) AC_CHECK_FUNCS(epoll_create) if test x"$ac_cv_header_sys_epoll_h" = x"yes" -a x"$ac_cv_func_epoll_create" = x"yes"; then - EVENTS_OBJ="$EVENTS_OBJ lib/events/events_epoll.o" + EVENTS_OBJ="$EVENTS_OBJ events_epoll.o" AC_DEFINE(HAVE_EVENTS_EPOLL, 1, [Whether epoll available]) fi AC_SUBST(EVENTS_OBJ) + -- cgit From 3b6042e192f7196b73ec4f3ef948e26cff5f4055 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 14 May 2008 15:19:43 +0200 Subject: lib/events: system/network.h isn't needed metze (This used to be commit 59faf3bf670140784d5698bbdc8b86afe8e188ec) --- source4/lib/events/configure.ac | 1 - source4/lib/events/events_aio.c | 1 - source4/lib/events/events_epoll.c | 1 - source4/lib/events/events_standard.c | 1 - 4 files changed, 4 deletions(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/configure.ac b/source4/lib/events/configure.ac index 4eb3575aac..afae82d7c0 100644 --- a/source4/lib/events/configure.ac +++ b/source4/lib/events/configure.ac @@ -6,7 +6,6 @@ AC_INIT(events, 1.0.0) AC_CONFIG_SRCDIR([events.c]) AC_CONFIG_HEADER(config.h) AC_LIBREPLACE_ALL_CHECKS -AC_LIBREPLACE_NETWORK_CHECKS m4_include(libtalloc.m4) diff --git a/source4/lib/events/events_aio.c b/source4/lib/events/events_aio.c index a0417384e0..b1343efd14 100644 --- a/source4/lib/events/events_aio.c +++ b/source4/lib/events/events_aio.c @@ -32,7 +32,6 @@ #include "includes.h" #include "system/filesys.h" -#include "system/network.h" #include "lib/util/dlinklist.h" #include "lib/events/events.h" #include "lib/events/events_internal.h" diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c index 07e66154fc..7316f0f31f 100644 --- a/source4/lib/events/events_epoll.c +++ b/source4/lib/events/events_epoll.c @@ -28,7 +28,6 @@ #include "events_util.h" #endif #include "system/filesys.h" -#include "system/network.h" #include "events.h" #include "events_internal.h" #include diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c index 4e41c42206..017ebc02f2 100644 --- a/source4/lib/events/events_standard.c +++ b/source4/lib/events/events_standard.c @@ -35,7 +35,6 @@ #include "events_util.h" #endif #include "system/filesys.h" -#include "system/network.h" #include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */ #include "events.h" #include "events_internal.h" -- cgit From d5d9476c351d49882efcf3faf805ffaabd2e0df4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 14 May 2008 17:28:42 +0200 Subject: Revert "lib/events: system/network.h isn't needed" Somehow this breaks 'make test'... This reverts commit 59faf3bf670140784d5698bbdc8b86afe8e188ec. metze (This used to be commit ece9df0875a32f76af5af913b6a6cdd8eacf0280) --- source4/lib/events/configure.ac | 1 + source4/lib/events/events_aio.c | 1 + source4/lib/events/events_epoll.c | 1 + source4/lib/events/events_standard.c | 1 + 4 files changed, 4 insertions(+) (limited to 'source4/lib/events') diff --git a/source4/lib/events/configure.ac b/source4/lib/events/configure.ac index afae82d7c0..4eb3575aac 100644 --- a/source4/lib/events/configure.ac +++ b/source4/lib/events/configure.ac @@ -6,6 +6,7 @@ AC_INIT(events, 1.0.0) AC_CONFIG_SRCDIR([events.c]) AC_CONFIG_HEADER(config.h) AC_LIBREPLACE_ALL_CHECKS +AC_LIBREPLACE_NETWORK_CHECKS m4_include(libtalloc.m4) diff --git a/source4/lib/events/events_aio.c b/source4/lib/events/events_aio.c index b1343efd14..a0417384e0 100644 --- a/source4/lib/events/events_aio.c +++ b/source4/lib/events/events_aio.c @@ -32,6 +32,7 @@ #include "includes.h" #include "system/filesys.h" +#include "system/network.h" #include "lib/util/dlinklist.h" #include "lib/events/events.h" #include "lib/events/events_internal.h" diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c index 7316f0f31f..07e66154fc 100644 --- a/source4/lib/events/events_epoll.c +++ b/source4/lib/events/events_epoll.c @@ -28,6 +28,7 @@ #include "events_util.h" #endif #include "system/filesys.h" +#include "system/network.h" #include "events.h" #include "events_internal.h" #include diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c index 017ebc02f2..4e41c42206 100644 --- a/source4/lib/events/events_standard.c +++ b/source4/lib/events/events_standard.c @@ -35,6 +35,7 @@ #include "events_util.h" #endif #include "system/filesys.h" +#include "system/network.h" #include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */ #include "events.h" #include "events_internal.h" -- cgit From 333c169529a3f64a28fcaff1056069867fd56a90 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 May 2008 20:30:46 +0200 Subject: Use variables for source directory in remaining subsystems. (This used to be commit 6b6b2196a8a8d9e741f5c399185ded7a16938da0) --- source4/lib/events/config.mk | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 34c24f76f5..3a20770427 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -15,7 +15,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_aio_init ############################## -EVENTS_AIO_OBJ_FILES = lib/events/events_aio.o +EVENTS_AIO_OBJ_FILES = $(libeventssrcdir)/events_aio.o ############################## [MODULE::EVENTS_EPOLL] @@ -23,7 +23,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_epoll_init ############################## -EVENTS_EPOLL_OBJ_FILES = lib/events/events_epoll.o +EVENTS_EPOLL_OBJ_FILES = $(libeventssrcdir)/events_epoll.o ############################## [MODULE::EVENTS_SELECT] @@ -31,7 +31,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_select_init ############################## -EVENTS_SELECT_OBJ_FILES = lib/events/events_select.o +EVENTS_SELECT_OBJ_FILES = $(libeventssrcdir)/events_select.o ############################## [MODULE::EVENTS_STANDARD] @@ -39,7 +39,7 @@ SUBSYSTEM = LIBEVENTS INIT_FUNCTION = s4_events_standard_init ############################## -EVENTS_STANDARD_OBJ_FILES = lib/events/events_standard.o +EVENTS_STANDARD_OBJ_FILES = $(libeventssrcdir)/events_standard.o ############################## # Start SUBSYSTEM LIBEVENTS @@ -47,12 +47,12 @@ EVENTS_STANDARD_OBJ_FILES = lib/events/events_standard.o # End SUBSYSTEM LIBEVENTS ############################## -LIBEVENTS_OBJ_FILES = $(addprefix lib/events/, events.o events_timed.o events_signal.o) +LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, events.o events_timed.o events_signal.o) -PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h) +PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h events_internal.h) [PYTHON::swig_events] SWIG_FILE = events.i PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG -swig_events_OBJ_FILES = lib/events/events_wrap.o +swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o -- cgit From 721332411aac09b096f6add77c7c59c0a300ba1c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 14:29:05 +0200 Subject: Regenerate with newer version of swig. (This used to be commit 034c68bea934db87bce13a750c17fb1bd2bbe3b6) --- source4/lib/events/events.py | 2 +- source4/lib/events/events_wrap.c | 65 ++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 20 deletions(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/events.py b/source4/lib/events/events.py index d8f70f6319..237726897d 100644 --- a/source4/lib/events/events.py +++ b/source4/lib/events/events.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.33 +# Version 1.3.35 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c index 9dbbb08734..727485dfdb 100644 --- a/source4/lib/events/events_wrap.c +++ b/source4/lib/events/events_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.33 + * Version 1.3.35 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -126,7 +126,7 @@ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "3" +#define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -161,6 +161,7 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { extern "C" { #endif -typedef void *(*swig_converter_func)(void *); +typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); -/* Structure to store inforomation on one type */ +/* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ @@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* @@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg) Py_DECREF(old_str); Py_DECREF(value); } else { - PyErr_Format(PyExc_RuntimeError, mesg); + PyErr_SetString(PyExc_RuntimeError, mesg); } } @@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v) { PySwigObject *sobj = (PySwigObject *) v; PyObject *next = sobj->next; - if (sobj->own) { + if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; @@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v) res = ((*meth)(mself, v)); } Py_XDECREF(res); - } else { - const char *name = SWIG_TypePrettyName(ty); + } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); -#endif + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } +#endif } Py_XDECREF(next); PyObject_DEL(v); @@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own) { + if (own == SWIG_POINTER_OWN) { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; @@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int return SWIG_OK; } else { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { @@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (!tc) { sobj = (PySwigObject *)sobj->next; } else { - if (ptr) *ptr = SWIG_TypeCast(tc,vptr); + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } break; } } @@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } if (sobj) { - if (own) *own = sobj->own; + if (own) + *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } @@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { } if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (!tc) return SWIG_ERROR; - *ptr = SWIG_TypeCast(tc,vptr); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } } else { *ptr = vptr; } @@ -2493,7 +2511,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0}; #define SWIG_name "_events" -#define SWIGVERSION 0x010333 +#define SWIGVERSION 0x010335 #define SWIG_VERSION SWIGVERSION @@ -2860,7 +2878,7 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; - int found; + int found, init; clientdata = clientdata; @@ -2870,6 +2888,9 @@ SWIG_InitializeModule(void *clientdata) { swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; + init = 1; + } else { + init = 0; } /* Try and load any already created modules */ @@ -2898,6 +2919,12 @@ SWIG_InitializeModule(void *clientdata) { module_head->next = &swig_module; } + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); -- cgit From 2914b0ca04355f6f175b603a1de6030b20ce0830 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 21:24:48 +0200 Subject: Remove support for .py files from smb_build - deal with it only in the makefiles. (This used to be commit b865249efaa58d0fc87fa25491fda3b970af81c3) --- source4/lib/events/config.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 3a20770427..e4b5f40571 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -56,3 +56,5 @@ SWIG_FILE = events.i PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o + +$(eval $(call python_py_module_template,events.py,$(libeventssrcdir)/events.py)) -- cgit From 82bcf967b79321706cd19c759ea54c4465fe0d96 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 21:32:53 +0200 Subject: Move CFLAGS overrides for SWIG modules to Makefile. (This used to be commit 58665a8a8e4b10435aebbf2c95b6a8e50db232d6) --- source4/lib/events/config.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index e4b5f40571..3e5a5e2a2f 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -58,3 +58,5 @@ PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o $(eval $(call python_py_module_template,events.py,$(libeventssrcdir)/events.py)) + +$(swig_events_OBJ_FILES): CFLAGS+="$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)" -- cgit From b1fc7bab111fcef7f546e821f24c175bdec6865a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 21:50:56 +0200 Subject: Move some python files into the samba package. (This used to be commit ed38c668cdbe10966e46bad97301122eea8001d0) --- source4/lib/events/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 3e5a5e2a2f..22c54b86ed 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -57,6 +57,6 @@ PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o -$(eval $(call python_py_module_template,events.py,$(libeventssrcdir)/events.py)) +$(eval $(call python_py_module_template,samba/events.py,$(libeventssrcdir)/events.py)) $(swig_events_OBJ_FILES): CFLAGS+="$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)" -- cgit From 49706ab19bd3ffd6125639e6a7753b2350cf54e1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 23:59:34 +0200 Subject: Move more modules inside of the samba package. (This used to be commit 9b39e99f48266a54ed0b8890c2efde218b4b118a) --- source4/lib/events/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index 22c54b86ed..ca47f0d1c4 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -52,7 +52,7 @@ LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, events.o events_timed.o e PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h events_internal.h) [PYTHON::swig_events] -SWIG_FILE = events.i +LIBRARY_REALNAME = samba/_events.$(SHLIBEXT) PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o -- cgit From 6b3e2c308ac4fb97a89e84b58136efc842ed4f0f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 22 May 2008 01:17:30 +0200 Subject: Fix events test. (This used to be commit 0fae6f11081cff7846319175cfec95fa3911571c) --- source4/lib/events/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/tests.py b/source4/lib/events/tests.py index b14f7e6250..006426207e 100644 --- a/source4/lib/events/tests.py +++ b/source4/lib/events/tests.py @@ -17,7 +17,7 @@ # along with this program. If not, see . # -import events +from samba import events import unittest # Just test the bindings are there and that calling them doesn't crash -- cgit From 5ce59419a07c8e147daf51b77ffe2117f3d6a505 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 22 May 2008 02:13:26 +0200 Subject: Fix CFLAGS for SWIG files. (This used to be commit 8ee4f075046e0b181ec8a4ac1eaf3ea5621a56bf) --- source4/lib/events/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index ca47f0d1c4..9d579807c8 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -59,4 +59,4 @@ swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o $(eval $(call python_py_module_template,samba/events.py,$(libeventssrcdir)/events.py)) -$(swig_events_OBJ_FILES): CFLAGS+="$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)" +$(swig_events_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL) -- cgit From 37d000d052795063f63a321835d60de55389c1bd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 22 May 2008 18:47:18 +0200 Subject: Add docstrings to events python module. (This used to be commit 7d43d2c7c91c86246b9bb2ae7eda050079767e7a) --- source4/lib/events/events.i | 5 +++++ source4/lib/events/events.py | 19 +++++++++++++++++-- source4/lib/events/events_wrap.c | 10 +++++----- 3 files changed, 27 insertions(+), 7 deletions(-) (limited to 'source4/lib/events') diff --git a/source4/lib/events/events.i b/source4/lib/events/events.i index c16d482efc..7de8aec79d 100644 --- a/source4/lib/events/events.i +++ b/source4/lib/events/events.i @@ -27,8 +27,11 @@ typedef struct event_context event; typedef struct event_context { %extend { + %feature("docstring") event "S.__init__()"; event(TALLOC_CTX *mem_ctx) { return event_context_init(mem_ctx); } + %feature("docstring") loop_once "S.loop_once() -> int"; int loop_once(void); + %feature("docstring") loop_wait "S.loop_wait() -> int"; int loop_wait(void); } } event; @@ -44,6 +47,8 @@ typedef struct event_context { struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name); +%feature("docstring") event_backend_list "event_backend_list() -> list"; const char **event_backend_list(TALLOC_CTX *mem_ctx); +%feature("docstring") event_set_default_backend "event_set_default_backend(name) -> None"; %rename(set_default_backend) event_set_default_backend; void event_set_default_backend(const char *backend); diff --git a/source4/lib/events/events.py b/source4/lib/events/events.py index 237726897d..264e0b7cdf 100644 --- a/source4/lib/events/events.py +++ b/source4/lib/events/events.py @@ -61,7 +61,16 @@ class event(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args, **kwargs): + """S.__init__()""" _events.event_swiginit(self,_events.new_event(*args, **kwargs)) + def loop_once(*args, **kwargs): + """S.loop_once() -> int""" + return _events.event_loop_once(*args, **kwargs) + + def loop_wait(*args, **kwargs): + """S.loop_wait() -> int""" + return _events.event_loop_wait(*args, **kwargs) + __swig_destroy__ = _events.delete_event event.loop_once = new_instancemethod(_events.event_loop_once,None,event) event.loop_wait = new_instancemethod(_events.event_loop_wait,None,event) @@ -69,7 +78,13 @@ event_swigregister = _events.event_swigregister event_swigregister(event) event_context_init_byname = _events.event_context_init_byname -event_backend_list = _events.event_backend_list -set_default_backend = _events.set_default_backend + +def event_backend_list(*args): + """event_backend_list() -> list""" + return _events.event_backend_list(*args) + +def set_default_backend(*args, **kwargs): + """event_set_default_backend(name) -> None""" + return _events.set_default_backend(*args, **kwargs) diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c index 727485dfdb..ccaeab7ad6 100644 --- a/source4/lib/events/events_wrap.c +++ b/source4/lib/events/events_wrap.c @@ -2773,15 +2773,15 @@ fail: static PyMethodDef SwigMethods[] = { - { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, NULL}, - { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, NULL}, - { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, NULL}, + { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, (char *)"S.__init__()"}, + { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, (char *)"S.loop_once() -> int"}, + { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, (char *)"S.loop_wait() -> int"}, { (char *)"delete_event", (PyCFunction)_wrap_delete_event, METH_O, NULL}, { (char *)"event_swigregister", event_swigregister, METH_VARARGS, NULL}, { (char *)"event_swiginit", event_swiginit, METH_VARARGS, NULL}, { (char *)"event_context_init_byname", (PyCFunction) _wrap_event_context_init_byname, METH_VARARGS | METH_KEYWORDS, NULL}, - { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, NULL}, - { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, (char *)"event_backend_list() -> list"}, + { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, (char *)"event_set_default_backend(name) -> None"}, { NULL, NULL, 0, NULL } }; -- cgit