diff options
author | Rui Paulo <rpaulo@FreeBSD.org> | 2010-08-02 12:13:33 +0000 |
---|---|---|
committer | Rui Paulo <rpaulo@FreeBSD.org> | 2010-08-02 12:13:33 +0000 |
commit | e0ea83ebb1a4b194c927cb114766e8781676380b (patch) | |
tree | 1bf8e417b1e4092355d2478f7c38c9db7e093700 /lib | |
parent | 37ddcfe2bb1d3b458470402a871a52af23e260e6 (diff) | |
download | src-e0ea83ebb1a4b194c927cb114766e8781676380b.tar.gz src-e0ea83ebb1a4b194c927cb114766e8781676380b.zip |
Notes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libdtrace/common/drti.c | 15 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_cc.c | 13 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_consume.c | 6 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_dof.c | 7 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_error.c | 7 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_impl.h | 17 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_lex.l | 9 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_link.c | 37 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_module.c | 33 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_open.c | 13 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_pid.c | 18 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_printf.c | 76 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_proc.c | 35 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_program.c | 40 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_string.c | 15 | ||||
-rw-r--r-- | lib/libdtrace/common/dt_subr.c | 50 | ||||
-rwxr-xr-x | lib/libdtrace/common/mkerrno.sh | 40 | ||||
-rwxr-xr-x | lib/libdtrace/common/mksignal.sh | 40 | ||||
-rw-r--r-- | lib/libgen/common/gmatch.c | 32 |
19 files changed, 324 insertions, 179 deletions
diff --git a/lib/libdtrace/common/drti.c b/lib/libdtrace/common/drti.c index f8570e686f5b..3b5f0cbbdf30 100644 --- a/lib/libdtrace/common/drti.c +++ b/lib/libdtrace/common/drti.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <unistd.h> #include <fcntl.h> #include <dlfcn.h> @@ -61,13 +58,14 @@ static const char *olddevname = "/devices/pseudo/dtrace@0:helper"; static const char *modname; /* Name of this load object */ static int gen; /* DOF helper generation */ extern dof_hdr_t __SUNW_dof; /* DOF defined in the .SUNW_dof section */ +static boolean_t dof_init_debug = B_FALSE; /* From DTRACE_DOF_INIT_DEBUG */ static void dprintf(int debug, const char *fmt, ...) { va_list ap; - if (debug && getenv("DTRACE_DOF_INIT_DEBUG") == NULL) + if (debug && !dof_init_debug) return; va_start(ap, fmt); @@ -104,6 +102,9 @@ dtrace_dof_init(void) if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL) return; + if (getenv("DTRACE_DOF_INIT_DEBUG") != NULL) + dof_init_debug = B_TRUE; + if (dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lmp) == -1 || lmp == NULL) { dprintf(1, "couldn't discover module name or address\n"); return; diff --git a/lib/libdtrace/common/dt_cc.c b/lib/libdtrace/common/dt_cc.c index 575fb9c68367..24a386bbde95 100644 --- a/lib/libdtrace/common/dt_cc.c +++ b/lib/libdtrace/common/dt_cc.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * DTrace D Language Compiler * @@ -2069,11 +2066,11 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg, if (dt_list_next(&dtp->dt_lib_path) != NULL && dt_load_libs(dtp) != 0) return (NULL); /* errno is set for us */ - (void) ctf_discard(dtp->dt_cdefs->dm_ctfp); - (void) ctf_discard(dtp->dt_ddefs->dm_ctfp); + if (dtp->dt_globals->dh_nelems != 0) + (void) dt_idhash_iter(dtp->dt_globals, dt_idreset, NULL); - (void) dt_idhash_iter(dtp->dt_globals, dt_idreset, NULL); - (void) dt_idhash_iter(dtp->dt_tls, dt_idreset, NULL); + if (dtp->dt_tls->dh_nelems != 0) + (void) dt_idhash_iter(dtp->dt_tls, dt_idreset, NULL); if (fp && (cflags & DTRACE_C_CPP) && (fp = dt_preproc(dtp, fp)) == NULL) return (NULL); /* errno is set for us */ diff --git a/lib/libdtrace/common/dt_consume.c b/lib/libdtrace/common/dt_consume.c index 62d39e07dd41..564189a000ad 100644 --- a/lib/libdtrace/common/dt_consume.c +++ b/lib/libdtrace/common/dt_consume.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdlib.h> #include <strings.h> #include <errno.h> @@ -1063,7 +1061,7 @@ dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act) do { n = len; s = alloca(n); - } while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) >= n); + } while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) > n); return (dt_printf(dtp, fp, format, s)); } diff --git a/lib/libdtrace/common/dt_dof.c b/lib/libdtrace/common/dt_dof.c index 075001157618..a7eb8e4d239f 100644 --- a/lib/libdtrace/common/dt_dof.c +++ b/lib/libdtrace/common/dt_dof.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/sysmacros.h> @@ -834,7 +831,6 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags) */ h.dofh_secnum = ddo->ddo_nsecs; ssize = sizeof (h) + dt_buf_len(&ddo->ddo_secs); - assert(ssize == sizeof (h) + sizeof (dof_sec_t) * ddo->ddo_nsecs); h.dofh_loadsz = ssize + dt_buf_len(&ddo->ddo_ldata) + @@ -860,6 +856,7 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags) sp = dt_buf_ptr(&ddo->ddo_secs); assert(sp[ddo->ddo_strsec].dofs_type == DOF_SECT_STRTAB); + assert(ssize == sizeof (h) + sizeof (dof_sec_t) * ddo->ddo_nsecs); sp[ddo->ddo_strsec].dofs_offset = ssize + dt_buf_len(&ddo->ddo_ldata); sp[ddo->ddo_strsec].dofs_size = dt_buf_len(&ddo->ddo_strs); diff --git a/lib/libdtrace/common/dt_error.c b/lib/libdtrace/common/dt_error.c index 5005f593a43d..0bfabc919c85 100644 --- a/lib/libdtrace/common/dt_error.c +++ b/lib/libdtrace/common/dt_error.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <strings.h> #include <dt_impl.h> @@ -105,7 +103,8 @@ static const struct { { EDT_BADSETOPT, "Invalid setopt() library action" }, { EDT_BADSTACKPC, "Invalid stack program counter size" }, { EDT_BADAGGVAR, "Invalid aggregation variable identifier" }, - { EDT_OVERSION, "Client requested deprecated version of library" } + { EDT_OVERSION, "Client requested deprecated version of library" }, + { EDT_ENABLING_ERR, "Failed to enable probe" } }; static const int _dt_nerr = sizeof (_dt_errlist) / sizeof (_dt_errlist[0]); diff --git a/lib/libdtrace/common/dt_impl.h b/lib/libdtrace/common/dt_impl.h index 9b22dfbb641a..1937ce06474d 100644 --- a/lib/libdtrace/common/dt_impl.h +++ b/lib/libdtrace/common/dt_impl.h @@ -20,21 +20,20 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _DT_IMPL_H #define _DT_IMPL_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <sys/objfs.h> #include <setjmp.h> #include <libctf.h> #include <dtrace.h> #include <gelf.h> +#include <synch.h> #ifdef __cplusplus extern "C" { @@ -498,7 +497,8 @@ enum { EDT_BADSETOPT, /* invalid setopt library action */ EDT_BADSTACKPC, /* invalid stack program counter size */ EDT_BADAGGVAR, /* invalid aggregation variable identifier */ - EDT_OVERSION /* client is requesting deprecated version */ + EDT_OVERSION, /* client is requesting deprecated version */ + EDT_ENABLING_ERR /* failed to enable probe */ }; /* @@ -568,17 +568,8 @@ extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *, extern void dt_buffered_disable(dtrace_hdl_t *); extern void dt_buffered_destroy(dtrace_hdl_t *); -extern int dt_rw_read_held(pthread_rwlock_t *); -extern int dt_rw_write_held(pthread_rwlock_t *); -extern int dt_mutex_held(pthread_mutex_t *); - extern uint64_t dt_stddev(uint64_t *, uint64_t); -#define DT_RW_READ_HELD(x) dt_rw_read_held(x) -#define DT_RW_WRITE_HELD(x) dt_rw_write_held(x) -#define DT_RW_LOCK_HELD(x) (DT_RW_READ_HELD(x) || DT_RW_WRITE_HELD(x)) -#define DT_MUTEX_HELD(x) dt_mutex_held(x) - extern int dt_options_load(dtrace_hdl_t *); extern void dt_dprintf(const char *, ...); diff --git a/lib/libdtrace/common/dt_lex.l b/lib/libdtrace/common/dt_lex.l index fc74df15e0a6..5b2ad34d2ee3 100644 --- a/lib/libdtrace/common/dt_lex.l +++ b/lib/libdtrace/common/dt_lex.l @@ -18,12 +18,11 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ #include <string.h> #include <stdlib.h> @@ -803,7 +802,7 @@ input(void) else if (yypcb->pcb_fileptr != NULL) c = fgetc(yypcb->pcb_fileptr); else if (yypcb->pcb_strptr < yypcb->pcb_string + yypcb->pcb_strlen) - c = *yypcb->pcb_strptr++; + c = *(unsigned char *)(yypcb->pcb_strptr++); else c = EOF; diff --git a/lib/libdtrace/common/dt_link.c b/lib/libdtrace/common/dt_link.c index e317fe7f1162..e910ac3ff1bc 100644 --- a/lib/libdtrace/common/dt_link.c +++ b/lib/libdtrace/common/dt_link.c @@ -776,15 +776,19 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, /* * We may have already processed this object file in an earlier linker * invocation. Check to see if the present instruction sequence matches - * the one we would install. + * the one we would install below. */ if (isenabled) { - if (ip[0] == DT_OP_CLR_O0) + if (ip[0] == DT_OP_NOP) { + (*off) += sizeof (ip[0]); return (0); + } } else { if (DT_IS_RESTORE(ip[1])) { - if (ip[0] == DT_OP_RET) + if (ip[0] == DT_OP_RET) { + (*off) += sizeof (ip[0]); return (0); + } } else if (DT_IS_MOV_O7(ip[1])) { if (DT_IS_RETL(ip[0])) return (0); @@ -818,7 +822,17 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, return (-1); } - ip[0] = DT_OP_CLR_O0; + + /* + * On SPARC, we take advantage of the fact that the first + * argument shares the same register as for the return value. + * The macro handles the work of zeroing that register so we + * don't need to do anything special here. We instrument the + * instruction in the delay slot as we'll need to modify the + * return register after that instruction has been emulated. + */ + ip[0] = DT_OP_NOP; + (*off) += sizeof (ip[0]); } else { /* * If the call is followed by a restore, it's a tail call so @@ -827,11 +841,16 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, * so change the call to a retl-like instruction that returns * to that register value + 8 (rather than the typical %o7 + * 8); the delay slot instruction is left, but should have no - * effect. Otherwise we change the call to be a nop. In the - * first and the last case we adjust the offset to land on what - * was once the delay slot of the call so we correctly get all - * the arguments as they would have been passed in a normal - * function call. + * effect. Otherwise we change the call to be a nop. We + * identify the subsequent instruction as the probe point in + * all but the leaf tail-call case to ensure that arguments to + * the probe are complete and consistent. An astute, though + * largely hypothetical, observer would note that there is the + * possibility of a false-positive probe firing if the function + * contained a branch to the instruction in the delay slot of + * the call. Fixing this would require significant in-kernel + * modifications, and isn't worth doing until we see it in the + * wild. */ if (DT_IS_RESTORE(ip[1])) { ip[0] = DT_OP_RET; diff --git a/lib/libdtrace/common/dt_module.c b/lib/libdtrace/common/dt_module.c index 25197031ce11..1490f775c37c 100644 --- a/lib/libdtrace/common/dt_module.c +++ b/lib/libdtrace/common/dt_module.c @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/modctl.h> #include <sys/kobj.h> @@ -66,6 +64,10 @@ dt_module_symhash_insert(dt_module_t *dmp, const char *name, uint_t id) static uint_t dt_module_syminit32(dt_module_t *dmp) { +#if STT_NUM != (STT_TLS + 1) +#error "STT_NUM has grown. update dt_module_syminit32()" +#endif + const Elf32_Sym *sym = dmp->dm_symtab.cts_data; const char *base = dmp->dm_strtab.cts_data; size_t ss_size = dmp->dm_strtab.cts_size; @@ -95,6 +97,10 @@ dt_module_syminit32(dt_module_t *dmp) static uint_t dt_module_syminit64(dt_module_t *dmp) { +#if STT_NUM != (STT_TLS + 1) +#error "STT_NUM has grown. update dt_module_syminit64()" +#endif + const Elf64_Sym *sym = dmp->dm_symtab.cts_data; const char *base = dmp->dm_strtab.cts_data; size_t ss_size = dmp->dm_strtab.cts_size; @@ -468,7 +474,7 @@ dt_module_load_sect(dtrace_hdl_t *dtp, dt_module_t *dmp, ctf_sect_t *ctsp) Elf_Data *dp; Elf_Scn *sp; - if (elf_getshstrndx(dmp->dm_elf, &shstrs) == 0) + if (elf_getshdrstrndx(dmp->dm_elf, &shstrs) == -1) return (dt_set_errno(dtp, EDT_NOTLOADED)); for (sp = NULL; (sp = elf_nextscn(dmp->dm_elf, sp)) != NULL; ) { @@ -711,10 +717,25 @@ dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp) void dt_module_destroy(dtrace_hdl_t *dtp, dt_module_t *dmp) { + uint_t h = dt_strtab_hash(dmp->dm_name, NULL) % dtp->dt_modbuckets; + dt_module_t **dmpp = &dtp->dt_mods[h]; + dt_list_delete(&dtp->dt_modlist, dmp); assert(dtp->dt_nmods != 0); dtp->dt_nmods--; + /* + * Now remove this module from its hash chain. We expect to always + * find the module on its hash chain, so in this loop we assert that + * we don't run off the end of the list. + */ + while (*dmpp != dmp) { + dmpp = &((*dmpp)->dm_next); + assert(*dmpp != NULL); + } + + *dmpp = dmp->dm_next; + dt_module_unload(dtp, dmp); free(dmp); } @@ -817,7 +838,7 @@ dt_module_update(dtrace_hdl_t *dtp, const char *name) (void) close(fd); if (dmp->dm_elf == NULL || err == -1 || - elf_getshstrndx(dmp->dm_elf, &shstrs) == 0) { + elf_getshdrstrndx(dmp->dm_elf, &shstrs) == -1) { dt_dprintf("failed to load %s: %s\n", fname, elf_errmsg(elf_errno())); dt_module_destroy(dtp, dmp); diff --git a/lib/libdtrace/common/dt_open.c b/lib/libdtrace/common/dt_open.c index 86f1864f5aa0..2b9cd7c414da 100644 --- a/lib/libdtrace/common/dt_open.c +++ b/lib/libdtrace/common/dt_open.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/modctl.h> #include <sys/systeminfo.h> @@ -104,8 +101,10 @@ #define DT_VERS_1_5 DT_VERSION_NUMBER(1, 5, 0) #define DT_VERS_1_6 DT_VERSION_NUMBER(1, 6, 0) #define DT_VERS_1_6_1 DT_VERSION_NUMBER(1, 6, 1) -#define DT_VERS_LATEST DT_VERS_1_6_1 -#define DT_VERS_STRING "Sun D 1.6.1" +#define DT_VERS_1_6_2 DT_VERSION_NUMBER(1, 6, 2) +#define DT_VERS_1_6_3 DT_VERSION_NUMBER(1, 6, 3) +#define DT_VERS_LATEST DT_VERS_1_6_3 +#define DT_VERS_STRING "Sun D 1.6.3" const dt_version_t _dtrace_versions[] = { DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */ @@ -119,6 +118,8 @@ const dt_version_t _dtrace_versions[] = { DT_VERS_1_5, /* D API 1.5 Solaris Express 7/07 */ DT_VERS_1_6, /* D API 1.6 */ DT_VERS_1_6_1, /* D API 1.6.1 */ + DT_VERS_1_6_2, /* D API 1.6.2 */ + DT_VERS_1_6_3, /* D API 1.6.3 */ 0 }; diff --git a/lib/libdtrace/common/dt_pid.c b/lib/libdtrace/common/dt_pid.c index cf9498b3ed3f..241805154adc 100644 --- a/lib/libdtrace/common/dt_pid.c +++ b/lib/libdtrace/common/dt_pid.c @@ -20,12 +20,10 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <assert.h> #include <strings.h> #include <stdlib.h> @@ -370,17 +368,17 @@ dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj) char name[DTRACE_MODNAMELEN]; dt_pid_probe_t *pp = arg; - if (gmatch(obj, pp->dpp_mod)) - return (dt_pid_per_mod(pp, pmp, obj)); - - (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid); - if ((pp->dpp_obj = strrchr(obj, '/')) == NULL) pp->dpp_obj = obj; else pp->dpp_obj++; - dt_pid_objname(name, sizeof (name), pp->dpp_lmid, obj); + if (gmatch(pp->dpp_obj, pp->dpp_mod)) + return (dt_pid_per_mod(pp, pmp, obj)); + + (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid); + + dt_pid_objname(name, sizeof (name), pp->dpp_lmid, pp->dpp_obj); if (gmatch(name, pp->dpp_mod)) return (dt_pid_per_mod(pp, pmp, obj)); @@ -578,7 +576,7 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, struct ps_prochandle *P = dpr->dpr_proc; int ret = 0; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); (void) Pupdate_maps(P); if (Pobject_iter(P, dt_pid_usdt_mapping, P) != 0) { diff --git a/lib/libdtrace/common/dt_printf.c b/lib/libdtrace/common/dt_printf.c index 953511b1d029..52904789bc7e 100644 --- a/lib/libdtrace/common/dt_printf.c +++ b/lib/libdtrace/common/dt_printf.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/sysmacros.h> #include <strings.h> #include <stdlib.h> @@ -34,6 +31,11 @@ #include <ctype.h> #include <errno.h> #include <limits.h> +#include <sys/socket.h> +#include <netdb.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <arpa/nameser.h> #include <dt_printf.h> #include <dt_string.h> @@ -330,7 +332,7 @@ pfprint_addr(dtrace_hdl_t *dtp, FILE *fp, const char *format, do { n = len; s = alloca(n); - } while ((len = dtrace_addr2str(dtp, val, s, n)) >= n); + } while ((len = dtrace_addr2str(dtp, val, s, n)) > n); return (dt_printf(dtp, fp, format, s)); } @@ -383,7 +385,7 @@ pfprint_uaddr(dtrace_hdl_t *dtp, FILE *fp, const char *format, do { n = len; s = alloca(n); - } while ((len = dtrace_uaddr2str(dtp, pid, val, s, n)) >= n); + } while ((len = dtrace_uaddr2str(dtp, pid, val, s, n)) > n); return (dt_printf(dtp, fp, format, s)); } @@ -494,6 +496,49 @@ pfprint_time822(dtrace_hdl_t *dtp, FILE *fp, const char *format, /*ARGSUSED*/ static int +pfprint_port(dtrace_hdl_t *dtp, FILE *fp, const char *format, + const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal) +{ + uint16_t port = htons(*((uint16_t *)addr)); + char buf[256]; + struct servent *sv, res; + + if ((sv = getservbyport_r(port, NULL, &res, buf, sizeof (buf))) != NULL) + return (dt_printf(dtp, fp, format, sv->s_name)); + + (void) snprintf(buf, sizeof (buf), "%d", *((uint16_t *)addr)); + return (dt_printf(dtp, fp, format, buf)); +} + +/*ARGSUSED*/ +static int +pfprint_inetaddr(dtrace_hdl_t *dtp, FILE *fp, const char *format, + const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal) +{ + char *s = alloca(size + 1); + struct hostent *host, res; + char inetaddr[NS_IN6ADDRSZ]; + char buf[1024]; + int e; + + bcopy(addr, s, size); + s[size] = '\0'; + + if (strchr(s, ':') == NULL && inet_pton(AF_INET, s, inetaddr) != -1) { + if ((host = gethostbyaddr_r(inetaddr, NS_INADDRSZ, + AF_INET, &res, buf, sizeof (buf), &e)) != NULL) + return (dt_printf(dtp, fp, format, host->h_name)); + } else if (inet_pton(AF_INET6, s, inetaddr) != -1) { + if ((host = getipnodebyaddr(inetaddr, NS_IN6ADDRSZ, + AF_INET6, &e)) != NULL) + return (dt_printf(dtp, fp, format, host->h_name)); + } + + return (dt_printf(dtp, fp, format, s)); +} + +/*ARGSUSED*/ +static int pfprint_cstr(dtrace_hdl_t *dtp, FILE *fp, const char *format, const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal) { @@ -597,6 +642,7 @@ static const dt_pfconv_t _dtrace_conversions[] = { { "hx", "x", "short", pfcheck_xshort, pfprint_uint }, { "hX", "X", "short", pfcheck_xshort, pfprint_uint }, { "i", "i", pfproto_xint, pfcheck_dint, pfprint_dint }, +{ "I", "s", pfproto_cstr, pfcheck_str, pfprint_inetaddr }, { "k", "s", "stack", pfcheck_stack, pfprint_stack }, { "lc", "lc", "int", pfcheck_type, pfprint_sint }, /* a.k.a. wint_t */ { "ld", "d", "long", pfcheck_type, pfprint_sint }, @@ -619,6 +665,7 @@ static const dt_pfconv_t _dtrace_conversions[] = { { "LG", "G", "long double", pfcheck_type, pfprint_fp }, { "o", "o", pfproto_xint, pfcheck_xint, pfprint_uint }, { "p", "x", pfproto_addr, pfcheck_addr, pfprint_uint }, +{ "P", "s", "uint16_t", pfcheck_type, pfprint_port }, { "s", "s", "char [] or string (or use stringof)", pfcheck_str, pfprint_cstr }, { "S", "s", pfproto_cstr, pfcheck_str, pfprint_estr }, { "T", "s", "int64_t", pfcheck_time, pfprint_time822 }, @@ -1225,6 +1272,20 @@ pfprint_average(dtrace_hdl_t *dtp, FILE *fp, const char *format, /*ARGSUSED*/ static int +pfprint_stddev(dtrace_hdl_t *dtp, FILE *fp, const char *format, + const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal) +{ + const uint64_t *data = addr; + + if (size != sizeof (uint64_t) * 4) + return (dt_set_errno(dtp, EDT_DMISMATCH)); + + return (dt_printf(dtp, fp, format, + dt_stddev((uint64_t *)data, normal))); +} + +/*ARGSUSED*/ +static int pfprint_quantize(dtrace_hdl_t *dtp, FILE *fp, const char *format, const dt_pfargd_t *pfd, const void *addr, size_t size, uint64_t normal) { @@ -1415,6 +1476,9 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv, case DTRACEAGG_AVG: func = pfprint_average; break; + case DTRACEAGG_STDDEV: + func = pfprint_stddev; + break; case DTRACEAGG_QUANTIZE: func = pfprint_quantize; break; diff --git a/lib/libdtrace/common/dt_proc.c b/lib/libdtrace/common/dt_proc.c index 419f13b8474c..96e85f1bdb0f 100644 --- a/lib/libdtrace/common/dt_proc.c +++ b/lib/libdtrace/common/dt_proc.c @@ -20,12 +20,10 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * DTrace Process Control * @@ -89,9 +87,8 @@ #include <dt_pid.h> #include <dt_impl.h> -#define IS_SYS_EXEC(w) (w == SYS_exec || w == SYS_execve) -#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_fork1 || \ - w == SYS_forkall || w == SYS_forksys) +#define IS_SYS_EXEC(w) (w == SYS_execve) +#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_forksys) static dt_bkpt_t * dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data) @@ -99,7 +96,7 @@ dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data) struct ps_prochandle *P = dpr->dpr_proc; dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); if ((dbp = dt_zalloc(dpr->dpr_hdl, sizeof (dt_bkpt_t))) != NULL) { dbp->dbp_func = func; @@ -121,7 +118,7 @@ dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts) int state = Pstate(dpr->dpr_proc); dt_bkpt_t *dbp, *nbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = nbp) { if (delbkpts && dbp->dbp_active && @@ -141,7 +138,7 @@ dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr) const lwpstatus_t *psp = &Pstatus(dpr->dpr_proc)->pr_lwp; dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { @@ -167,7 +164,7 @@ dt_proc_bpenable(dt_proc_t *dpr) { dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { @@ -184,7 +181,7 @@ dt_proc_bpdisable(dt_proc_t *dpr) { dt_bkpt_t *dbp; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { @@ -232,7 +229,7 @@ dt_proc_notify(dtrace_hdl_t *dtp, dt_proc_hash_t *dph, dt_proc_t *dpr, static void dt_proc_stop(dt_proc_t *dpr, uint8_t why) { - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); assert(why != DT_PROC_STOP_IDLE); if (dpr->dpr_stop & why) { @@ -333,7 +330,7 @@ dt_proc_attach(dt_proc_t *dpr, int exec) rd_err_e err; GElf_Sym sym; - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); if (exec) { if (psp->pr_lwp.pr_errno != 0) @@ -399,7 +396,7 @@ dt_proc_waitrun(dt_proc_t *dpr) const long wstop = PCWSTOP; int pfd = Pctlfd(P); - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); + assert(MUTEX_HELD(&dpr->dpr_lock)); assert(psp->pr_flags & PR_STOPPED); assert(Pstate(P) == PS_STOP); @@ -498,7 +495,6 @@ dt_proc_control(void *arg) * We must trace exit from exec() system calls so that if the exec is * successful, we can reset our breakpoints and re-initialize libproc. */ - (void) Psysexit(P, SYS_exec, B_TRUE); (void) Psysexit(P, SYS_execve, B_TRUE); /* @@ -509,10 +505,6 @@ dt_proc_control(void *arg) */ (void) Psysentry(P, SYS_vfork, B_TRUE); (void) Psysexit(P, SYS_vfork, B_TRUE); - (void) Psysentry(P, SYS_fork1, B_TRUE); - (void) Psysexit(P, SYS_fork1, B_TRUE); - (void) Psysentry(P, SYS_forkall, B_TRUE); - (void) Psysexit(P, SYS_forkall, B_TRUE); (void) Psysentry(P, SYS_forksys, B_TRUE); (void) Psysexit(P, SYS_forksys, B_TRUE); @@ -712,9 +704,12 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P) if (!(Pstatus(dpr->dpr_proc)->pr_flags & (PR_KLC | PR_RLC))) { dt_dprintf("abandoning pid %d\n", (int)dpr->dpr_pid); rflag = PRELEASE_HANG; + } else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) { + dt_dprintf("killing pid %d\n", (int)dpr->dpr_pid); + rflag = PRELEASE_KILL; /* apply kill-on-last-close */ } else { dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid); - rflag = 0; /* apply kill or run-on-last-close */ + rflag = 0; /* apply run-on-last-close */ } if (dpr->dpr_tid) { diff --git a/lib/libdtrace/common/dt_program.c b/lib/libdtrace/common/dt_program.c index 8497dab01e05..19f377de26ac 100644 --- a/lib/libdtrace/common/dt_program.c +++ b/lib/libdtrace/common/dt_program.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <unistd.h> #include <strings.h> #include <stdlib.h> @@ -44,10 +41,12 @@ dt_program_create(dtrace_hdl_t *dtp) { dtrace_prog_t *pgp = dt_zalloc(dtp, sizeof (dtrace_prog_t)); - if (pgp != NULL) + if (pgp != NULL) { dt_list_append(&dtp->dt_programs, pgp); - else + } else { (void) dt_set_errno(dtp, EDT_NOMEM); + return (NULL); + } /* * By default, programs start with DOF version 1 so that output files @@ -173,6 +172,9 @@ dtrace_program_exec(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, case E2BIG: err = EDT_DIFSIZE; break; + case EBUSY: + err = EDT_ENABLING_ERR; + break; default: err = errno; } @@ -431,8 +433,13 @@ dt_header_decl(dt_idhash_t *dhp, dt_ident_t *idp, void *data) if (fprintf(infop->dthi_out, ");\n") < 0) return (dt_set_errno(dtp, errno)); - if (fprintf(infop->dthi_out, "extern int " - "__dtraceenabled_%s___%s(void);\n", infop->dthi_pfname, fname) < 0) + if (fprintf(infop->dthi_out, + "#ifndef\t__sparc\n" + "extern int __dtraceenabled_%s___%s(void);\n" + "#else\n" + "extern int __dtraceenabled_%s___%s(long);\n" + "#endif\n", + infop->dthi_pfname, fname, infop->dthi_pfname, fname) < 0) return (dt_set_errno(dtp, errno)); return (0); @@ -494,13 +501,20 @@ dt_header_probe(dt_idhash_t *dhp, dt_ident_t *idp, void *data) return (dt_set_errno(dtp, errno)); if (!infop->dthi_empty) { - if (fprintf(infop->dthi_out, "#define\t%s_%s_ENABLED() \\\n", - infop->dthi_pmname, mname) < 0) - return (dt_set_errno(dtp, errno)); - - if (fprintf(infop->dthi_out, "\t__dtraceenabled_%s___%s()\n", + if (fprintf(infop->dthi_out, + "#ifndef\t__sparc\n" + "#define\t%s_%s_ENABLED() \\\n" + "\t__dtraceenabled_%s___%s()\n" + "#else\n" + "#define\t%s_%s_ENABLED() \\\n" + "\t__dtraceenabled_%s___%s(0)\n" + "#endif\n", + infop->dthi_pmname, mname, + infop->dthi_pfname, fname, + infop->dthi_pmname, mname, infop->dthi_pfname, fname) < 0) return (dt_set_errno(dtp, errno)); + } else { if (fprintf(infop->dthi_out, "#define\t%s_%s_ENABLED() (0)\n", infop->dthi_pmname, mname) < 0) diff --git a/lib/libdtrace/common/dt_string.c b/lib/libdtrace/common/dt_string.c index 02fa50720370..3a5315eef99a 100644 --- a/lib/libdtrace/common/dt_string.c +++ b/lib/libdtrace/common/dt_string.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,19 +18,18 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <strings.h> #include <stdlib.h> #include <errno.h> #include <ctype.h> #include <dt_string.h> +#include <dt_impl.h> /* * Create a copy of string s, but only duplicate the first n bytes. @@ -41,6 +39,9 @@ strndup(const char *s, size_t n) { char *s2 = malloc(n + 1); + if (s2 == NULL) + longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); + (void) strncpy(s2, s, n); s2[n] = '\0'; return (s2); diff --git a/lib/libdtrace/common/dt_subr.c b/lib/libdtrace/common/dt_subr.c index b2163e69e9a6..97221c84d6cc 100644 --- a/lib/libdtrace/common/dt_subr.c +++ b/lib/libdtrace/common/dt_subr.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,13 +18,12 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/sysmacros.h> #include <strings.h> @@ -57,8 +55,8 @@ int dtrace_xstr2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec, const char *s, int argc, char *const argv[], dtrace_probedesc_t *pdp) { - size_t off, len, vlen; - const char *p, *q, *v; + size_t off, len, vlen, wlen; + const char *p, *q, *v, *w; char buf[32]; /* for id_t as %d (see below) */ @@ -74,6 +72,8 @@ dtrace_xstr2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec, q = p + 1; vlen = 0; + w = NULL; + wlen = 0; if ((v = strchr(q, '$')) != NULL && v < q + len) { /* @@ -98,14 +98,14 @@ dtrace_xstr2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec, } if (isdigit(v[1])) { - char *end; long i; errno = 0; - i = strtol(v + 1, &end, 10); + i = strtol(v + 1, (char **)&w, 10); + + wlen = vlen - (w - v); - if (i < 0 || i >= argc || - errno != 0 || end != v + vlen) + if (i < 0 || i >= argc || errno != 0) return (dt_set_errno(dtp, EDT_BADSPCV)); v = argv[i]; @@ -141,7 +141,7 @@ dtrace_xstr2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec, off = dtrace_probespecs[spec--].dtps_offset; bcopy(q, (char *)pdp + off, len); bcopy(v, (char *)pdp + off + len, vlen); - + bcopy(w, (char *)pdp + off + len + vlen, wlen); } while (--p >= s); pdp->dtpd_id = DTRACE_IDNONE; @@ -803,30 +803,6 @@ dt_popcb(const ulong_t *bp, ulong_t n) return (popc + dt_popc(bp[maxw] & ((1UL << maxb) - 1))); } -struct _rwlock; -struct _lwp_mutex; - -int -dt_rw_read_held(pthread_rwlock_t *lock) -{ - extern int _rw_read_held(struct _rwlock *); - return (_rw_read_held((struct _rwlock *)lock)); -} - -int -dt_rw_write_held(pthread_rwlock_t *lock) -{ - extern int _rw_write_held(struct _rwlock *); - return (_rw_write_held((struct _rwlock *)lock)); -} - -int -dt_mutex_held(pthread_mutex_t *lock) -{ - extern int _mutex_held(struct _lwp_mutex *); - return (_mutex_held((struct _lwp_mutex *)lock)); -} - static int dt_string2str(char *s, char *str, int nbytes) { diff --git a/lib/libdtrace/common/mkerrno.sh b/lib/libdtrace/common/mkerrno.sh new file mode 100755 index 000000000000..50b7f1c1b908 --- /dev/null +++ b/lib/libdtrace/common/mkerrno.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2003 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +echo "\ +/*\n\ + * Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n\ + * Use is subject to license terms.\n\ + */\n\ +\n\ +#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n" + +pattern='^#define[ ]\(E[A-Z0-9]*\)[ ]*\([A-Z0-9]*\).*$' +replace='inline int \1 = \2;@#pragma D binding "1.0" \1' + +sed -n "s/$pattern/$replace/p" | tr '@' '\n' diff --git a/lib/libdtrace/common/mksignal.sh b/lib/libdtrace/common/mksignal.sh new file mode 100755 index 000000000000..1bffa6468c2b --- /dev/null +++ b/lib/libdtrace/common/mksignal.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2003 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +echo "\ +/*\n\ + * Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n\ + * Use is subject to license terms.\n\ + */\n\ +\n\ +#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n" + +pattern='^#define[ ]*_*\(SIG[A-Z0-9]*\)[ ]\{1,\}\([A-Z0-9]*\).*$' +replace='inline int \1 = \2;@#pragma D binding "1.0" \1' + +sed -n "s/$pattern/$replace/p;/SIGRTMAX/q" | tr '@' '\n' diff --git a/lib/libgen/common/gmatch.c b/lib/libgen/common/gmatch.c index dc47f7ec3f01..3f906f6a4ac4 100644 --- a/lib/libgen/common/gmatch.c +++ b/lib/libgen/common/gmatch.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,21 +19,16 @@ * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1.5.2 */ - -/*LINTLIBRARY*/ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ -#pragma weak gmatch = _gmatch +#pragma ident "%Z%%M% %I% %E% SMI" -#include "gen_synonyms.h" #include <sys/types.h> #include <libgen.h> #include <stdlib.h> @@ -47,7 +41,7 @@ c = cl; \ if (n <= 0) \ return (0); \ - p += n; + p += n int gmatch(const char *s, const char *p) @@ -88,13 +82,13 @@ gmatch(const char *s, const char *p) notflag = 1; p++; } - Popwchar(p, c) + Popwchar(p, c); do { if (c == '-' && lc && *p != ']') { - Popwchar(p, c) + Popwchar(p, c); if (c == '\\') { - Popwchar(p, c) + Popwchar(p, c); } if (notflag) { if (!multibyte || @@ -113,7 +107,7 @@ gmatch(const char *s, const char *p) } } else if (c == '\\') { /* skip to quoted character */ - Popwchar(p, c) + Popwchar(p, c); } lc = c; if (notflag) { @@ -127,14 +121,14 @@ gmatch(const char *s, const char *p) if (scc == lc) ok++; } - Popwchar(p, c) + Popwchar(p, c); } while (c != ']'); return (ok ? gmatch(s, p) : 0); } case '\\': /* skip to quoted character and see if it matches */ - Popwchar(p, c) + Popwchar(p, c); default: if (c != scc) |