diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-04-26 11:49:29 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-04-26 11:49:29 +0000 |
commit | a44dcbbe65f326617f147978ef5cee916f4b252e (patch) | |
tree | 0274b95f25ef1e1032ecfc318dcc10316dd6b9f2 | |
parent | b8149f085265457277733d0a6ba41a72a05a0c37 (diff) | |
parent | 6175f5a92a3a312be8142de7390d92df1d05bd75 (diff) | |
download | illumos-joyent-a44dcbbe65f326617f147978ef5cee916f4b252e.tar.gz |
[illumos-gate merge]
commit 6175f5a92a3a312be8142de7390d92df1d05bd75
8007 want sys/stddef.h for offsetof and container_of macros (fix container_of visibility)
commit 8e1c282f21a1ca9422d0f1c9922b6679bb245185
8032 libtnfctl: add EAGAIN to prb_status_t enum list
8039 libtnfctl: prb_child.c cstyle cleanup
commit 4ee0199ec059ca9417a72125beae8d89fbc5a9df
commit a3848ed0a29283946b7129498d914f532442a95f
8017 Comply with POSIX.1-2008 and C++11 for the definition of NULL
Conflicts:
usr/src/uts/common/sys/stddef.h
usr/src/uts/common/fs/zfs/arc.c
-rw-r--r-- | usr/src/lib/libtnfctl/open.c | 12 | ||||
-rw-r--r-- | usr/src/lib/libtnfctl/prb_child.c | 58 | ||||
-rw-r--r-- | usr/src/lib/libtnfctl/prb_proc.h | 6 | ||||
-rw-r--r-- | usr/src/uts/common/sys/null.h | 25 | ||||
-rw-r--r-- | usr/src/uts/common/sys/stddef.h | 56 |
5 files changed, 117 insertions, 40 deletions
diff --git a/usr/src/lib/libtnfctl/open.c b/usr/src/lib/libtnfctl/open.c index e36fe67db4..f3087aa40a 100644 --- a/usr/src/lib/libtnfctl/open.c +++ b/usr/src/lib/libtnfctl/open.c @@ -50,9 +50,9 @@ static tnfctl_errcode_t step_to_end_of_exec(tnfctl_handle_t *hndl); */ tnfctl_errcode_t tnfctl_exec_open(const char *pgm_name, char * const *args, char * const *envp, - const char *ld_preload, - const char *libtnfprobe_path, - tnfctl_handle_t **ret_val) + const char *ld_preload, + const char *libtnfprobe_path, + tnfctl_handle_t **ret_val) { tnfctl_handle_t *hdl; prb_proc_ctl_t *proc_p = NULL; @@ -213,7 +213,7 @@ failure_ret: */ tnfctl_errcode_t tnfctl_indirect_open(void *prochandle, tnfctl_ind_config_t *config, - tnfctl_handle_t **ret_val) + tnfctl_handle_t **ret_val) { tnfctl_handle_t *hdl; tnfctl_errcode_t prexstat; @@ -323,7 +323,7 @@ tnfctl_trace_attrs_get(tnfctl_handle_t *hdl, tnfctl_trace_attrs_t *attrs) */ tnfctl_errcode_t tnfctl_buffer_alloc(tnfctl_handle_t *hdl, const char *trace_file_name, - uint_t trace_file_size) + uint_t trace_file_size) { tnfctl_errcode_t prexstat; @@ -454,7 +454,7 @@ step_to_end_of_exec(tnfctl_handle_t *hndl) switch (prbstat) { case PRB_STATUS_OK: break; - case EAGAIN: + case PRB_STATUS_EAGAIN: /* * If we had exec'ed a setuid/setgid program PIOCWSTOP * will return EAGAIN. Reopen the 'fd' and try again. diff --git a/usr/src/lib/libtnfctl/prb_child.c b/usr/src/lib/libtnfctl/prb_child.c index 0b87b93d93..e5d01a94e5 100644 --- a/usr/src/lib/libtnfctl/prb_child.c +++ b/usr/src/lib/libtnfctl/prb_child.c @@ -23,8 +23,6 @@ * Copyright (c) 1994, by Sun Microsytems, Inc. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * interfaces to exec a command and run it till all loadobjects have * been loaded (rtld sync point). @@ -62,13 +60,13 @@ static prb_status_t sync_child(int pid, volatile shmem_msg_t *smp, */ prb_status_t prb_child_create(const char *cmdname, char * const *cmdargs, - const char *loption, const char *libtnfprobe_path, - char * const *envp, prb_proc_ctl_t **ret_val) + const char *loption, const char *libtnfprobe_path, + char * const *envp, prb_proc_ctl_t **ret_val) { prb_status_t prbstat; pid_t childpid; char executable_name[PATH_MAX + 2]; - extern char **environ; + extern char **environ; char * const * env_to_use; size_t loptlen, probepathlen; volatile shmem_msg_t *smp; @@ -80,7 +78,7 @@ prb_child_create(const char *cmdname, char * const *cmdargs, /* fork to create the child process */ childpid = fork(); - if (childpid == (pid_t) - 1) { + if (childpid == (pid_t)-1) { DBG(perror("prb_child_create: fork failed")); return (prb_status_map(errno)); } @@ -91,8 +89,8 @@ prb_child_create(const char *cmdname, char * const *cmdargs, /* ---- CHILD PROCESS ---- */ DBG_TNF_PROBE_1(prb_child_create_1, "libtnfctl", - "sunw%verbosity 1; sunw%debug 'child process created'", - tnf_long, pid, getpid()); + "sunw%verbosity 1; sunw%debug 'child process created'", + tnf_long, pid, getpid()); if (envp) { env_to_use = envp; @@ -103,18 +101,18 @@ prb_child_create(const char *cmdname, char * const *cmdargs, loptlen = (loption) ? strlen(loption) : 0; /* probepathlen has a "/" added in ("+ 1") */ probepathlen = (libtnfprobe_path) ? - (strlen(libtnfprobe_path) + 1) : 0; + (strlen(libtnfprobe_path) + 1) : 0; oldenv = getenv(PRELOAD); if (oldenv) { - newenv = (char *) malloc(strlen(PRELOAD) + - 1 + /* "=" */ - strlen(oldenv) + - 1 + /* " " */ - probepathlen + - strlen(LIBPROBE) + - 1 + /* " " */ - loptlen + - 1); /* NULL */ + newenv = (char *)malloc(strlen(PRELOAD) + + 1 + /* "=" */ + strlen(oldenv) + + 1 + /* " " */ + probepathlen + + strlen(LIBPROBE) + + 1 + /* " " */ + loptlen + + 1); /* NULL */ if (!newenv) goto ContChild; @@ -132,13 +130,13 @@ prb_child_create(const char *cmdname, char * const *cmdargs, (void) strcat(newenv, loption); } } else { - newenv = (char *) malloc(strlen(PRELOAD) + - 1 + /* "=" */ - probepathlen + - strlen(LIBPROBE) + - 1 + /* " " */ - loptlen + - 1); /* NULL */ + newenv = (char *)malloc(strlen(PRELOAD) + + 1 + /* "=" */ + probepathlen + + strlen(LIBPROBE) + + 1 + /* " " */ + loptlen + + 1); /* NULL */ if (!newenv) goto ContChild; (void) strcpy(newenv, PRELOAD); @@ -153,7 +151,7 @@ prb_child_create(const char *cmdname, char * const *cmdargs, (void) strcat(newenv, loption); } } - (void) putenv((char *) newenv); + (void) putenv((char *)newenv); env_to_use = environ; /* * We don't check the return value of putenv because the @@ -166,9 +164,9 @@ ContChild: (void) prb_shmem_wait(smp); DBG_TNF_PROBE_1(prb_child_create_2, "libtnfctl", - "sunw%verbosity 2; " - "sunw%debug 'child process about to exec'", - tnf_string, cmdname, cmdname); + "sunw%verbosity 2; " + "sunw%debug 'child process about to exec'", + tnf_string, cmdname, cmdname); /* * make the child it's own process group. @@ -179,7 +177,7 @@ ContChild: prbstat = find_executable(cmdname, executable_name); if (prbstat) { DBG((void) fprintf(stderr, "prb_child_create: %s\n", - prb_status_str(prbstat))); + prb_status_str(prbstat))); /* parent waits for exit */ _exit(1); } diff --git a/usr/src/lib/libtnfctl/prb_proc.h b/usr/src/lib/libtnfctl/prb_proc.h index 0ea8419622..1e32d46f65 100644 --- a/usr/src/lib/libtnfctl/prb_proc.h +++ b/usr/src/lib/libtnfctl/prb_proc.h @@ -26,8 +26,6 @@ #ifndef _PRB_PROC_H #define _PRB_PROC_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -45,6 +43,7 @@ extern "C" { #include <sys/types.h> #include <sys/syscall.h> #include <sys/procfs.h> +#include <sys/errno.h> #include <signal.h> #include <note.h> @@ -64,6 +63,7 @@ typedef enum prb_status { * standard errno values. */ PRB_STATUS_MINERRNO = 1, /* minimum errno value */ + PRB_STATUS_EAGAIN = EAGAIN, PRB_STATUS_MAXERRNO = 1023, /* maximum errno value */ PRB_STATUS_ALLOCFAIL, /* memory allocation failed */ @@ -141,7 +141,7 @@ prb_status_t prb_proc_wait(prb_proc_ctl_t *proc_p, boolean_t use_sigmask, sigset_t *oldmask); prb_status_t prb_proc_cont(prb_proc_ctl_t *proc_p); prb_status_t prb_proc_state(prb_proc_ctl_t *proc_p, - prb_proc_state_t * state_p); + prb_proc_state_t *state_p); prb_status_t prb_proc_setrlc(prb_proc_ctl_t *proc_p, boolean_t rlc); prb_status_t prb_proc_setklc(prb_proc_ctl_t *proc_p, boolean_t klc); prb_status_t prb_proc_exit(prb_proc_ctl_t *proc_p, uint_t syscall, diff --git a/usr/src/uts/common/sys/null.h b/usr/src/uts/common/sys/null.h index da580d05c4..251dcfc994 100644 --- a/usr/src/uts/common/sys/null.h +++ b/usr/src/uts/common/sys/null.h @@ -16,13 +16,36 @@ #ifndef _SYS_NULL_H #define _SYS_NULL_H +#include <sys/feature_tests.h> + #ifndef NULL +/* + * POSIX.1-2008 requires that the NULL macro be cast to type void *. + * Historically, this has not been done, so we only enable this in a + * POSIX.1-2008 compilation environment. + */ + +#if defined(_XPG7) && !defined(__cplusplus) +#define NULL ((void *)0) +#else + +/* + * ISO C++ requires that the NULL macro be a constant integral type evaluating + * to zero until C++11, and an integer or pointer literal with value zero from + * C++11 onwards. + */ + +#if defined(__cplusplus) && __cplusplus >= 201103L +#define NULL nullptr +#else #if defined(_LP64) #define NULL 0L #else #define NULL 0 -#endif +#endif /* _LP64 */ +#endif /* C++11 */ +#endif /* _XPG7 */ #endif /* NULL */ diff --git a/usr/src/uts/common/sys/stddef.h b/usr/src/uts/common/sys/stddef.h new file mode 100644 index 0000000000..a0bd1f83a1 --- /dev/null +++ b/usr/src/uts/common/sys/stddef.h @@ -0,0 +1,56 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Toomas Soome <tsoome@me.com> + */ + +#ifndef _SYS_STDDEF_H +#define _SYS_STDDEF_H + +/* + * Commonly used macros and definitions. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(offsetof) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#define offsetof(s, m) __builtin_offsetof(s, m) +#else +#if __cplusplus >= 199711L +#define offsetof(s, m) (std::size_t)(&(((s *)NULL)->m)) +#else +#define offsetof(s, m) ((size_t)(&(((s *)NULL)->m))) +#endif +#endif +#endif /* !offsetof */ + +#if !defined(container_of) + +/* + * We must not expose container_of() to userland, but we want it + * to be available for early boot and for the kernel. + */ +#if ((defined(_KERNEL) || defined(_FAKE_KERNEL)) && !defined(_KMEMUSER)) || \ + (defined(_BOOT) && defined(_KMEMUSER)) +#define container_of(m, s, name) \ + (void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name)) +#endif +#endif /* !container_of */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STDDEF_H */ |