[Openais] [patch 1/1] Expose util.{c, h} as a shared library and public header

Steven Dake sdake at redhat.com
Sun Sep 9 00:08:57 PDT 2007


merged

regards
-steve
On Tue, 2007-08-28 at 09:42 +0200, beekhof at gmail.com wrote:
> plain text document attachment (expose-utils.patch)
> Needed for plugins to be built outside the openais source tree
> 
> Requires: Makefile-loops.patch, headers.patch
> 
> ---
>  Makefile                |    5 -
>  exec/ipc.c              |    4 -
>  include/ais_util.h      |  137 +++++++++++++++++++++++++++++++++++++++++++
>  lib/Makefile            |   24 +++++--
>  lib/amf.c               |    2 
>  lib/cfg.c               |    2 
>  lib/ckpt.c              |    2 
>  lib/clm.c               |    2 
>  lib/cpg.c               |    2 
>  lib/evs.c               |    2 
>  lib/evt.c               |    2 
>  lib/lck.c               |    2 
>  lib/libaisutil.versions |   18 +++++
>  lib/msg.c               |    2 
>  lib/util.c              |    2 
>  lib/util.h              |  151 ------------------------------------------------
>  16 files changed, 188 insertions(+), 171 deletions(-)
> 
> Index: Makefile
> ===================================================================
> --- Makefile.orig	2007-08-23 22:03:31.000000000 +0200
> +++ Makefile	2007-08-28 09:36:48.000000000 +0200
> @@ -71,10 +71,11 @@ clean:
>  	rm -rf doc/api
>  
>  AIS_LIBS	= ais SaAmf SaClm SaCkpt SaEvt SaLck SaMsg evs cpg \
> -		  cfg
> +		  cfg aisutil
>  
>  AIS_HEADERS	= saAis.h saAmf.h saClm.h saCkpt.h saEvt.h saEvt.h saLck.h \
> -		  saMsg.h cpg.h cfg.h evs.h ipc_gen.h mar_gen.h swab.h 
> +		  saMsg.h cpg.h cfg.h evs.h ipc_gen.h mar_gen.h swab.h 	   \
> +		  ais_util.h
>  
>  install: all
>  	mkdir -p $(DESTDIR)$(SBINDIR)
> Index: exec/ipc.c
> ===================================================================
> --- exec/ipc.c.orig	2007-08-27 15:50:23.000000000 +0200
> +++ exec/ipc.c	2007-08-27 15:50:46.000000000 +0200
> @@ -381,7 +381,9 @@ static void conn_info_destroy (struct co
>  	free (conn_info);
>  }
>  
> -static int libais_connection_active (struct conn_info *conn_info)
> +int libais_connection_active (struct conn_info *conn_info);
> +
> +int libais_connection_active (struct conn_info *conn_info)
>  {
>  	return (conn_info->state == CONN_STATE_ACTIVE);
>  }
> Index: include/ais_util.h
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ include/ais_util.h	2007-08-23 22:03:32.000000000 +0200
> @@ -0,0 +1,137 @@
> +/*
> + * Copyright (c) 2002-2005 MontaVista Software, Inc.
> + *
> + * All rights reserved.
> + *
> + * Author: Steven Dake (sdake at 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.
> + */
> +#ifndef AIS_UTIL_H_DEFINED
> +#define AIS_UTIL_H_DEFINED
> +
> +#include <pthread.h>
> +#include <sys/poll.h>
> +#include <sys/socket.h>
> +
> +#include <ipc_gen.h>
> +
> +/* Debug macro
> + */
> +#ifdef DEBUG
> +	#define DPRINT(s) printf s
> +#else
> +	#define DPRINT(s)
> +#endif
> +		
> +#ifdef SO_NOSIGPIPE
> +#ifndef MSG_NOSIGNAL
> +#define MSG_NOSIGNAL 0
> +#endif
> +void socket_nosigpipe(int s);
> +#else
> +#define socket_nosigpipe(s)
> +#endif
> +
> +struct saHandleDatabase {
> +	unsigned int handleCount;
> +	struct saHandle *handles;
> +	pthread_mutex_t mutex;
> +	void (*handleInstanceDestructor) (void *);
> +};
> +
> +
> +struct saVersionDatabase {
> +	int versionCount;
> +	SaVersionT *versionsSupported;
> +};
> +
> +SaAisErrorT saSendMsgRetry (
> +	int s,
> +	struct iovec *iov,
> +	int iov_len);
> +
> +SaAisErrorT saSendMsgReceiveReply (
> +	int s,
> +	struct iovec *iov,
> +	int iov_len,
> +	void *responseMessage,
> +	int responseLen);
> +
> +SaAisErrorT saSendReceiveReply (
> +	int s,
> +	void *requestMessage,
> +	int requestLen,
> +	void *responseMessage,
> +	int responseLen);
> +
> +SaAisErrorT
> +saPollRetry (
> +	struct pollfd *ufds,
> +	unsigned int nfds,
> +	int timeout);
> +
> +SaAisErrorT
> +saHandleCreate (
> +	struct saHandleDatabase *handleDatabase,
> +	int instanceSize,
> +	SaUint64T *handleOut);
> +
> +SaAisErrorT
> +saHandleDestroy (
> +	struct saHandleDatabase *handleDatabase,
> +	SaUint64T handle);
> +
> +SaAisErrorT
> +saHandleInstanceGet (
> +	struct saHandleDatabase *handleDatabase,
> +	SaUint64T handle,
> +	void **instance);
> +
> +SaAisErrorT
> +saHandleInstancePut (
> +	struct saHandleDatabase *handleDatabase,
> +	SaUint64T handle);
> +
> +SaAisErrorT
> +saVersionVerify (
> +	struct saVersionDatabase *versionDatabase,
> +	SaVersionT *version);
> +
> +#define offset_of(type,member) (int)(&(((type *)0)->member))
> +
> +SaTimeT
> +clustTimeNow(void);
> +
> +extern SaAisErrorT saServiceConnect (
> +    int *responseOut, int *callbackOut, enum service_types service);
> +
> +extern SaAisErrorT saRecvRetry (int s, void *msg, size_t len);
> +
> +extern SaAisErrorT saSendRetry (int s, const void *msg, size_t len);
> +
> +#endif /* AIS_UTIL_H_DEFINED */
> Index: lib/Makefile
> ===================================================================
> --- lib/Makefile.orig	2007-08-23 22:03:31.000000000 +0200
> +++ lib/Makefile	2007-08-24 23:06:25.000000000 +0200
> @@ -44,7 +44,8 @@ all:libSaClm.a libSaClm.so.2.0.0 \
>  	libcpg.a libcpg.so.2.0.0 \
>  	libais.a libais.so.2.0.0 \
>  	libevs.a libevs.so.2.0.0 \
> -	libcfg.a libcfg.so.2.0.0
> +	libcfg.a libcfg.so.2.0.0 \
> +	libaisutil.a libaisutil.so.2.0.0
>  
>  LIBAIS_SRC = util.c amf.c clm.c ckpt.c evt.c
>  
> @@ -53,8 +54,14 @@ LIBEVS_SRC = util.c evs.c
>  libSaClm.a: util.o clm.o
>  	$(AR) -rc libSaClm.a util.o clm.o
>  
> +libaisutil.a: util.o
> +	$(AR) -rc libaisutil.a util.o
> +
>  ifeq (${OPENAIS_COMPAT}, DARWIN)
>  
> +libaisutil.so.2.0.0: util.o
> +	$(CC) $(LDFLAGS) -bundle -bind_at_load util.o -o $@
> +
>  libSaClm.so.2.0.0: util.o clm.o
>  	$(CC) $(LDFLAGS) -bundle -bind_at_load util.o clm.o -o $@
>  
> @@ -87,6 +94,9 @@ libcfg.so.2.0.0: util.o cfg.o
>  
>  else
>  
> +libaisutil.so.2.0.0: util.o
> +	$(CC) $(LDFLAGS) -shared -Wl,-soname,libaisutil.so.2,-version-script=libaisutil.versions util.o -o $@
> +
>  libSaClm.so.2.0.0: util.o clm.o
>  	$(CC) $(LDFLAGS) -shared -Wl,-soname,libSaClm.so.2,-version-script=libSaClm.versions util.o clm.o -o $@
>  
> @@ -160,19 +170,19 @@ depend:
>  	makedepend -Y -- $(CFLAGS) $(CPPFLAGS) $(LIBAIS_SRC) > /dev/null 2>&1
>  # DO NOT DELETE
>  
> -util.o: ../include/saAis.h ../include/ipc_gen.h ../exec/totemip.h util.h
> +util.o: ../include/saAis.h ../include/ipc_gen.h ../exec/totemip.h ../include/ais_util.h
>  amf.o: ../include/saAis.h ../include/saAmf.h ../include/saAis.h
>  amf.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_amf.h
> -amf.o: ../include/ipc_gen.h ../include/saAmf.h util.h
> +amf.o: ../include/ipc_gen.h ../include/saAmf.h ../include/ais_util.h
>  clm.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
>  clm.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_clm.h
> -clm.o: ../include/saClm.h ../include/ipc_gen.h util.h
> +clm.o: ../include/saClm.h ../include/ipc_gen.h ../include/ais_util.h
>  ckpt.o: ../include/saAis.h ../include/list.h ../include/saCkpt.h
>  ckpt.o: ../include/ipc_gen.h ../exec/totemip.h ../include/ipc_ckpt.h
> -ckpt.o: ../include/saAis.h ../include/saCkpt.h ../include/ipc_gen.h util.h
> +ckpt.o: ../include/saAis.h ../include/saCkpt.h ../include/ipc_gen.h ../include/ais_util.h
>  evt.o: ../include/ipc_evt.h ../include/saAis.h ../include/saEvt.h
> -evt.o: ../include/saClm.h ../include/ipc_gen.h util.h ../include/ipc_gen.h
> +evt.o: ../include/saClm.h ../include/ipc_gen.h ../include/ais_util.h ../include/ipc_gen.h
>  evt.o: ../exec/totemip.h ../exec/totem.h ../exec/totemip.h ../include/list.h
>  cpg.o: ../include/saAis.h ../include/ipc_gen.h ../exec/totemip.h
>  cpg.o: ../include/ipc_cpg.h ../include/saAis.h ../include/saClm.h
> -cpg.o: ../include/ipc_gen.h util.h
> +cpg.o: ../include/ipc_gen.h ../include/ais_util.h
> Index: lib/amf.c
> ===================================================================
> --- lib/amf.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/amf.c	2007-08-23 22:03:32.000000000 +0200
> @@ -49,7 +49,7 @@
>  #include <saAmf.h>
>  #include <ipc_gen.h>
>  #include <ipc_amf.h>
> -#include "util.h"
> +#include <ais_util.h>
>  
> 
>  struct res_overlay {
> Index: lib/cfg.c
> ===================================================================
> --- lib/cfg.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/cfg.c	2007-08-23 22:03:32.000000000 +0200
> @@ -51,7 +51,7 @@
>  #include <mar_gen.h>
>  #include <ipc_gen.h>
>  #include <ipc_cfg.h>
> -#include "util.h"
> +#include <ais_util.h>
>  
>  struct res_overlay {
>  	mar_res_header_t header;
> Index: lib/ckpt.c
> ===================================================================
> --- lib/ckpt.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/ckpt.c	2007-08-23 22:03:32.000000000 +0200
> @@ -54,7 +54,7 @@
>  #include <ipc_gen.h>
>  #include <ipc_ckpt.h>
>  
> -#include "util.h"
> +#include <ais_util.h>
>  
>  struct message_overlay {
>  	mar_res_header_t header __attribute__((aligned(8)));
> Index: lib/clm.c
> ===================================================================
> --- lib/clm.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/clm.c	2007-08-23 22:03:32.000000000 +0200
> @@ -54,7 +54,7 @@
>  #include <mar_gen.h>
>  #include <mar_clm.h>
>  
> -#include "util.h"
> +#include <ais_util.h>
>  
>  struct res_overlay {
>  	mar_res_header_t header;
> Index: lib/cpg.c
> ===================================================================
> --- lib/cpg.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/cpg.c	2007-08-23 22:03:32.000000000 +0200
> @@ -49,7 +49,7 @@
>  #include <cpg.h>
>  #include <ipc_cpg.h>
>  #include <mar_cpg.h>
> -#include "util.h"
> +#include <ais_util.h>
>  
>  struct cpg_inst {
>  	int response_fd;
> Index: lib/evs.c
> ===================================================================
> --- lib/evs.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/evs.c	2007-08-23 22:03:32.000000000 +0200
> @@ -51,7 +51,7 @@
>  #include <saAis.h>
>  #include <evs.h>
>  #include <ipc_evs.h>
> -#include "util.h"
> +#include <ais_util.h>
>  
>  struct evs_inst {
>  	int response_fd;
> Index: lib/evt.c
> ===================================================================
> --- lib/evt.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/evt.c	2007-08-23 22:03:32.000000000 +0200
> @@ -40,7 +40,7 @@
>  #include <sys/time.h>
>  #include <sys/socket.h>
>  #include <ipc_evt.h>
> -#include "util.h"
> +#include <ais_util.h>
>  #include "../exec/totem.h"
>  #include <list.h>
>  
> Index: lib/lck.c
> ===================================================================
> --- lib/lck.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/lck.c	2007-08-23 22:03:32.000000000 +0200
> @@ -51,7 +51,7 @@
>  #include <ipc_gen.h>
>  #include <ipc_lck.h>
>  
> -#include "util.h"
> +#include <ais_util.h>
>  
>  struct message_overlay {
>  	mar_res_header_t header __attribute__((aligned(8)));
> Index: lib/libaisutil.versions
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ lib/libaisutil.versions	2007-08-24 23:08:14.000000000 +0200
> @@ -0,0 +1,18 @@
> +# Version and symbol export for libaisutil.so
> +
> +OPENAIS_UTIL_2.0 {
> +	global:
> +		saHandleCreate;
> +		saHandleDestroy;
> +		saHandleInstanceGet;
> +		saHandleInstancePut;
> +		saRecvRetry;
> +		saSelectRetry;
> +		saSendMsgReceiveReply;
> +		saSendMsgRetry;
> +		saSendReceiveReply;
> +		saSendRetry;
> +		saServiceConnect;
> +		saVersionVerify;
> +		clustTimeNow;
> +};
> Index: lib/msg.c
> ===================================================================
> --- lib/msg.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/msg.c	2007-08-23 22:03:32.000000000 +0200
> @@ -51,7 +51,7 @@
>  #include <ipc_gen.h>
>  #include <ipc_msg.h>
>  
> -#include "util.h"
> +#include <ais_util.h>
>  
>  struct message_overlay {
>  	mar_res_header_t header __attribute__((aligned(8)));
> Index: lib/util.c
> ===================================================================
> --- lib/util.c.orig	2007-08-23 22:03:32.000000000 +0200
> +++ lib/util.c	2007-08-23 22:03:32.000000000 +0200
> @@ -55,7 +55,7 @@
>  
>  #include <saAis.h>
>  #include <ipc_gen.h>
> -#include "util.h"
> +#include <ais_util.h>
>  
>  enum SA_HANDLE_STATE {
>  	SA_HANDLE_STATE_EMPTY,
> Index: lib/util.h
> ===================================================================
> --- lib/util.h	2007-08-24 08:09:49.000000000 +0200
> +++ /dev/null	1970-01-01 00:00:00.000000000 +0000
> @@ -1,151 +0,0 @@
> -
> -/*
> - * Copyright (c) 2002-2003 MontaVista Software, Inc.
> - *
> - * All rights reserved.
> - *
> - * Author: Steven Dake (sdake at 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.
> - */
> -
> -#ifndef AIS_UTIL_H_DEFINED
> -#define AIS_UTIL_H_DEFINED
> -
> -#include <pthread.h>
> -#include <sys/poll.h>
> -#include <sys/socket.h>
> -
> -#include "../include/ipc_gen.h"
> -
> -/* Debug macro
> - */
> -#ifdef DEBUG
> -	#define DPRINT(s) printf s
> -#else
> -	#define DPRINT(s)
> -#endif
> -		
> -#ifdef SO_NOSIGPIPE
> -#ifndef MSG_NOSIGNAL
> -#define MSG_NOSIGNAL 0
> -#endif
> -void socket_nosigpipe(int s);
> -#else
> -#define socket_nosigpipe(s)
> -#endif
> -
> -struct saHandleDatabase {
> -	unsigned int handleCount;
> -	struct saHandle *handles;
> -	pthread_mutex_t mutex;
> -	void (*handleInstanceDestructor) (void *);
> -};
> -
> -
> -struct saVersionDatabase {
> -	int versionCount;
> -	SaVersionT *versionsSupported;
> -};
> -
> -SaAisErrorT
> -saServiceConnect (
> -        int *responseOut,
> -        int *callbackOut,
> -        enum service_types service);
> -
> -SaAisErrorT
> -saRecvRetry (
> -	int s,
> -	void *msg,
> -	size_t len);
> -
> -SaAisErrorT
> -saSendRetry (
> -	int s,
> -	const void *msg,
> -	size_t len);
> -
> -SaAisErrorT saSendMsgRetry (
> -	int s,
> -	struct iovec *iov,
> -	int iov_len);
> -
> -SaAisErrorT saSendMsgReceiveReply (
> -	int s,
> -	struct iovec *iov,
> -	int iov_len,
> -	void *responseMessage,
> -	int responseLen);
> -
> -SaAisErrorT saSendReceiveReply (
> -	int s,
> -	void *requestMessage,
> -	int requestLen,
> -	void *responseMessage,
> -	int responseLen);
> -
> -SaAisErrorT
> -saPollRetry (
> -	struct pollfd *ufds,
> -	unsigned int nfds,
> -	int timeout);
> -
> -SaAisErrorT
> -saHandleCreate (
> -	struct saHandleDatabase *handleDatabase,
> -	int instanceSize,
> -	SaUint64T *handleOut);
> -
> -SaAisErrorT
> -saHandleDestroy (
> -	struct saHandleDatabase *handleDatabase,
> -	SaUint64T handle);
> -
> -SaAisErrorT
> -saHandleInstanceGet (
> -	struct saHandleDatabase *handleDatabase,
> -	SaUint64T handle,
> -	void **instance);
> -
> -SaAisErrorT
> -saHandleInstancePut (
> -	struct saHandleDatabase *handleDatabase,
> -	SaUint64T handle);
> -
> -SaAisErrorT
> -saVersionVerify (
> -	struct saVersionDatabase *versionDatabase,
> -	SaVersionT *version);
> -
> -#define offset_of(type,member) (int)(&(((type *)0)->member))
> -
> -SaTimeT
> -clustTimeNow(void);
> -
> -#endif /* AIS_UTIL_H_DEFINED */
> -
> 



More information about the Openais mailing list