Daniel P. Berrange
2015-Feb-09 13:10 UTC
Re: [Libguestfs] [PATCH 2/5] macosx: Add definition of program_name for gnulib
On Mon, Feb 09, 2015 at 11:06:16AM +0000, Margaret Lewicka wrote:> gnulib's error.c requires program_name to be externally defined > for !_LIBC systems. This defines program_name for Darwin only. > --- > configure.ac | 3 +++ > src/Makefile.am | 6 ++++++ > src/program_name.c | 4 ++++ > 3 files changed, 13 insertions(+) > create mode 100644 src/program_name.csrc/guestfs-internal-frontend.h has a #define to replace use of 'program_name' with something that is defined, so this should not be required unless the header includes are not right somewhere. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Margaret Lewicka
2015-Feb-09 14:55 UTC
Re: [Libguestfs] [PATCH 2/5] macosx: Add definition of program_name for gnulib
On 9 February 2015 at 13:10, Daniel P. Berrange <berrange@redhat.com> wrote:> On Mon, Feb 09, 2015 at 11:06:16AM +0000, Margaret Lewicka wrote: >> gnulib's error.c requires program_name to be externally defined >> for !_LIBC systems. This defines program_name for Darwin only. >> --- >> configure.ac | 3 +++ >> src/Makefile.am | 6 ++++++ >> src/program_name.c | 4 ++++ >> 3 files changed, 13 insertions(+) >> create mode 100644 src/program_name.c > > src/guestfs-internal-frontend.h has a #define to replace use > of 'program_name' with something that is defined, so this > should not be required unless the header includes are not > right somewhere.It is required, because gnulib itself explicitly defines an extern char *program_name. See gnulib/lib/error.c:118 -- M.
Richard W.M. Jones
2015-Feb-11 13:46 UTC
Re: [Libguestfs] [PATCH 2/5] macosx: Add definition of program_name for gnulib
On Mon, Feb 09, 2015 at 02:55:58PM +0000, Margaret Lewicka wrote:> On 9 February 2015 at 13:10, Daniel P. Berrange <berrange@redhat.com> wrote: > > On Mon, Feb 09, 2015 at 11:06:16AM +0000, Margaret Lewicka wrote: > >> gnulib's error.c requires program_name to be externally defined > >> for !_LIBC systems. This defines program_name for Darwin only. > >> --- > >> configure.ac | 3 +++ > >> src/Makefile.am | 6 ++++++ > >> src/program_name.c | 4 ++++ > >> 3 files changed, 13 insertions(+) > >> create mode 100644 src/program_name.c > > > > src/guestfs-internal-frontend.h has a #define to replace use > > of 'program_name' with something that is defined, so this > > should not be required unless the header includes are not > > right somewhere. > > It is required, because gnulib itself explicitly defines an extern > char *program_name. See gnulib/lib/error.c:118What actually happens in gnulib's error.c is: #ifdef _LIBC /* In the GNU C library, there is a predefined variable for this. */ # define program_name program_invocation_name #endif which on glibc causes all uses of `program_name' in the error.c source to refer to refer to a string that glibc defines called `program_invocation_name': extern char *program_invocation_name; /* defined in glibc, same as argv[0]*/ On non-glibc, error.c says: /* The calling program should define program_name and set it to the name of the executing program. */ extern char *program_name; This indicates to me that we shouldn't define `program_name' as a symbol in libguestfs. Instead every libguestfs-using program should define it. For example, virt-df (df/main.c) would have: #if /* this is Mac OS X */ char *program_name = "virt-df"; #endif That sucks a lot. I think the alternative is that you find a similar symbol defined by Mac OS X that gives you the value of argv[0], and then send a patch to gnulib which does: #if /* this is Mac OS X */ #define program_name whatever_mac_os_x_defines_as_program_name #endif My reading is that something like this might work, untested of course: #if /* this is Mac OS X */ #define program_name (((char **)*_NSGetArgv())[0]) #endif Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Seemingly Similar Threads
- Re: [PATCH 2/5] macosx: Add definition of program_name for gnulib
- Re: [PATCH 2/5] macosx: Add definition of program_name for gnulib
- Re: [PATCH 2/5] macosx: Add definition of program_name for gnulib
- Re: [PATCH 2/5] macosx: Add definition of program_name for gnulib
- Re: [PATCH] gnulib: Define argv[0] as program_name for error.c on Darwin