Просмотр исходного кода

Cleanup of dynamic loading to allow using the same interface factory code for
statically linked components.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@916 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 20 лет назад
Родитель
Сommit
166609be38
29 измененных файлов с 295 добавлено и 650 удалено
  1. 3 3
      Makefile
  2. 17 18
      exec/Makefile
  3. 5 9
      exec/amf.c
  4. 0 46
      exec/amf.h
  5. 6 9
      exec/cfg.c
  6. 0 44
      exec/cfg.h
  7. 6 9
      exec/ckpt.c
  8. 0 44
      exec/ckpt.h
  9. 6 9
      exec/clm.c
  10. 0 47
      exec/clm.h
  11. 6 9
      exec/evs.c
  12. 0 49
      exec/evs.h
  13. 5 10
      exec/evt.c
  14. 0 45
      exec/evt.h
  15. 6 9
      exec/lck.c
  16. 11 46
      exec/main.c
  17. 2 7
      exec/main.h
  18. 0 6
      exec/mainconfig.c
  19. 0 4
      exec/mainconfig.h
  20. 6 8
      exec/msg.c
  21. 0 44
      exec/msg.h
  22. 5 5
      exec/totemnet.c
  23. 8 5
      lcr/Makefile
  24. 16 14
      lcr/README.lcr
  25. 2 4
      lcr/lcr_comp.h
  26. 124 86
      lcr/lcr_ifact.c
  27. 30 32
      lcr/libtest_a.c
  28. 30 28
      lcr/libtest_b.c
  29. 1 1
      lcr/test.c

+ 3 - 3
Makefile

@@ -35,7 +35,7 @@ BUILD_DYNAMIC=0
 
 
 # Production mode flags
 # Production mode flags
 CFLAGS = -O3 -Wall
 CFLAGS = -O3 -Wall
-LDFLAGS = -lpthread
+LDFLAGS = -lpthread -ldl
 DESTDIR=/usr/local/openais
 DESTDIR=/usr/local/openais
 
 
 # Debug mode flags
 # Debug mode flags
@@ -47,8 +47,8 @@ DESTDIR=/usr/local/openais
 #LDFLAGS = -pg
 #LDFLAGS = -pg
 
 
 ifeq (${BUILD_DYNAMIC}, 1)
 ifeq (${BUILD_DYNAMIC}, 1)
-CFLAGS += -DBUILD_DYNAMIC=1 -fPIC
-LDFLAGS += -ldl -rdynamic
+CFLAGS += -fPIC
+LDFLAGS += -rdynamic
 endif
 endif
 
 
 all:
 all:

+ 17 - 18
exec/Makefile

@@ -31,15 +31,15 @@
 # BUILD_DYNAMIC can be defined to 1 to build for dynamic loading of service
 # BUILD_DYNAMIC can be defined to 1 to build for dynamic loading of service
 #	handler modules.  If the developer intends to debug, building without
 #	handler modules.  If the developer intends to debug, building without
 #	dynamic modules should provide an easier route.
 #	dynamic modules should provide an easier route.
-BUILD_DYNAMIC=1
+BUILD_DYNAMIC=0
 
 
 # Production mode flags
 # Production mode flags
 CFLAGS = -O3 -Wall -fomit-frame-pointer
 CFLAGS = -O3 -Wall -fomit-frame-pointer
-LDFLAGS = -lpthread
+LDFLAGS = -lpthread -ldl
 
 
 # Debug mode flags
 # Debug mode flags
 #CFLAGS = -g -Wall 
 #CFLAGS = -g -Wall 
-#LDFLAGS = -g -lpthread
+#LDFLAGS = -g -lpthread -ldl
 
 
 # Profile mode flags
 # Profile mode flags
 #CFLAGS = -O3 -pg
 #CFLAGS = -O3 -pg
@@ -60,15 +60,14 @@ SERV_OBJS = evs.o clm.o amf.o ckpt.o evt.o lck.o msg.o cfg.o
 
 
 # main executive objects
 # main executive objects
 MAIN_SRC = main.c print.c mempool.c \
 MAIN_SRC = main.c print.c mempool.c \
-		util.c sync.c ykd.c mainconfig.c amfconfig.o
+		util.c sync.c ykd.c mainconfig.c amfconfig.c
 MAIN_OBJS = main.o print.o mempool.o \
 MAIN_OBJS = main.o print.o mempool.o \
-		util.o sync.o ykd.o mainconfig.o amfconfig.o
+		util.o sync.o ykd.o mainconfig.o amfconfig.o ../lcr/lcr_ifact.o
 
 
 ifeq (${BUILD_DYNAMIC}, 1) 
 ifeq (${BUILD_DYNAMIC}, 1) 
 EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS)
 EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS)
-CFLAGS += -DBUILD_DYNAMIC=1 -fPIC
-LDFLAGS += -ldl -rdynamic
-EXEC_LIBS +=  ../lcr/lcr_ifact.o
+CFLAGS += -fPIC
+LDFLAGS += -rdynamic
 
 
 all:libtotem_pg.a libtotem_pg.so.1.0 ../lcr/lcr_ifact.o \
 all:libtotem_pg.a libtotem_pg.so.1.0 ../lcr/lcr_ifact.o \
 	service_evs.lcrso service_clm.lcrso service_amf.lcrso \
 	service_evs.lcrso service_clm.lcrso service_amf.lcrso \
@@ -197,33 +196,33 @@ totemconfig.o: totemconfig.c
 main.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 main.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 main.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 main.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 main.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h amfconfig.h
 main.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h amfconfig.h
-main.o: main.h clm.h ../include/saClm.h amf.h handlers.h ckpt.h evt.h 
+main.o: main.h ../include/saClm.h handlers.h 
 main.o: ../include/saEvt.h swab.h print.h
 main.o: ../include/saEvt.h swab.h print.h
 clm.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
 clm.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
 clm.o: ../include/ipc_evs.h  ../include/saClm.h ../include/ipc_gen.h
 clm.o: ../include/ipc_evs.h  ../include/saClm.h ../include/ipc_gen.h
 clm.o: ../include/ipc_clm.h ../include/list.h ../include/queue.h aispoll.h
 clm.o: ../include/ipc_clm.h ../include/list.h ../include/queue.h aispoll.h
-clm.o: totempg.h totemsrp.h amfconfig.h main.h clm.h amf.h handlers.h ckpt.h
-clm.o: evt.h  ../include/saEvt.h mempool.h print.h
+clm.o: totempg.h totemsrp.h amfconfig.h main.h handlers.h 
+clm.o:  ../include/saEvt.h mempool.h print.h
 amf.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 amf.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 amf.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 amf.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 amf.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h util.h
 amf.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h util.h
-amf.o: amfconfig.h main.h clm.h ../include/saClm.h amf.h handlers.h ckpt.h evt.h
+amf.o: amfconfig.h main.h ../include/saClm.h handlers.h
 amf.o:  ../include/saEvt.h print.h
 amf.o:  ../include/saEvt.h print.h
 ckpt.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 ckpt.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 ckpt.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 ckpt.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 ckpt.o: ../include/queue.h aispoll.h mempool.h util.h amfconfig.h totempg.h
 ckpt.o: ../include/queue.h aispoll.h mempool.h util.h amfconfig.h totempg.h
-ckpt.o: totemsrp.h main.h clm.h ../include/saClm.h amf.h handlers.h ckpt.h
-ckpt.o: evt.h  ../include/saEvt.h print.h
+ckpt.o: totemsrp.h main.h ../include/saClm.h handlers.h 
+ckpt.o:  ../include/saEvt.h print.h
 evt.o: ../include/ipc_evt.h ../include/saAis.h ../include/saEvt.h
 evt.o: ../include/ipc_evt.h ../include/saAis.h ../include/saEvt.h
 evt.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 evt.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 evt.o: ../include/queue.h util.h ../include/saAis.h aispoll.h mempool.h
 evt.o: ../include/queue.h util.h ../include/saAis.h aispoll.h mempool.h
