[libdispatch-dev] [PATCH] dispatch_getprogname()
Robert Watson
robert at fledge.watson.org
Mon Dec 28 03:46:00 PST 2009
On Fri, 25 Dec 2009, Mark Heily wrote:
>>> When compiling a libdispatch debug build on Linux, I found that
>>> getprogname(3) is not available. Here is a patch that implements a wrapper
>>> function.
>>
>> Could you tweak the approach slightly to:
>>
>> - Add a src/shims/getprogname.[ch], implementing getprogname() there if
>> it's
>> not available? - Directly test for program_invocation_short_name using
>> configure and use the
>> resulting HAVE_ ifdef as needed?
>
> See below for the revised patch.
Hi Mark--
I've committed this patch as r177. I think the configure.ac check is probably
not quite right, as program_invocation_short_name looks to me like a regular
symbol pointing at a string rather than a function -- probably we should redo
as a test that use of the symbol links.
Robert N M Watson
Computer Laboratory
University of Cambridge
>
> Regards,
>
> - Mark
>
>
>
> Index: configure.ac
> ===================================================================
> --- configure.ac (revision 174)
> +++ configure.ac (working copy)
> @@ -192,7 +192,7 @@
> AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
> AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
> AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include
> <sys/mount.h>]])
> -AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time
> malloc_create_zone sysconf])
> +AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time
> malloc_create_zone sysconf getprogname program_invocation_short_name])
>
> AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED],
> [have_posix_spawn_start_suspended=true],
> Index: src/shims/getprogname.h
> ===================================================================
> --- src/shims/getprogname.h (revision 0)
> +++ src/shims/getprogname.h (revision 0)
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright (c) 2009 Apple Inc. All rights reserved.
> + *
> + * @APPLE_APACHE_LICENSE_HEADER_START@
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + *
> + * @APPLE_APACHE_LICENSE_HEADER_END@
> + */
> +
> +#ifndef __DISPATCH_SHIMS_GETPROGNAME__
> +#define __DISPATCH_SHIMS_GETPROGNAME__
> +
> +#ifndef HAVE_GETPROGNAME
> +static inline char *
> +getprogname(void)
> +{
> +# if HAVE_PROGRAM_INVOCATION_SHORT_NAME
> + return program_invocation_short_name;
> +# else
> +# error getprogname(3) is not available on this platform
> +# endif
> +}
> +#endif /* HAVE_GETPROGNAME */
> +
> +#endif /* __DISPATCH_SHIMS_GETPROGNAME__ */
> Index: src/os_shims.h
> ===================================================================
> --- src/os_shims.h (revision 174)
> +++ src/os_shims.h (working copy)
> @@ -46,6 +46,7 @@
> #define FD_COPY(f, t) (void)(*(t) = *(f))
> #endif
>
> +#include "shims/getprogname.h"
> #include "shims/malloc_zone.h"
> #include "shims/tsd.h"
> #include "shims/perfmon.h"
>
>
More information about the libdispatch-dev
mailing list