[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libvir] [PATCH] 1/2: Move safewrite and saferead to a separate file.



On Fri, Feb 22, 2008 at 02:58:36PM +0100, Jim Meyering wrote:
> Move safewrite and saferead to a separate file.
> 
> We currently use safewrite from inside libvirt and don't want to publish
> any such function name.  However, we do want to use it in applications
> like virsh, libvirtd and libvirt_proxy that link with libvirt.  To that
> end, this change moves that function definition (along with the nearly
> identical saferead) into a new file, util-lib.c.  To avoid maintaining
> separate copies of even such small functions, we simply include that new
> file from util.c.  Then, the separate applications that need to use
> safewrite simply compile and link with util-lib.c.

  I realized this morning that as is this didn't worked well if virsh
was compiled against a static version of the library, since the function
would be redefined and an error shows up at link time. The enclosed patch
is the simplest we could find with Jim to solve the issue, it just renames
the safe function when compiled inside the library,

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/
Index: src/Makefile.am
===================================================================
RCS file: /data/cvs/libxen/src/Makefile.am,v
retrieving revision 1.69
diff -p -r1.69 Makefile.am
*** src/Makefile.am	22 Feb 2008 15:53:13 -0000	1.69
--- src/Makefile.am	25 Feb 2008 08:34:36 -0000
*************** libvirt_la_LDFLAGS = -Wl,--version-scrip
*** 96,102 ****
                       -version-info @LIBVIRT_VERSION_INFO@ \
                      $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
  		    @CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
! libvirt_la_CFLAGS = $(COVERAGE_CFLAGS)
  
  bin_PROGRAMS = virsh
  
--- 96,102 ----
                       -version-info @LIBVIRT_VERSION_INFO@ \
                      $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
  		    @CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
! libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
  
  bin_PROGRAMS = virsh
  
Index: src/util-lib.h
===================================================================
RCS file: /data/cvs/libxen/src/util-lib.h,v
retrieving revision 1.1
diff -p -r1.1 util-lib.h
*** src/util-lib.h	22 Feb 2008 15:53:13 -0000	1.1
--- src/util-lib.h	25 Feb 2008 08:34:36 -0000
***************
*** 10,15 ****
--- 10,24 ----
  
  #include <sys/types.h>
  
+ /*
+  * To avoid a double definition of the function when compiling
+  * programs using both util-lib and libvirt, like virsh
+  */
+ #ifdef IN_LIBVIRT
+ #define saferead libvirt_saferead
+ #define safewrite libvirt_safewrite
+ #endif
+ 
  int saferead(int fd, void *buf, size_t count);
  ssize_t safewrite(int fd, const void *buf, size_t count);
  

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]