-evt.o: amfconfig.h totempg.h totemsrp.h main.h  clm.h ../include/saClm.h
-evt.o: amf.h ../include/ipc_evs.h handlers.h ckpt.h evt.h 
+evt.o: amfconfig.h totempg.h totemsrp.h main.h  ../include/saClm.h
+evt.o: ../include/ipc_evs.h handlers.h 
 evt.o: ../include/saEvt.h swab.h print.h
 evt.o: ../include/saEvt.h swab.h print.h
 evs.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 evs.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
 evs.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
 evs.o:  ../include/saClm.h ../include/ipc_gen.h ../include/list.h
-evs.o: ../include/queue.h aispoll.h totempg.h totemsrp.h amfconfig.h main.h clm.h
-evs.o: ../include/saClm.h amf.h handlers.h ckpt.h evt.h 
+evs.o: ../include/queue.h aispoll.h totempg.h totemsrp.h amfconfig.h main.h 
+evs.o: ../include/saClm.h handlers.h 
 evs.o: ../include/saEvt.h mempool.h print.h
 evs.o: ../include/saEvt.h mempool.h print.h
 amfconfig.o: ../include/saAis.h ../include/list.h util.h amfconfig.h aispoll.h
 amfconfig.o: ../include/saAis.h ../include/list.h util.h amfconfig.h aispoll.h
 amfconfig.o: totempg.h totemsrp.h mempool.h print.h ../include/saClm.h
 amfconfig.o: totempg.h totemsrp.h mempool.h print.h ../include/saClm.h

+ 5 - 9
exec/amf.c

@@ -404,8 +404,6 @@ struct openais_service_handler amf_service_handler = {
 	.confchg_fn			= amf_confchg_fn,
 	.confchg_fn			= amf_confchg_fn,
 };
 };
 
 
-#ifdef BUILD_DYNAMIC
-
 struct openais_service_handler *amf_get_handler_ver0 (void);
 struct openais_service_handler *amf_get_handler_ver0 (void);
 
 
 struct openais_service_handler_iface_ver0 amf_service_handler_iface = {
 struct openais_service_handler_iface_ver0 amf_service_handler_iface = {
@@ -432,17 +430,15 @@ struct lcr_comp amf_comp_ver0 = {
 	.ifaces				= openais_amf_ver0
 	.ifaces				= openais_amf_ver0
 };
 };
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &amf_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *amf_get_handler_ver0 (void)
 struct openais_service_handler *amf_get_handler_ver0 (void)
 {
 {
 	return (&amf_service_handler);
 	return (&amf_service_handler);
 }
 }
-#endif /* BUILD_DYNAMIC */
+static void register_this_component (void) {
+	lcr_component_register (&amf_comp_ver0);
+}
+
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };
 
 
 enum clc_command_run_operation_type {
 enum clc_command_run_operation_type {
 	CLC_COMMAND_RUN_OPERATION_TYPE_INSTANTIATE = 1,
 	CLC_COMMAND_RUN_OPERATION_TYPE_INSTANTIATE = 1,

+ 0 - 46
exec/amf.h

@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2002-2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "../include/saAis.h"
-#include "../include/saAmf.h"
-#include "aispoll.h"
-#include "amfconfig.h"
-#include "handlers.h"
-
-#ifndef AMF_H_DEFINED
-#define AMF_H_DEFINED
-
-void amf_dump ();
-extern struct openais_service_handler amf_service_handler;
-
-#endif /* AMF_H_DEFINED */

+ 6 - 9
exec/cfg.c

@@ -148,8 +148,6 @@ struct openais_service_handler cfg_service_handler = {
 /*
 /*
  * Dynamic Loader definition
  * Dynamic Loader definition
  */
  */
-#ifdef BUILD_DYNAMIC
-
 struct openais_service_handler *cfg_get_handler_ver0 (void);
 struct openais_service_handler *cfg_get_handler_ver0 (void);
 
 
 struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
 struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
@@ -175,17 +173,16 @@ struct lcr_comp cfg_comp_ver0 = {
 	.ifaces					= openais_cfg_ver0
 	.ifaces					= openais_cfg_ver0
 };
 };
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &cfg_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *cfg_get_handler_ver0 (void)
 struct openais_service_handler *cfg_get_handler_ver0 (void)
 {
 {
 	return (&cfg_service_handler);
 	return (&cfg_service_handler);
 }
 }
-#endif /* BUILD_DYNAMIC */
+static void register_this_component (void) {
+printf ("registering cfg component\n");
+	lcr_component_register (&cfg_comp_ver0);
+}
+
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };
 
 
 /* IMPL */
 /* IMPL */
 
 

+ 0 - 44
exec/cfg.h

@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2005 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "../include/ipc_gen.h"
-#include "../include/ipc_cfg.h"
-#include "aispoll.h"
-#include "handlers.h"
-
-#ifndef CFG_H_DEFINED
-#define CFG_H_DEFINED
-
-extern struct openais_service_handler cfg_service_handler;
-
-#endif /* CFG_H_DEFINED */

+ 6 - 9
exec/ckpt.c

@@ -502,8 +502,6 @@ struct openais_service_handler ckpt_service_handler = {
 /*
 /*
  * Dynamic loader definition
  * Dynamic loader definition
  */
  */
-#ifdef BUILD_DYNAMIC
-
 struct openais_service_handler *ckpt_get_handler_ver0 (void);
 struct openais_service_handler *ckpt_get_handler_ver0 (void);
 
 
 struct openais_service_handler_iface_ver0 ckpt_service_handler_iface = {
 struct openais_service_handler_iface_ver0 ckpt_service_handler_iface = {
@@ -529,17 +527,16 @@ struct lcr_comp ckpt_comp_ver0 = {
 	.ifaces				= openais_ckpt_ver0
 	.ifaces				= openais_ckpt_ver0
 };
 };
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &ckpt_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *ckpt_get_handler_ver0 (void)
 struct openais_service_handler *ckpt_get_handler_ver0 (void)
 {
 {
 	return (&ckpt_service_handler);
 	return (&ckpt_service_handler);
 }
 }
-#endif /* BUILD_DYNAMIC */
+
+static void register_this_component (void) {
+	lcr_component_register (&ckpt_comp_ver0);
+}
+
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };
 
 
 /*
 /*
  * All data types used for executive messages
  * All data types used for executive messages

+ 0 - 44
exec/ckpt.h

@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2003-2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "../include/saAis.h"
-#include "../include/saCkpt.h"
-#include "aispoll.h"
-#include "totemsrp.h"
-
-#ifndef CKPT_H_DEFINED
-#define CKPT_H_DEFINED
-
-extern struct openais_service_handler ckpt_service_handler;
-
-#endif /* CKPT_H_DEFINED */

+ 6 - 9
exec/clm.c

@@ -210,7 +210,6 @@ struct openais_service_handler clm_service_handler = {
 /*
 /*
  * Dynamic loader definition
  * Dynamic loader definition
  */
  */
-#ifdef BUILD_DYNAMIC
 struct openais_service_handler *clm_get_service_handler_ver0 (void);
 struct openais_service_handler *clm_get_service_handler_ver0 (void);
 
 
 struct openais_service_handler_iface_ver0 clm_service_handler_iface = {
 struct openais_service_handler_iface_ver0 clm_service_handler_iface = {
@@ -236,18 +235,16 @@ struct lcr_comp clm_comp_ver0 = {
 	.ifaces					= openais_clm_ver0
 	.ifaces					= openais_clm_ver0
 };
 };
 
 
-
-int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &clm_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *clm_get_service_handler_ver0 (void)
 struct openais_service_handler *clm_get_service_handler_ver0 (void)
 {
 {
 	return (&clm_service_handler);
 	return (&clm_service_handler);
 }
 }
-#endif /* BUILD_DYNAMIC */
+
+static void clm_comp_register (void) {
+	lcr_component_register (&clm_comp_ver0);
+}
+
+static void (*const __ctor_clm_comp[1]) (void) __attribute__ ((section(".ctors"))) = { clm_comp_register }; 
 
 
 struct req_exec_clm_nodejoin {
 struct req_exec_clm_nodejoin {
 	struct req_header header;
 	struct req_header header;

+ 0 - 47
exec/clm.h

@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2002-2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "../include/saAis.h"
-#include "../include/saClm.h"
-
-#ifndef CLM_H_DEFINED
-#define CLM_H_DEFINED
-
-#include <netinet/in.h>
-
-extern SaClmClusterNodeT *clm_get_by_nodeid (unsigned int node_id);
-
-extern struct openais_service_handler clm_service_handler;
-
-#endif /* CLM_H_DEFINED */

+ 6 - 9
exec/evs.c

@@ -163,8 +163,6 @@ static DECLARE_LIST_INIT (confchg_notify);
  * Dynamic loading descriptor
  * Dynamic loading descriptor
  */
  */
 
 
-#ifdef BUILD_DYNAMIC
-
 struct openais_service_handler *evs_get_service_handler_ver0 (void);
 struct openais_service_handler *evs_get_service_handler_ver0 (void);
 
 
 struct openais_service_handler_iface_ver0 evs_service_handler_iface = {
 struct openais_service_handler_iface_ver0 evs_service_handler_iface = {
@@ -190,18 +188,16 @@ struct lcr_comp evs_comp_ver0 = {
 	.ifaces		= openais_evs_ver0
 	.ifaces		= openais_evs_ver0
 };
 };
 
 
-int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &evs_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *evs_get_service_handler_ver0 (void)
 struct openais_service_handler *evs_get_service_handler_ver0 (void)
 {
 {
 	return (&evs_service_handler);
 	return (&evs_service_handler);
 }
 }
 
 
-#endif /* BUILD_DYNAMIC */
+static void evs_comp_register (void) {
+	lcr_component_register (&evs_comp_ver0);
+}
+
+static void (*const __ctor_evs_comp[1]) (void) __attribute__ ((section(".ctors"))) = { evs_comp_register };
 
 
 struct res_evs_confchg_callback res_evs_confchg_callback;
 struct res_evs_confchg_callback res_evs_confchg_callback;
 
 
@@ -527,3 +523,4 @@ static void message_handler_req_exec_mcast (void *msg, struct totem_ip_address *
 		}
 		}
 	}
 	}
 }
 }
+

+ 0 - 49
exec/evs.h

@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "../include/saAis.h"
-
-#ifndef EVS_H_DEFINED
-#define EVS_H_DEFINED
-
-#include <netinet/in.h>
-
-struct libevs_ci {
-	struct evs_group *groups;
-	int group_entries;
-};
-
-extern struct openais_service_handler evs_service_handler;
-
-#endif /* EVS_H_DEFINED */

+ 5 - 10
exec/evt.c

@@ -59,8 +59,6 @@
 #include "main.h"
 #include "main.h"
 #include "totemip.h"
 #include "totemip.h"
 #include "totempg.h"
 #include "totempg.h"
-#include "clm.h"
-#include "evt.h"
 #include "swab.h"
 #include "swab.h"
 
 
 #define LOG_SERVICE LOG_SERVICE_EVT
 #define LOG_SERVICE LOG_SERVICE_EVT
@@ -230,7 +228,6 @@ struct openais_service_handler evt_service_handler = {
 	.sync_abort					= evt_sync_abort
 	.sync_abort					= evt_sync_abort
 };
 };
 
 
-#ifdef BUILD_DYNAMIC
 struct openais_service_handler *evt_get_handler_ver0(void);
 struct openais_service_handler *evt_get_handler_ver0(void);
 
 
 struct openais_service_handler_iface_ver0 evt_service_handler_iface = {
 struct openais_service_handler_iface_ver0 evt_service_handler_iface = {
@@ -256,18 +253,16 @@ struct lcr_comp evt_comp_ver0 = {
 	.ifaces					= openais_evt_ver0
 	.ifaces					= openais_evt_ver0
 };
 };
 
 
-extern int lcr_comp_get(struct lcr_comp **component)
-{
-	*component = &evt_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *evt_get_handler_ver0(void)
 struct openais_service_handler *evt_get_handler_ver0(void)
 {
 {
 	return (&evt_service_handler);
 	return (&evt_service_handler);
 }
 }
 
 
-#endif /* BUILD_DYNAMIC */
+static void evt_comp_register (void) {
+	lcr_component_register (&evt_comp_ver0);
+}
+
+static void (*const __ctor_evt_comp[1]) (void) __attribute__ ((section(".ctors"))) = { evt_comp_register };
 
 
 /* 
 /* 
  * list of all retained events 
  * list of all retained events 

+ 0 - 45
exec/evt.h

@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2004 Mark Haverkamp
- * Copyright (c) 2004 Open Source Development Lab
- *
- * All rights reserved.
- *
- * This software licensed under BSD license, the text of which follows:
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the Open Source Developent Lab nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EVT_H
-#define EVT_H
-#include "../include/saAis.h"
-#include "../include/saEvt.h"
-#include "handlers.h"
-
-extern struct openais_service_handler evt_service_handler;
-
-#endif
-/*
- *	vi: set autoindent tabstop=4 shiftwidth=4 :
- */

+ 6 - 9
exec/lck.c

@@ -302,8 +302,6 @@ struct openais_service_handler lck_service_handler = {
 /*
 /*
  * Dynamic loader definition
  * Dynamic loader definition
  */
  */
-#ifdef BUILD_DYNAMIC
-
 struct openais_service_handler *lck_get_handler_ver0 (void);
 struct openais_service_handler *lck_get_handler_ver0 (void);
 
 
 struct openais_service_handler_iface_ver0 lck_service_handler_iface = {
 struct openais_service_handler_iface_ver0 lck_service_handler_iface = {
@@ -329,17 +327,16 @@ struct lcr_comp lck_comp_ver0 = {
 	.ifaces					= openais_lck_ver0
 	.ifaces					= openais_lck_ver0
 };
 };
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &lck_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *lck_get_handler_ver0 (void)
 struct openais_service_handler *lck_get_handler_ver0 (void)
 {
 {
 	return (&lck_service_handler);
 	return (&lck_service_handler);
 }
 }
-#endif /* BUILD_DYNAMIC */
+
+static void register_this_component (void) {
+	lcr_component_register (&lck_comp_ver0);
+}
+
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };
 
 
 /*
 /*
  * All data types used for executive messages
  * All data types used for executive messages

+ 11 - 46
exec/main.c

@@ -1,8 +1,7 @@
-//#define BUILD_DYNAMIC 1
 /*
 /*
  * vi: set autoindent tabstop=4 shiftwidth=4 :
  * vi: set autoindent tabstop=4 shiftwidth=4 :
  *
  *
- * Copyright (c) 2002-2004 MontaVista Software, Inc.
+ * Copyright (c) 2002-2006 MontaVista Software, Inc.
  *
  *
  * All rights reserved.
  * All rights reserved.
  *
  *
@@ -71,14 +70,6 @@
 #include "main.h"
 #include "main.h"
 #include "handlers.h"
 #include "handlers.h"
 #include "sync.h"
 #include "sync.h"
-#include "evs.h"
-#include "clm.h"
-#include "amf.h"
-#include "ckpt.h"
-#include "evt.h"
-#include "lck.h"
-#include "msg.h"
-#include "cfg.h"
 #include "ykd.h"
 #include "ykd.h"
 #include "swab.h"
 #include "swab.h"
 
 
@@ -1127,7 +1118,7 @@ int service_handler_init (
 {
 {
 	int res = 0;
 	int res = 0;
 	assert (ais_service_handlers[handler->id] != NULL);
 	assert (ais_service_handlers[handler->id] != NULL);
-	log_printf (LOG_LEVEL_NOTICE, "Initialising service handler '%s'\n", handler->name);
+	log_printf (LOG_LEVEL_NOTICE, "Initializing service handler '%s'\n", handler->name);
 	if (ais_service_handlers[handler->id]->exec_init_fn) {
 	if (ais_service_handlers[handler->id]->exec_init_fn) {
 		res = ais_service_handlers[handler->id]->exec_init_fn (config);
 		res = ais_service_handlers[handler->id]->exec_init_fn (config);
 	}
 	}
@@ -1136,7 +1127,6 @@ int service_handler_init (
 
 
 void default_services_register (struct openais_config *openais_config)
 void default_services_register (struct openais_config *openais_config)
 {
 {
-#ifdef BUILD_DYNAMIC
 	int i;
 	int i;
 
 
 	for (i = 0; i < openais_config->num_dynamic_services; i++) {
 	for (i = 0; i < openais_config->num_dynamic_services; i++) {
@@ -1150,52 +1140,25 @@ void default_services_register (struct openais_config *openais_config)
 		if (!openais_config->dynamic_services[i].iface_ver0) {
 		if (!openais_config->dynamic_services[i].iface_ver0) {
 			log_printf(LOG_LEVEL_ERROR, "AIS Component %s did not load.\n", openais_config->dynamic_services[i].name);
 			log_printf(LOG_LEVEL_ERROR, "AIS Component %s did not load.\n", openais_config->dynamic_services[i].name);
 			ais_done(AIS_DONE_DYNAMICLOAD);
 			ais_done(AIS_DONE_DYNAMICLOAD);
+		} else {
+			log_printf(LOG_LEVEL_ERROR, "AIS Component %s loaded.\n", openais_config->dynamic_services[i].name);
 		}
 		}
+
 		service_handler_register (
 		service_handler_register (
 			openais_config->dynamic_services[i].iface_ver0->openais_get_service_handler_ver0(),
 			openais_config->dynamic_services[i].iface_ver0->openais_get_service_handler_ver0(),
 			openais_config);
 			openais_config);
 	}
 	}
 
 
-#else /* NOT BUILD_DYNAMIC */
-	/*
-	 * link everything together - better for debugging - smaller memory footprint
-	 */
-
-	service_handler_register (&evs_service_handler, openais_config);
-	service_handler_register (&clm_service_handler, openais_config);
-	service_handler_register (&amf_service_handler, openais_config);
-	service_handler_register (&ckpt_service_handler, openais_config);
-	service_handler_register (&evt_service_handler, openais_config);
-	service_handler_register (&lck_service_handler, openais_config);
-	service_handler_register (&msg_service_handler, openais_config);
-	service_handler_register (&cfg_service_handler, openais_config);
-#endif /* BUILD_DYNAMIC */
 }
 }
 
 
 void default_services_init (struct openais_config *openais_config)
 void default_services_init (struct openais_config *openais_config)
 {
 {
-#ifdef BUILD_DYNAMIC
 	int i;
 	int i;
 
 
 	for (i = 0; i < openais_config->num_dynamic_services; i++) {
 	for (i = 0; i < openais_config->num_dynamic_services; i++) {
 		service_handler_init (openais_config->dynamic_services[i].iface_ver0->openais_get_service_handler_ver0(),
 		service_handler_init (openais_config->dynamic_services[i].iface_ver0->openais_get_service_handler_ver0(),
 				      openais_config);
 				      openais_config);
 	}
 	}
-
-#else /* NOT BUILD_DYNAMIC */
-	/*
-	 * link everything together - better for debugging - smaller memory footprint
-	 */
-
-	service_handler_init (&evs_service_handler, openais_config);
-	service_handler_init (&clm_service_handler, openais_config);
-	service_handler_init (&amf_service_handler, openais_config);
-	service_handler_init (&ckpt_service_handler, openais_config);
-	service_handler_init (&evt_service_handler, openais_config);
-	service_handler_init (&lck_service_handler, openais_config);
-	service_handler_init (&msg_service_handler, openais_config);
-	service_handler_init (&cfg_service_handler, openais_config);
-#endif /* BUILD_DYNAMIC */
 }
 }
 
 
 int main (int argc, char **argv)
 int main (int argc, char **argv)
@@ -1226,7 +1189,7 @@ int main (int argc, char **argv)
 	 */
 	 */
 	res = openais_main_config_read (&error_string, &openais_config, 1);
 	res = openais_main_config_read (&error_string, &openais_config, 1);
 	if (res == -1) {
 	if (res == -1) {
-		log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: Copyright (C) 2002-2004 MontaVista Software, Inc and contributors.\n");
+		log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n");
 
 
 		log_printf (LOG_LEVEL_ERROR, error_string);
 		log_printf (LOG_LEVEL_ERROR, error_string);
 		ais_done (AIS_DONE_MAINCONFIGREAD);
 		ais_done (AIS_DONE_MAINCONFIGREAD);
@@ -1241,7 +1204,7 @@ int main (int argc, char **argv)
 	if (!openais_config.totem_config.interface_count) {
 	if (!openais_config.totem_config.interface_count) {
 		res = totem_config_read (&openais_config.totem_config, &error_string, 1);
 		res = totem_config_read (&openais_config.totem_config, &error_string, 1);
 		if (res == -1) {
 		if (res == -1) {
-			log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: Copyright (C) 2002-2004 MontaVista Software, Inc and contributors.\n");
+			log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n");
 			log_printf (LOG_LEVEL_ERROR, error_string);
 			log_printf (LOG_LEVEL_ERROR, error_string);
 			ais_done (AIS_DONE_MAINCONFIGREAD);
 			ais_done (AIS_DONE_MAINCONFIGREAD);
 		}
 		}
@@ -1265,7 +1228,7 @@ int main (int argc, char **argv)
 		ais_done (AIS_DONE_LOGSETUP);
 		ais_done (AIS_DONE_LOGSETUP);
 	}
 	}
 
 
-	log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: Copyright (C) 2002-2004 MontaVista Software, Inc. and contributors.\n");
+	log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: Copyright (C) 2002-2006 MontaVista Software, Inc. and contributors.\n");
 
 
 	/*
 	/*
 	 * Set round robin realtime scheduling with priority 99
 	 * Set round robin realtime scheduling with priority 99
@@ -1301,8 +1264,10 @@ int main (int argc, char **argv)
 		&openais_group,
 		&openais_group,
 		1);
 		1);
 
 
+	/*
+	 * This must occur after totempg is initialized because "this_ip" must be set
+	 */
 	this_ip = &openais_config.totem_config.interfaces[0].boundto;
 	this_ip = &openais_config.totem_config.interfaces[0].boundto;
-
 	default_services_init(&openais_config); 
 	default_services_init(&openais_config); 
 
 
 	sync_register (openais_sync_callbacks_retrieve, openais_sync_completed);
 	sync_register (openais_sync_callbacks_retrieve, openais_sync_completed);

+ 2 - 7
exec/main.h

@@ -36,17 +36,12 @@
 #define FALSE 0
 #define FALSE 0
 #include <sys/un.h>
 #include <sys/un.h>
 #include "../include/saAis.h"
 #include "../include/saAis.h"
+#include "../include/saClm.h"
 #include "../include/queue.h"
 #include "../include/queue.h"
 #include "../include/ipc_gen.h"
 #include "../include/ipc_gen.h"
 #include "mainconfig.h"
 #include "mainconfig.h"
 #include "poll.h"
 #include "poll.h"
-#include "evs.h"
-#include "clm.h"
-#include "amf.h"
-#include "ckpt.h"
-#include "evt.h"
-#include "lck.h"
-#include "msg.h"
+#include "handlers.h"
 
 
 #ifndef AIS_EXEC_H_DEFINED
 #ifndef AIS_EXEC_H_DEFINED
 #define AIS_EXEC_H_DEFINED
 #define AIS_EXEC_H_DEFINED

+ 0 - 6
exec/mainconfig.c

@@ -88,7 +88,6 @@ char *strstr_rs (const char *haystack, const char *needle)
 	return (end_address);
 	return (end_address);
 }
 }
 
 
-#ifdef BUILD_DYNAMIC
 static void set_default_services(struct openais_config *config)
 static void set_default_services(struct openais_config *config)
 {
 {
 	config->dynamic_services[0].name = "openais_evs";
 	config->dynamic_services[0].name = "openais_evs";
@@ -135,7 +134,6 @@ static char *get_component(const char *line, int *version)
 
 
 	return compname;
 	return compname;
 }
 }
-#endif
 
 
 extern int openais_main_config_read (char **error_string,
 extern int openais_main_config_read (char **error_string,
     struct openais_config *openais_config,
     struct openais_config *openais_config,
@@ -284,7 +282,6 @@ extern int openais_main_config_read (char **error_string,
 			if ((loc = strstr_rs (line, "}"))) {
 			if ((loc = strstr_rs (line, "}"))) {
 				parse = MAIN_HEAD;
 				parse = MAIN_HEAD;
 			}
 			}
-#ifdef BUILD_DYNAMIC
 			else {
 			else {
 				int version;
 				int version;
 				char *name = get_component(line, &version);
 				char *name = get_component(line, &version);
@@ -294,7 +291,6 @@ extern int openais_main_config_read (char **error_string,
 					openais_config->num_dynamic_services++;
 					openais_config->num_dynamic_services++;
 				}
 				}
 			}
 			}
-#endif
 			break;
 			break;
 		default:
 		default:
 			assert (0 == 1); /* SHOULDN'T HAPPEN */
 			assert (0 == 1); /* SHOULDN'T HAPPEN */
@@ -307,12 +303,10 @@ extern int openais_main_config_read (char **error_string,
 		goto parse_error;
 		goto parse_error;
 	}
 	}
 
 
-#ifdef BUILD_DYNAMIC
 	/* Load default services if the config file doesn't specify */
 	/* Load default services if the config file doesn't specify */
 	if (!openais_config->num_dynamic_services) {
 	if (!openais_config->num_dynamic_services) {
 		set_default_services(openais_config);
 		set_default_services(openais_config);
 	}
 	}
-#endif
 	if (parse == MAIN_HEAD) {
 	if (parse == MAIN_HEAD) {
 		fclose (fp);
 		fclose (fp);
 		return (0);
 		return (0);

+ 0 - 4
exec/mainconfig.h

@@ -44,7 +44,6 @@
 /*
 /*
  * All service handlers in the AIS
  * All service handlers in the AIS
  */
  */
-#ifdef BUILD_DYNAMIC
 struct dynamic_service {
 struct dynamic_service {
 	char *name;
 	char *name;
 	unsigned int ver;
 	unsigned int ver;
@@ -52,7 +51,6 @@ struct dynamic_service {
 	struct openais_service_handler_iface_ver0 *iface_ver0;
 	struct openais_service_handler_iface_ver0 *iface_ver0;
 };
 };
 #define MAX_DYNAMIC_SERVICES 128
 #define MAX_DYNAMIC_SERVICES 128
-#endif
 
 
 struct openais_config {
 struct openais_config {
 	/*
 	/*
@@ -73,10 +71,8 @@ struct openais_config {
 	unsigned int amf_enabled;
 	unsigned int amf_enabled;
 
 
 	struct totem_config totem_config;
 	struct totem_config totem_config;
-#ifdef BUILD_DYNAMIC
 	struct dynamic_service dynamic_services[MAX_DYNAMIC_SERVICES];
 	struct dynamic_service dynamic_services[MAX_DYNAMIC_SERVICES];
 	int num_dynamic_services;
 	int num_dynamic_services;
-#endif
 };
 };
 
 
 extern char *strstr_rs (const char *haystack, const char *needle);
 extern char *strstr_rs (const char *haystack, const char *needle);

+ 6 - 8
exec/msg.c

@@ -451,7 +451,6 @@ struct openais_service_handler msg_service_handler = {
 	.sync_abort			= msg_sync_abort
 	.sync_abort			= msg_sync_abort
 };
 };
 
 
-#ifdef BUILD_DYNAMIC
 struct openais_service_handler *msg_get_handler_ver0 (void);
 struct openais_service_handler *msg_get_handler_ver0 (void);
 
 
 struct openais_service_handler_iface_ver0 msg_service_handler_iface = {
 struct openais_service_handler_iface_ver0 msg_service_handler_iface = {
@@ -477,18 +476,17 @@ struct lcr_comp msg_comp_ver0 = {
 	.ifaces				= openais_msg_ver0
 	.ifaces				= openais_msg_ver0
 };
 };
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &msg_comp_ver0;
-	return (0);
-}
-
 struct openais_service_handler *msg_get_handler_ver0 (void)
 struct openais_service_handler *msg_get_handler_ver0 (void)
 {
 {
 	return (&msg_service_handler);
 	return (&msg_service_handler);
 }
 }
 
 
-#endif /* BUILD_DYNAMIC */
+static void register_this_component (void) {
+	lcr_component_register (&msg_comp_ver0);
+}
+
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };
+
 /*
 /*
  * All data types used for executive messages
  * All data types used for executive messages
  */
  */

+ 0 - 44
exec/msg.h

@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2005 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "../include/saAis.h"
-#include "../include/saCkpt.h"
-#include "aispoll.h"
-#include "totemsrp.h"
-
-#ifndef MSG_H_DEFINED
-#define MSG_H_DEFINED
-
-extern struct openais_service_handler msg_service_handler;
-
-#endif /* MSG_H_DEFINED */

+ 5 - 5
exec/totemnet.c

@@ -807,8 +807,8 @@ static void timer_function_netif_check_timeout (
 	totemip_copy (&instance->my_id, &instance->totemnet_interface->boundto);
 	totemip_copy (&instance->my_id, &instance->totemnet_interface->boundto);
 
 
 	/*
 	/*
-	* This stuff depends on totemnet_build_sockets
-	*/
+	 * This stuff depends on totemnet_build_sockets
+	 */
 	if (interface_up) {
 	if (interface_up) {
 		if (instance->netif_state_report & NETIF_STATE_REPORT_UP) {
 		if (instance->netif_state_report & NETIF_STATE_REPORT_UP) {
 			instance->totemnet_log_printf (instance->totemnet_log_level_notice,
 			instance->totemnet_log_printf (instance->totemnet_log_level_notice,
@@ -960,7 +960,7 @@ static int totemnet_build_sockets_ipv4 (
 	totemip_totemip_to_sockaddr_convert(mcast_address, instance->totem_config->ip_port, &sockaddr, &addrlen);
 	totemip_totemip_to_sockaddr_convert(mcast_address, instance->totem_config->ip_port, &sockaddr, &addrlen);
 	res = bind (sockets->mcast_send, (struct sockaddr *)&sockaddr, addrlen);
 	res = bind (sockets->mcast_send, (struct sockaddr *)&sockaddr, addrlen);
 	if (res == -1) {
 	if (res == -1) {
-		perror ("bind failed");
+		instance->totemnet_log_printf (instance->totemnet_log_level_error, "Bind to mcast send socket failed (reason=%s)\n", strerror(errno));
 		return (-1);
 		return (-1);
 	}
 	}
 
 
@@ -1086,7 +1086,7 @@ static int totemnet_build_sockets_ipv6 (
 
 
 	res = bind (sockets->mcast_recv, (struct sockaddr *)&sockaddr, addrlen);
 	res = bind (sockets->mcast_recv, (struct sockaddr *)&sockaddr, addrlen);
 	if (res == -1) {
 	if (res == -1) {
-		perror ("bind failed");
+		instance->totemnet_log_printf (instance->totemnet_log_level_error, "Bind to mcast recv socket failed (reason=%s)\n", strerror(errno));
 		return (-1);
 		return (-1);
 	}
 	}
 
 
@@ -1227,7 +1227,7 @@ static int totemnet_build_sockets (
 	else {
 	else {
 		res = totemnet_build_sockets_ipv6 (instance, mcast_address,
 		res = totemnet_build_sockets_ipv6 (instance, mcast_address,
 			bindnet_address, sockets, bound_to, interface_up, interface_num);
 			bindnet_address, sockets, bound_to, interface_up, interface_num);
-}
+	}
 
 
 	/* We only send out of the token socket */
 	/* We only send out of the token socket */
 	totemnet_traffic_control_set(instance, sockets->token);
 	totemnet_traffic_control_set(instance, sockets->token);

+ 8 - 5
lcr/Makefile

@@ -22,12 +22,12 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 # THE POSSIBILITY OF SUCH DAMAGE.
 # THE POSSIBILITY OF SUCH DAMAGE.
 # Production mode flags
 # Production mode flags
-#CFLAGS = -O3 -Wall
-#LDFLAGS = 
+CFLAGS = -O3 -Wall -fomit-frame-pointer
+LDFLAGS = -rdynamic
 
 
 # Debug mode flags
 # Debug mode flags
-CFLAGS = -g -Wall
-LDFLAGS = -g -L./
+#CFLAGS = -g -Wall
+#LDFLAGS = -g -L./ -rdynamic
 
 
 # Profile mode flags
 # Profile mode flags
 #CFLAGS = -O3 -pg -DDEBUG
 #CFLAGS = -O3 -pg -DDEBUG
@@ -39,7 +39,7 @@ LDFLAGS = -g -L./
 
 
 LDFLAGS += -ldl
 LDFLAGS += -ldl
 
 
-all:liblcr.a test uic libtest_a.lcrso libtest_b.lcrso
+all:liblcr.a test test_static uic libtest_a.lcrso libtest_b.lcrso
 
 
 liblcr.a: lcr_ifact.o
 liblcr.a: lcr_ifact.o
 	$(AR) -rc liblcr.a lcr_ifact.o
 	$(AR) -rc liblcr.a lcr_ifact.o
@@ -53,6 +53,9 @@ libtest_b.lcrso: libtest_b.o
 test: test.o uis.o lcr_ifact.o
 test: test.o uis.o lcr_ifact.o
 	$(CC) $(LDFLAGS) test.o lcr_ifact.o uis.o -lpthread -ldl -o test
 	$(CC) $(LDFLAGS) test.o lcr_ifact.o uis.o -lpthread -ldl -o test
 	
 	
+test_static: test.o libtest_a.o libtest_b.o uis.o lcr_ifact.o
+	$(CC) $(LDFLAGS) test.o libtest_a.o libtest_b.o lcr_ifact.o -o test_static
+
 uic: uic.o
 uic: uic.o
 	$(CC) $(LDFLAGS) uic.o -o uic
 	$(CC) $(LDFLAGS) uic.o -o uic
 
 

+ 16 - 14
lcr/README.lcr

@@ -15,6 +15,10 @@ interface) may have multiple functions within the class.  Each interface may
 depend upon other interfaces, and those interfaces are then loaded prior to the
 depend upon other interfaces, and those interfaces are then loaded prior to the
 requested interface being referenced.
 requested interface being referenced.
 
 
+Note that with recent changes, the lcr interface factory can be used when
+statically linking without additional steps.  The interface for notifying
+lcr of a component has changed.
+
 A list of shared objects is scanned each time an interface is requested to
 A list of shared objects is scanned each time an interface is requested to
 load via the following interface:
 load via the following interface:
 
 
@@ -69,18 +73,17 @@ struct lcr_comp test_comp = {
 the iface count describes the number of interfaces within the component,
 the iface count describes the number of interfaces within the component,
 and lcr_ifaces is an array of pointers to lcr_iface data types.
 and lcr_ifaces is an array of pointers to lcr_iface data types.
 
 
-The final step is to export a function which tells the LCR referencing code
-about all of this static data that is setup:
+The lcr_comp_get method has been replaced.  The final step is to setup a
+constructor that is started when the task is started.  This ctor will
+register the component with the lcr framework.
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-        lcr_ifaces[0] = iface1_ver0;
-        lcr_ifaces[1] = iface1_ver1;
-        *component = &test_comp;
-        printf ("in lcr_comp_get for test component, address %p\n", &test_comp);
-        return (0);
+static void register_this_component (void) {
+        lcr_component_register (&test_comp);
 }
 }
 
 
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };
+
+
 Now the component can be referenced and used in another application.
 Now the component can be referenced and used in another application.
 int main ()
 int main ()
 {
 {
@@ -100,12 +103,11 @@ int main ()
 }
 }
 
 
 
 
-See libtest for a sample component and test.c for an example program which
-exercises the component.
+See libtest_a and libtest_b for two sample components.  The test program
+demonstrates usage.  The test_static demonstrates operation when statically
+linked.  Note the dynamic inteface factory is still available for use when
+statically linking components.
 
 
 On startup, a thread is created which listens for requests from the "uic" 
 On startup, a thread is created which listens for requests from the "uic" 
 application.  These requests are then processed by the lcr service which
 application.  These requests are then processed by the lcr service which
 would execute a live replacement.
 would execute a live replacement.
-
-There is alot of stuff which isn't done, and if you want to try out this code,
-you will have to modify the path to the dynamic library that is loaded.

+ 2 - 4
lcr/lcr_comp.h

@@ -53,9 +53,7 @@ struct lcr_comp {
 	struct lcr_iface *ifaces;	/* List of interfaces in this component */
 	struct lcr_iface *ifaces;	/* List of interfaces in this component */
 	int iface_count;		/* size of ifaces list */
 	int iface_count;		/* size of ifaces list */
 };
 };
-/*
- * Exported by the component to retrieve the component information
- */
-extern int lcr_comp_get (struct lcr_comp **component);
+
+extern void lcr_component_register (struct lcr_comp *comp);
 
 
 #endif /* LCR_COMP_H_DEFINED */
 #endif /* LCR_COMP_H_DEFINED */

+ 124 - 86
lcr/lcr_ifact.c

@@ -41,8 +41,8 @@ struct lcr_component_instance {
 	struct lcr_iface *ifaces;
 	struct lcr_iface *ifaces;
 	int iface_count;
 	int iface_count;
 	void *dl_handle;
 	void *dl_handle;
-	int (*lcr_comp_get) (struct lcr_comp **component);
 	int refcount;
 	int refcount;
+	char library_name[256];
 };
 };
 
 
 struct lcr_iface_instance {
 struct lcr_iface_instance {
@@ -63,6 +63,8 @@ static struct hdb_handle_database lcr_iface_instance_database = {
 	.iterator	= 0
 	.iterator	= 0
 };
 };
 
 
+static unsigned int g_component_handle;
+
 static int lcr_select_so (const struct dirent *dirent)
 static int lcr_select_so (const struct dirent *dirent)
 {
 {
 	unsigned int len;
 	unsigned int len;
@@ -77,29 +79,14 @@ static int lcr_select_so (const struct dirent *dirent)
 	return (0);
 	return (0);
 }
 }
 
 
-int lcr_ifact_reference (
-	unsigned int *iface_handle,
+static inline struct lcr_component_instance *lcr_comp_find (
 	char *iface_name,
 	char *iface_name,
-	int version,
-	void **iface,
-	void *context)
+	unsigned int version,
+	int *iface_number)
 {
 {
 	struct lcr_component_instance *instance;
 	struct lcr_component_instance *instance;
-	struct lcr_component_instance new_component;
-	struct lcr_iface_instance *iface_instance;
-	int found = 0;
-	int i;
-	int res = -1;
-	struct lcr_comp *comp;
 	unsigned int component_handle;
 	unsigned int component_handle;
-	struct dirent **scandir_list;
-	int scandir_entries;
-	unsigned int libs_to_scan;
-	char cwd[512];
-	char dl_name[1024];
-
-	getcwd (cwd, sizeof (cwd));
-	strcat (cwd, "/");
+	int i;
 
 
 	/*
 	/*
 	 * Try to find interface in already loaded component
 	 * Try to find interface in already loaded component
@@ -112,98 +99,131 @@ int lcr_ifact_reference (
 			if ((strcmp (instance->ifaces[i].name, iface_name) == 0) &&
 			if ((strcmp (instance->ifaces[i].name, iface_name) == 0) &&
 				instance->ifaces[i].version == version) {
 				instance->ifaces[i].version == version) {
 
 
-				found = 1;
-				goto found;
+				*iface_number = i;
+				return (instance);
 			}
 			}
 		}
 		}
 		hdb_handle_put (&lcr_component_instance_database, component_handle);
 		hdb_handle_put (&lcr_component_instance_database, component_handle);
 	}
 	}
 
 
+	return (NULL);
+}
+
+static inline int lcr_lib_loaded (
+	char *library_name)
+{
+	struct lcr_component_instance *instance;
+	unsigned int component_handle;
+
+	/*
+	 * Try to find interface in already loaded component
+	 */
+	hdb_iterator_reset (&lcr_component_instance_database);
+	while (hdb_iterator_next (&lcr_component_instance_database,
+		(void **)&instance, &component_handle) == 0) {
+
+		if (strcmp (instance->library_name, library_name) == 0) {
+			return (1);
+		}
+
+		hdb_handle_put (&lcr_component_instance_database, component_handle);
+	}
+
+	return (0);
+}
+
+int lcr_ifact_reference (
+	unsigned int *iface_handle,
+	char *iface_name,
+	int version,
+	void **iface,
+	void *context)
+{
+	void *dl_handle;
+	struct lcr_iface_instance *iface_instance;
+	struct lcr_component_instance *instance;
+	int iface_number;
+	struct dirent **scandir_list;
+	int scandir_entries;
+	unsigned int libs_to_scan;
+	char cwd[512];
+	char dl_name[1024];
+
+	getcwd (cwd, sizeof (cwd));
+	strcat (cwd, "/");
+
+	/*
+	 * Determine if the component is already loaded
+	 */
+	instance = lcr_comp_find (iface_name, version, &iface_number);
+	if (instance) {
+		goto found;
+	}
+
 // TODO error checking in this code is weak
 // TODO error checking in this code is weak
 	/*
 	/*
 	 * Find all *.lcrso files in the cwd
 	 * Find all *.lcrso files in the cwd
 	 */
 	 */
 	scandir_entries = scandir(".", &scandir_list, lcr_select_so, alphasort);
 	scandir_entries = scandir(".", &scandir_list, lcr_select_so, alphasort);
 	if (scandir_entries < 0)
 	if (scandir_entries < 0)
-		printf ("ERROR %d\n", errno);
+		printf ("scandir error reason=%d\n", strerror (errno));
 	else
 	else
 	/*
 	/*
-	 * ELSE do the job
+	 * no error so load the object
 	 */
 	 */
 	for (libs_to_scan = 0; libs_to_scan < scandir_entries; libs_to_scan++) {
 	for (libs_to_scan = 0; libs_to_scan < scandir_entries; libs_to_scan++) {
-
-	/*
-	 * Load objects, scan them, unload them if they are not a match
-	 */
-	fflush (stdout);
-	sprintf (dl_name, "%s%s", cwd, scandir_list[libs_to_scan]->d_name);
-	new_component.dl_handle =
-		dlopen (dl_name, RTLD_NOW);
-	if (new_component.dl_handle == 0) {
-		printf ("Error loading interface %s\n", dlerror());
-		return (-1);
-	}
-	new_component.lcr_comp_get =
-		dlsym (new_component.dl_handle, "lcr_comp_get");
-	if (new_component.lcr_comp_get == 0) {
-		printf ("Error linking interface %s\n", dlerror());
-		return (-1);
-	}
-	res = new_component.lcr_comp_get (&comp);
-	new_component.ifaces = comp->ifaces;
-	new_component.iface_count = comp->iface_count;
-
-	/*
-	 * Search loaded component for matching interface
-	 */
-	for (i = 0; i < new_component.iface_count; i++) {
-		if ((strcmp (new_component.ifaces[i].name, iface_name) == 0) &&
-			new_component.ifaces[i].version == version) {
-
-			hdb_handle_create (&lcr_component_instance_database,
-				sizeof (struct lcr_component_instance),
-				&component_handle);
-			hdb_handle_get (&lcr_component_instance_database,
-				component_handle, (void *)&instance);
-			memcpy (instance, &new_component,
-				sizeof (struct lcr_component_instance));
-	  
-//			printf("Found interface %s ver %d in dynamically loaded object %s\n", iface_name, version, dl_name);
-			found = 1;
-			free(scandir_list[libs_to_scan]);
+		/*
+		 * Load objects, scan them, unload them if they are not a match
+		 */
+		sprintf (dl_name, "%s%s", cwd, scandir_list[libs_to_scan]->d_name);
+		/*
+	 	 * Don't reload already loaded libraries
+		 */
+		if (lcr_lib_loaded (dl_name)) {
+			continue;
+		}
+		dl_handle = dlopen (dl_name, RTLD_NOW);
+		if (dl_handle == NULL) {
+			printf ("Error loading interface %s reason=%s\n", dl_name, dlerror());
+			return (-1);
+		}
+		instance = lcr_comp_find (iface_name, version, &iface_number);
+		if (instance) {
+			instance->dl_handle = dl_handle;
+			strcpy (instance->library_name, dl_name);
 			goto found;
 			goto found;
 		}
 		}
-	}
 
 
-	/*
-	 * No matching interfaces found, try next shared object
-	 */
-	dlclose (new_component.dl_handle);
-	} /* scanning for loop */
+		/*
+		 * No matching interfaces found, try next shared object
+		 */
+		if (g_component_handle != 0xFFFFFFFF) {
+			hdb_handle_destroy (&lcr_component_instance_database,
+				g_component_handle);
+			g_component_handle = 0xFFFFFFFF;
+		}
+		dlclose (dl_handle);
+	} /* scanning for lcrso loop */
 
 
 	/*
 	/*
 	 * No matching interfaces found in all shared objects
 	 * No matching interfaces found in all shared objects
 	 */
 	 */
 	return (-1);
 	return (-1);
 found:
 found:
-
-	if (found) {
-		*iface = instance->ifaces[i].interfaces;
-		if (instance->ifaces[i].constructor) {
-			instance->ifaces[i].constructor (context);
-		}
-		hdb_handle_create (&lcr_iface_instance_database,
-			sizeof (struct lcr_iface_instance),
-			iface_handle);
-		hdb_handle_get (&lcr_iface_instance_database,
-			*iface_handle, (void *)&iface_instance);
-		iface_instance->component_handle = component_handle;
-		iface_instance->context = context;
-		iface_instance->destructor = instance->ifaces[i].destructor;
-		res = 0;
+	*iface = instance->ifaces[iface_number].interfaces;
+	if (instance->ifaces[iface_number].constructor) {
+		instance->ifaces[iface_number].constructor (context);
 	}
 	}
+	hdb_handle_create (&lcr_iface_instance_database,
+		sizeof (struct lcr_iface_instance),
+		iface_handle);
+	hdb_handle_get (&lcr_iface_instance_database,
+		*iface_handle, (void *)&iface_instance);
+	iface_instance->component_handle = g_component_handle;
+	iface_instance->context = context;
+	iface_instance->destructor = instance->ifaces[iface_number].destructor;
 
 
-	return res;
+	return (0);
 }
 }
 
 
 int lcr_ifact_release (unsigned int handle)
 int lcr_ifact_release (unsigned int handle)
@@ -226,3 +246,21 @@ int lcr_ifact_release (unsigned int handle)
 
 
 	return (res);
 	return (res);
 }
 }
+
+void lcr_component_register (struct lcr_comp *comp)
+{
+	struct lcr_component_instance *instance;
+
+	hdb_handle_create (&lcr_component_instance_database,
+		sizeof (struct lcr_component_instance),
+		&g_component_handle);
+	hdb_handle_get (&lcr_component_instance_database,
+		g_component_handle, (void *)&instance);
+
+	instance->ifaces = comp->ifaces;
+	instance->iface_count = comp->iface_count;
+	instance->dl_handle = NULL;
+
+	hdb_handle_put (&lcr_component_instance_database,
+		g_component_handle);
+}

+ 30 - 32
lcr/libtest_a.c

@@ -33,28 +33,28 @@
 /*
 /*
  * Version 0 of the interface
  * Version 0 of the interface
  */
  */
-int iface1_constructor (void *context);
+static int iface1_constructor (void *context);
 
 
-int iface1_destructor (void *context);
+static void iface1_destructor (void *context);
 
 
-void iface1_func1 (void);
+static void iface1_func1 (void);
 
 
-void iface1_func2 (void);
+static void iface1_func2 (void);
 
 
-void iface1_func3 (void);
+static void iface1_func3 (void);
 
 
 /*
 /*
  * Version 1 of the interface
  * Version 1 of the interface
  */
  */
-int iface1_ver1_constructor (void *context);
+static int iface1_ver1_constructor (void *context);
 
 
-int iface1_ver1_destructor (void *context);
+static void iface1_ver1_destructor (void *context);
 
 
-void iface1_ver1_func1 (void);
+static void iface1_ver1_func1 (void);
 
 
-void iface1_ver1_func2 (void);
+static void iface1_ver1_func2 (void);
 
 
-void iface1_ver1_func3 (void);
+static void iface1_ver1_func3 (void);
 
 
 struct iface_list {
 struct iface_list {
 	void (*iface1_func1)(void);
 	void (*iface1_func1)(void);
@@ -68,19 +68,19 @@ struct iface_ver1_list {
 	void (*iface1_ver1_func3)(void);
 	void (*iface1_ver1_func3)(void);
 };
 };
 
 
-struct iface_list iface_list = {
+static struct iface_list iface_list = {
 	.iface1_func1		= iface1_func1,
 	.iface1_func1		= iface1_func1,
 	.iface1_func2		= iface1_func2,
 	.iface1_func2		= iface1_func2,
 	.iface1_func3		= iface1_func3,
 	.iface1_func3		= iface1_func3,
 };
 };
 
 
-struct iface_list iface_ver1_list = {
+static struct iface_list iface_ver1_list = {
 	.iface1_func1		= iface1_ver1_func1,
 	.iface1_func1		= iface1_ver1_func1,
 	.iface1_func2		= iface1_ver1_func2,
 	.iface1_func2		= iface1_ver1_func2,
 	.iface1_func3		= iface1_ver1_func3,
 	.iface1_func3		= iface1_ver1_func3,
 };
 };
 
 
-struct lcr_iface iface1[2] = {
+static struct lcr_iface iface1[2] = {
 	/* version 0 */
 	/* version 0 */
 	{
 	{
 		.name			= "A_iface1",
 		.name			= "A_iface1",
@@ -107,59 +107,57 @@ struct lcr_iface iface1[2] = {
 	}
 	}
 };
 };
 
 
-struct lcr_comp test_comp = {
+static struct lcr_comp test_comp = {
 	.iface_count 		= 2,
 	.iface_count 		= 2,
 	.ifaces 		= iface1
 	.ifaces 		= iface1
 };
 };
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &test_comp;
-	return (0);
-}
-
-int iface1_constructor (void *context)
+static int iface1_constructor (void *context)
 {
 {
 	printf ("A - version 0 constructor context %p\n", context);
 	printf ("A - version 0 constructor context %p\n", context);
 	return (0);
 	return (0);
 }
 }
 
 
-int iface1_destructor (void *context)
+static void iface1_destructor (void *context)
 {
 {
 	printf ("A - version 0 destructor context %p\n", context);
 	printf ("A - version 0 destructor context %p\n", context);
-	return (0);
 }
 }
-void iface1_func1 (void) {
+static void iface1_func1 (void) {
 	printf ("A - version 0 func1\n");
 	printf ("A - version 0 func1\n");
 }
 }
 
 
-void iface1_func2 (void) {
+static void iface1_func2 (void) {
 	printf ("A - version 0 func2\n");
 	printf ("A - version 0 func2\n");
 }
 }
 
 
-void iface1_func3 (void) {
+static void iface1_func3 (void) {
 	printf ("A - version 0 func3\n");
 	printf ("A - version 0 func3\n");
 }
 }
 
 
-int iface1_ver1_constructor (void *context)
+static int iface1_ver1_constructor (void *context)
 {
 {
 	printf ("A - version 1 constructor context %p\n", context);
 	printf ("A - version 1 constructor context %p\n", context);
 	return (0);
 	return (0);
 }
 }
 
 
-int iface1_ver1_destructor (void *context)
+static void iface1_ver1_destructor (void *context)
 {
 {
 	printf ("A - version 1 destructor context %p\n", context);
 	printf ("A - version 1 destructor context %p\n", context);
-	return (0);
 }
 }
-void iface1_ver1_func1 (void) {
+static void iface1_ver1_func1 (void) {
 	printf ("A - version 1 func1\n");
 	printf ("A - version 1 func1\n");
 }
 }
 
 
-void iface1_ver1_func2 (void) {
+static void iface1_ver1_func2 (void) {
 	printf ("A - version 1 func2\n");
 	printf ("A - version 1 func2\n");
 }
 }
 
 
-void iface1_ver1_func3 (void) {
+static void iface1_ver1_func3 (void) {
 	printf ("A - version 1 func3\n");
 	printf ("A - version 1 func3\n");
 }
 }
+
+static void register_this_component (void) {
+	lcr_component_register (&test_comp);
+}
+
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };

+ 30 - 28
lcr/libtest_b.c

@@ -33,28 +33,28 @@
 /*
 /*
  * Version 0 of the interface
  * Version 0 of the interface
  */
  */
-int iface1_constructor (void *context);
+static int iface1_constructor (void *context);
 
 
-int iface1_destructor (void *context);
+static void iface1_destructor (void *context);
 
 
-void iface1_func1 (void);
+static void iface1_func1 (void);
 
 
-void iface1_func2 (void);
+static void iface1_func2 (void);
 
 
-void iface1_func3 (void);
+static void iface1_func3 (void);
 
 
 /*
 /*
  * Version 1 of the interface
  * Version 1 of the interface
  */
  */
-int iface1_ver1_constructor (void *context);
+static int iface1_ver1_constructor (void *context);
 
 
-int iface1_ver1_destructor (void *context);
+static void iface1_ver1_destructor (void *context);
 
 
-void iface1_ver1_func1 (void);
+static void iface1_ver1_func1 (void);
 
 
-void iface1_ver1_func2 (void);
+static void iface1_ver1_func2 (void);
 
 
-void iface1_ver1_func3 (void);
+static void iface1_ver1_func3 (void);
 
 
 struct iface_list {
 struct iface_list {
 	void (*iface1_func1)(void);
 	void (*iface1_func1)(void);
@@ -116,54 +116,56 @@ struct lcr_comp test_comp = {
 	.ifaces 		= iface1
 	.ifaces 		= iface1
 };
 };
 
 
-extern int lcr_comp_get (struct lcr_comp **component)
-{
-	*component = &test_comp;
-	return (0);
-}
-
-int iface1_constructor (void *context)
+static int iface1_constructor (void *context)
 {
 {
 	printf ("B - version 0 constructor context %p\n", context);
 	printf ("B - version 0 constructor context %p\n", context);
 	return (0);
 	return (0);
 }
 }
 
 
-int iface1_destructor (void *context)
+static void iface1_destructor (void *context)
 {
 {
 	printf ("B - version 0 destructor context %p\n", context);
 	printf ("B - version 0 destructor context %p\n", context);
-	return (0);
 }
 }
-void iface1_func1 (void) {
+
+static void iface1_func1 (void) {
 	printf ("B - version 0 func1\n");
 	printf ("B - version 0 func1\n");
 }
 }
 
 
-void iface1_func2 (void) {
+static void iface1_func2 (void) {
 	printf ("B - version 0 func2\n");
 	printf ("B - version 0 func2\n");
 }
 }
 
 
-void iface1_func3 (void) {
+static void iface1_func3 (void) {
 	printf ("B - version 0 func3\n");
 	printf ("B - version 0 func3\n");
 }
 }
 
 
-int iface1_ver1_constructor (void *context)
+static int iface1_ver1_constructor (void *context)
 {
 {
 	printf ("B - version 1 constructor context %p\n", context);
 	printf ("B - version 1 constructor context %p\n", context);
 	return (0);
 	return (0);
 }
 }
 
 
-int iface1_ver1_destructor (void *context)
+static void iface1_ver1_destructor (void *context)
 {
 {
 	printf ("B - version 1 destructor context %p\n", context);
 	printf ("B - version 1 destructor context %p\n", context);
-	return (0);
 }
 }
-void iface1_ver1_func1 (void) {
+
+static void iface1_ver1_func1 (void) {
 	printf ("B - version 1 func1\n");
 	printf ("B - version 1 func1\n");
 }
 }
 
 
-void iface1_ver1_func2 (void) {
+static void iface1_ver1_func2 (void) {
 	printf ("B - version 1 func2\n");
 	printf ("B - version 1 func2\n");
 }
 }
 
 
-void iface1_ver1_func3 (void) {
+static void iface1_ver1_func3 (void) {
 	printf ("B - version 1 func3\n");
 	printf ("B - version 1 func3\n");
 }
 }
+
+static void register_this_component (void)
+{
+	lcr_component_register (&test_comp);
+}
+
+static void (*const __init_this_component[1]) (void) __attribute__ ((section(".ctors"))) = { register_this_component };
+

+ 1 - 1
lcr/test.c

@@ -62,7 +62,7 @@ int main (void) {
 		"B_iface1",
 		"B_iface1",
 		0, /* version 0 */
 		0, /* version 0 */
 		(void **)&b_iface_ver0,
 		(void **)&b_iface_ver0,
-		(void *)0xbbbb00000);
+		(void *)0xbbbb0000);
 
 
 	lcr_ifact_reference (
 	lcr_ifact_reference (
 		&a_ifact_handle_ver1,
 		&a_ifact_handle_ver1,