Mercurial > illumos > illumos-gate
changeset 13105:48f2dbca79a2
PSARC 2010/299 GNU/Linux/BSD compatibility functions
6960818 add get_nprocs(), getline(), strdupa(), strndup() to libc
6901783 strndup would be nice
6824404 libc should provide ffsl() & ffsll()
6793969 RFE: Add|stpcpy|to libc
6735446 Want a __progname symbol for BSD-style source compatibility
6421095 Solaris should provide strcasestr
6275498 Provide string compare functions wcscasecmp,wcsncasecmp in solaris like linux
line wrap: on
line diff
--- a/usr/src/cmd/acctadm/main.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/acctadm/main.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/acctctl.h> @@ -134,7 +134,7 @@ (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname(argv[0]); + (void) setpname(argv[0]); for (; optind < argc; optind++) { while ((c = getopt(argc, argv, OPTS)) != (int)EOF) {
--- a/usr/src/cmd/acctadm/utils.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/acctadm/utils.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <assert.h> @@ -85,7 +85,7 @@ } char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/');
--- a/usr/src/cmd/acctadm/utils.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/acctadm/utils.h Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _UTILS_H @@ -42,7 +42,7 @@ extern void warn(const char *, ...); extern void die(char *, ...); -extern char *setprogname(char *); +extern char *setpname(char *); extern const char *ac_type_name(int); extern int open_exacct_file(const char *, int); extern boolean_t verify_exacct_file(const char *, int);
--- a/usr/src/cmd/awk/awk.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/awk/awk.h Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -362,6 +361,6 @@ extern Cell *call(Node **, int); extern Cell *arg(Node **, int); extern Cell *getnf(Node **, int); -extern Cell *getline(Node **, int); +extern Cell *getaline(Node **, int); #endif /* AWK_H */
--- a/usr/src/cmd/awk/maketab.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/awk/maketab.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -101,7 +100,7 @@ { CALL, "call", "call" }, { ARG, "arg", "arg" }, { VARNF, "getnf", "NF" }, - { GETLINE, "getline", "getline" }, + { GETLINE, "getaline", "getline" }, { 0, "", "" }, };
--- a/usr/src/cmd/awk/run.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/awk/run.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -359,7 +358,7 @@ } Cell * -getline(Node **a, int n) +getaline(Node **a, int n) { /* a[0] is variable, a[1] is operator, a[2] is filename */ register Cell *r, *x;
--- a/usr/src/cmd/bnu/sysfiles.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/bnu/sysfiles.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,17 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 1998 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - #include "uucp.h" #include <unistd.h> @@ -55,7 +51,7 @@ /* private variables */ static void tokenize(), nameparse(), setfile(), setioctl(), scansys(), scancfg(), setconfig(); -static int namematch(), nextdialers(), nextdevices(), nextsystems(), getline(); +static int namematch(), nextdialers(), nextdevices(), nextsystems(), getaline(); /* pointer arrays might be dynamically allocated */ static char *Systems[64] = {0}; /* list of Systems files */ @@ -164,7 +160,7 @@ Systems[0] = Devices[0] = Dialers[0] = NULL; if ((f = fopen(SYSFILES, "r")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Sysfiles */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -215,7 +211,7 @@ msgtime = MSGTIME; if ((f = fopen(DEVCONFIG, "r")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Devconfig */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -241,7 +237,7 @@ */ static int -getline(f, line) +getaline(f, line) FILE *f; char *line; { char *lptr, *lend; @@ -484,7 +480,7 @@ ASSERT(len >= BUFSIZ, "BUFFER TOO SMALL", "getsysline", 0); for(;;) { - while (getline(fsystems, buf) != NULL) + while (getaline(fsystems, buf) != NULL) if ((*buf != '#') && (*buf != ' ') && (*buf != '\t') && (*buf != '\n')) { (void) _uu_resetlocale(LC_ALL, prev); @@ -752,7 +748,7 @@ extern char _ProtoCfg[]; if ((f = fopen(CONFIG, "r")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Config file */ tok = strtok(buf, " \t"); if ( (tok != NULL) && (*tok != '#') ) {
--- a/usr/src/cmd/boot/bootadm/bootadm_hyper.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/boot/bootadm/bootadm_hyper.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdio.h> @@ -347,9 +347,8 @@ if ((strncmp(optstr, "ttya-mode", namlen) == 0) || (strncmp(optstr, "ttyb-mode", namlen) == 0)) { - char *port = alloca(namlen + 1); + char *port = strndupa(optstr, namlen); - (void) strlcpy(port, optstr, namlen + 1); return (serial_metal_to_hyper(port, value)); } @@ -840,19 +839,15 @@ * Process important lines from menu.lst boot entry. */ if (lp->flags == BAM_TITLE) { - title = alloca(strlen(lp->arg) + 1); - (void) strcpy(title, lp->arg); + title = strdupa(lp->arg); } else if (lp->cmd != NULL) { if (strcmp(lp->cmd, "findroot") == 0) { - findroot = alloca(strlen(lp->arg) + 1); - (void) strcpy(findroot, lp->arg); + findroot = strdupa(lp->arg); } else if (strcmp(lp->cmd, "bootfs") == 0) { - bootfs = alloca(strlen(lp->arg) + 1); - (void) strcpy(bootfs, lp->arg); + bootfs = strdupa(lp->arg); } else if (strcmp(lp->cmd, menu_cmds[MODULE_DOLLAR_CMD]) == 0) { - module = alloca(strlen(lp->arg) + 1); - (void) strcpy(module, lp->arg); + module = strdupa(lp->arg); } else if ((strcmp(lp->cmd, menu_cmds[KERNEL_DOLLAR_CMD]) == 0) && (ret = cvt_metal_kernel(lp->arg, @@ -1065,25 +1060,19 @@ * Process important lines from menu.lst boot entry. */ if (lp->flags == BAM_TITLE) { - title = alloca(strlen(lp->arg) + 1); - (void) strcpy(title, lp->arg); + title = strdupa(lp->arg); } else if (lp->cmd != NULL) { if (strcmp(lp->cmd, "findroot") == 0) { - findroot = alloca(strlen(lp->arg) + 1); - (void) strcpy(findroot, lp->arg); + findroot = strdupa(lp->arg); } else if (strcmp(lp->cmd, "bootfs") == 0) { - bootfs = alloca(strlen(lp->arg) + 1); - (void) strcpy(bootfs, lp->arg); + bootfs = strdupa(lp->arg); } else if (strcmp(lp->cmd, menu_cmds[MODULE_DOLLAR_CMD]) == 0) { if (strstr(lp->arg, "boot_archive") == NULL) { - module = alloca(strlen(lp->arg) + 1); - (void) strcpy(module, lp->arg); + module = strdupa(lp->arg); cvt_hyper_module(module, &kern_path); } else { - barchive_path = - alloca(strlen(lp->arg) + 1); - (void) strcpy(barchive_path, lp->arg); + barchive_path = strdupa(lp->arg); } } else if ((strcmp(lp->cmd, menu_cmds[KERNEL_DOLLAR_CMD]) == 0) &&
--- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/Makefile Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/Makefile Thu Aug 12 14:55:22 2010 -0700 @@ -1,6 +1,5 @@ # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. # PROG= in.ftpd ftpcount ftpshut ftprestart privatepw @@ -15,8 +14,7 @@ access.o extensions.o realpath.o acl.o private.o \ authenticate.o conversions.o rdservers.o paths.o hostacc.o \ routevector.o restrict.o domain.o wu_fnmatch.o timeout.o \ - getpwnam.o strsep.o strcasestr.o inet.o xferlog.o gssutil.o \ - privs.o + getpwnam.o inet.o xferlog.o gssutil.o privs.o FTPCOUNT_OBJS= $(COMMON_OBJS) ftpcount.o rdservers.o inet.o FTPSHUT_OBJS= $(COMMON_OBJS) ftpshut.o rdservers.o inet.o FTPREST_OBJS= $(COMMON_OBJS) ftprestart.o rdservers.o inet.o
--- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/proto.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/proto.h Thu Aug 12 14:55:22 2010 -0700 @@ -336,8 +336,3 @@ */ char *getusershell(void); void endusershell(void); - -/* - ** support/strcasestr.c - */ -char *strcasestr(register char *s, register char *find);
--- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strcasestr.c Thu Aug 12 14:07:03 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -#pragma ident "%Z%%M% %I% %E% SMI" - -/**************************************************************************** - - Copyright (c) 1999,2000 WU-FTPD Development Group. - All rights reserved. - - Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 - The Regents of the University of California. - Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. - Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. - Portions Copyright (c) 1989 Massachusetts Institute of Technology. - Portions Copyright (c) 1998 Sendmail, Inc. - Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. - Portions Copyright (c) 1997 by Stan Barber. - Portions Copyright (c) 1997 by Kent Landfield. - Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 - Free Software Foundation, Inc. - - Use and distribution of this software and its source code are governed - by the terms and conditions of the WU-FTPD Software License ("LICENSE"). - - If you did not receive a copy of the license, it may be obtained online - at http://www.wu-ftpd.org/license.html. - - $Id: strcasestr.c,v 1.5 2000/07/01 18:36:29 wuftpd Exp $ - -****************************************************************************/ -#include <string.h> -/* - * Find the first occurrence of find in s. - */ -char *strcasestr(register char *s, register char *find) -{ - register char c, sc; - register size_t len; - - if ((c = *find++) != 0) { - len = strlen(find); - do { - do { - if ((sc = *s++) == 0) - return (NULL); - } while (sc != c); - } while (strncasecmp(s, find, len) != 0); - s--; - } - return ((char *) s); -}
--- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strsep.c Thu Aug 12 14:07:03 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#pragma ident "%Z%%M% %I% %E% SMI" - -/**************************************************************************** - - Copyright (c) 1999,2000 WU-FTPD Development Group. - All rights reserved. - - Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 - The Regents of the University of California. - Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. - Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. - Portions Copyright (c) 1989 Massachusetts Institute of Technology. - Portions Copyright (c) 1998 Sendmail, Inc. - Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. - Portions Copyright (c) 1997 by Stan Barber. - Portions Copyright (c) 1997 by Kent Landfield. - Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 - Free Software Foundation, Inc. - - Use and distribution of this software and its source code are governed - by the terms and conditions of the WU-FTPD Software License ("LICENSE"). - - If you did not receive a copy of the license, it may be obtained online - at http://www.wu-ftpd.org/license.html. - - $Id: strsep.c,v 1.6 2000/07/01 18:36:29 wuftpd Exp $ - -****************************************************************************/ -#include <string.h> -#include <stdio.h> - -/* - * Get next token from string *stringp, where tokens are nonempty - * strings separated by characters from delim. - * - * Writes NULLs into the string at *stringp to end tokens. - * delim need not remain constant from call to call. - * On return, *stringp points past the last NUL written (if there might - * be further tokens), or is NULL (if there are definitely no more tokens). - * - * If *stringp is NULL, strsep returns NULL. - */ -char *strsep(register char **stringp, register const char *delim) -{ - register char *s; - register const char *spanp; - register int c, sc; - char *tok; - - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -}
--- a/usr/src/cmd/cpc/common/strtoset.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/cpc/common/strtoset.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,14 +18,13 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdio.h> #include <stdlib.h> -#include <alloca.h> #include <errno.h> #include <libintl.h> @@ -491,7 +490,7 @@ toks[x] = NULL; - opts = strcpy(alloca(strlen(spec) + 1), spec); + opts = strdupa(spec); while (*opts != '\0') { int idx = getsubopt(&opts, toks, &val);
--- a/usr/src/cmd/csplit/csplit.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/csplit/csplit.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ /* * csplit - Context or line file splitter @@ -83,7 +79,7 @@ static offset_t findline(char *, offset_t); static void flush(void); static FILE *getfile(void); -static char *getline(int); +static char *getaline(int); static void line_arg(char *); static void num_arg(char *, int); static void re_arg(char *); @@ -143,13 +139,13 @@ if (errno == ENOSPC) { (void) fprintf(stderr, "csplit: "); (void) fprintf(stderr, gettext( - "No space left on device\n")); + "No space left on device\n")); exit(1); } else { (void) fprintf(stderr, "csplit: "); (void) fprintf(stderr, gettext( - "Bad write to temporary " - "file\n")); + "Bad write to temporary " + "file\n")); exit(1); } @@ -294,7 +290,7 @@ * Its arguments are a pointer to the compiled regular expression(expr), * and an offset(oset). The variable lncnt is used to count the number * of lines searched. First the current stream location is saved via - * ftello(), and getline is called so that R.E. searching starts at the + * ftello(), and getaline is called so that R.E. searching starts at the * line after the previously referenced line. The while loop checks * that there are more lines(error if none), bumps the line count, and * checks for the R.E. on each line. If the R.E. matches on one of the @@ -310,11 +306,11 @@ saveloc = ftello(infile); if (curline != (offset_t)1 || benhere) /* If first line, first time, */ - (void) getline(FALSE); /* then don't skip */ + (void) getaline(FALSE); /* then don't skip */ else lncnt--; benhere = 1; - while (getline(FALSE) != NULL) { + while (getaline(FALSE) != NULL) { lncnt++; if ((sptr = strrchr(linbuf, '\n')) != NULL) *sptr = '\0'; @@ -362,7 +358,8 @@ if (create) { if (fptr == 0) - for (fptr = file; *fptr != NULL; fptr++); + for (fptr = file; *fptr != NULL; fptr++) + continue; (void) sprintf(fptr, "%.*d", fiwidth, ctr++); /* check for suffix length overflow */ @@ -406,12 +403,12 @@ /* * Getline gets a line via fgets from the input stream "infile". * The line is put into linbuf and may not be larger than LINSIZ. - * If getline is called with a non-zero value, the current line + * If getaline is called with a non-zero value, the current line * is bumped, otherwise it is not(for R.E. searching). */ static char * -getline(int bumpcur) +getaline(int bumpcur) { char *ret; if (bumpcur) @@ -570,15 +567,15 @@ if (curline > ln) fatal("%s - out of range\n", targ); while (curline < ln) { - if (getline(TRUE) == NULL) + if (getaline(TRUE) == NULL) fatal("%s - out of range\n", targ); flush(); } } else /* last file */ - if (getline(TRUE) != NULL) { + if (getaline(TRUE) != NULL) { flush(); for (;;) { - if (getline(TRUE) == NULL) + if (getaline(TRUE) == NULL) break; flush(); } @@ -591,7 +588,7 @@ usage() { (void) fprintf(stderr, gettext( - "usage: csplit [-ks] [-f prefix] [-n number] " - "file arg1 ...argn\n")); + "usage: csplit [-ks] [-f prefix] [-n number] " + "file arg1 ...argn\n")); exit(1); }
--- a/usr/src/cmd/devctl/devctl.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/devctl/devctl.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,14 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - - /* * devctl - device control utility * @@ -107,7 +103,7 @@ extern int errno; -static void setprogname(char *name); +static void setpname(char *name); static void print_bus_state(char *devname, uint_t state); static void print_dev_state(char *devname, uint_t state); static int dev_getstate(devctl_hdl_t); @@ -191,7 +187,7 @@ devctl_hdl_t dcp; struct stat stat_buf; - setprogname(argv[0]); + setpname(argv[0]); while ((c = getopt(argc, argv, "vd")) != -1) { switch (c) { case 'v': @@ -255,8 +251,8 @@ if ((pathlen = readlink(orig_path, devctl_device, MAXPATHLEN)) == -1) { (void) fprintf(stderr, - "devctl: readlink(%s) - %s\n", - orig_path, strerror(errno)); + "devctl: readlink(%s) - %s\n", + orig_path, strerror(errno)); exit(-1); } devctl_device[pathlen] = '\0'; @@ -308,16 +304,16 @@ dcp = devctl_pm_dev_acquire(devctl_device, 0); if (dcp == NULL) { (void) fprintf(stderr, - "devctl: device_pm_dev_acquire %s - %s\n", - devctl_device, strerror(errno)); + "devctl: device_pm_dev_acquire %s - %s\n", + devctl_device, strerror(errno)); exit(-1); } } else { dcp = devctl_device_acquire(devctl_device, 0); if (dcp == NULL) { (void) fprintf(stderr, - "devctl: device_acquire %s - %s\n", - devctl_device, strerror(errno)); + "devctl: device_acquire %s - %s\n", + devctl_device, strerror(errno)); exit(-1); } } @@ -516,7 +512,7 @@ } static void -setprogname(char *name) +setpname(char *name) { register char *p;
--- a/usr/src/cmd/diff3/diff3prog.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/diff3/diff3prog.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ #include <stdio.h> #include <stdlib.h> @@ -105,7 +102,7 @@ static int number(char **lc); static int digit(int c); static int getchange(FILE *b); -static int getline(FILE *b); +static int getaline(FILE *b); static void merge(int m1, int m2); static void separate(char *s); static void change(int i, struct range *rold, int dup); @@ -154,9 +151,9 @@ usage(); if (oflag) { (void) snprintf(f1mark, sizeof (f1mark), "<<<<<<< %s", - argc >= 7 ? argv[6] : argv[3]); + argc >= 7 ? argv[6] : argv[3]); (void) snprintf(f3mark, sizeof (f3mark), ">>>>>>> %s", - argc >= 8 ? argv[7] : argv[5]); + argc >= 8 ? argv[7] : argv[5]); } m = readin(argv[1], d13); @@ -165,7 +162,7 @@ if ((fp[i] = fopen(argv[i+3], "r")) == NULL) { save_err = errno; (void) fprintf(stderr, "diff3: can't open %s: ", - argv[i+3]); + argv[i+3]); errno = save_err; perror(""); exit(1); @@ -250,14 +247,14 @@ static int getchange(FILE *b) { - while (getline(b)) + while (getaline(b)) if (digit(line[0])) return (1); return (0); } static int -getline(FILE *b) +getaline(FILE *b) { int i, c; for (i = 0; i < sizeof (line)-1; i++) { @@ -288,10 +285,10 @@ for (; (t1 = d1 < d13+m1) | (t2 = d2 < d23+m2); ) { if (debug) { (void) printf("%d,%d=%d,%d %d,%d=%d,%d\n", - d1->old.from, d1->old.to, - d1->new.from, d1->new.to, - d2->old.from, d2->old.to, - d2->new.from, d2->new.to); + d1->old.from, d1->old.to, + d1->new.from, d1->new.to, + d2->old.from, d2->old.to, + d2->new.from, d2->new.to); } /* first file is different from others */ @@ -454,7 +451,7 @@ { int j, n; for (n = 0; cline[i] < from-1; n += j) { - if ((j = getline(fp[i])) == 0) + if ((j = getaline(fp[i])) == 0) trouble(); if (pr) (void) printf("%s%s", pr, line);
--- a/usr/src/cmd/dis/dis_target.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/dis/dis_target.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <assert.h> @@ -100,10 +99,9 @@ Elf_Data *ds_data; }; -/* Lifted from Psymtab.c */ +/* Lifted from Psymtab.c, omitting STT_TLS */ #define DATA_TYPES \ - ((1 << STT_OBJECT) | (1 << STT_FUNC) | \ - (1 << STT_COMMON) | (1 << STT_TLS)) + ((1 << STT_OBJECT) | (1 << STT_FUNC) | (1 << STT_COMMON)) #define IS_DATA_TYPE(tp) (((1 << (tp)) & DATA_TYPES) != 0) /*
--- a/usr/src/cmd/ed/ed.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ed/ed.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ /* * Editor @@ -331,7 +327,7 @@ static void setzeroasone(void); static long putline(void); static LINE address(void); -static char *getline(long); +static char *getaline(long); static char *getblock(long, long); static char *place(char *, char *, char *); static void comple(wchar_t); @@ -693,7 +689,7 @@ putd(); putchr('\t'); } - puts(getline((a1++)->cur)); + puts(getaline((a1++)->cur)); } while (a1 <= addr2); dot = addr2; @@ -1441,7 +1437,7 @@ fp = genbuf; a1 = addr1; do { - lp = getline(a1++->cur); + lp = getaline(a1++->cur); if (fss.Ffill && fss.Flim && lenchk(linebuf, &fss) < 0) { write(1, gettext("line too long: lno = "), strlen(gettext("line too long: lno = "))); @@ -1676,7 +1672,7 @@ } static char * -getline(long tl) +getaline(long tl) { char *bp, *lp; int nl; @@ -1911,7 +1907,7 @@ return; gp = genbuf; for (a1 = addr1; a1 <= addr2; a1++) { - lp = getline(a1->cur); + lp = getaline(a1->cur); while (*gp = *lp++) if (gp++ > &genbuf[LBSIZE-1]) (void) error(27); @@ -2259,7 +2255,7 @@ if (addr1 > addr2) return (EOF); - (void) getline((addr1++)->cur); + (void) getaline((addr1++)->cur); return (0); } @@ -2292,7 +2288,7 @@ else { if (addr == zero) return (0); - p1 = getline(addr->cur); + p1 = getaline(addr->cur); locs = 0; } return (step(p1, expbuf)); @@ -2595,7 +2591,7 @@ if (a1->cur & 01) { a1->cur &= ~01; dot = a1; - puts(getline(a1->cur)); + puts(getaline(a1->cur)); if ((c = get_wchr()) == EOF) (void) error(52); if (c == 'a' || c == 'i' || c == 'c')
--- a/usr/src/cmd/eeprom/common/error.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/eeprom/common/error.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 +18,9 @@ * * CDDL HEADER END */ -#pragma ident "%Z%%M% %I% %E% SMI" /* - * Copyright 1989-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdio.h> @@ -36,7 +33,7 @@ char *progname; void -setprogname(char *name) +setpname(char *name) { register char *p = name, c;
--- a/usr/src/cmd/eeprom/i386/benv.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/eeprom/i386/benv.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -39,7 +40,7 @@ extern void get_kbenv(void); extern void close_kbenv(void); extern caddr_t get_propval(char *name, char *node); -extern void setprogname(char *prog); +extern void setpname(char *prog); extern char *getbootcmd(void); char *boottree; @@ -1052,7 +1053,7 @@ benv_des_t *bd; char *file = NULL; - setprogname(argv[0]); + setpname(argv[0]); while ((c = getopt(argc, argv, "f:Itv")) != -1) switch (c) {
--- a/usr/src/cmd/eeprom/sparc/openprom.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/eeprom/sparc/openprom.c Thu Aug 12 14:55:22 2010 -0700 @@ -1,7 +1,9 @@ /* * Open Boot Prom eeprom utility - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + */ + +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -42,7 +44,7 @@ } Oppbuf; extern int _error(int do_perror, char *fmt, ...); -extern void setprogname(char *); +extern void setpname(char *); static int get_password(char *, int); extern int loadlogo(char *, int, int, char *); @@ -133,7 +135,7 @@ "[variable[=value] ...]", argv[0])); } - setprogname(argv[0]); + setpname(argv[0]); /* * If no arguments, dump all fields.
--- a/usr/src/cmd/env/env.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/env/env.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,23 +18,22 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T * All Rights Reserved */ /* - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ - -/* * env [ - ] [ name=value ]... [command arg...] * set environment, then execute command (or print environment) * - says start fresh, otherwise merge with inherited environment */ - #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -49,7 +47,6 @@ static void Usage(); -static char *nullp = NULL; extern char **environ; @@ -70,7 +67,7 @@ /* check for non-standard "-" option */ if ((argc > 1) && (strcmp(argv[1], "-")) == 0) { - environ = &nullp; + (void) clearenv(); for (i = 1; i < argc; i++) argv[i] = argv[i+1]; argc--; @@ -80,7 +77,7 @@ while ((opt = getopt(argc, argv, "i")) != EOF) { switch (opt) { case 'i': - environ = &nullp; + (void) clearenv(); break; default:
--- a/usr/src/cmd/eqn/io.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/eqn/io.c Thu Aug 12 14:55:22 2010 -0700 @@ -1,6 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -12,8 +11,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "e.h" #include <stdlib.h> #include <locale.h> @@ -27,7 +24,7 @@ static void do_inline(void); int eqn(int, char *[]); -static int getline(char *); +static int getaline(char *); static void init(void); void nrwid(int, int, int); int oalloc(void); @@ -53,7 +50,7 @@ setfile(argc, argv); init_tbl(); /* install keywords in tables */ - while ((type = getline(in)) != EOF) { + while ((type = getaline(in)) != EOF) { eqline = linect; if (in[0] == '.' && in[1] == 'E' && in[2] == 'Q') { for (i = 11; i < 100; used[i++] = 0) @@ -96,7 +93,7 @@ } static int -getline(char *s) +getaline(char *s) { int c; while ((*s++ = c = gtc()) != '\n' && c != EOF && c != lefteq) @@ -130,7 +127,7 @@ ofree(eqnreg); } printf(".ps \\n(99\n.ft \\n(98\n"); - } while (getline(in) == lefteq); + } while (getaline(in) == lefteq); if (*in) printf(".as %d \"%s", ds, in); printf(".ps \\n(99\n.ft \\n(98\n");
--- a/usr/src/cmd/fm/fmd/common/fmd_idspace.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fm/fmd/common/fmd_idspace.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <fmd_alloc.h> #include <fmd_subr.h> #include <fmd_conf.h> @@ -34,47 +31,6 @@ #include <fmd_idspace.h> #include <fmd.h> -static int -highbit(ulong_t i) -{ - int h = 1; - - if (i == 0) - return (0); - -#ifdef _LP64 - if (i & 0xffffffff00000000ul) { - h += 32; - i >>= 32; - } -#endif - - if (i & 0xffff0000) { - h += 16; - i >>= 16; - } - - if (i & 0xff00) { - h += 8; - i >>= 8; - } - - if (i & 0xf0) { - h += 4; - i >>= 4; - } - - if (i & 0xc) { - h += 2; - i >>= 2; - } - - if (i & 0x2) - h += 1; - - return (h); -} - fmd_idspace_t * fmd_idspace_create(const char *name, id_t min, id_t max) { @@ -93,7 +49,7 @@ (void) fmd_conf_getprop(fmd.d_conf, "ids.max", &ids_max); hashmax = max - min + 1; - hashlen = 1 << highbit(hashmax / ids_avg); + hashlen = 1 << fls(hashmax / ids_avg); if (hashlen > ids_max) hashlen = ids_max;
--- a/usr/src/cmd/fm/fmd/common/fmd_module.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fm/fmd/common/fmd_module.c Thu Aug 12 14:55:22 2010 -0700 @@ -958,8 +958,7 @@ ASSERT(fmd_module_locked(mp)); - dictnam = alloca(strlen(dict) + 1); - (void) strcpy(dictnam, fmd_strbasename(dict)); + dictnam = strdupa(fmd_strbasename(dict)); if ((p = strrchr(dictnam, '.')) != NULL && strcmp(p, ".dict") == 0)
--- a/usr/src/cmd/fm/modules/common/ip-transport/ip.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fm/modules/common/ip-transport/ip.c Thu Aug 12 14:55:22 2010 -0700 @@ -34,7 +34,6 @@ #include <strings.h> #include <unistd.h> #include <pthread.h> -#include <alloca.h> #include <fcntl.h> #include <errno.h> #include <netdb.h> @@ -1028,8 +1027,7 @@ (void) nvlist_add_uint8(ip_auth, FM_VERSION, FM_FMRI_AUTH_VERSION); - s = alloca(strlen(auth) + 1); - (void) strcpy(s, auth); + s = strdupa(auth); fmd_prop_free_string(hdl, auth); for (p = strtok_r(s, ",", &q); p != NULL;
--- a/usr/src/cmd/format/label.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/format/label.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,22 +18,15 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* * This file contains the code relating to label manipulation. */ -#include "global.h" -#include "label.h" -#include "misc.h" -#include "main.h" -#include "partition.h" -#include "ctlr_scsi.h" -#include "checkdev.h" #include <string.h> #include <stdlib.h> #include <memory.h> @@ -43,6 +36,13 @@ #include <sys/uuid.h> #include <errno.h> #include <devid.h> +#include "global.h" +#include "label.h" +#include "misc.h" +#include "main.h" +#include "partition.h" +#include "ctlr_scsi.h" +#include "checkdev.h" #if defined(_FIRMWARE_NEEDS_FDISK) #include <sys/dktp/fdisk.h>
--- a/usr/src/cmd/format/modify_partition.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/format/modify_partition.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,14 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* * This file contains functions to implement the partition menu commands. */ +#include <stdlib.h> +#include <string.h> #include "global.h" #include "partition.h" #include "menu_partition.h" @@ -36,9 +38,6 @@ #include "label.h" #include "auto_sense.h" -#include <stdlib.h> -#include <string.h> - #ifdef __STDC__ /* Function prototypes for ANSI C Compilers */
--- a/usr/src/cmd/format/partition.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/format/partition.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,21 +18,21 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* * This file contains functions that operate on partition tables. */ +#include <string.h> +#include <stdlib.h> #include "global.h" #include "partition.h" #include "misc.h" #include "menu_command.h" #include "menu_partition.h" -#include <string.h> -#include <stdlib.h> /*
--- a/usr/src/cmd/fps/Makefile Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fps/Makefile Thu Aug 12 14:55:22 2010 -0700 @@ -19,8 +19,7 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # include ../Makefile.cmd @@ -42,16 +41,12 @@ check: fpsd # -# Note that the compilation of fptest is handled differently. -# If the primary compiler is not a Sun Studio compiler, fptest will -# *not* be compiled. This is because fptest is dependent on some Sun +# The compilation of fptest is forced to be done with the Sun +# Studio compiler. This is because fptest is dependent on some Sun # performance libraries provided as part of the Sun Studio compiler -# installation. fptest statically links libsunperf.a, libfui.a, -# libfai.a, libfsu.a, and libsunmath.a. The other SUBDIRS will be -# compiled. -# -# If the make macro __GNUC is "#", it means Sun Studio compiler is being -# used for the compilation. +# installation. fptest statically links libsunperf.a, libfui.a, +# libfai.a, libfsu.a, and libsunmath.a. The other SUBDIRS will be +# compiled normally. # $(SUBDIRS): FRC @@ -63,14 +58,11 @@ *) \ if [ $@ != fptest ]; \ then \ - cd $@; pwd; VERSION='$(VERSION)' $(MAKE) \ - $(TARGET); \ + cd $@; pwd; VERSION='$(VERSION)' \ + $(MAKE) $(TARGET); \ else \ - if [ "$(__GNUC)" = "#" ]; \ - then \ - cd $@; pwd; VERSION='$(VERSION)' \ - $(MAKE) $(TARGET); \ - fi \ + cd $@; pwd; VERSION='$(VERSION)' \ + $(MAKE) __GNUC=$(POUND_SIGN) $(TARGET); \ fi \ ;; \ esac
--- a/usr/src/cmd/fs.d/nfs/lib/nfslog_config.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fs.d/nfs/lib/nfslog_config.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <ctype.h> #include <errno.h> #include <locale.h> @@ -90,7 +87,7 @@ static void remove_config(nfsl_config_t **, nfsl_config_t *, nfsl_config_t **); void nfsl_printconfig(nfsl_config_t *); #endif /* DEBUG */ -static char *getline(FILE *, char *, char *, int); +static char *gataline(FILE *, char *, char *, int); static int get_info(char *, char **, char **, char **, char **, char **, char **, int *); static void free_config(nfsl_config_t *); @@ -286,7 +283,7 @@ assert (*listpp != NULL); tail = getlastconfig(*listpp); - while (getline(fp, NFSL_CONFIG_FILE_PATH, linebuf, sizeof (linebuf))) { + while (gataline(fp, NFSL_CONFIG_FILE_PATH, linebuf, sizeof (linebuf))) { if (linebuf[0] == '\0') { /* * ignore lines that exceed max size @@ -939,13 +936,13 @@ } /* - * getline attempts to get a line from the configuration file, + * gataline attempts to get a line from the configuration file, * upto LINESZ. A line in the file is a concatenation of lines if the * continuation symbol '\' is used at the end of the line. Returns * line on success, a NULL on EOF, and an empty string on lines > linesz. */ static char * -getline(FILE *fp, char *path, char *line, int linesz) { +gataline(FILE *fp, char *path, char *line, int linesz) { register char *p = line; register int len; int excess = 0;
--- a/usr/src/cmd/fs.d/udfs/fsck/utilities.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fs.d/udfs/fsck/utilities.c Thu Aug 12 14:55:22 2010 -0700 @@ -1,6 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -25,8 +24,6 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <fcntl.h> #include <errno.h> @@ -64,7 +61,7 @@ void flush(int32_t, struct bufarea *); int32_t bread(int32_t, char *, daddr_t, long); void bwrite(int, char *, daddr_t, long); -static int32_t getline(FILE *, char *, int32_t); +static int32_t getaline(FILE *, char *, int32_t); void errexit(char *, ...) __NORETURN; static long diskreads, totalreads; /* Disk cache statistics */ offset_t llseek(); @@ -86,7 +83,7 @@ (void) printf("\n"); (void) printf( gettext("%s: UNEXPECTED INCONSISTENCY; RUN fsck " - "MANUALLY.\n"), devname); + "MANUALLY.\n"), devname); va_end(args); exit(36); } @@ -172,7 +169,7 @@ if (len > fsbsize) { (void) printf(gettext("File entry at %x is too long " - "(%d bytes)\n"), block, len); + "(%d bytes)\n"), block, len); len = fsbsize; } bp = getdatablk((daddr_t)(block + part_start), fsbsize); @@ -185,7 +182,7 @@ err = verifytag(&fp->fe_tag, block, &fp->fe_tag, UD_FILE_ENTRY); if (err) { (void) printf(gettext("Tag error %s or bad file entry, " - "tag=%d\n"), tagerrs[err], fp->fe_tag.tag_id); + "tag=%d\n"), tagerrs[err], fp->fe_tag.tag_id); bp->b_flags &= ~B_INUSE; return (NULL); } @@ -220,7 +217,7 @@ (void) printf(gettext(" yes\n\n")); return (1); } - if (getline(stdin, line, sizeof (line)) == EOF) + if (getaline(stdin, line, sizeof (line)) == EOF) errexit("\n"); (void) printf("\n"); if (line[0] == 'y' || line[0] == 'Y') @@ -232,7 +229,7 @@ } int32_t -getline(FILE *fp, char *loc, int32_t maxlen) +getaline(FILE *fp, char *loc, int32_t maxlen) { int n; register char *p, *lastloc; @@ -337,7 +334,7 @@ return; if (bp->b_errs != 0) pfatal(gettext("WRITING ZERO'ED BLOCK %d TO DISK\n"), - bp->b_bno); + bp->b_bno); bp->b_dirty = 0; bp->b_errs = 0; bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size); @@ -370,7 +367,7 @@ pbp = pdirbp = NULL; if (bufhead.b_size != cnt) errexit(gettext("Panic: lost %d buffers\n"), - bufhead.b_size - cnt); + bufhead.b_size - cnt); if (debug) (void) printf("cache missed %ld of %ld (%ld%%)\n", diskreads, totalreads, @@ -461,7 +458,7 @@ extern int returntosingle; (void) printf(gettext("returning to single-user after filesystem " - "check\n")); + "check\n")); returntosingle = 1; (void) signal(SIGQUIT, SIG_DFL); } @@ -498,7 +495,7 @@ default: errexit(gettext("UNKNOWN INODESC FIX MODE %d\n"), - idesc->id_fix); + idesc->id_fix); } /* NOTREACHED */ } @@ -535,7 +532,7 @@ continue; if (device_stat.st_rdev == mount_stat.st_dev) { (void) strncpy(mnt.mnt_mountp, mountpoint, - sizeof (mountpoint)); + sizeof (mountpoint)); if (hasmntopt(&mnt, MNTOPT_RO) != 0) found = 2; /* mounted as RO */ else
--- a/usr/src/cmd/fs.d/ufs/fsck/utilities.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fs.d/ufs/fsck/utilities.c Thu Aug 12 14:55:22 2010 -0700 @@ -1,6 +1,5 @@ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -70,7 +69,7 @@ static struct mnttab *search_mnttab(caddr_t, caddr_t, caddr_t, size_t); static struct vfstab *search_vfstab(caddr_t, caddr_t, caddr_t, size_t); static void vpwarn(caddr_t, va_list); -static int getline(FILE *, caddr_t, int); +static int getaline(FILE *, caddr_t, int); static struct bufarea *alloc_bufarea(void); static void rwerror(caddr_t, diskaddr_t, int rval); static void debugclean(void); @@ -156,7 +155,7 @@ return (1); } (void) fflush(stdout); - if (getline(stdin, line, sizeof (line)) == EOF) + if (getaline(stdin, line, sizeof (line)) == EOF) errexit("\n"); (void) printf("\n"); if (line[0] == 'y' || line[0] == 'Y') { @@ -167,7 +166,7 @@ } int -getline(FILE *fp, caddr_t loc, int maxlen) +getaline(FILE *fp, caddr_t loc, int maxlen) { int n; caddr_t p, lastloc;
--- a/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -420,7 +420,7 @@ static void unblock_sigint(sigset_t *old_mask); static void recover_from_sigint(int signum); static int confirm_abort(void); -static int getline(FILE *fp, char *loc, int maxlen); +static int getaline(FILE *fp, char *loc, int maxlen); static void flush_writes(void); static long compute_maxcpg(long, long, long, long, long); static int in_64bit_mode(void); @@ -5498,7 +5498,7 @@ "you will be given instructions on how to\nrecover " "the filesystem. Do you wish to cancel the filesystem " "grow\noperation (y/n)?")); - if (getline(stdin, line, sizeof (line)) == EOF) + if (getaline(stdin, line, sizeof (line)) == EOF) line[0] = 'y'; printf("\n"); @@ -5510,7 +5510,7 @@ } static int -getline(FILE *fp, char *loc, int maxlen) +getaline(FILE *fp, char *loc, int maxlen) { int n; char *p, *lastloc;
--- a/usr/src/cmd/idmap/idmap/idmap.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/idmap/idmap/idmap.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,11 +18,11 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. */ - #include <stdio.h> #include <stdlib.h> #include <locale.h> @@ -1607,23 +1607,6 @@ } /* - * The same as strdup, but length chars is duplicated, no matter on - * '\0'. The caller must guarantee "length" chars in "from". - */ -static char * -strndup(char *from, size_t length) -{ - char *out = (char *)malloc(length + 1); - if (out == NULL) { - print_error(NULL, gettext("Not enough memory\n")); - return (NULL); - } - (void) strncpy(out, from, length); - out[length] = '\0'; - return (out); -} - -/* * Convert pid from string to it's numerical representation. If it is * a valid string, i.e. number of a proper length, return 1. Otherwise * print an error message and return 0.
--- a/usr/src/cmd/ipf/lib/common/getline.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ipf/lib/common/getline.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,17 +18,14 @@ * Similar to fgets(3) but can handle '\\' and NL is converted to NUL. * Returns NULL if error occured, EOF encounterd or input line is too long. */ -char *getline(str, size, file, linenum) -register char *str; -size_t size; -FILE *file; -int *linenum; +char * +getaline(char *str, size_t size, FILE *file, int *linenum) { char *p; int s, len; do { - for (p = str, s = size;; p += (len - 1), s -= (len - 1)) { + for (p = str, s = size; ; p += (len - 1), s -= (len - 1)) { /* * if an error occured, EOF was encounterd, or there * was no room to put NUL, return NULL.
--- a/usr/src/cmd/ldap/common/ldaptest.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ldap/common/ldaptest.c Thu Aug 12 14:55:22 2010 -0700 @@ -1,12 +1,7 @@ /* - * - * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <ctype.h> #include <string.h> @@ -40,7 +35,7 @@ char *dnsuffix; static char * -getline( char *line, int len, FILE *fp, char *prompt ) +getaline( char *line, int len, FILE *fp, char *prompt ) { printf(prompt); @@ -62,7 +57,7 @@ num = 0; result = (char **) 0; while ( 1 ) { - getline( buf, sizeof(buf), stdin, prompt ); + getaline( buf, sizeof(buf), stdin, prompt ); if ( *buf == '\0' ) break; @@ -161,14 +156,14 @@ result = NULL; while ( 1 ) { if ( prompt1 ) { - getline( buf, sizeof(buf), stdin, prompt1 ); + getaline( buf, sizeof(buf), stdin, prompt1 ); tmp.mod_op = atoi( buf ); if ( tmp.mod_op == -1 || buf[0] == '\0' ) break; } - getline( buf, sizeof(buf), stdin, prompt2 ); + getaline( buf, sizeof(buf), stdin, prompt2 ); if ( buf[0] == '\0' ) break; tmp.mod_type = strdup( buf ); @@ -229,7 +224,7 @@ if ( !freeit ) { #ifdef KERBEROS - getline( dn, sizeof(dn), stdin, + getaline( dn, sizeof(dn), stdin, "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " ); if (( *authmethodp = atoi( dn )) == 3 ) { *authmethodp = LDAP_AUTH_KRBV4; @@ -240,12 +235,12 @@ *authmethodp = LDAP_AUTH_SIMPLE; #endif /* KERBEROS */ - getline( dn, sizeof(dn), stdin, "re-bind dn? " ); + getaline( dn, sizeof(dn), stdin, "re-bind dn? " ); strcat( dn, dnsuffix ); *dnp = dn; if ( *authmethodp == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) { - getline( passwd, sizeof(passwd), stdin, + getaline( passwd, sizeof(passwd), stdin, "re-bind password? " ); } else { passwd[0] = '\0'; @@ -394,7 +389,7 @@ timelimit.tv_usec = 0; (void) memset( line, '\0', sizeof(line) ); - while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) { + while ( getaline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) { command1 = line[0]; command2 = line[1]; command3 = line[2]; @@ -403,7 +398,7 @@ case 'a': /* add or abandon */ switch ( command2 ) { case 'd': /* add */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( (attrs = get_modlist( NULL, "attr? ", "value? " )) == NULL ) @@ -424,7 +419,7 @@ break; case 'b': /* abandon */ - getline( line, sizeof(line), stdin, "msgid? " ); + getaline( line, sizeof(line), stdin, "msgid? " ); id = atoi( line ); if ( ldap_abandon( ld, id ) != 0 ) ldap_perror( ld, "ldap_abandon" ); @@ -438,17 +433,17 @@ case 'b': /* asynch bind */ #ifdef KERBEROS - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "method (0->simple, 1->krbv41, 2->krbv42)? " ); method = atoi( line ) | 0x80; #else /* KERBEROS */ method = LDAP_AUTH_SIMPLE; #endif /* KERBEROS */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) - getline( passwd, sizeof(passwd), stdin, + getaline( passwd, sizeof(passwd), stdin, "password? " ); else passwd[0] = '\0'; @@ -464,7 +459,7 @@ case 'B': /* synch bind */ #ifdef KERBEROS - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "method 0->simple 1->krbv41 2->krbv42 3->krb? " ); method = atoi( line ); if ( method == 3 ) @@ -472,12 +467,12 @@ else method = method | 0x80; #else /* KERBEROS */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "method 0->simple, 1->SASL? "); method = atoi (line); if (method == 1){ method = LDAP_AUTH_SASL; - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "mechanism 0->CRAM_MD5, 1->TLS? "); theInt = atoi(line); if (theInt == 0){ @@ -491,11 +486,11 @@ } #endif /* KERBEROS */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( dn[0] != '\0' ) - getline( passwd, sizeof(passwd), stdin, + getaline( passwd, sizeof(passwd), stdin, "password? " ); else passwd[0] = '\0'; @@ -531,10 +526,10 @@ break; case 'c': /* compare */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); - getline( attr, sizeof(attr), stdin, "attr? " ); - getline( value, sizeof(value), stdin, "value? " ); + getaline( attr, sizeof(attr), stdin, "attr? " ); + getaline( value, sizeof(value), stdin, "value? " ); if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ bv.bv_val = value; @@ -553,7 +548,7 @@ case 'd': /* turn on debugging */ #ifdef LDAP_DEBUG - getline( line, sizeof(line), stdin, "debug level? " ); + getaline( line, sizeof(line), stdin, "debug level? " ); ldap_debug = atoi( line ); if ( ldap_debug & LDAP_DEBUG_PACKETS ) { lber_debug = ldap_debug; @@ -564,7 +559,7 @@ break; case 'E': /* explode a dn */ - getline( line, sizeof(line), stdin, "dn? " ); + getaline( line, sizeof(line), stdin, "dn? " ); exdn = ldap_explode_dn( line, 0 ); for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) { printf( "\t%s\n", exdn[i] ); @@ -572,19 +567,19 @@ break; case 'g': /* set next msgid */ - getline( line, sizeof(line), stdin, "msgid? " ); + getaline( line, sizeof(line), stdin, "msgid? " ); ld->ld_msgid = atoi( line ); break; case 'v': /* set version number */ - getline( line, sizeof(line), stdin, "version? " ); + getaline( line, sizeof(line), stdin, "version? " ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &theInt); break; case 'm': /* modify or modifyrdn */ if ( strncmp( line, "modify", 4 ) == 0 ) { - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( (mods = get_modlist( "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ", @@ -604,10 +599,10 @@ printf( "Modify initiated with id %d\n", id ); } } else if ( strncmp( line, "modrdn", 4 ) == 0 ) { - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); - getline( rdn, sizeof(rdn), stdin, "newrdn? " ); - getline( line, sizeof(line), stdin, "delete old rdn (0=>no, 1=>yes)?"); + getaline( rdn, sizeof(rdn), stdin, "newrdn? " ); + getaline( line, sizeof(line), stdin, "delete old rdn (0=>no, 1=>yes)?"); delrdn = atoi(line); if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ if ((err = ldap_rename(ld, dn, rdn, NULL, delrdn, NULL,NULL, &id)) != LDAP_SUCCESS){ @@ -640,13 +635,13 @@ case 'r': /* result or remove */ switch ( command3 ) { case 's': /* result */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "msgid (-1=>any)? " ); if ( line[0] == '\0' ) id = -1; else id = atoi( line ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "all (0=>any, 1=>all)? " ); if ( line[0] == '\0' ) all = 1; @@ -667,7 +662,7 @@ break; case 'm': /* remove */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ if ((err = ldap_delete_ext( ld, dn, NULL, NULL, &id )) != LDAP_SUCCESS ) @@ -689,21 +684,21 @@ break; case 's': /* search */ - getline( dn, sizeof(dn), stdin, "searchbase? " ); + getaline( dn, sizeof(dn), stdin, "searchbase? " ); strcat( dn, dnsuffix ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "scope (0=Base, 1=One Level, 2=Subtree)? " ); scope = atoi( line ); - getline( filter, sizeof(filter), stdin, + getaline( filter, sizeof(filter), stdin, "search filter (e.g. sn=jones)? " ); types = get_list( "attrs to return? " ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "attrsonly (0=attrs&values, 1=attrs only)? " ); attrsonly = atoi( line ); if ( cldapflg ) { #ifdef CLDAP - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Requestor DN (for logging)? " ); if ( cldap_search_s( ld, dn, scope, filter, types, attrsonly, &res, line ) != 0 ) { @@ -719,7 +714,7 @@ theInt = 0; if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ resultusetimelimit = 1; - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "ldap_search_ext (0=>no, 1=>yes - default: yes)? " ); if (line[0] == '\0') theInt = 1; @@ -727,10 +722,10 @@ theInt = atoi( line ); } if (theInt){ - getline(line, sizeof(line), stdin, "time limit?"); + getaline(line, sizeof(line), stdin, "time limit?"); timelimit.tv_sec = atoi(line); resultusetimelimit = 1; - getline(line, sizeof(line), stdin, "size limit?"); + getaline(line, sizeof(line), stdin, "size limit?"); sizelimit = atoi(line); if (( err = ldap_search_ext(ld, dn, scope, filter, types, attrsonly, NULL, NULL, &timelimit, sizelimit, &id)) != LDAP_SUCCESS){ @@ -751,20 +746,20 @@ break; case 't': /* set timeout value */ - getline( line, sizeof(line), stdin, "timeout? " ); + getaline( line, sizeof(line), stdin, "timeout? " ); timeout.tv_sec = atoi( line ); break; case 'U': /* set ufn search prefix */ - getline( line, sizeof(line), stdin, "ufn prefix? " ); + getaline( line, sizeof(line), stdin, "ufn prefix? " ); ldap_ufn_setprefix( ld, line ); break; case 'u': /* user friendly search w/optional timeout */ - getline( dn, sizeof(dn), stdin, "ufn? " ); + getaline( dn, sizeof(dn), stdin, "ufn? " ); strcat( dn, dnsuffix ); types = get_list( "attrs to return? " ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "attrsonly (0=attrs&values, 1=attrs only)? " ); attrsonly = atoi( line ); @@ -787,10 +782,10 @@ break; case 'l': /* URL search */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "attrsonly (0=attrs&values, 1=attrs only)? " ); attrsonly = atoi( line ); - getline( line, sizeof(line), stdin, "LDAP URL? " ); + getaline( line, sizeof(line), stdin, "LDAP URL? " ); if (( id = ldap_url_search( ld, line, attrsonly )) == -1 ) { ldap_perror( ld, "ldap_url_search" ); @@ -800,7 +795,7 @@ break; case 'p': /* parse LDAP URL */ - getline( line, sizeof(line), stdin, "LDAP URL? " ); + getaline( line, sizeof(line), stdin, "LDAP URL? " ); if (( i = ldap_url_parse( line, &ludp )) != 0 ) { fprintf( stderr, "ldap_url_parse: error %d\n", i ); } else { @@ -842,7 +837,7 @@ break; case 'n': /* set dn suffix, for convenience */ - getline( line, sizeof(line), stdin, "DN suffix? " ); + getaline( line, sizeof(line), stdin, "DN suffix? " ); strcpy( dnsuffix, line ); break; @@ -850,9 +845,9 @@ #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "Cache timeout (secs)? " ); + getaline( line, sizeof(line), stdin, "Cache timeout (secs)? " ); i = atoi( line ); - getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " ); + getaline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " ); if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) { printf( "local cache is on\n" ); } else { @@ -865,7 +860,7 @@ #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "DN? " ); + getaline( line, sizeof(line), stdin, "DN? " ); ldap_uncache_entry( ld, line ); #endif /* NO_CACHE */ break; @@ -874,33 +869,33 @@ #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "request msgid? " ); + getaline( line, sizeof(line), stdin, "request msgid? " ); ldap_uncache_request( ld, atoi( line )); #endif /* NO_CACHE */ break; case 'o': /* set ldap options */ - getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" ); + getaline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_DEREF, &theInt ); - getline( line, sizeof(line), stdin, "timelimit?" ); + getaline( line, sizeof(line), stdin, "timelimit?" ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &theInt); - getline( line, sizeof(line), stdin, "sizelimit?" ); + getaline( line, sizeof(line), stdin, "sizelimit?" ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &theInt); ld->ld_options = 0; #ifdef STR_TRANSLATION - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Automatic translation of T.61 strings (0=no, 1=yes)?" ); if ( atoi( line ) == 0 ) { ld->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS; } else { ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS; #ifdef LDAP_CHARSET_8859 - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Translate to/from ISO-8859 (0=no, 1=yes?" ); if ( atoi( line ) != 0 ) { ldap_set_string_translators( ld, @@ -912,18 +907,18 @@ #endif /* STR_TRANSLATION */ #ifdef LDAP_DNS - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" ); if ( atoi( line ) != 0 ) { ld->ld_options |= LDAP_OPT_DNS; } #endif /* LDAP_DNS */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Recognize and chase referrals (0=no, 1=yes)?" ); if ( atoi( line ) != 0 ) { theInt = LDAP_OPT_ON; - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" ); if ( atoi( line ) != 0 ) { ldap_set_option( ld, LDAP_OPT_REBIND_FN, bind_prompt ); @@ -935,7 +930,7 @@ break; case 'k': /* Set some controls */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Set control: (0 for none, 1 for ManageDSA, 2 for preferredLang, 3 for BAD)?"); theInt = atoi(line); switch (theInt){ @@ -949,7 +944,7 @@ ldap_set_option(ld, LDAP_OPT_SERVER_CONTROLS, ctrls); break; case 2: - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Preferred Language Control : lang ?"); aCtrl.ldctl_oid = "1.3.6.1.4.1.1466.20035"; aCtrl.ldctl_iscritical = 1; @@ -959,7 +954,7 @@ ldap_set_option(ld, LDAP_OPT_SERVER_CONTROLS, ctrls); break; default: - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Bad Control is critical (0=false, 1=true)?"); aCtrl.ldctl_oid = "1.1.1.1.1.1"; aCtrl.ldctl_iscritical = atoi(line); @@ -973,7 +968,7 @@ #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" ); + getaline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" ); switch( atoi( line )) { case 0: ldap_set_cache_options( ld, 0 );
--- a/usr/src/cmd/mail/copymt.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mail/copymt.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 +18,14 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 2.1 */ /* NAME copymt - copy mail (f1) to temp (f2) @@ -62,7 +64,7 @@ nextadr = let[nlet].adr; } - while ((n = getline(line, sizeof line, f1)) > 0) { + while ((n = getaline(line, sizeof line, f1)) > 0) { if (!newline) { goto putout; } else if ((hdr = isheader (line, &ctf)) == FALSE) {
--- a/usr/src/cmd/mail/gethead.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mail/gethead.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "mail.h" #define MAXHDRSIZE 100 /* Maximum length of header line */ @@ -129,7 +126,8 @@ } /* skip past trailing white space after header tag */ - for (rc = 5; wline[rc] == ' ' || wline[rc] == '\t'; ++rc); + for (rc = 5; wline[rc] == ' ' || wline[rc] == '\t'; ++rc) + ; (void) strlcpy(hold, wline + rc, MAXHDRSIZE); fgets(wline, MAXHDRSIZE, file); @@ -171,12 +169,15 @@ * delimiting white space. */ for (; hold[rc] != '\0' && hold[rc] != ' ' && - hold[rc] != '\t'; ++rc); - for (; hold[rc] == ' ' || hold[rc] == '\t'; ++rc); + hold[rc] != '\t'; ++rc) + ; + for (; hold[rc] == ' ' || hold[rc] == '\t'; ++rc) + ; /* Get the date information. */ (void) strlcpy(wline, hold + rc, MAXHDRSIZE); - for (rc = 0; wline[rc] != '\0' && wline[rc] != '\n'; ++rc); + for (rc = 0; wline[rc] != '\0' && wline[rc] != '\n'; ++rc) + ; wline[rc] = '\0'; if (!flgh && current == ln) mark = '>'; @@ -224,7 +225,7 @@ * return number of bytes in length */ int -getline(char *ptr2line, int max, FILE *f) +getaline(char *ptr2line, int max, FILE *f) { int i, ch; for (i = 0; i < max-1 && (ch = getc(f)) != EOF; ) @@ -243,9 +244,9 @@ int fd = mkstemp(lettmp = tmpl); if (fd < 0 || (tmpf = fdopen(fd, "w+")) == NULL) { - fprintf(stderr, + fprintf(stderr, "%s: Can't open '%s', type: w+\n", program, lettmp); - done(0); + done(0); } }
--- a/usr/src/cmd/mail/mail.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mail/mail.h Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ #ifndef _MAIL_H #define _MAIL_H -#pragma ident "%Z%%M% %I% %E% SMI" - /* * All global externs defined here. All variables are initialized * in init.c @@ -304,7 +301,7 @@ extern void gendeliv(FILE *fp, int rc, char *name); extern int getcomment(char *s, char *q); extern int gethead(int current, int all); -extern int getline(char *ptr2line, int max, FILE *f); +extern int getaline(char *ptr2line, int max, FILE *f); extern int getnumbr(char *s); extern int getsurr(FILE *fp, string *buf, int firstfield); extern void goback(int letnum);
--- a/usr/src/cmd/mail/sendmail.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mail/sendmail.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ #include "mail.h" #include <sys/param.h> @@ -160,7 +157,7 @@ } } - while ((n = getline(line, sizeof (line), stdin)) > 0) { + while ((n = getaline(line, sizeof (line), stdin)) > 0) { last1c = line[n-1]; if (pushrest) { if (!wtmpf(line, n)) { @@ -287,7 +284,7 @@ } if (n == 1 && last1c == '\n') { /* blank line -- suppress */ - n = getline(buf, sizeof (buf), stdin); + n = getaline(buf, sizeof (buf), stdin); if (n == 0 || (ttyf && !strncmp(buf, ".\n", 2))) { /* * no content: put mime-version, content-type @@ -385,7 +382,7 @@ } count += n; n = ttyf - ? getline(buf, sizeof (buf), stdin) + ? getaline(buf, sizeof (buf), stdin) : fread(buf, 1, sizeof (buf), stdin); } setsig(SIGINT, saveint);
--- a/usr/src/cmd/mailx/collect.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mailx/collect.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,15 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 1998 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California @@ -38,8 +36,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * mailx -- a modified version of a University of California at Berkeley * mail program @@ -244,7 +240,7 @@ hdrs = 0; continue; } - if ((nread = getline(linebuf,LINESIZE,stdin,&hasnulls)) == NULL) { + if ((nread = getaline(linebuf,LINESIZE,stdin,&hasnulls)) == NULL) { if (intty && value("ignoreeof") != NOSTR) { if (++eof > 35) break; @@ -1227,7 +1223,7 @@ passed must be 1 larger than "size" for the trailing NUL byte. */ int -getline(char *line, int size, FILE *f, int *hasnulls) +getaline(char *line, int size, FILE *f, int *hasnulls) { register int i, ch; for (i = 0; (i < size) && ((ch=getc(f)) != EOF); ) {
--- a/usr/src/cmd/mailx/hdr/def.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mailx/hdr/def.h Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -40,8 +39,6 @@ #ifndef _MAILX_DEF_H #define _MAILX_DEF_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -474,7 +471,7 @@ extern off_t fsize(FILE *iob); extern int getfold(char *name); extern int gethfield(register FILE *f, char linebuf[], register long rem); -extern int getline(char *line, int size, FILE *f, int *hasnulls); +extern int getaline(char *line, int size, FILE *f, int *hasnulls); extern int getmessage(char *buf, int *vector, int flags); extern int getmsglist(char *buf, int *vector, int flags); extern int getname(uid_t uid, char namebuf[]);
--- a/usr/src/cmd/mailx/send.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mailx/send.c Thu Aug 12 14:55:22 2010 -0700 @@ -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. @@ -21,8 +20,7 @@ */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -38,8 +36,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "rcv.h" #include <locale.h> @@ -96,7 +92,7 @@ lc = 0; clearerr(obuf); while (c > 0L) { - nread = getline(line, LINESIZE, ibuf, &unused); + nread = getaline(line, LINESIZE, ibuf, &unused); c -= nread; lc++; if (ishead) {
--- a/usr/src/cmd/mdb/common/modules/libc/libc.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/mdb/common/modules/libc/libc.c Thu Aug 12 14:55:22 2010 -0700 @@ -845,11 +845,12 @@ prt_addr(uberdata.ulwp_replace_last, 1), prt_addr(uberdata.atforklist, 0)); - HD("robustlocks robustlist"); - mdb_printf(OFFSTR "%s %s\n", + HD("robustlocks robustlist progname"); + mdb_printf(OFFSTR "%s %s %s\n", OFFSET(robustlocks), prt_addr(uberdata.robustlocks, 1), - prt_addr(uberdata.robustlist, 0)); + prt_addr(uberdata.robustlist, 1), + prt_addr(uberdata.progname, 0)); HD("tdb_bootstrap tdb_sync_addr_hash tdb_'count tdb_'fail"); mdb_printf(OFFSTR "%s %s %-10d %d\n",
--- a/usr/src/cmd/more/more.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/more/more.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -39,8 +39,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * @(#) more.c 1.1 88/03/29 more:more.c */ @@ -224,7 +222,7 @@ static void reset_tty(void); static void rdline(register FILE *f); static off_t command(char *filename, register FILE *f); -static int getline(register FILE *f, int *length); +static int getaline(register FILE *f, int *length); static int number(char *cmd); static int colon(char *filename, int cmd, off_t nlines); @@ -504,7 +502,7 @@ for (;;) { while (num_lines > 0 && !Pause) { - if ((nchars = getline (f, &length)) == EOF) + if ((nchars = getaline (f, &length)) == EOF) { if (clreol) clreos(); return; @@ -726,7 +724,7 @@ */ static int -getline(register FILE *f, int *length) +getaline(register FILE *f, int *length) { register int c; register char *p;
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_dtime.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_dtime.c Thu Aug 12 14:55:22 2010 -0700 @@ -184,12 +184,12 @@ /* - * getline + * getaline * * Get a line from the file and handle the continued lines. */ static char * -getline(FILE *fp, char *line, int llen) +getaline(FILE *fp, char *line, int llen) { char *save; int len; @@ -483,7 +483,7 @@ return (-1); do { - if (getline(fp, tbuf, sizeof (tbuf)) != tbuf) + if (getaline(fp, tbuf, sizeof (tbuf)) != tbuf) return (-1); } while (!*tbuf);
--- a/usr/src/cmd/nscd/nscd_initf.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/nscd/nscd_initf.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -236,10 +237,11 @@ _nss_initf_passwd_compat, _nss_initf_group_compat, /* - * no initf() for pseudo-databases: passwd, shadow, user_attr, - * and group (when called from the compat backend) + * no initf() for pseudo-databases: passwd, shadow, audit_user, + * user_attr, and group (when called from the compat backend) */ NULL, NULL, NULL, + NULL, NULL};
--- a/usr/src/cmd/oawk/makeprctab.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/oawk/makeprctab.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -85,7 +84,7 @@ { BREAK, "jump", "break"}, { CONTINUE, "jump", "continue"}, { FNCN, "fncn", "fncn"}, - { GETLINE, "getline", "getline"}, + { GETLINE, "getaline", "getline"}, { 0, ""}, }; #define SIZE LASTTOKEN - FIRSTTOKEN
--- a/usr/src/cmd/oawk/run.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/oawk/run.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -156,7 +155,7 @@ CELL * -getline(void) +getaline(void) { CELL *x;
--- a/usr/src/cmd/pg/pg.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/pg/pg.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -91,7 +90,7 @@ static void error(char *); static void terminit(); static void compact(); -static off_t getline(FILE *); +static off_t getaline(FILE *); static int mrdchar(); static off_t find(int, off_t); static int search(char *, off_t); @@ -159,7 +158,7 @@ static short nfiles; static char *shell; static char *promptstr = ":"; -static off_t nchars; /* return from getline in find() */ +static off_t nchars; /* return from getaline in find() */ static jmp_buf restore; static char Line[LINSIZ+2]; @@ -1369,7 +1368,7 @@ else (void) fseeko(f, (off_t)dol->l_addr, SEEK_SET); dot = dol - 1; - while ((nchars = getline(f)) != EOF) { + while ((nchars = getaline(f)) != EOF) { dot++; newdol(f); if (where == dot->l_no || brk_hit) @@ -1396,7 +1395,7 @@ } else { dot = zero + where - 1; (void) fseeko(f, (off_t)dot->l_addr, SEEK_SET); - nchars = getline(f); + nchars = getaline(f); return (dot->l_no); } } @@ -1416,7 +1415,7 @@ */ static off_t -getline(f) +getaline(f) FILE *f; { char *p; @@ -1432,7 +1431,7 @@ rdchar = (int (*)())fgetwc; fileptr = f; - /* copy overlap from previous call to getline */ + /* copy overlap from previous call to getaline */ if (savlength) (void) strncpy(Line, multic, (size_t)savlength); for (column = 0, p = Line + savlength; ; ) { @@ -1482,7 +1481,7 @@ if (c != '\n') { /* We're stopping in the middle of the line */ if (column != columns || !auto_right_margin) *p++ = '\n'; /* for the display */ - /* save overlap for next call to getline */ + /* save overlap for next call to getaline */ savlength = length; if (savlength == 0) { /*
--- a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This plugin creates PICL nodes and properties for objects handled through * the blade support chip (BSC). The BSC Solaris land device driver exposes @@ -102,7 +99,6 @@ static int lookup_led_status(int8_t state, const char **string); static int read_led_status(ptree_rarg_t *parg, void *buf); static void convert_node_name(char *ptr); -static const char *strcasestr(const char *s1, const char *s2); static int add_temp_sensors(int lom_fd, picl_nodehdl_t lominfh); static int add_voltage_monitors(int lom_fd, picl_nodehdl_t lominfh); @@ -300,7 +296,7 @@ char devices_path[PATH_MAX]; err = ptree_get_propval_by_name(*lominfh, PICL_PROP_DEVFS_PATH, - devfs_path, sizeof (devfs_path)); + devfs_path, sizeof (devfs_path)); /* Build up the full device path and set the global */ strcpy(devices_path, "/devices"); @@ -854,24 +850,6 @@ } } -/* - * find first occurrence of string s2 within string s1 (ignoring case) - */ -static const char * -strcasestr(const char *s1, const char *s2) -{ - int len1 = strlen(s1); - int len2 = strlen(s2); - int i; - - for (i = 0; i <= len1 - len2; i++) { - if (strncasecmp(s1 + i, s2, len2) == 0) - return (s1 + i); - } - - return (NULL); -} - static int add_temp_sensors(int lom_fd, picl_nodehdl_t lominfh) { @@ -1060,10 +1038,10 @@ */ if ((led_state->colour != LOM_LED_COLOUR_NONE) && (led_state->colour != LOM_LED_COLOUR_ANY)) { - err = add_regular_prop(ledh, PICL_PROP_COLOR, - PICL_PTYPE_CHARSTRING, PICL_READ, - colour_lkup[led_state->index].size, - colour_lkup[led_state->index].str_colour, &proph); + err = add_regular_prop(ledh, PICL_PROP_COLOR, + PICL_PTYPE_CHARSTRING, PICL_READ, + colour_lkup[led_state->index].size, + colour_lkup[led_state->index].str_colour, &proph); } if (err != PICL_SUCCESS) return;
--- a/usr/src/cmd/prctl/prctl.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/prctl/prctl.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,12 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ - #include <unistd.h> #include <rctl.h> #include <libproc.h> @@ -223,7 +222,7 @@ (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname(argv[0]); + (void) setpname(argv[0]); while ((opt = getopt(argc, argv, "sPp:Fd:e:i:n:rt:v:x")) != EOF) {
--- a/usr/src/cmd/prctl/utils.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/prctl/utils.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <libintl.h> #include <string.h> @@ -44,7 +42,7 @@ static char *pname; char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/');
--- a/usr/src/cmd/prctl/utils.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/prctl/utils.h Thu Aug 12 14:55:22 2010 -0700 @@ -18,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _UTILS_H #define _UTILS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -35,7 +33,7 @@ #include <sys/types.h> extern void warn(const char *, ...); -extern char *setprogname(char *); +extern char *setpname(char *); /* * scale_t
--- a/usr/src/cmd/prtconf/prtconf.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/prtconf/prtconf.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -25,7 +26,6 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - #include <stdio.h> #include <stdarg.h> #include <stdlib.h> @@ -50,7 +50,7 @@ #endif /* __x86 */ static void -setprogname(const char *name) +setpname(const char *name) { char *p; @@ -178,7 +178,7 @@ int c, ret; char hw_provider[SYS_NMLN]; - setprogname(argv[0]); + setpname(argv[0]); opts.o_promdev = "/dev/openprom"; while ((c = getopt(argc, argv, optstring)) != -1) {
--- a/usr/src/cmd/prtdiag/main.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/prtdiag/main.c Thu Aug 12 14:55:22 2010 -0700 @@ -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. @@ -21,8 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -30,8 +28,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <locale.h> #include <stdlib.h> @@ -43,7 +39,7 @@ extern int do_prominfo(int, char *, int, int); static char * -setprogname(char *name) +setpname(char *name) { char *p; @@ -58,7 +54,7 @@ { int c; int syserrlog = 0; - char *progname = setprogname(argv[0]); + char *progname = setpname(argv[0]); int print_flag = 1; int logging = 0;
--- a/usr/src/cmd/rcap/common/utils.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rcap/common/utils.c Thu Aug 12 14:55:22 2010 -0700 @@ -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/param.h> #include <libintl.h> #include <stdarg.h> @@ -154,7 +152,7 @@ } char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/');
--- a/usr/src/cmd/rcap/common/utils.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rcap/common/utils.h Thu Aug 12 14:55:22 2010 -0700 @@ -18,16 +18,14 @@ * * 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. */ #ifndef _UTILS_H #define _UTILS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <assert.h> #include <libintl.h> #include <stdarg.h> @@ -93,7 +91,7 @@ extern rcm_level_t get_message_priority(void); extern rcm_level_t set_message_priority(rcm_level_t); extern rcm_dst_t set_message_destination(rcm_dst_t); -extern char *setprogname(char *); +extern char *setpname(char *); extern void warn(const char *, ...); extern int valid_abspath(char *); extern void vdprintfe(int, const char *, va_list);
--- a/usr/src/cmd/rcap/rcapadm/rcapadm.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rcap/rcapadm/rcapadm.c Thu Aug 12 14:55:22 2010 -0700 @@ -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/stat.h> #include <sys/wait.h> @@ -129,7 +127,7 @@ else (void) printf(gettext(" " "state: %s\n"), *persistent ? gettext("enabled") : - gettext("disabled")); + gettext("disabled")); (void) printf(gettext(" memory cap enforcement" " threshold: %d%%\n"), conf.rcfg_memory_cap_enforcement_pressure); @@ -190,7 +188,7 @@ char *zonename; char *maxrss = NULL; - (void) setprogname("rcapadm"); + (void) setpname("rcapadm"); (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN);
--- a/usr/src/cmd/rcap/rcapd/rcapd_main.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rcap/rcapd/rcapd_main.c Thu Aug 12 14:55:22 2010 -0700 @@ -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" - /* * rcapd is a long-running daemon enforcing project-based resource caps (see * rcapd(1M)). Each instance of a process aggregate (project or, generically, @@ -1217,7 +1215,7 @@ if (fchmod(fd, 0644) == 0 && write(fd, &rs, sizeof (rs)) == sizeof (rs)) { list_walk_collection(report_collection_cb, - (void *)(intptr_t)fd); + (void *)(intptr_t)fd); /* * Replace the existing statistics file with this new * one. @@ -1447,7 +1445,7 @@ hrtime_t next_rss_sample; /* (latest) time of next RSS sample */ (void) set_message_priority(RCM_INFO); - (void) setprogname("rcapd"); + (void) setpname("rcapd"); rcapd_pid = getpid(); (void) chdir("/"); should_run = 1;
--- a/usr/src/cmd/rcap/rcapstat/rcapstat.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rcap/rcapstat/rcapstat.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> @@ -365,7 +365,7 @@ (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname("rcapstat"); + (void) setpname("rcapstat"); global = unformatted = 0; while ((opt = getopt(argc, argv, "gpuzT:")) != (int)EOF) {
--- a/usr/src/cmd/rctladm/rctladm.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rctladm/rctladm.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/rctl_impl.h> #include <sys/types.h> #include <sys/stat.h> @@ -452,7 +450,7 @@ (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname(argv[0]); + (void) setpname(argv[0]); while ((c = getopt(argc, argv, OPTS)) != EOF) { switch (c) {
--- a/usr/src/cmd/rctladm/utils.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rctladm/utils.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <libintl.h> #include <string.h> @@ -73,7 +71,7 @@ } char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/');
--- a/usr/src/cmd/rctladm/utils.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/rctladm/utils.h Thu Aug 12 14:55:22 2010 -0700 @@ -18,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _UTILS_H #define _UTILS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -44,7 +42,7 @@ extern void warn(const char *, ...); extern void die(char *, ...) __NORETURN; -extern char *setprogname(char *); +extern char *setpname(char *); #ifdef __cplusplus }
--- a/usr/src/cmd/sendmail/db/clib/strsep.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/sendmail/db/clib/strsep.c Thu Aug 12 14:55:22 2010 -0700 @@ -36,18 +36,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + /* - * Copyright (c) 1998 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ #include "config.h" -#pragma ident "%Z%%M% %I% %E% SMI" - #ifndef lint static const char sccsid[] = "@(#)strsep.c 10.1 (Sleepycat) 4/12/97"; -static const char sccsi2[] = "%W% (Sun) %G%"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -70,6 +67,9 @@ * PUBLIC: char *strsep __P((char **, const char *)); * PUBLIC: #endif */ + +#ifndef HAVE_STRSEP + char * strsep(stringp, delim) register char **stringp; @@ -98,3 +98,5 @@ } /* NOTREACHED */ } + +#endif /* HAVE_STRSEP */
--- a/usr/src/cmd/sgs/crle/common/print.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/sgs/crle/common/print.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> @@ -33,7 +32,6 @@ #include <unistd.h> #include <errno.h> #include <limits.h> -#include <alloca.h> #include "sgs.h" #include "rtc.h" #include "conv.h" @@ -346,7 +344,7 @@ /* * Construct the original command line argument. */ - cmd = strcpy(alloca(MSG_CMD_64_SIZE + 1), MSG_ORIG(MSG_CMD_64)); + cmd = strdupa(MSG_ORIG(MSG_CMD_64)); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -383,7 +381,7 @@ */ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_CONF), crle->c_confil); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -395,7 +393,7 @@ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_FLAGS), conv_dl_flag(head->ch_dlflags, CONV_FMT_ALT_CRLE, &dl_flag_buf)); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -443,13 +441,13 @@ */ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_OUTPUT), crle->c_objdir); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_DUMPGRP), (strtbl + obj->co_name)); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -488,7 +486,7 @@ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_EDLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -555,7 +553,7 @@ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_ESLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -607,7 +605,7 @@ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_ADLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -647,7 +645,7 @@ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_ASLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -707,7 +705,7 @@ } (void) printf(pfmt, str); (void) snprintf(_cmd, PATH_MAX, sfmt, str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -808,7 +806,7 @@ /* LINTED */ (void) snprintf(_cmd, PATH_MAX, getformat(dobj->co_flags), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -901,8 +899,7 @@ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_OUTPUT), crle->c_objdir); - cmd = strcpy(alloca(strlen(_cmd) + 1), - _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -911,7 +908,7 @@ /* LINTED */ (void) snprintf(_cmd, PATH_MAX, getformat(flags), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL);
--- a/usr/src/cmd/sgs/libconv/common/demangle.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/sgs/libconv/common/demangle.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,10 +20,8 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <stdio.h> #include <demangle.h> @@ -50,8 +48,7 @@ * buffer). One model is: * * if ((_name1 = demangle(name1)) != name1) { - * char * __name1 = alloca(strlen(_name1) + 1); - * (void) strcpy(__name1, _name1); + * char * __name1 = strdupa(_name1); * name1 = (const char *)__name1; * } * name2 = demangle(name2);
--- a/usr/src/cmd/sgs/lorder/lorder.sh Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/sgs/lorder/lorder.sh Thu Aug 12 14:55:22 2010 -0700 @@ -3,9 +3,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. @@ -22,12 +21,9 @@ # # Copyright (c) 1989 AT&T # All Rights Reserved - - -# Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. - -#pragma ident "%Z%%M% %I% %E% SMI" +# +# Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. +# # COMMON LORDER # @@ -91,7 +87,7 @@ # ${WHERE}/${PFX}nm -p $* 2>$TDIR/$$tmp | sed -e '/^[ ]*$/d' -e ' /^[0-9]* R $/d - / [a-zFS] /d + / [a-zFLS] /d /[^]]:$/{ s/:// h
--- a/usr/src/cmd/sgs/rtld/common/external.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/sgs/rtld/common/external.c Thu Aug 12 14:55:22 2010 -0700 @@ -582,6 +582,26 @@ } /* + * Local str[n]casecmp() interfaces for the dynamic linker, + * to avoid problems when linking with libc_pic.a + */ +int +strcasecmp(const char *s1, const char *s2) +{ + extern int ascii_strcasecmp(const char *, const char *); + + return (ascii_strcasecmp(s1, s2)); +} + +int +strncasecmp(const char *s1, const char *s2, size_t n) +{ + extern int ascii_strncasecmp(const char *, const char *, size_t); + + return (ascii_strncasecmp(s1, s2, n)); +} + +/* * The following functions are cancellation points in libc. * They are called from other functions in libc that we extract * and use directly. We don't do cancellation while we are in
--- a/usr/src/cmd/ssh/include/config.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ssh/include/config.h Thu Aug 12 14:55:22 2010 -0700 @@ -1,9 +1,9 @@ /* config.h. Generated by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* $Id: acconfig.h,v 1.145 2002/09/26 00:38:48 tim Exp $ */ + /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _CONFIG_H @@ -214,7 +214,7 @@ /* #undef USE_EXTERNAL_ASKPASS */ /* Define if libc defines __progname */ -/* #undef HAVE___PROGNAME */ +#define HAVE___PROGNAME 1 /* Define if compiler implements __FUNCTION__ */ #define HAVE___FUNCTION__ 1
--- a/usr/src/cmd/svr4pkg/libinst/dockdeps.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/svr4pkg/libinst/dockdeps.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - - #include <stdio.h> #include <errno.h> #include <limits.h> @@ -92,7 +89,7 @@ boolean_t a_preinstallCheck); static void incompat(char *pkginst, char *pkgname, boolean_t a_preinstallCheck); -static int getline(FILE *fp); +static int getaline(FILE *fp); /* * ***************************************************************************** @@ -124,7 +121,7 @@ } } - while (getline(fp)) { + while (getaline(fp)) { switch (type) { case 'I': case 'P': @@ -323,7 +320,7 @@ } static int -getline(FILE *fp) +getaline(FILE *fp) { register int i, c, found; char *pt, *new, line[LSIZE]; @@ -422,7 +419,7 @@ register int i; char *inst; - while (getline(fp)) { + while (getaline(fp)) { if (type != 'P') continue;
--- a/usr/src/cmd/vi/misc/ctags.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/misc/ctags.c Thu Aug 12 14:55:22 2010 -0700 @@ -1,6 +1,5 @@ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -43,9 +42,6 @@ "California.\nAll rights reserved.\n"; #endif -#pragma ident "%Z%%M% %I% %E% SMI" - /* from UCB 5.1 5/31/85 */ - #include <stdio.h> #include <ctype.h> #include <locale.h> @@ -172,7 +168,7 @@ static int start_entry(char **lp, char *token, int *f); static void Y_entries(); static char *toss_comment(char *start); -static void getline(long int where); +static void getaline(long int where); static void free_tree(NODE *node); static void add_node(NODE *node, NODE *cur_node); static void put_entries(NODE *node); @@ -371,7 +367,7 @@ * throw away all the code before the second "%%" */ toss_yysec(); - getline(lineftell); + getaline(lineftell); pfnote("yylex", lineno, TRUE); toss_yysec(); C_entries(); @@ -684,7 +680,7 @@ if (start_entry(&sp, token, &f)) { (void) strncpy(tok, token, tp-token+1); tok[tp-token+1] = 0; - getline(tokftell); + getaline(tokftell); pfnote(tok, pfline, f); gotone = f; /* function */ } @@ -844,7 +840,7 @@ char tok[BUFSIZ]; brace = 0; - getline(lineftell); + getaline(lineftell); pfnote("yyparse", lineno, TRUE); while (fgets(line, sizeof (line), inf) != NULL) for (sp = line; *sp; sp++) @@ -951,7 +947,7 @@ } static void -getline(where) +getaline(where) long int where; { long saveftell = ftell(inf);
--- a/usr/src/cmd/vi/port/ex.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex.h Thu Aug 12 14:55:22 2010 -0700 @@ -18,22 +18,19 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* Copyright (c) 1981 Regents of the University of California */ #ifndef _EX_H #define _EX_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -604,7 +601,7 @@ void vrollR(int); void vnline(unsigned char *); void noerror(); -void getline(line); +void getaline(line); void viprintf(); void gettmode(void); void setterm(unsigned char *);
--- a/usr/src/cmd/vi/port/ex_cmds.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_cmds.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -29,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -1005,7 +1003,7 @@ nonzero(); if (seensemi) addr1 = addr2; - getline(*addr1); + getaline(*addr1); if (c == CTRL('k')) { flush1(); destline--;
--- a/usr/src/cmd/vi/port/ex_cmdsub.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_cmdsub.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -253,7 +250,7 @@ cp = genbuf; *cp = 0; for (a1 = addr1; a1 <= addr2; a1++) { - getline(*a1); + getaline(*a1); cp1 = linebuf; if (a1 != addr1 && c == 0) { while (*cp1 == ' ' || *cp1 == '\t') @@ -410,7 +407,7 @@ if (tad1 > addr2) return (EOF); - getline(*tad1++); + getaline(*tad1++); return (0); } @@ -423,7 +420,7 @@ if (tad1 > unddol) return (EOF); - getline(*tad1++); + getaline(*tad1++); tad1++; return (0); } @@ -490,7 +487,7 @@ * Get last line of undo area ("3") into linebuf. */ - getline(*unddol); + getaline(*unddol); if (kill) *pkill[1] = 0; @@ -518,7 +515,7 @@ * So linebuf = "1" */ - getline(dol[1]); + getaline(dol[1]); if (kill) strcLIN(pkill[0]); @@ -1129,7 +1126,7 @@ if (addr1 > addr2) return; if (op == EOF && zhadpr) { - getline(*addr1); + getaline(*addr1); putchar((int)('\r' | QUOTE)); shudclob = 1; } else if (znoclear == 0 && clear_screen != NOSTR && !inopen) { @@ -1165,7 +1162,7 @@ pofix(); for (addr = adr1; addr <= adr2; addr++) { - getline(*addr); + getaline(*addr); pline(lineno(addr)); if (inopen) putchar((int)('\n' | QUOTE));
--- a/usr/src/cmd/vi/port/ex_get.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_get.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" @@ -300,5 +297,5 @@ if (addr == zero) lastin = 0; else - getline(*addr), lastin = smunch(0, linebuf); + getaline(*addr), lastin = smunch(0, linebuf); }
--- a/usr/src/cmd/vi/port/ex_io.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_io.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -480,7 +477,7 @@ for (a=first; a<=last; a++) { if (a==first+5 && last-first > 10) a = last - 4; - getline(*a); + getaline(*a); chkmdln(linebuf); } } @@ -767,7 +764,7 @@ nib = BUFSIZE; fp = genbuf; do { - getline(*a1++); + getaline(*a1++); lp = linebuf; for (;;) { if (--nib < 0) {
--- a/usr/src/cmd/vi/port/ex_re.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_re.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_re.h" @@ -1107,7 +1104,7 @@ if (addr == zero) return (0); p1 = linebuf; - getline(*addr); + getaline(*addr); if(value(vi_IGNORECASE)) { p1 = genbuf; p2 = linebuf;
--- a/usr/src/cmd/vi/port/ex_set.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_set.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_temp.h" #include "ex_tty.h" @@ -189,7 +186,7 @@ viprintf("%d\n", tmpadr); else { viprintf("%d\t", tmpadr); - getline(*tmpadr); + getaline(*tmpadr); pline(lineno(tmpadr)); putchar('\n'); } @@ -231,7 +228,7 @@ viprintf("%d\n", tmpadr); else { viprintf("%d\t", tmpadr); - getline(*tmpadr); + getaline(*tmpadr); pline(lineno(tmpadr)); putchar('\n'); }
--- a/usr/src/cmd/vi/port/ex_subr.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_subr.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/stropts.h> #include <sys/eucioctl.h> #ifndef PRESUNEUC @@ -219,7 +216,7 @@ getDOT(void) { - getline(*dot); + getaline(*dot); } line *
--- a/usr/src/cmd/vi/port/ex_temp.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_temp.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_temp.h" #include "ex_vis.h" @@ -157,7 +154,7 @@ } void -getline(line tl) +getaline(line tl) { unsigned char *bp, *lp; int nl; @@ -688,7 +685,7 @@ } CP(savelb, linebuf); for (addr = addr1; addr <= addr2; addr++) { - getline(*addr); + getaline(*addr); if (sp->rg_flags) { if (addr == addr2) *wcursor = 0;
--- a/usr/src/cmd/vi/port/ex_vadj.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_vadj.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tune.h" #include "ex_tty.h" @@ -90,7 +87,7 @@ * and so it's not worth optimizing. */ vdirty(vcline+1, WECHO); - getline(*tp); + getaline(*tp); /* * If we are opening at the top of the window, can try a window @@ -685,7 +682,7 @@ if (l == vcline) strcLIN(temp); else - getline(*tp); + getaline(*tp); /* * Delete junk between displayed lines. @@ -729,7 +726,7 @@ vcline = l; for (; tp <= dol && Peekkey != ATTN; tp++) { - getline(*tp); + getaline(*tp); if (p + vdepth() - 1 > WBOT) break; vopen(tp, p); @@ -897,7 +894,7 @@ if (l == vcline) strcLIN(temp); else - getline(dot[l - vcline]); + getaline(dot[l - vcline]); /* * Be careful that a long line doesn't cause the * screen to shoot up.
--- a/usr/src/cmd/vi/port/ex_vget.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_vget.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -755,7 +752,7 @@ fprintf(trace, "linebuf = '%s'\n", linebuf); for (p=zero+1; p<=truedol; p++) { fprintf(trace, "%o ", *p); - getline(*p); + getaline(*p); fprintf(trace, "'%s'\n", linebuf); } fprintf(trace, "]\n");
--- a/usr/src/cmd/vi/port/ex_voper.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_voper.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -747,7 +747,7 @@ markDOT(); if (wcursor) { vsave(); - getline(*wdot); + getaline(*wdot); if (wcursor > strend(linebuf)) wcursor = 0; else {
--- a/usr/src/cmd/vi/port/ex_vops.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_vops.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -29,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -526,7 +524,7 @@ */ *cursor = 0; strcpy(genbuf, linebuf); - getline(*wdot); + getaline(*wdot); if (strlen(genbuf) + strlen(wcursor) > LBSIZE - 2) { getDOT(); (void) beep(); @@ -910,7 +908,7 @@ if (vpastwh(linebuf) >= cursor) wcursor = 0; else { - getline(*wdot); + getaline(*wdot); wcursor = strend(linebuf); getDOT(); }
--- a/usr/src/cmd/vi/port/ex_vops2.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_vops2.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -29,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -781,7 +779,7 @@ * of the repeated insert, then copy this line to the temp file. */ (void) strlcpy((char *)genbuf, (char *)linebuf, sizeof (genbuf)); - getline(*startsrcline); + getaline(*startsrcline); if (strlcpy((char *)(genbuf + endsrccol + 1), (char *)(linebuf + startsrccol), destsize) >= destsize) { error(gettext("Line too long")); @@ -808,7 +806,7 @@ getDOT(); cursor = linebuf + endsrccol; } else { - getline(*srcline); + getaline(*srcline); /* copy linebuf to temp file */ vdoappend(linebuf); vcline++; @@ -840,7 +838,7 @@ */ while (tmpcnt <= savecnt) { for (srcline = startsrcline; srcline <= endsrcline; ++srcline) { - getline(*srcline); + getaline(*srcline); /* copy linebuf to temp file */ vdoappend(linebuf); vcline++;
--- a/usr/src/cmd/vi/port/ex_vops3.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_vops3.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -331,7 +328,7 @@ int cnt = 0; addr--; - getline(*addr); + getaline(*addr); for (cp = linebuf; *cp; cp++) if (*cp == '(') cnt++; @@ -548,7 +545,7 @@ return (0); } wdot++; - getline(*wdot); + getaline(*wdot); wcursor = linebuf; return (1); } else { @@ -562,7 +559,7 @@ return (0); } wdot--; - getline(*wdot); + getaline(*wdot); if(!*linebuf) wcursor = linebuf; else { @@ -585,7 +582,7 @@ addr -= dir; break; } - getline(*addr); + getaline(*addr); if (linebuf[0] == '{' || #ifdef XPG4 /* POSIX 1003.2 Section 5.35.7.1: control-L */ @@ -595,7 +592,7 @@ isa(svalue(vi_SECTIONS))) { if (c == ']' && f != vmove) { addr--; - getline(*addr); + getaline(*addr); } break; }
--- a/usr/src/cmd/vi/port/ex_vwind.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/ex_vwind.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -201,24 +198,24 @@ { line *top; - getline(*addr); + getaline(*addr); if (state != VISUAL) top = addr; else switch (where) { case '^': addr = vback(addr, basWLINES - vdepth()); - getline(*addr); + getaline(*addr); /* fall into ... */ case '-': top = vback(addr, basWLINES - vdepth()); - getline(*addr); + getaline(*addr); break; case '.': top = vback(addr, basWLINES / 2 - vdepth()); - getline(*addr); + getaline(*addr); break; default: @@ -334,7 +331,7 @@ if (cnt > 0) for (; tp > one; tp--) { - getline(tp[-1]); + getaline(tp[-1]); d = vdepth(); if (d > cnt) break; @@ -354,7 +351,7 @@ j = 0; while (cnt > 0) { cnt--; - getline(tp[cnt]); + getaline(tp[cnt]); j += vdepth(); } if (tp > dot)
--- a/usr/src/cmd/vi/port/exrecover.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/vi/port/exrecover.c Thu Aug 12 14:55:22 2010 -0700 @@ -18,10 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. -*/ + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ @@ -707,7 +707,7 @@ #ifdef DEBUG fprintf(stderr,"GETTING A LINE \n"); #endif - getline(*a1++); + getaline(*a1++); lp = linebuf; #ifdef DEBUG fprintf(stderr,"LINE:%s\n",linebuf); @@ -755,7 +755,7 @@ #define WRITE 1 void -getline(line tl) +getaline(line tl) { unsigned char *bp, *lp; int nl;
--- a/usr/src/cmd/ypcmd/mknetid/getname.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ypcmd/mknetid/getname.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,14 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.3 */ - #include <stdio.h> #include <string.h> @@ -35,12 +31,12 @@ #define isignore(c) (strchr(ignore, c) != NULL) /* - * getline() + * getaline() * Read a line from a file. * What's returned is a cookie to be passed to getname */ char ** -getline(line, maxlinelen, f, lcount, com) +getaline(line, maxlinelen, f, lcount, com) char *line; int maxlinelen; FILE *f;
--- a/usr/src/cmd/ypcmd/mknetid/mknetid.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ypcmd/mknetid/mknetid.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,14 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.5 */ - /* * Network name to unix credential database generator. * Uses /etc/passwd, /etc/group, /etc/hosts and /etc/netid to @@ -57,7 +53,7 @@ #define NUMGIDS (NGROUPS_MAX + 1) /* group-access-list + gid */ -extern char **getline(); +extern char **getaline(); extern char *malloc(); extern char *strcpy(); @@ -172,7 +168,7 @@ curfile = mapfile; curline = 0; - while (lp = getline(line, sizeof (line), mf, &curline, "#")) { + while (lp = getaline(line, sizeof (line), mf, &curline, "#")) { check_getname(lp, name, WHITE, WHITE, "#"); if (wasprinted(name)) { multdef(name); @@ -219,7 +215,7 @@ curfile = grpfile; curline = 0; - while (lp = getline(line, sizeof (line), gf, &curline, "")) { + while (lp = getaline(line, sizeof (line), gf, &curline, "")) { check_getname(lp, name, WHITE, COLON, ""); if (name[0] == '+') { continue; @@ -252,7 +248,7 @@ curfile = pwdfile; curline = 0; - while (lp = getline(line, sizeof (line), pf, &curline, "")) { + while (lp = getaline(line, sizeof (line), pf, &curline, "")) { check_getname(lp, user, WHITE, COLON, ""); /* username */ if (user[0] == '-' || user[0] == '+') { continue; /* NIS entry */ @@ -291,7 +287,7 @@ curfile = hostfile; curline = 0; - while (lp = getline(line, sizeof (line), hf, &curline, "#")) { + while (lp = getaline(line, sizeof (line), hf, &curline, "#")) { check_getname(lp, name, WHITE, WHITE, "#"); if (getname(name, MAXNAMELEN, WHITE, WHITE, lp, "#") != 1) { continue;
--- a/usr/src/cmd/ypcmd/revnetgroup/revnetgroup.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ypcmd/revnetgroup/revnetgroup.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,16 +18,13 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1994, by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - + /* * For SUNWnskit - version 1.1 - * - * Based on: - * #pragma ident "%Z%%M% %I% %E% SMI" (SMI4.1 1.6) */ #include <stdlib.h> @@ -277,7 +273,7 @@ char *group; char *line; - while (getline(buf, MAXGROUPLEN, nf)) { + while (getaline(buf, MAXGROUPLEN, nf)) { for (p = buf; *p && isspace((int)*p); p++) ; /* skip leading blanks */ for (; *p && *p != '#' && *p != ' ' && *p != '\t'; p++)
--- a/usr/src/cmd/ypcmd/revnetgroup/util.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ypcmd/revnetgroup/util.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1996-2001 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.4 */ - #include <stdio.h> #include <string.h> #include "util.h" @@ -38,7 +35,7 @@ * of a line */ char * -getline(line, maxlen, fp) +getaline(line, maxlen, fp) char *line; int maxlen; FILE *fp;
--- a/usr/src/cmd/ypcmd/revnetgroup/util.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/cmd/ypcmd/revnetgroup/util.h Thu Aug 12 14:55:22 2010 -0700 @@ -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,17 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 1995 Sun Microsystems Inc. - * All rights reserved. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - #ifndef __UTIL_H #define __UTIL_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.5 */ - #ifdef __cplusplus extern "C" { #endif @@ -57,7 +53,7 @@ */ extern char *alloca(); -char *getline(); +char *getaline(); void fatal(); #ifdef __cplusplus
--- a/usr/src/common/net/wanboot/boot_http.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/common/net/wanboot/boot_http.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * 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 <errno.h> #include <sys/types.h> #include <sys/socket.h> @@ -180,7 +177,7 @@ static int get_chunk_header(http_conn_t *); static int init_bread(http_conn_t *); static int get_msgcnt(http_conn_t *, ssize_t *); -static int getline(http_conn_t *, char *, int, boolean_t); +static int getaline(http_conn_t *, char *, int, boolean_t); static int getbytes(http_conn_t *, char *, int); static int http_srv_send(http_conn_t *, const void *, size_t); static int http_srv_recv(http_conn_t *, void *, size_t); @@ -945,7 +942,7 @@ * check the response status line, expecting * HTTP/1.1 200 OK */ - i = getline(c_id, line, sizeof (line), B_FALSE); + i = getaline(c_id, line, sizeof (line), B_FALSE); if (i == 0) { if (resp != NULL) { *resp = lresp; @@ -1150,7 +1147,7 @@ /* Look for the boundary line. */ count = 0; - while ((i = getline(c_id, line, sizeof (line), B_TRUE)) == 0 && + while ((i = getaline(c_id, line, sizeof (line), B_TRUE)) == 0 && count < FAILSAFE) count ++; if (i < 0 || count > limit) { @@ -1662,7 +1659,7 @@ * Allow for concat(basic_auth_userid ":" basic_auth_password) */ authlen = strlen(c_id->basic_auth_userid) + 2 + - strlen(c_id->basic_auth_password); + strlen(c_id->basic_auth_password); if ((authstr = malloc(authlen + 1)) == NULL) { free(request); SET_ERR(c_id, ERRSRC_LIBHTTP, EHTTP_NOMEM); @@ -1680,7 +1677,7 @@ } (void) EVP_EncodeBlock((unsigned char *)authencstr, - (unsigned char *)authstr, authlen); + (unsigned char *)authstr, authlen); /* * Finally do concat(Authorization: Basic " authencstr "\r\n") @@ -2186,7 +2183,7 @@ if ((verify_err = SSL_get_verify_result(c_id->ssl)) != X509_V_OK) { SET_ERR(c_id, ERRSRC_VERIFERR, verify_err); libbootlog(BOOTLOG_CRIT, - "check_cert_chain: Certificate doesn't verify"); + "check_cert_chain: Certificate doesn't verify"); return (-1); } @@ -2207,7 +2204,7 @@ return (-1); } (void) X509_NAME_get_text_by_NID(X509_get_subject_name(peer), - NID_commonName, peer_CN, 256); + NID_commonName, peer_CN, 256); if (verbosemode) libbootlog(BOOTLOG_VERBOSE, @@ -2283,7 +2280,7 @@ * c_id->resphdr. * * Note that I/O errors are put into the error stack by http_srv_recv(), - * which is called by getline(). + * which is called by getaline(). */ static int read_headerlines(http_conn_t *c_id, boolean_t bread) @@ -2298,7 +2295,7 @@ /* process headers, stop when we get to an empty line */ cur = 0; next = 0; - while ((n = getline(c_id, line, sizeof (line), bread)) > 0) { + while ((n = getaline(c_id, line, sizeof (line), bread)) > 0) { if (verbosemode) libbootlog(BOOTLOG_VERBOSE, @@ -2430,11 +2427,11 @@ ok = 1; c_id->is_firstchunk = B_FALSE; } else { - ok = ((i = getline(c_id, line, sizeof (line), B_FALSE)) == 0); + ok = ((i = getaline(c_id, line, sizeof (line), B_FALSE)) == 0); } if (ok) - i = getline(c_id, line, sizeof (line), B_FALSE); + i = getaline(c_id, line, sizeof (line), B_FALSE); if (!ok || i < 0) { /* * If I/O error, the Cause was already put into @@ -2619,7 +2616,7 @@ } /* - * getline - Get lines of data from the HTTP response, up to 'len' bytes. + * getaline - Get lines of data from the HTTP response, up to 'len' bytes. * NOTE: the line will not end with a NULL if all 'len' bytes * were read. * @@ -2642,7 +2639,7 @@ * Note that I/O errors are put into the error stack by http_srv_recv().1 */ static int -getline(http_conn_t *c_id, char *line, int len, boolean_t bread) +getaline(http_conn_t *c_id, char *line, int len, boolean_t bread) { int i = 0; ssize_t msgcnt = 0; @@ -2724,7 +2721,7 @@ * * Note that all reads performed here assume that a message body is being * read. If this changes in the future, then the logic should more closely - * resemble getline(). + * resemble getaline(). * * Note that I/O errors are put into the error stack by http_srv_recv(). */ @@ -2758,7 +2755,7 @@ if (c_id->inbuf.n != c_id->inbuf.i) { nbytes = (int)MIN(cnt, c_id->inbuf.n - c_id->inbuf.i); (void) memcpy(line, &c_id->inbuf.buf[c_id->inbuf.i], - nbytes); + nbytes); c_id->inbuf.i += nbytes; } else { nbytes = http_srv_recv(c_id, line, cnt);
--- a/usr/src/head/poll.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/head/poll.h Thu Aug 12 14:55:22 2010 -0700 @@ -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,49 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - #ifndef _POLL_H #define _POLL_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ - /* * Poll system call interface definitions. */ +#include <sys/feature_tests.h> #include <sys/poll.h> +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#include <time.h> +#include <signal.h> +#endif /* defined(__EXTENSIONS__) ... */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) + +#if defined(__STDC__) + +extern int ppoll(struct pollfd *_RESTRICT_KYWD, nfds_t, + const struct timespec *_RESTRICT_KYWD, const sigset_t *_RESTRICT_KYWD); + +#else /* __STDC__ */ + +extern int ppoll(); + +#endif /* __STDC__ */ + +#endif /* defined(__EXTENSIONS__) ... */ + +#ifdef __cplusplus +} +#endif #endif /* _POLL_H */
--- a/usr/src/head/stdio.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/head/stdio.h Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -261,6 +260,15 @@ #endif /* !__PRAGMA_REDEFINE_EXTNAME */ #endif /* _LP64 && _LARGEFILE64_SOURCE */ +#ifndef _SSIZE_T +#define _SSIZE_T +#if defined(_LP64) || defined(_I32LPx) +typedef long ssize_t; /* size of something in bytes or -1 */ +#else +typedef int ssize_t; /* (historical version) */ +#endif +#endif /* !_SSIZE_T */ + #if defined(__STDC__) #if defined(__EXTENSIONS__) || \ @@ -271,6 +279,7 @@ #if defined(__EXTENSIONS__) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +extern int fcloseall(void); extern void setbuffer(FILE *, char *, size_t); extern int setlinebuf(FILE *); /* PRINTFLIKE2 */ @@ -279,6 +288,15 @@ extern int vasprintf(char **, const char *, __va_list); #endif +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD, + int, FILE *_RESTRICT_KYWD); +extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD, + FILE *_RESTRICT_KYWD); +#endif /* __EXTENSIONS__ ... */ + /* * The following are known to POSIX and XOPEN, but not to ANSI-C. */ @@ -333,7 +351,7 @@ /* * The following are defined as part of the Large File Summit interfaces. */ -#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) +#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) extern int fseeko(FILE *, off_t, int); extern off_t ftello(FILE *); #endif @@ -342,7 +360,7 @@ * The following are defined as part of the transitional Large File Summit * interfaces. */ -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ !defined(__PRAGMA_REDEFINE_EXTNAME)) extern FILE *fopen64(const char *, const char *); extern FILE *freopen64(const char *, const char *, FILE *); @@ -367,19 +385,26 @@ #endif #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern int fcloseall(); extern void setbuffer(); extern int setlinebuf(); extern int asprintf(); extern int vasprintf(); #endif +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) + /* || defined(_XPG7) */ +extern ssize_t getdelim(); +extern ssize_t getline(); +#endif /* __EXTENSIONS__ ... */ + #if defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX) extern FILE *fdopen(); extern char *ctermid(); extern int fileno(); #endif /* defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX) */ -#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ (_POSIX_C_SOURCE - 0 >= 199506L) extern void flockfile(); extern int ftrylockfile(); @@ -410,12 +435,12 @@ #endif /* defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) */ -#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) +#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) extern int fseeko(); extern off_t ftello(); #endif -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ !defined(__PRAGMA_REDEFINE_EXTNAME)) extern FILE *fopen64(); extern FILE *freopen64(); @@ -430,7 +455,7 @@ #if !defined(__lint) -#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ (_POSIX_C_SOURCE - 0 >= 199506L) #ifndef _LP64 #ifdef __STDC__
--- a/usr/src/head/stdlib.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/head/stdlib.h Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -212,6 +211,8 @@ #if defined(__EXTENSIONS__) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +extern char *canonicalize_file_name(const char *); +extern int clearenv(void); extern void closefrom(int); extern int daemon(int, int); extern int dup2(int, int); @@ -232,6 +233,8 @@ extern void *memalign(size_t, size_t); extern char *ttyname(int); extern char *mkdtemp(char *); +extern const char *getprogname(void); +extern void setprogname(const char *); #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) extern char *lltostr(long long, char *); @@ -315,6 +318,8 @@ #endif #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern char *canonicalize_file_name(); +extern int clearenv(); extern void closefrom(); extern int daemon(); extern int dup2(); @@ -335,6 +340,8 @@ extern void *memalign(); extern char *ttyname(); extern char *mkdtemp(); +extern char *getprogname(); +extern void setprogname(); #if defined(_LONGLONG_TYPE) extern char *lltostr();
--- a/usr/src/head/string.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/head/string.h Thu Aug 12 14:55:22 2010 -0700 @@ -18,15 +18,14 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - #ifndef _STRING_H #define _STRING_H @@ -89,16 +88,33 @@ #if defined(__EXTENSIONS__) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, size_t); +extern char *stpcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern char *stpncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); +extern char *strndup(const char *, size_t); +extern size_t strnlen(const char *, size_t); +extern char *strsignal(int); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t); extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t); -extern char *strsignal(int); -extern size_t strnlen(const char *, size_t); extern int ffs(int); -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, size_t); +extern int ffsl(long); +extern int ffsll(long long); +extern int fls(int); +extern int flsl(long); +extern int flsll(long long); +extern void *memmem(const void *, size_t, const void *, size_t); +extern char *strcasestr(const char *, const char *); +extern char *strnstr(const char *, const char *, size_t); extern size_t strlcpy(char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t); extern char *strsep(char **stringp, const char *delim); +extern char *strchrnul(const char *, int); #endif /* defined(__EXTENSIONS__)... */ #if defined(__EXTENSIONS__) || \ @@ -107,6 +123,60 @@ extern char *strdup(const char *); #endif +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +#if defined(__GNUC__) + +/* + * gcc provides this inlining facility but Studio C does not. + * We should use it exclusively once Studio C also provides it. + */ +extern void *__builtin_alloca(size_t); + +#define strdupa(s) \ + (__extension__( \ + { \ + char *__str = (char *)(s); \ + strcpy((char *)__builtin_alloca(strlen(__str) + 1), __str); \ + })) + +#define strndupa(s, n) \ + (__extension__( \ + { \ + char *__str = (char *)(s); \ + size_t __len = strnlen(__str, (n)); \ + (__str = strncpy((char *)__builtin_alloca(__len + 1), \ + __str, __len), \ + __str[__len] = '\0', __str); \ + })) + +#else /* __GNUC__ */ + +#if defined(unix) /* excludes c99 */ +/* + * Studio C currently can't do the gcc-style inlining, + * so we use thread-local storage instead. + */ +extern void *__builtin_alloca(size_t); +extern __thread char *__strdupa_str; +extern __thread size_t __strdupa_len; + +#define strdupa(s) \ + (__strdupa_str = (char *)(s), \ + strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1), \ + __strdupa_str)) + +#define strndupa(s, n) \ + (__strdupa_str = (char *)(s), \ + __strdupa_len = strnlen(__strdupa_str, (n)), \ + __strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \ + __strdupa_str, __strdupa_len), \ + __strdupa_str[__strdupa_len] = '\0', __strdupa_str) +#endif /* unix */ + +#endif /* __GNUC__ */ +#endif /* __EXTENSIONS__ ... */ + #else /* __STDC__ */ #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ @@ -124,17 +194,34 @@ extern void *memccpy(); #endif -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern int strcasecmp(); +extern int strncasecmp(); +extern char *stpcpy(); +extern char *stpncpy(); +extern char *strndup(); +extern size_t strnlen(); +extern char *strsignal(); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) extern int uucopy(); extern int uucopystr(); -extern char *strsignal(); -extern size_t strnlen(); extern int ffs(); -extern int strcasecmp(); -extern int strncasecmp(); +extern int ffsl(); +extern int ffsll(); +extern int fls(); +extern int flsl(); +extern int flsll(); +extern char *strcasestr(); +extern char *strnstr(); extern size_t strlcpy(); extern size_t strlcat(); extern char *strsep(); +extern char *strchrnul(); #endif /* defined(__EXTENSIONS__) ... */ #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
--- a/usr/src/head/unistd.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/head/unistd.h Thu Aug 12 14:55:22 2010 -0700 @@ -162,11 +162,11 @@ * which need mutexes to support priority inheritance/ceiling. */ #if defined(_XPG6) -#define _POSIX_THREAD_PRIO_INHERIT 200112L -#define _POSIX_THREAD_PRIO_PROTECT 200112L +#define _POSIX_THREAD_PRIO_INHERIT 200112L +#define _POSIX_THREAD_PRIO_PROTECT 200112L #else -#define _POSIX_THREAD_PRIO_INHERIT 1 -#define _POSIX_THREAD_PRIO_PROTECT 1 +#define _POSIX_THREAD_PRIO_INHERIT 1 +#define _POSIX_THREAD_PRIO_PROTECT 1 #endif #ifndef _POSIX_VDISABLE @@ -558,6 +558,10 @@ extern int symlinkat(const char *, int, const char *); extern int unlinkat(int, const char *, int); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int get_nprocs(void); +extern int get_nprocs_conf(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ /* transitional large file interface versions */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ @@ -855,6 +859,10 @@ extern int symlinkat(); extern int unlinkat(); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int get_nprocs(); +extern int get_nprocs_conf(); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ /* transitional large file interface versions */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
--- a/usr/src/head/wchar.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/head/wchar.h Thu Aug 12 14:55:22 2010 -0700 @@ -20,17 +20,13 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _WCHAR_H #define _WCHAR_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/feature_tests.h> - #include <iso/wchar_iso.h> #include <iso/wchar_c99.h> @@ -146,6 +142,18 @@ extern wctype_t wctype(const char *); #endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */ +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern wchar_t *wcsdup(const wchar_t *); +extern size_t wcsnlen(const wchar_t *, size_t); +extern wchar_t *wcpcpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD); +extern wchar_t *wcpncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +extern int wcscasecmp(const wchar_t *, const wchar_t *); +extern int wcsncasecmp(const wchar_t *, const wchar_t *, size_t); +#endif + #else /* __STDC__ */ #if !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) @@ -169,6 +177,17 @@ extern wctype_t wctype(); #endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */ +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern wchar_t *wcsdup(); +extern size_t wcsnlen(); +extern wchar_t *wcpcpy(); +extern wchar_t *wcpncpy(); +extern int wcscasecmp(); +extern int wcsncasecmp(); +#endif + #endif /* __STDC__ */ #ifdef __cplusplus
--- a/usr/src/lib/fm/libfmd_msg/common/fmd_msg.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/fm/libfmd_msg/common/fmd_msg.c Thu Aug 12 14:55:22 2010 -0700 @@ -1380,9 +1380,7 @@ if (locale != NULL && strcmp(h->fmh_locale, locale) == 0) locale = NULL; /* simplify later tests */ - dict = alloca((size_t)(p - code) + 1); - (void) strncpy(dict, code, (size_t)(p - code)); - dict[(size_t)(p - code)] = '\0'; + dict = strndupa(code, p - code); fmd_msg_lock(); @@ -1392,8 +1390,7 @@ */ if (h->fmh_binding != NULL) { p = bindtextdomain(dict, NULL); - old_b = alloca(strlen(p) + 1); - (void) strcpy(old_b, p); + old_b = strdupa(p); (void) bindtextdomain(dict, h->fmh_binding); } @@ -1412,8 +1409,7 @@ * the text for a different locale, switch locales now under the lock. */ p = setlocale(LC_ALL, NULL); - old_c = alloca(strlen(p) + 1); - (void) strcpy(old_c, p); + old_c = strdupa(p); if (locale != NULL) (void) setlocale(LC_ALL, locale); @@ -1559,9 +1555,7 @@ if (locale != NULL && strcmp(h->fmh_locale, locale) == 0) locale = NULL; /* simplify later tests */ - dict = alloca((size_t)(p - code) + 1); - (void) strncpy(dict, code, (size_t)(p - code)); - dict[(size_t)(p - code)] = '\0'; + dict = strndupa(code, p - code); fmd_msg_lock(); @@ -1571,8 +1565,7 @@ */ if (h->fmh_binding != NULL) { p = bindtextdomain(dict, NULL); - old_b = alloca(strlen(p) + 1); - (void) strcpy(old_b, p); + old_b = strdupa(p); (void) bindtextdomain(dict, h->fmh_binding); } @@ -1591,8 +1584,7 @@ * the text for a different locale, switch locales now under the lock. */ p = setlocale(LC_ALL, NULL); - old_c = alloca(strlen(p) + 1); - (void) strcpy(old_c, p); + old_c = strdupa(p); if (locale != NULL) (void) setlocale(LC_ALL, locale);
--- a/usr/src/lib/libc/amd64/Makefile Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/amd64/Makefile Thu Aug 12 14:55:22 2010 -0700 @@ -89,7 +89,6 @@ bcopy.o \ bsearch.o \ bzero.o \ - ffs.o \ qsort.o \ strtol.o \ strtoul.o \ @@ -325,6 +324,8 @@ a64l.o \ abort.o \ addsev.o \ + ascii_strcasecmp.o \ + ascii_strncasecmp.o \ assert.o \ atof.o \ atoi.o \ @@ -367,6 +368,8 @@ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -388,6 +391,7 @@ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -435,6 +439,7 @@ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -498,18 +503,20 @@ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ - strcasecmp.o \ strcat.o \ strchr.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ strlcat.o \ strlcpy.o \ - strncasecmp.o \ strncat.o \ + strndup.o \ strpbrk.o \ strrchr.o \ strsep.o \ @@ -539,6 +546,7 @@ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -613,6 +621,7 @@ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -645,7 +654,11 @@ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcsstr.o \ wcstoimax.o \ wcstol.o \ @@ -940,8 +953,10 @@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -998,6 +1013,7 @@ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ lwp.o \ ma.o \
--- a/usr/src/lib/libc/i386/Makefile.com Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/i386/Makefile.com Thu Aug 12 14:55:22 2010 -0700 @@ -90,7 +90,6 @@ bcopy.o \ bsearch.o \ bzero.o \ - ffs.o \ qsort.o \ strtol.o \ strtoul.o \ @@ -355,6 +354,8 @@ a64l.o \ abort.o \ addsev.o \ + ascii_strcasecmp.o \ + ascii_strncasecmp.o \ assert.o \ atof.o \ atoi.o \ @@ -398,6 +399,8 @@ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -419,6 +422,7 @@ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -466,6 +470,7 @@ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -530,15 +535,17 @@ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ - strcasecmp.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ strlcat.o \ strlcpy.o \ - strncasecmp.o \ + strndup.o \ strpbrk.o \ strsep.o \ strsignal.o \ @@ -567,6 +574,7 @@ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -655,6 +663,7 @@ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -687,7 +696,11 @@ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcsstr.o \ wcstoimax.o \ wcstol.o \ @@ -995,8 +1008,10 @@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -1056,6 +1071,7 @@ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ lwp.o \ ma.o \
--- a/usr/src/lib/libc/inc/thr_uberdata.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/inc/thr_uberdata.h Thu Aug 12 14:55:22 2010 -0700 @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _THR_UBERDATA_H @@ -905,6 +905,7 @@ atfork_t *atforklist; /* circular Q for fork handlers */ robust_t **robustlocks; /* table of registered robust locks */ robust_t *robustlist; /* list of registered robust locks */ + char *progname; /* the basename of the program, from argv[0] */ struct uberdata **tdb_bootstrap; tdb_t tdb; /* thread debug interfaces (for libc_db) */ } uberdata_t; @@ -1348,6 +1349,7 @@ extern void setup_cancelsig(int); extern void init_sigev_thread(void); extern void init_aio(void); +extern void init_progname(void); extern void _cancelon(void); extern void _canceloff(void); extern void _canceloff_nocancel(void);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/ascii_strcasecmp.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#include "lint.h" +#include <sys/types.h> +#include <strings.h> + +/* + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ + +extern const char strcase_charmap[]; + +int +ascii_strcasecmp(const char *s1, const char *s2) +{ + const unsigned char *cm = (const unsigned char *)strcase_charmap; + const unsigned char *us1 = (const unsigned char *)s1; + const unsigned char *us2 = (const unsigned char *)s2; + + while (cm[*us1] == cm[*us2++]) + if (*us1++ == '\0') + return (0); + return (cm[*us1] - cm[*(us2 - 1)]); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/ascii_strncasecmp.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#include "lint.h" +#include <sys/types.h> +#include <strings.h> + +/* + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ + +extern const char strcase_charmap[]; + +int +ascii_strncasecmp(const char *s1, const char *s2, size_t n) +{ + const unsigned char *cm = (const unsigned char *)strcase_charmap; + const unsigned char *us1 = (const unsigned char *)s1; + const unsigned char *us2 = (const unsigned char *)s2; + + while (n != 0 && cm[*us1] == cm[*us2++]) { + if (*us1++ == '\0') + return (0); + n--; + } + return (n == 0 ? 0 : cm[*us1] - cm[*(us2 - 1)]); +}
--- a/usr/src/lib/libc/port/gen/err.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/err.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,13 @@ */ /* - * 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 "lint.h" #include "file64.h" #include "mtlib.h" +#include "thr_uberdata.h" #include <sys/types.h> #include <err.h> #include <stdio.h> @@ -36,11 +34,51 @@ #include <stdarg.h> #include <string.h> #include <errno.h> +#include <dlfcn.h> #include "stdiom.h" /* Function exit/warning functions and global variables. */ -static const char *progname; +const char *__progname; /* GNU/Linux/BSD compatibility */ + +#define PROGNAMESIZE 128 /* buffer size for __progname */ + +const char * +getprogname(void) +{ + return (__progname); +} + +void +setprogname(const char *argv0) +{ + uberdata_t *udp = curthread->ul_uberdata; + const char *progname; + + if ((progname = strrchr(argv0, '/')) == NULL) + progname = argv0; + else + progname++; + + if (udp->progname == NULL) + udp->progname = lmalloc(PROGNAMESIZE); + (void) strlcpy(udp->progname, progname, PROGNAMESIZE); + __progname = udp->progname; +} + +/* called only from libc_init() */ +void +init_progname(void) +{ + Dl_argsinfo_t args; + const char *argv0; + + if (dlinfo(RTLD_SELF, RTLD_DI_ARGSINFO, &args) < 0) + argv0 = "UNKNOWN"; + else + argv0 = args.dla_argv[0]; + setprogname(argv0); +} /* * warncore() is the workhorse of these functions. Everything else has @@ -49,22 +87,12 @@ static rmutex_t * warncore(FILE *fp, const char *fmt, va_list args) { - const char *execname; rmutex_t *lk; FLOCKFILE(lk, fp); - if (progname == NULL) { - execname = getexecname(); - if ((execname != NULL) && - ((progname = strrchr(execname, '/')) != NULL)) - progname++; - else - progname = execname; - } - - if (progname != NULL) - (void) fprintf(fp, "%s: ", progname); + if (__progname != NULL) + (void) fprintf(fp, "%s: ", __progname); if (fmt != NULL) { (void) vfprintf(fp, fmt, args);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/ffs.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> +#include <strings.h> +#include <sys/types.h> + +static int +ffs_impl(uint64_t bits) +{ + int i = 1; + uint32_t bits32; + + if (bits == 0) + return (0); + + if ((bits32 = (uint32_t)bits) == 0) { + bits32 = (uint32_t)(bits >> 32); + i += 32; + } + + if ((bits32 & 0xffff) == 0) { + bits32 >>= 16; + i += 16; + } + if ((bits32 & 0xff) == 0) { + bits32 >>= 8; + i += 8; + } + if ((bits32 & 0xf) == 0) { + bits32 >>= 4; + i += 4; + } + if ((bits32 & 0x3) == 0) { + bits32 >>= 2; + i += 2; + } + if ((bits32 & 0x1) == 0) + i += 1; + + return (i); +} + +int +ffs(int bits) +{ + return (ffs_impl((uint64_t)(uint_t)bits)); +} + +int +ffsl(long bits) +{ + return (ffs_impl((uint64_t)(ulong_t)bits)); +} + +int +ffsll(long long bits) +{ + return (ffs_impl((uint64_t)(u_longlong_t)bits)); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/fls.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> +#include <strings.h> +#include <sys/types.h> + +static int +fls_impl(uint64_t bits) +{ + int i = 1; + uint32_t bits32; + + if (bits == 0) + return (0); + + if ((bits32 = (uint32_t)(bits >> 32)) != 0) + i += 32; + else + bits32 = (uint32_t)bits; + + if ((bits32 & 0xffff0000) != 0) { + bits32 >>= 16; + i += 16; + } + if ((bits32 & 0xff00) != 0) { + bits32 >>= 8; + i += 8; + } + if ((bits32 & 0xf0) != 0) { + bits32 >>= 4; + i += 4; + } + if ((bits32 & 0xc) != 0) { + bits32 >>= 2; + i += 2; + } + if ((bits32 & 0x2) != 0) + i += 1; + + return (i); +} + +int +fls(int bits) +{ + return (fls_impl((uint64_t)(uint_t)bits)); +} + +int +flsl(long bits) +{ + return (fls_impl((uint64_t)(ulong_t)bits)); +} + +int +flsll(long long bits) +{ + return (fls_impl((uint64_t)(u_longlong_t)bits)); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/get_nprocs.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <unistd.h> + +/* + * get_nprocs(3C) - return the number of online processors + */ +int +get_nprocs(void) +{ + return ((int)sysconf(_SC_NPROCESSORS_ONLN)); +} + +/* + * get_nprocs_conf(3C) - return the number of configured processors + */ +int +get_nprocs_conf(void) +{ + return ((int)sysconf(_SC_NPROCESSORS_CONF)); +}
--- a/usr/src/lib/libc/port/gen/getenv.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/getenv.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #pragma weak _putenv = putenv #include "lint.h" @@ -445,6 +442,30 @@ } /* + * Dump entire environment. + */ +int +clearenv(void) +{ + /* + * Just drop the entire environment list on the floor, as it + * would be non-trivial to try and free the used memory. + */ + static const char *nullp = NULL; + + lmutex_lock(&update_lock); + _environ = &nullp; + my_environ = NULL; + environ_base = NULL; + environ_size = 0; + environ_gen++; + membar_producer(); + lmutex_unlock(&update_lock); + + return (0); +} + +/* * At last, a lockless implementation of getenv()! */ char *
--- a/usr/src/lib/libc/port/gen/getmntent.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/getmntent.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -342,7 +341,7 @@ * an ioctl() call. */ static int -getline(char *lp, FILE *fp) +getaline(char *lp, FILE *fp) { char *cp; @@ -372,7 +371,7 @@ } /* skip leading spaces and comments */ - if ((ret = getline(line, fp)) != 0) + if ((ret = getaline(line, fp)) != 0) return (ret); /* split up each field */
--- a/usr/src/lib/libc/port/gen/getvfsent.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/getvfsent.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <mtlib.h> #include <stdio.h> @@ -66,7 +63,7 @@ static const char sepstr[] = " \t\n"; static const char dash[] = "-"; -static int getline(char *, FILE *); +static int getaline(char *, FILE *); int getvfsspec(FILE *fd, struct vfstab *vgetp, char *special) @@ -78,8 +75,8 @@ if (special && stat64(special, &statb) == 0 && - ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || - bmode == S_IFCHR)) { + ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || + bmode == S_IFCHR)) { bstat = 1; brdev = statb.st_rdev; } else @@ -119,12 +116,12 @@ /* Match by straight strcmp */ while ((ret = getvfsent(fd, vgetp)) == 0 && - (DIFF(vfs_special) || DIFF(vfs_fsckdev) || - DIFF(vfs_mountp) || - DIFF(vfs_fstype) || - DIFF(vfs_fsckpass) || - DIFF(vfs_automnt) || - DIFF(vfs_mntopts))) + (DIFF(vfs_special) || DIFF(vfs_fsckdev) || + DIFF(vfs_mountp) || + DIFF(vfs_fstype) || + DIFF(vfs_fsckpass) || + DIFF(vfs_automnt) || + DIFF(vfs_mntopts))) ; /* If something other than EOF, return it */ @@ -139,31 +136,31 @@ (void) fseeko64(fd, start, SEEK_SET); if (vrefp->vfs_special && stat64(vrefp->vfs_special, &statb) == 0 && - ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || - bmode == S_IFCHR)) { + ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || + bmode == S_IFCHR)) { bstat = 1; brdev = statb.st_rdev; } else bstat = 0; if (vrefp->vfs_fsckdev && stat64(vrefp->vfs_fsckdev, &statb) == 0 && - ((cmode = (statb.st_mode & S_IFMT)) == S_IFBLK || - cmode == S_IFCHR)) { + ((cmode = (statb.st_mode & S_IFMT)) == S_IFBLK || + cmode == S_IFCHR)) { cstat = 1; crdev = statb.st_rdev; } else cstat = 0; while ((ret = getvfsent(fd, vgetp)) == 0 && - ((bstat == 0 && DIFF(vfs_special)) || - (bstat == 1 && SDIFF(vfs_special, bmode, brdev)) || - (cstat == 0 && DIFF(vfs_fsckdev)) || - (cstat == 1 && SDIFF(vfs_fsckdev, cmode, crdev)) || - DIFF(vfs_mountp) || - DIFF(vfs_fstype) || - DIFF(vfs_fsckpass) || - DIFF(vfs_automnt) || - DIFF(vfs_mntopts))) + ((bstat == 0 && DIFF(vfs_special)) || + (bstat == 1 && SDIFF(vfs_special, bmode, brdev)) || + (cstat == 0 && DIFF(vfs_fsckdev)) || + (cstat == 1 && SDIFF(vfs_fsckdev, cmode, crdev)) || + DIFF(vfs_mountp) || + DIFF(vfs_fstype) || + DIFF(vfs_fsckpass) || + DIFF(vfs_automnt) || + DIFF(vfs_mntopts))) ; return (ret); } @@ -179,7 +176,7 @@ return (0); /* skip leading spaces and comments */ - if ((ret = getline(line, fd)) != 0) + if ((ret = getaline(line, fd)) != 0) return (ret); /* split up each field */ @@ -199,7 +196,7 @@ } static int -getline(char *lp, FILE *fd) +getaline(char *lp, FILE *fd) { char *cp;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/memmem.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <string.h> + +/* + * Find the first occurrence of the byte string s in byte string l. + */ + +void * +memmem(const void *l, size_t l_len, const void *s, size_t s_len) +{ + char *cur, *last; + const char *cl = (const char *)l; + const char *cs = (const char *)s; + + /* we need something to compare */ + if (l_len == 0 || s_len == 0) + return (NULL); + + /* "s" must be smaller or equal to "l" */ + if (l_len < s_len) + return (NULL); + + /* special case where s_len == 1 */ + if (s_len == 1) + return (memchr(l, (int)*cs, l_len)); + + /* the last position where its possible to find "s" in "l" */ + last = (char *)cl + l_len - s_len; + + for (cur = (char *)cl; cur <= last; cur++) + if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0) + return (cur); + + return (NULL); +}
--- a/usr/src/lib/libc/port/gen/mkdtemp.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/mkdtemp.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,18 +20,14 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * mkdtemp(3C) - create a directory with a unique name. */ #include "lint.h" -#include <alloca.h> #include <errno.h> #include <stdlib.h> #include <string.h> @@ -40,11 +36,11 @@ char * mkdtemp(char *template) { - char *t = alloca(strlen(template) + 1); + char *t; char *r; /* Save template */ - (void) strcpy(t, template); + t = strdupa(template); for (;;) { r = mktemp(template);
--- a/usr/src/lib/libc/port/gen/mktemp.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/mktemp.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * mktemp() expects a string with up to six trailing 'X's. * These will be overlaid with letters, digits and symbols from @@ -97,29 +94,6 @@ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', }; -/* - * Find highest one bit set. - * Returns bit number of highest bit that is set. - * Low order bit is number 0, high order bit is number 31. - */ -static int -highbit(uint_t i) -{ - int h = 0; - - if (i & 0xffff0000) - h += 16, i >>= 16; - if (i & 0xff00) - h += 8, i >>= 8; - if (i & 0xf0) - h += 4, i >>= 4; - if (i & 0xc) - h += 2, i >>= 2; - if (i & 0x2) - h += 1; - return (h); -} - char * libc_mktemps(char *as, int slen) { @@ -162,7 +136,7 @@ /* for all possible values of pid, 0 <= pid < (1 << pidshift) */ if (pidshift == 0) /* one-time initialization */ - pidshift = highbit((uint_t)MAXPID) + 1; + pidshift = fls((uint_t)MAXPID); /* high bit number */ /* count the X's */ xcnt = 0;
--- a/usr/src/lib/libc/port/gen/poll.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/poll.c Thu Aug 12 14:55:22 2010 -0700 @@ -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" - #pragma weak _poll = poll #include "lint.h" @@ -34,6 +31,14 @@ #include "libc.h" int +ppoll(struct pollfd *_RESTRICT_KYWD fds, nfds_t nfd, + const struct timespec *_RESTRICT_KYWD tsp, + const sigset_t *_RESTRICT_KYWD sigmask) +{ + return (_pollsys(fds, nfd, tsp, sigmask)); +} + +int poll(struct pollfd *fds, nfds_t nfd, int timeout) { timespec_t ts;
--- a/usr/src/lib/libc/port/gen/realpath.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/realpath.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <sys/types.h> #include <dirent.h> @@ -42,18 +39,18 @@ /* * Canonicalize the path given in file_name, resolving away all symbolic link * components. Store the result into the buffer named by resolved_name, which - * must be long enough (MAXPATHLEN bytes will suffice). Returns NULL + * must be long enough (PATH_MAX bytes will suffice). Returns NULL * on failure and resolved_name on success. On failure, to maintain * compatibility with the past, the contents of file_name will be copied * into resolved_name. */ -char * -realpath(const char *file_name, char *resolved_name) +static char * +realpath_impl(const char *file_name, char *resolved_name) { char cwd[PATH_MAX]; int len; - if (file_name == NULL || resolved_name == NULL) { + if (file_name == NULL) { errno = EINVAL; return (NULL); } @@ -121,3 +118,32 @@ (void) strcpy(resolved_name, cwd); return (resolved_name); } + +/* + * Canonicalize the path given in file_name, resolving away all symbolic link + * components. If resolved_name is a null pointer, return a malloc()d + * buffer containing the result, else store the result into resolved_name + * and return resolved_name. Return NULL on failure. + */ +char * +realpath(const char *file_name, char *resolved_name) +{ + char buffer[PATH_MAX]; + + if (resolved_name != NULL) + return (realpath_impl(file_name, resolved_name)); + + if (realpath_impl(file_name, buffer) != NULL) + return (strdup(buffer)); + + return (NULL); +} + +/* + * GNU extension. + */ +char * +canonicalize_file_name(const char *path) +{ + return (realpath(path, NULL)); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/stpcpy.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#include "lint.h" +#include <string.h> +#include <sys/types.h> + +/* + * Copy string s2 to s1. s1 must be large enough. + * return a pointer to the terminating null character of s1. + */ +char * +stpcpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2) +{ + (void) strcpy(s1, s2); + return (s1 + strlen(s1)); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/stpncpy.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#include "lint.h" +#include <string.h> +#include <sys/types.h> + +/* + * Copy s2 to s1, truncating or null-padding to always copy n bytes + * return a pointer to the terminating null byte in s1, or, + * if s1 is not null-terminated, s1 + n. + */ +char * +stpncpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n) +{ + size_t len = strnlen(s2, n); + + (void) strncpy(s1, s2, n); + + return ((len < n) ? s1 + len : s1 + n); +}
--- a/usr/src/lib/libc/port/gen/strcasecmp.c Thu Aug 12 14:07:03 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include "lint.h" -#include <sys/types.h> -#include <strings.h> - -/* - * This array is designed for mapping upper and lower case letter - * together for a case independent comparison. The mappings are - * based upon ascii character sequences. - */ - -extern const char strcase_charmap[]; - -int -strcasecmp(const char *s1, const char *s2) -{ - const unsigned char *cm = (const unsigned char *)strcase_charmap; - const unsigned char *us1 = (const unsigned char *)s1; - const unsigned char *us2 = (const unsigned char *)s2; - - while (cm[*us1] == cm[*us2++]) - if (*us1++ == '\0') - return (0); - return (cm[*us1] - cm[*(us2 - 1)]); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/strchrnul.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,37 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include <string.h> + +char * +strchrnul(const char *s, int c) +{ + char *ptr = strchr(s, c); + + if (ptr == NULL) + ptr = (char *)s + strlen(s); + + return (ptr); +}
--- a/usr/src/lib/libc/port/gen/strncasecmp.c Thu Aug 12 14:07:03 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include "lint.h" -#include <sys/types.h> -#include <strings.h> - -/* - * This array is designed for mapping upper and lower case letter - * together for a case independent comparison. The mappings are - * based upon ascii character sequences. - */ - -extern const char strcase_charmap[]; - -int -strncasecmp(const char *s1, const char *s2, size_t n) -{ - const unsigned char *cm = (const unsigned char *)strcase_charmap; - const unsigned char *us1 = (const unsigned char *)s1; - const unsigned char *us2 = (const unsigned char *)s2; - - while (n != 0 && cm[*us1] == cm[*us2++]) { - if (*us1++ == '\0') - return (0); - n--; - } - return (n == 0 ? 0 : cm[*us1] - cm[*(us2 - 1)]); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/strndup.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> +#include <stdlib.h> +#include <sys/types.h> + +/* + * Create a copy of string s, but only duplicate the first n bytes. + * Return NULL if the new string can't be allocated. + */ +char * +strndup(const char *s1, size_t n) +{ + char *s2; + + n = strnlen(s1, n); + if ((s2 = malloc(n + 1)) != NULL) + (void) strlcpy(s2, s1, n + 1); + return (s2); +}
--- a/usr/src/lib/libc/port/gen/strstr.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/gen/strstr.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <string.h> #include <stddef.h> @@ -37,9 +34,9 @@ /* * strstr() locates the first occurrence in the string as1 of * the sequence of characters (excluding the terminating null - * character) in the string as2. strstr() returns a pointer + * character) in the string as2. strstr() returns a pointer * to the located string, or a null pointer if the string is - * not found. If as2 is "", the function returns as1. + * not found. If as2 is empty, the function returns as1. */ char * @@ -54,19 +51,61 @@ if (s2 == NULL || *s2 == '\0') return ((char *)s1); + c = *s2; - - while (*s1) - if (*s1++ == c) { + while (*s1 != '\0') { + if (c == *s1++) { tptr = s1; - while ((c = *++s2) == *s1++ && c) - ; - if (c == 0) + while ((c = *++s2) == *s1++ && c != '\0') + continue; + if (c == '\0') return ((char *)tptr - 1); s1 = tptr; s2 = as2; c = *s2; } + } return (NULL); } + +/* + * strnstr() locates the first occurrence in the string as1 of + * the sequence of characters (excluding the terminating null + * character) in the string as2, where not more than n characters + * from the string as1 are searched. strnstr() returns a pointer + * to the located string, or a null pointer if the string is + * not found. If as2 is empty, the function returns as1. + */ + +char * +strnstr(const char *as1, const char *as2, size_t n) +{ + const char *s1, *s2; + const char *tptr; + size_t k; + char c; + + s1 = as1; + s2 = as2; + + if (s2 == NULL || *s2 == '\0') + return ((char *)s1); + + c = *s2; + while (*s1 != '\0' && n--) { + if (c == *s1++) { + k = n; + tptr = s1; + while ((c = *++s2) == *s1++ && c != '\0' && k--) + continue; + if (c == '\0') + return ((char *)tptr - 1); + s1 = tptr; + s2 = as2; + c = *s2; + } + } + + return (NULL); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/gen/tls_data.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,34 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> + +/* + * Thread-local variables. + * Needed by strdupa() and strndupa() macros when compiling with Studio C. + */ +__thread char *__strdupa_str; +__thread size_t __strdupa_len;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/i18n/strcasecmp.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#include "lint.h" +#include <sys/types.h> +#include <strings.h> +#include <ctype.h> + +int +strcasecmp(const char *s1, const char *s2) +{ + extern int charset_is_ascii; + extern int ascii_strcasecmp(const char *s1, const char *s2); + int *cm; + const uchar_t *us1; + const uchar_t *us2; + + /* + * If we are in a locale that uses the ASCII character set + * (C or POSIX), use the fast ascii_strcasecmp() function. + */ + if (charset_is_ascii) + return (ascii_strcasecmp(s1, s2)); + + cm = __trans_lower; + us1 = (const uchar_t *)s1; + us2 = (const uchar_t *)s2; + + while (cm[*us1] == cm[*us2++]) + if (*us1++ == '\0') + return (0); + return (cm[*us1] - cm[*(us2 - 1)]); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/i18n/strcasestr.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#include "lint.h" +#include <string.h> +#include <ctype.h> +#include <sys/types.h> + +/* + * strcasestr() locates the first occurrence in the string s1 of the + * sequence of characters (excluding the terminating null character) + * in the string s2, ignoring case. strcasestr() returns a pointer + * to the located string, or a null pointer if the string is not found. + * If s2 is empty, the function returns s1. + */ + +char * +strcasestr(const char *s1, const char *s2) +{ + int *cm = __trans_lower; + const uchar_t *us1 = (const uchar_t *)s1; + const uchar_t *us2 = (const uchar_t *)s2; + const uchar_t *tptr; + int c; + + if (us2 == NULL || *us2 == '\0') + return ((char *)us1); + + c = cm[*us2]; + while (*us1 != '\0') { + if (c == cm[*us1++]) { + tptr = us1; + while (cm[c = *++us2] == cm[*us1++] && c != '\0') + continue; + if (c == '\0') + return ((char *)tptr - 1); + us1 = tptr; + us2 = (const uchar_t *)s2; + c = cm[*us2]; + } + } + + return (NULL); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/i18n/strncasecmp.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#include "lint.h" +#include <sys/types.h> +#include <strings.h> +#include <ctype.h> + +int +strncasecmp(const char *s1, const char *s2, size_t n) +{ + extern int charset_is_ascii; + extern int ascii_strncasecmp(const char *s1, const char *s2, size_t n); + int *cm; + const uchar_t *us1; + const uchar_t *us2; + + /* + * If we are in a locale that uses the ASCII character set + * (C or POSIX), use the fast ascii_strncasecmp() function. + */ + if (charset_is_ascii) + return (ascii_strncasecmp(s1, s2, n)); + + cm = __trans_lower; + us1 = (const uchar_t *)s1; + us2 = (const uchar_t *)s2; + + while (n != 0 && cm[*us1] == cm[*us2++]) { + if (*us1++ == '\0') + return (0); + n--; + } + return (n == 0 ? 0 : cm[*us1] - cm[*(us2 - 1)]); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/i18n/wcsnlen.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Returns the number of non-NULL characters in str, + * but not more than maxlen. Does not look past str + maxlen. + */ + +#include "lint.h" +#include <stdlib.h> +#include <wchar.h> + +size_t +wcsnlen(const wchar_t *str, size_t maxlen) +{ + const wchar_t *ptr = str; + + if (maxlen != 0) { + do { + if (*ptr++ == L'\0') { + ptr--; + break; + } + } while (--maxlen != 0); + } + + return (ptr - str); +}
--- a/usr/src/lib/libc/port/i18n/wscasecmp.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/i18n/wscasecmp.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Compare strings ignoring case difference. * returns: s1>s2: >0 s1==s2: 0 s1<s2: <0 @@ -40,7 +37,7 @@ #include "libc.h" int -wscasecmp(const wchar_t *s1, const wchar_t *s2) +wcscasecmp(const wchar_t *s1, const wchar_t *s2) { if (s1 == s2) return (0); @@ -50,3 +47,9 @@ return (0); return (towlower(*s1) - towlower(*(s2 - 1))); } + +int +wscasecmp(const wchar_t *s1, const wchar_t *s2) +{ + return (wcscasecmp(s1, s2)); +}
--- a/usr/src/lib/libc/port/i18n/wscpy.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/i18n/wscpy.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,18 +20,18 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1986 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* - * Copy string s2 to s1. S1 must be large enough. + * wcscpy(): copy string s2 to s1. S1 must be large enough. * Return s1. + * + * wcpcpy(): copy string s2 to s1. S1 must be large enough. + * Return a pointer to the terminating null character of s1. */ #pragma weak _wcscpy = wcscpy @@ -47,7 +47,7 @@ wchar_t *os1 = s1; while (*s1++ = *s2++) - ; + continue; return (os1); } @@ -56,3 +56,11 @@ { return (wcscpy(s1, s2)); } + +wchar_t * +wcpcpy(wchar_t *s1, const wchar_t *s2) +{ + while (*s1++ = *s2++) + continue; + return (s1 - 1); +}
--- a/usr/src/lib/libc/port/i18n/wsdup.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/i18n/wsdup.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1986 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * string duplication * returns pointer to a new string which is the duplicate of string @@ -42,10 +39,16 @@ #include "libc.h" wchar_t * -wsdup(const wchar_t *s1) +wcsdup(const wchar_t *s1) { wchar_t *s2; s2 = malloc((wcslen(s1) + 1) * sizeof (wchar_t)); return (s2 == NULL ? NULL : wcscpy(s2, s1)); } + +wchar_t * +wsdup(const wchar_t *s1) +{ + return (wcsdup(s1)); +}
--- a/usr/src/lib/libc/port/i18n/wsncasecmp.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/i18n/wsncasecmp.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Compare strings ignoring case difference. * returns: s1>s2: >0 s1==s2: 0 s1<s2: <0 @@ -40,7 +37,7 @@ #include "libc.h" int -wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) +wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) { if (s1 == s2) return (0); @@ -51,3 +48,9 @@ return (0); return ((n == 0) ? 0 : (towlower(*s1) - towlower(*(s2 - 1)))); } + +int +wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) +{ + return (wcsncasecmp(s1, s2, n)); +}
--- a/usr/src/lib/libc/port/i18n/wsncpy.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/i18n/wsncpy.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,20 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1986 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Copy s2 to s1, truncating or null-padding to always copy n characters. - * Return s1. - */ - #pragma weak _wcsncpy = wcsncpy #pragma weak _wsncpy = wsncpy @@ -41,14 +33,18 @@ #include <stdlib.h> #include <wchar.h> +/* + * Copy s2 to s1, truncating or null-padding to always copy n + * wide-character codes. Return s1. + */ wchar_t * wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n) { wchar_t *os1 = s1; n++; - while ((--n > 0) && ((*s1++ = *s2++) != 0)) - ; + while (--n > 0 && (*s1++ = *s2++) != 0) + continue; if (n > 0) while (--n > 0) *s1++ = 0; @@ -60,3 +56,26 @@ { return (wcsncpy(s1, s2, n)); } + +/* + * Same as wcsncpy(), except return a pointer to the terminating null + * wide-character code in s1, or, if s1 is not null-terminated, s1 + n. + */ +wchar_t * +wcpncpy(wchar_t *s1, const wchar_t *s2, size_t n) +{ + wchar_t *os1 = s1; + + n++; + while (--n != 0) { + if ((*s1++ = *s2++) == 0) { + os1 = s1 - 1; + break; + } + os1 = s1; + } + if (n != 0) + while (--n != 0) + *s1++ = 0; + return (os1); +}
--- a/usr/src/lib/libc/port/llib-lc Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/llib-lc Thu Aug 12 14:55:22 2010 -0700 @@ -20,13 +20,14 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* LINTLIBRARY */ /* PROTOLIB1 */ +#define __EXTENSIONS__ + #include <aio.h> #include <alloca.h> #include <attr.h> @@ -58,6 +59,7 @@ #include <ndbm.h> #include <limits.h> #include <nl_types.h> +#include <poll.h> #include <project.h> #include <priv.h> #include <pwd.h> @@ -103,7 +105,6 @@ #include <sys/mount.h> #include <sys/msg.h> #include <sys/param.h> -#include <sys/poll.h> #include <sys/priocntl.h> #include <sys/procset.h> #include <sys/processor.h> @@ -167,6 +168,12 @@ char **environ; /* + * This is a GNU/Linux/BSD compatibility interface, + * not declared in any header file. + */ +const char *__progname; + +/* * POSIX versions of standard libc routines; these aren't extracted * from the headers above since we cannot #define _POSIX_C_SOURCE. */
--- a/usr/src/lib/libc/port/mapfile-vers Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/mapfile-vers Thu Aug 12 14:55:22 2010 -0700 @@ -124,6 +124,8 @@ backtrace; backtrace_symbols; backtrace_symbols_fd; + canonicalize_file_name; + clearenv; clock_getres; clock_gettime; clock_nanosleep; @@ -147,17 +149,29 @@ errx; faccessat; fchmodat; + fcloseall; fdatasync; + ffsl; + ffsll; fgetattr; + fls; + flsl; + flsll; forkallx; forkx; fsetattr; getattrat; + getdelim; + getline; + get_nprocs; + get_nprocs_conf; + getprogname; htonl; htonll; htons; linkat; lio_listio; + memmem; mkdirat; mkdtemp; mkfifoat; @@ -187,6 +201,7 @@ posix_spawn_file_actions_addclosefrom_np; posix_spawnattr_getsigignore_np; posix_spawnattr_setsigignore_np; + ppoll; priv_basicset; pthread_key_create_once_np; pthread_mutexattr_getrobust; @@ -213,6 +228,7 @@ sem_unlink; sem_wait; setattrat; + setprogname; _sharefs; shm_open; shm_unlink; @@ -220,7 +236,13 @@ sigtimedwait; sigwaitinfo; smt_pause; + stpcpy; + stpncpy; + strcasestr; + strchrnul; + strndup; strnlen; + strnstr; strsep; symlinkat; thr_keycreate_once; @@ -245,6 +267,12 @@ vwarnx; warn; warnx; + wcpcpy; + wcpncpy; + wcscasecmp; + wcsdup; + wcsncasecmp; + wcsnlen; $if lf64 aio_cancel64; @@ -2531,8 +2559,11 @@ __nis_preftype; __nis_server; _nss_default_finders; + __progname { FLAGS = NODIRECT }; _smbuf; _sp; + __strdupa_str { FLAGS = NODIRECT }; + __strdupa_len { FLAGS = NODIRECT }; _tdb_bootstrap; __threaded; thr_probe_getfunc_addr;
--- a/usr/src/lib/libc/port/stdio/flush.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/stdio/flush.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include "mtlib.h" #include "file64.h" @@ -723,6 +720,55 @@ return (res); } +/* close all open streams */ +int +fcloseall(void) +{ + FPDECL(iop); + + struct _link_ *lp; + rmutex_t *lk; + + if (__libc_threaded) + cancel_safe_mutex_lock(&_first_link_lock); + + lp = &__first_link; + + do { + int i; + + FIRSTFP(lp, iop); + for (i = lp->niob; --i >= 0; NEXTFP(iop)) { + /* code stolen from fclose(), above */ + + FLOCKFILE(lk, iop); + if (iop->_flag == 0) { + FUNLOCKFILE(lk); + continue; + } + + /* Not unbuffered and opened for read and/or write? */ + if (!(iop->_flag & _IONBF) && + (iop->_flag & (_IOWRT | _IOREAD | _IORW))) + (void) _fflush_u(iop); + (void) close(GET_FD(iop)); + if (iop->_flag & _IOMYBUF) + free((char *)iop->_base - PUSHBACK); + iop->_base = NULL; + iop->_ptr = NULL; + iop->_cnt = 0; + iop->_flag = 0; /* marks it as available */ + FUNLOCKFILE(lk); + fcloses++; + } + } while ((lp = lp->next) != NULL); + + if (__libc_threaded) + cancel_safe_mutex_unlock(&_first_link_lock); + + return (0); +} + /* flush buffer, close fd but keep the stream used by freopen() */ int close_fd(FILE *iop)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/port/stdio/getline.c Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include "file64.h" +#include "mtlib.h" +#include <stdio.h> +#include <errno.h> +#include <thread.h> +#include <synch.h> +#include <unistd.h> +#include <limits.h> +#include <malloc.h> +#include <sys/types.h> +#include "stdiom.h" + +#define LINESZ 128 /* initial guess for a NULL *lineptr */ + +ssize_t +getdelim(char **_RESTRICT_KYWD lineptr, size_t *_RESTRICT_KYWD n, + int delimiter, FILE *_RESTRICT_KYWD iop) +{ + rmutex_t *lk; + char *ptr; + size_t size; + int c; + size_t cnt; + + if (lineptr == NULL || n == NULL || + delimiter < 0 || delimiter > UCHAR_MAX) { + errno = EINVAL; + return (-1); + } + + if (*lineptr == NULL || *n < LINESZ) { /* initial allocation */ + if ((*lineptr = realloc(*lineptr, LINESZ)) == NULL) { + errno = ENOMEM; + return (-1); + } + *n = LINESZ; + } + ptr = *lineptr; + size = *n; + cnt = 0; + + FLOCKFILE(lk, iop); + + _SET_ORIENTATION_BYTE(iop); + + do { + c = (--iop->_cnt < 0) ? __filbuf(iop) : *iop->_ptr++; + if (c == EOF) + break; + *ptr++ = c; + if (++cnt == size) { /* must reallocate */ + if ((ptr = realloc(*lineptr, 2 * size)) == NULL) { + FUNLOCKFILE(lk); + ptr = *lineptr + size - 1; + *ptr = '\0'; + errno = ENOMEM; + return (-1); + } + *lineptr = ptr; + ptr += size; + *n = size = 2 * size; + } + } while (c != delimiter); + + *ptr = '\0'; + + FUNLOCKFILE(lk); + if (cnt > SSIZE_MAX) { + errno = EOVERFLOW; + return (-1); + } + return (cnt ? cnt : -1); +} + +ssize_t +getline(char **_RESTRICT_KYWD lineptr, size_t *_RESTRICT_KYWD n, + FILE *_RESTRICT_KYWD iop) +{ + return (getdelim(lineptr, n, '\n', iop)); +}
--- a/usr/src/lib/libc/port/threads/alloc.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/threads/alloc.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include "thr_uberdata.h" #include <sys/syscall.h> @@ -148,10 +145,14 @@ ASSERT(((caddr_t)ptr - (caddr_t)base + 4 * SUBCHUNKSIZE) == BASE_SIZE); } +/* + * This highbit code is the same as the code in fls_impl(). + * We inline it here for speed. + */ static int getbucketnum(size_t size) { - int highbit = 0; + int highbit = 1; if (size-- <= MINSIZE) return (0); @@ -171,8 +172,8 @@ if (size & 0x2) highbit += 1; - ASSERT(highbit >= MINSHIFT); - return (highbit - (MINSHIFT - 1)); + ASSERT(highbit > MINSHIFT); + return (highbit - MINSHIFT); } void *
--- a/usr/src/lib/libc/port/threads/thr.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/port/threads/thr.c Thu Aug 12 14:55:22 2010 -0700 @@ -132,6 +132,7 @@ NULL, /* atforklist */ NULL, /* robustlocks */ NULL, /* robustlist */ + NULL, /* progname */ NULL, /* __tdb_bootstrap */ { /* tdb */ NULL, /* tdb_sync_addr_hash */ @@ -1259,6 +1260,7 @@ __tdb_bootstrap = oldself->ul_uberdata->tdb_bootstrap; mutex_setup(); atfork_init(); /* every link map needs atfork() processing */ + init_progname(); return; } @@ -1458,9 +1460,11 @@ /* * When we have initialized the primary link map, inform * the dynamic linker about our interface functions. + * Set up our pointer to the program name. */ if (self->ul_primarymap) _ld_libc((void *)rtld_funcs); + init_progname(); /* * Defer signals until TLS constructors have been called.
--- a/usr/src/lib/libc/sparc/Makefile.com Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/sparc/Makefile.com Thu Aug 12 14:55:22 2010 -0700 @@ -101,7 +101,9 @@ fpgetsticky.o \ fpsetmask.o \ fpsetrnd.o \ - fpsetsticky.o \ + fpsetsticky.o + +$(__GNUC)FPASMOBJS += \ __quad.o ATOMICOBJS= \ @@ -115,7 +117,6 @@ bcopy.o \ bzero.o \ bsearch.o \ - ffs.o \ memccpy.o \ qsort.o \ strtol.o \ @@ -131,6 +132,7 @@ _xregs_clrptr.o \ abs.o \ alloca.o \ + ascii_strcasecmp.o \ byteorder.o \ cuexit.o \ ecvt.o \ @@ -151,7 +153,6 @@ siglongjmp.o \ smt_pause.o \ sparc_data.o \ - strcasecmp.o \ strchr.o \ strcmp.o \ strlcpy.o \ @@ -384,6 +385,7 @@ a64l.o \ abort.o \ addsev.o \ + ascii_strncasecmp.o \ assert.o \ atof.o \ atoi.o \ @@ -427,6 +429,8 @@ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -448,6 +452,7 @@ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -496,6 +501,7 @@ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -560,15 +566,18 @@ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ strcat.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ + strlcat.o \ strncat.o \ - strlcat.o \ - strncasecmp.o \ + strndup.o \ strpbrk.o \ strrchr.o \ strsep.o \ @@ -598,6 +607,7 @@ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -686,6 +696,7 @@ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -718,7 +729,11 @@ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcstoimax.o \ wcstol.o \ wcstoul.o \ @@ -1022,8 +1037,10 @@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -1087,6 +1104,7 @@ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ getctxt.o \ lwp.o \ @@ -1120,6 +1138,9 @@ $(TIL:%=pics/%) := CFLAGS += $(LIBCBASE)/threads/sparc.il +# This hack is needed until the sparc gcc is fixed for TLS +pics/tls_data.o := CC = env 'CW_NO_SHADOW=1' $(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc + # special kludge for inlines with 'cas': pics/rwlock.o pics/synch.o pics/lwp.o pics/door_calls.o := \ sparc_CFLAGS += -_gcc=-Wa,-xarch=v8plus
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/sparc/gen/ascii_strcasecmp.s Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,347 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * The ascii_strcasecmp() function is a case insensitive versions of strcmp(). + * It assumes the ASCII character set and ignores differences in case + * when comparing lower and upper case characters. In other words, it + * behaves as if both strings had been converted to lower case using + * tolower() in the "C" locale on each byte, and the results had then + * been compared using strcmp(). + * + * The assembly code below is an optimized version of the following C + * reference: + * + * static const char charmap[] = { + * '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + * '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + * '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + * '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + * '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + * '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + * '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + * '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + * '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + * '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + * '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + * '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + * '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + * '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + * '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + * '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + * '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + * '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + * '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + * '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + * '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', + * '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', + * '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', + * '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', + * '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + * '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + * '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + * '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', + * }; + * + * int + * ascii_strcasecmp(const char *s1, const char *s2) + * { + * const unsigned char *cm = (const unsigned char *)charmap; + * const unsigned char *us1 = (const unsigned char *)s1; + * const unsigned char *us2 = (const unsigned char *)s2; + * + * while (cm[*us1] == cm[*us2++]) + * if (*us1++ == '\0') + * return (0); + * return (cm[*us1] - cm[*(us2 - 1)]); + * } + * + * The following algorithm, from a 1987 news posting by Alan Mycroft, is + * used for finding null bytes in a word: + * + * #define has_null(word) ((word - 0x01010101) & (~word & 0x80808080)) + * + * The following algorithm is used for a wordwise tolower() operation: + * + * unsigned int + * parallel_tolower (unsigned int x) + * { + * unsigned int p; + * unsigned int q; + * + * unsigned int m1 = 0x80808080; + * unsigned int m2 = 0x3f3f3f3f; + * unsigned int m3 = 0x25252525; + * + * q = x & ~m1;// newb = byte & 0x7F + * p = q + m2; // newb > 0x5A --> MSB set + * q = q + m3; // newb < 0x41 --> MSB clear + * p = p & ~q; // newb > 0x40 && newb < 0x5B --> MSB set + * q = m1 & ~x;// byte < 0x80 --> 0x80 + * q = p & q; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x80,else 0 + * q = q >> 2; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x20,else 0 + * return (x + q); // translate uppercase characters to lowercase + * } + * + * Both algorithms have been tested exhaustively for all possible 2^32 inputs. + */ + +#include <sys/asm_linkage.h> + + ! The first part of this algorithm walks through the beginning of + ! both strings a byte at a time until the source ptr is aligned to + ! a word boundary. During these steps, the bytes are translated to + ! lower-case if they are upper-case, and are checked against + ! the source string. + + ENTRY(ascii_strcasecmp) + + .align 32 + + save %sp, -SA(WINDOWSIZE), %sp + subcc %i0, %i1, %i2 ! s1 == s2 ? + bz .stringsequal ! yup, done, strings equal + andcc %i0, 3, %i3 ! s1 word-aligned ? + bz .s1aligned1 ! yup + sethi %hi(0x80808080), %i4 ! start loading Mycroft's magic1 + + ldub [%i1 + %i2], %i0 ! s1[0] + ldub [%i1], %g1 ! s2[0] + sub %i0, 'A', %l0 ! transform for faster uppercase check + sub %g1, 'A', %l1 ! transform for faster uppercase check + cmp %l0, ('Z' - 'A') ! s1[0] uppercase? + bleu,a .noxlate11 ! yes + add %i0, ('a' - 'A'), %i0 ! s1[0] = tolower(s1[0]) +.noxlate11: + cmp %l1, ('Z' - 'A') ! s2[0] uppercase? + bleu,a .noxlate12 ! yes + add %g1, ('a' - 'A'), %g1 ! s2[0] = tolower(s2[0]) +.noxlate12: + subcc %i0, %g1, %i0 ! tolower(s1[0]) != tolower(s2[0]) ? + bne .done ! yup, done + inc %i1 ! s1++, s2++ + addcc %i0, %g1, %i0 ! s1[0] == 0 ? + bz .done ! yup, done, strings equal + cmp %i3, 3 ! s1 aligned now? + bz .s1aligned2 ! yup + sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 + + ldub [%i1 + %i2], %i0 ! s1[1] + ldub [%i1], %g1 ! s2[1] + sub %i0, 'A', %l0 ! transform for faster uppercase check + sub %g1, 'A', %l1 ! transform for faster uppercase check + cmp %l0, ('Z' - 'A') ! s1[1] uppercase? + bleu,a .noxlate21 ! yes + add %i0, ('a' - 'A'), %i0 ! s1[1] = tolower(s1[1]) +.noxlate21: + cmp %l1, ('Z' - 'A') ! s2[1] uppercase? + bleu,a .noxlate22 ! yes + add %g1, ('a' - 'A'), %g1 ! s2[1] = tolower(s2[1]) +.noxlate22: + subcc %i0, %g1, %i0 ! tolower(s1[1]) != tolower(s2[1]) ? + bne .done ! yup, done + inc %i1 ! s1++, s2++ + addcc %i0, %g1, %i0 ! s1[1] == 0 ? + bz .done ! yup, done, strings equal + cmp %i3, 2 ! s1 aligned now? + bz .s1aligned3 ! yup + or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 + + ldub [%i1 + %i2], %i0 ! s1[2] + ldub [%i1], %g1 ! s2[2] + sub %i0, 'A', %l0 ! transform for faster uppercase check + sub %g1, 'A', %l1 ! transform for faster uppercase check + cmp %l0, ('Z' - 'A') ! s1[2] uppercase? + bleu,a .noxlate31 ! yes + add %i0, ('a' - 'A'), %i0 ! s1[2] = tolower(s1[2]) +.noxlate31: + cmp %l1, ('Z' - 'A') ! s2[2] uppercase? + bleu,a .noxlate32 ! yes + add %g1, ('a' - 'A'), %g1 ! s2[2] = tolower(s2[2]) +.noxlate32: + subcc %i0, %g1, %i0 ! tolower(s1[2]) != tolower(s2[2]) ? + bne .done ! yup, done + inc %i1 ! s1++, s2++ + addcc %i0, %g1, %i0 ! s1[2] == 0 ? + bz .done ! yup, done, strings equal + or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 + ba .s1aligned4 ! s1 aligned now + andcc %i1, 3, %i3 ! s2 word-aligned ? + + ! Here, we initialize our checks for a zero byte and decide + ! whether or not we can optimize further if we're fortunate + ! enough to have a word aligned desintation + +.s1aligned1: + sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 +.s1aligned2: + or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 +.s1aligned3: + or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 + andcc %i1, 3, %i3 ! s2 word aligned ? +.s1aligned4: + sethi %hi(0x3f3f3f3f), %l2 ! load m2 for parallel tolower() + sethi %hi(0x25252525), %l3 ! load m3 for parallel tolower() + or %l2, %lo(0x3f3f3f3f),%l2! finish loading m2 + bz .word4 ! yup, s2 word-aligned + or %l3, %lo(0x25252525),%l3! finish loading m3 + + add %i2, %i3, %i2 ! start adjusting offset s1-s2 + sll %i3, 3, %l6 ! shift factor for left shifts + andn %i1, 3, %i1 ! round s1 pointer down to next word + sub %g0, %l6, %l7 ! shift factor for right shifts + orn %i3, %g0, %i3 ! generate all ones + lduw [%i1], %i0 ! new lower word from s2 + srl %i3, %l6, %i3 ! mask for fixing up bytes + sll %i0, %l6, %g1 ! partial unaligned word from s2 + orn %i0, %i3, %i0 ! force start bytes to non-zero + nop ! pad to align loop to 16-byte boundary + nop ! pad to align loop to 16-byte boundary + + ! This is the comparision procedure used if the destination is not + ! word aligned, if it is, we use word4 & cmp4 + +.cmp: + andn %i4, %i0, %l4 ! ~word & 0x80808080 + sub %i0, %i5, %l5 ! word - 0x01010101 + andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 + bz,a .doload ! null byte in previous aligned s2 word + lduw [%i1 + 4], %i0 ! load next aligned word from s2 +.doload: + srl %i0, %l7, %i3 ! byte(s) from new aligned word from s2 + or %g1, %i3, %g1 ! merge to get unaligned word from s2 + lduw [%i1 + %i2], %i3 ! x1 = word from s1 + andn %i3, %i4, %l0 ! q1 = x1 & ~m1 + andn %g1, %i4, %l4 ! q2 = x2 & ~m1 + add %l0, %l2, %l1 ! p1 = q1 + m2 + add %l4, %l2, %l5 ! p2 = q2 + m2 + add %l0, %l3, %l0 ! q1 = q1 + m3 + add %l4, %l3, %l4 ! q2 = q2 + m3 + andn %l1, %l0, %l1 ! p1 = p1 & ~q1 + andn %l5, %l4, %l5 ! p2 = p2 & ~q2 + andn %i4, %i3, %l0 ! q1 = m1 & ~x1 + andn %i4, %g1, %l4 ! q2 = m1 & ~x2 + and %l0, %l1, %l0 ! q1 = p1 & q1 + and %l4, %l5, %l4 ! q2 = p2 & q2 + srl %l0, 2, %l0 ! q1 = q1 >> 2 + srl %l4, 2, %l4 ! q2 = q2 >> 2 + add %l0, %i3, %i3 ! lowercase word from s1 + add %l4, %g1, %g1 ! lowercase word from s2 + cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? + bne .wordsdiffer ! yup, now find byte that is different + add %i1, 4, %i1 ! s1+=4, s2+=4 + andn %i4, %i3, %l4 ! ~word & 0x80808080 + sub %i3, %i5, %l5 ! word - 0x01010101 + andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 + bz .cmp ! no null-byte in s1 yet + sll %i0, %l6, %g1 ! bytes from old aligned word from s2 + + ! words are equal but the end of s1 has been reached + ! this means the strings must be equal +.stringsequal: + ret ! return + restore %g0, %g0, %o0 ! return 0, i.e. strings are equal + nop ! pad + + ! we have a word aligned source and destination! This means + ! things get to go fast! + +.word4: + lduw [%i1 + %i2], %i3 ! x1 = word from s1 + +.cmp4: + andn %i3, %i4, %l0 ! q1 = x1 & ~m1 + lduw [%i1], %g1 ! x2 = word from s2 + andn %g1, %i4, %l4 ! q2 = x2 & ~m1 + add %l0, %l2, %l1 ! p1 = q1 + m2 + add %l4, %l2, %l5 ! p2 = q2 + m2 + add %l0, %l3, %l0 ! q1 = q1 + m3 + add %l4, %l3, %l4 ! q2 = q2 + m3 + andn %l1, %l0, %l1 ! p1 = p1 & ~q1 + andn %l5, %l4, %l5 ! p2 = p2 & ~q2 + andn %i4, %i3, %l0 ! q1 = m1 & ~x1 + andn %i4, %g1, %l4 ! q2 = m1 & ~x2 + and %l0, %l1, %l0 ! q1 = p1 & q1 + and %l4, %l5, %l4 ! q2 = p2 & q2 + srl %l0, 2, %l0 ! q1 = q1 >> 2 + srl %l4, 2, %l4 ! q2 = q2 >> 2 + add %l0, %i3, %i3 ! lowercase word from s1 + add %l4, %g1, %g1 ! lowercase word from s2 + cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? + bne .wordsdiffer ! yup, now find mismatching character + add %i1, 4, %i1 ! s1+=4, s2+=4 + andn %i4, %i3, %l4 ! ~word & 0x80808080 + sub %i3, %i5, %l5 ! word - 0x01010101 + andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 + bz,a .cmp4 ! no null-byte in s1 yet + lduw [%i1 + %i2], %i3 ! load word from s1 + + ! words are equal but the end of s1 has been reached + ! this means the strings must be equal +.stringsequal4: + ret ! return + restore %g0, %g0, %o0 ! return 0, i.e. strings are equal + +.wordsdiffer: + srl %g1, 24, %i2 ! first byte of mismatching word in s2 + srl %i3, 24, %i1 ! first byte of mismatching word in s1 + subcc %i1, %i2, %i0 ! *s1-*s2 + bnz .done ! bytes differ, return difference + srl %g1, 16, %i2 ! second byte of mismatching word in s2 + andcc %i1, 0xff, %i0 ! *s1 == 0 ? + bz .done ! yup, done, strings equal + + ! we know byte 1 is equal, so can compare bytes 1,2 as a group + + srl %i3, 16, %i1 ! second byte of mismatching word in s1 + subcc %i1, %i2, %i0 ! *s1-*s2 + bnz .done ! bytes differ, return difference + srl %g1, 8, %i2 ! third byte of mismatching word in s2 + andcc %i1, 0xff, %i0 ! *s1 == 0 ? + bz .done ! yup, done, strings equal + + ! we know bytes 1, 2 are equal, so can compare bytes 1,2,3 as a group + + srl %i3, 8, %i1 ! third byte of mismatching word in s1 + subcc %i1, %i2, %i0 ! *s1-*s2 + bnz .done ! bytes differ, return difference + andcc %i1, 0xff, %g0 ! *s1 == 0 ? + bz .stringsequal ! yup, done, strings equal + + ! we know bytes 1,2,3 are equal, so can compare bytes 1,2,3,4 as group + + subcc %i3, %g1, %i0 ! *s1-*s2 + bz,a .done ! bytes differ, return difference + andcc %i3, 0xff, %i0 ! *s1 == 0, strings equal + +.done: + ret ! return + restore %i0, %g0, %o0 ! return 0 or byte difference + + SET_SIZE(ascii_strcasecmp)
--- a/usr/src/lib/libc/sparc/gen/strcasecmp.s Thu Aug 12 14:07:03 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,349 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "strcasecmp.s" -/* - * The strcasecmp() function is a case insensitive versions of strcmp(). - * It assumes the ASCII character set and ignores differences in case - * when comparing lower and upper case characters. In other words, it - * behaves as if both strings had been converted to lower case using - * tolower() in the "C" locale on each byte, and the results had then - * been compared using strcmp(). - * - * The assembly code below is an optimized version of the following C - * reference: - * - * static const char charmap[] = { - * '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', - * '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', - * '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', - * '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', - * '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', - * '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', - * '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', - * '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', - * '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - * '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', - * '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - * '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', - * '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', - * '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', - * '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', - * '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', - * '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', - * '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', - * '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', - * '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', - * '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', - * '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', - * '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', - * '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', - * '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - * '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - * '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - * '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', - * }; - * - * int - * strcasecmp(const char *s1, const char *s2) - * { - * const unsigned char *cm = (const unsigned char *)charmap; - * const unsigned char *us1 = (const unsigned char *)s1; - * const unsigned char *us2 = (const unsigned char *)s2; - * - * while (cm[*us1] == cm[*us2++]) - * if (*us1++ == '\0') - * return (0); - * return (cm[*us1] - cm[*(us2 - 1)]); - * } - * - * The following algorithm, from a 1987 news posting by Alan Mycroft, is - * used for finding null bytes in a word: - * - * #define has_null(word) ((word - 0x01010101) & (~word & 0x80808080)) - * - * The following algorithm is used for a wordwise tolower() operation: - * - * unsigned int - * parallel_tolower (unsigned int x) - * { - * unsigned int p; - * unsigned int q; - * - * unsigned int m1 = 0x80808080; - * unsigned int m2 = 0x3f3f3f3f; - * unsigned int m3 = 0x25252525; - * - * q = x & ~m1;// newb = byte & 0x7F - * p = q + m2; // newb > 0x5A --> MSB set - * q = q + m3; // newb < 0x41 --> MSB clear - * p = p & ~q; // newb > 0x40 && newb < 0x5B --> MSB set - * q = m1 & ~x;// byte < 0x80 --> 0x80 - * q = p & q; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x80,else 0 - * q = q >> 2; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x20,else 0 - * return (x + q); // translate uppercase characters to lowercase - * } - * - * Both algorithms have been tested exhaustively for all possible 2^32 inputs. - */ - -#include <sys/asm_linkage.h> - - ! The first part of this algorithm walks through the beginning of - ! both strings a byte at a time until the source ptr is aligned to - ! a word boundary. During these steps, the bytes are translated to - ! lower-case if they are upper-case, and are checked against - ! the source string. - - ENTRY(strcasecmp) - - .align 32 - - save %sp, -SA(WINDOWSIZE), %sp - subcc %i0, %i1, %i2 ! s1 == s2 ? - bz .stringsequal ! yup, done, strings equal - andcc %i0, 3, %i3 ! s1 word-aligned ? - bz .s1aligned1 ! yup - sethi %hi(0x80808080), %i4 ! start loading Mycroft's magic1 - - ldub [%i1 + %i2], %i0 ! s1[0] - ldub [%i1], %g1 ! s2[0] - sub %i0, 'A', %l0 ! transform for faster uppercase check - sub %g1, 'A', %l1 ! transform for faster uppercase check - cmp %l0, ('Z' - 'A') ! s1[0] uppercase? - bleu,a .noxlate11 ! yes - add %i0, ('a' - 'A'), %i0 ! s1[0] = tolower(s1[0]) -.noxlate11: - cmp %l1, ('Z' - 'A') ! s2[0] uppercase? - bleu,a .noxlate12 ! yes - add %g1, ('a' - 'A'), %g1 ! s2[0] = tolower(s2[0]) -.noxlate12: - subcc %i0, %g1, %i0 ! tolower(s1[0]) != tolower(s2[0]) ? - bne .done ! yup, done - inc %i1 ! s1++, s2++ - addcc %i0, %g1, %i0 ! s1[0] == 0 ? - bz .done ! yup, done, strings equal - cmp %i3, 3 ! s1 aligned now? - bz .s1aligned2 ! yup - sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 - - ldub [%i1 + %i2], %i0 ! s1[1] - ldub [%i1], %g1 ! s2[1] - sub %i0, 'A', %l0 ! transform for faster uppercase check - sub %g1, 'A', %l1 ! transform for faster uppercase check - cmp %l0, ('Z' - 'A') ! s1[1] uppercase? - bleu,a .noxlate21 ! yes - add %i0, ('a' - 'A'), %i0 ! s1[1] = tolower(s1[1]) -.noxlate21: - cmp %l1, ('Z' - 'A') ! s2[1] uppercase? - bleu,a .noxlate22 ! yes - add %g1, ('a' - 'A'), %g1 ! s2[1] = tolower(s2[1]) -.noxlate22: - subcc %i0, %g1, %i0 ! tolower(s1[1]) != tolower(s2[1]) ? - bne .done ! yup, done - inc %i1 ! s1++, s2++ - addcc %i0, %g1, %i0 ! s1[1] == 0 ? - bz .done ! yup, done, strings equal - cmp %i3, 2 ! s1 aligned now? - bz .s1aligned3 ! yup - or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 - - ldub [%i1 + %i2], %i0 ! s1[2] - ldub [%i1], %g1 ! s2[2] - sub %i0, 'A', %l0 ! transform for faster uppercase check - sub %g1, 'A', %l1 ! transform for faster uppercase check - cmp %l0, ('Z' - 'A') ! s1[2] uppercase? - bleu,a .noxlate31 ! yes - add %i0, ('a' - 'A'), %i0 ! s1[2] = tolower(s1[2]) -.noxlate31: - cmp %l1, ('Z' - 'A') ! s2[2] uppercase? - bleu,a .noxlate32 ! yes - add %g1, ('a' - 'A'), %g1 ! s2[2] = tolower(s2[2]) -.noxlate32: - subcc %i0, %g1, %i0 ! tolower(s1[2]) != tolower(s2[2]) ? - bne .done ! yup, done - inc %i1 ! s1++, s2++ - addcc %i0, %g1, %i0 ! s1[2] == 0 ? - bz .done ! yup, done, strings equal - or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 - ba .s1aligned4 ! s1 aligned now - andcc %i1, 3, %i3 ! s2 word-aligned ? - - ! Here, we initialize our checks for a zero byte and decide - ! whether or not we can optimize further if we're fortunate - ! enough to have a word aligned desintation - -.s1aligned1: - sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 -.s1aligned2: - or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 -.s1aligned3: - or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 - andcc %i1, 3, %i3 ! s2 word aligned ? -.s1aligned4: - sethi %hi(0x3f3f3f3f), %l2 ! load m2 for parallel tolower() - sethi %hi(0x25252525), %l3 ! load m3 for parallel tolower() - or %l2, %lo(0x3f3f3f3f),%l2! finish loading m2 - bz .word4 ! yup, s2 word-aligned - or %l3, %lo(0x25252525),%l3! finish loading m3 - - add %i2, %i3, %i2 ! start adjusting offset s1-s2 - sll %i3, 3, %l6 ! shift factor for left shifts - andn %i1, 3, %i1 ! round s1 pointer down to next word - sub %g0, %l6, %l7 ! shift factor for right shifts - orn %i3, %g0, %i3 ! generate all ones - lduw [%i1], %i0 ! new lower word from s2 - srl %i3, %l6, %i3 ! mask for fixing up bytes - sll %i0, %l6, %g1 ! partial unaligned word from s2 - orn %i0, %i3, %i0 ! force start bytes to non-zero - nop ! pad to align loop to 16-byte boundary - nop ! pad to align loop to 16-byte boundary - - ! This is the comparision procedure used if the destination is not - ! word aligned, if it is, we use word4 & cmp4 - -.cmp: - andn %i4, %i0, %l4 ! ~word & 0x80808080 - sub %i0, %i5, %l5 ! word - 0x01010101 - andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 - bz,a .doload ! null byte in previous aligned s2 word - lduw [%i1 + 4], %i0 ! load next aligned word from s2 -.doload: - srl %i0, %l7, %i3 ! byte(s) from new aligned word from s2 - or %g1, %i3, %g1 ! merge to get unaligned word from s2 - lduw [%i1 + %i2], %i3 ! x1 = word from s1 - andn %i3, %i4, %l0 ! q1 = x1 & ~m1 - andn %g1, %i4, %l4 ! q2 = x2 & ~m1 - add %l0, %l2, %l1 ! p1 = q1 + m2 - add %l4, %l2, %l5 ! p2 = q2 + m2 - add %l0, %l3, %l0 ! q1 = q1 + m3 - add %l4, %l3, %l4 ! q2 = q2 + m3 - andn %l1, %l0, %l1 ! p1 = p1 & ~q1 - andn %l5, %l4, %l5 ! p2 = p2 & ~q2 - andn %i4, %i3, %l0 ! q1 = m1 & ~x1 - andn %i4, %g1, %l4 ! q2 = m1 & ~x2 - and %l0, %l1, %l0 ! q1 = p1 & q1 - and %l4, %l5, %l4 ! q2 = p2 & q2 - srl %l0, 2, %l0 ! q1 = q1 >> 2 - srl %l4, 2, %l4 ! q2 = q2 >> 2 - add %l0, %i3, %i3 ! lowercase word from s1 - add %l4, %g1, %g1 ! lowercase word from s2 - cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? - bne .wordsdiffer ! yup, now find byte that is different - add %i1, 4, %i1 ! s1+=4, s2+=4 - andn %i4, %i3, %l4 ! ~word & 0x80808080 - sub %i3, %i5, %l5 ! word - 0x01010101 - andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 - bz .cmp ! no null-byte in s1 yet - sll %i0, %l6, %g1 ! bytes from old aligned word from s2 - - ! words are equal but the end of s1 has been reached - ! this means the strings must be equal -.stringsequal: - ret ! return - restore %g0, %g0, %o0 ! return 0, i.e. strings are equal - nop ! pad - - ! we have a word aligned source and destination! This means - ! things get to go fast! - -.word4: - lduw [%i1 + %i2], %i3 ! x1 = word from s1 - -.cmp4: - andn %i3, %i4, %l0 ! q1 = x1 & ~m1 - lduw [%i1], %g1 ! x2 = word from s2 - andn %g1, %i4, %l4 ! q2 = x2 & ~m1 - add %l0, %l2, %l1 ! p1 = q1 + m2 - add %l4, %l2, %l5 ! p2 = q2 + m2 - add %l0, %l3, %l0 ! q1 = q1 + m3 - add %l4, %l3, %l4 ! q2 = q2 + m3 - andn %l1, %l0, %l1 ! p1 = p1 & ~q1 - andn %l5, %l4, %l5 ! p2 = p2 & ~q2 - andn %i4, %i3, %l0 ! q1 = m1 & ~x1 - andn %i4, %g1, %l4 ! q2 = m1 & ~x2 - and %l0, %l1, %l0 ! q1 = p1 & q1 - and %l4, %l5, %l4 ! q2 = p2 & q2 - srl %l0, 2, %l0 ! q1 = q1 >> 2 - srl %l4, 2, %l4 ! q2 = q2 >> 2 - add %l0, %i3, %i3 ! lowercase word from s1 - add %l4, %g1, %g1 ! lowercase word from s2 - cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? - bne .wordsdiffer ! yup, now find mismatching character - add %i1, 4, %i1 ! s1+=4, s2+=4 - andn %i4, %i3, %l4 ! ~word & 0x80808080 - sub %i3, %i5, %l5 ! word - 0x01010101 - andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 - bz,a .cmp4 ! no null-byte in s1 yet - lduw [%i1 + %i2], %i3 ! load word from s1 - - ! words are equal but the end of s1 has been reached - ! this means the strings must be equal -.stringsequal4: - ret ! return - restore %g0, %g0, %o0 ! return 0, i.e. strings are equal - -.wordsdiffer: - srl %g1, 24, %i2 ! first byte of mismatching word in s2 - srl %i3, 24, %i1 ! first byte of mismatching word in s1 - subcc %i1, %i2, %i0 ! *s1-*s2 - bnz .done ! bytes differ, return difference - srl %g1, 16, %i2 ! second byte of mismatching word in s2 - andcc %i1, 0xff, %i0 ! *s1 == 0 ? - bz .done ! yup, done, strings equal - - ! we know byte 1 is equal, so can compare bytes 1,2 as a group - - srl %i3, 16, %i1 ! second byte of mismatching word in s1 - subcc %i1, %i2, %i0 ! *s1-*s2 - bnz .done ! bytes differ, return difference - srl %g1, 8, %i2 ! third byte of mismatching word in s2 - andcc %i1, 0xff, %i0 ! *s1 == 0 ? - bz .done ! yup, done, strings equal - - ! we know bytes 1, 2 are equal, so can compare bytes 1,2,3 as a group - - srl %i3, 8, %i1 ! third byte of mismatching word in s1 - subcc %i1, %i2, %i0 ! *s1-*s2 - bnz .done ! bytes differ, return difference - andcc %i1, 0xff, %g0 ! *s1 == 0 ? - bz .stringsequal ! yup, done, strings equal - - ! we know bytes 1,2,3 are equal, so can compare bytes 1,2,3,4 as group - - subcc %i3, %g1, %i0 ! *s1-*s2 - bz,a .done ! bytes differ, return difference - andcc %i3, 0xff, %i0 ! *s1 == 0, strings equal - -.done: - ret ! return - restore %i0, %g0, %o0 ! return 0 or byte difference - - SET_SIZE(strcasecmp)
--- a/usr/src/lib/libc/sparcv9/Makefile.com Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libc/sparcv9/Makefile.com Thu Aug 12 14:55:22 2010 -0700 @@ -119,7 +119,6 @@ bcopy.o \ bsearch.o \ bzero.o \ - ffs.o \ memccpy.o \ qsort.o \ strtol.o \ @@ -132,6 +131,7 @@ _xregs_clrptr.o \ abs.o \ alloca.o \ + ascii_strcasecmp.o \ byteorder.o \ cuexit.o \ ecvt.o \ @@ -146,7 +146,6 @@ siglongjmp.o \ smt_pause.o \ sparc_data.o \ - strcasecmp.o \ strchr.o \ strcmp.o \ strlcpy.o \ @@ -350,6 +349,7 @@ a64l.o \ abort.o \ addsev.o \ + ascii_strncasecmp.o \ assert.o \ attrat.o \ atof.o \ @@ -393,6 +393,8 @@ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -414,6 +416,7 @@ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -462,6 +465,7 @@ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -525,15 +529,18 @@ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ strcat.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ + strlcat.o \ strncat.o \ - strlcat.o \ - strncasecmp.o \ + strndup.o \ strpbrk.o \ strrchr.o \ strsep.o \ @@ -563,6 +570,7 @@ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -637,6 +645,7 @@ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -669,7 +678,11 @@ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcstoimax.o \ wcstol.o \ wcstoul.o \ @@ -964,8 +977,10 @@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -1023,6 +1038,7 @@ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ getctxt.o \ lwp.o \ @@ -1056,6 +1072,9 @@ $(TIL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/threads/sparcv9.il +# This hack is needed until the sparc gcc is fixed for TLS +pics/tls_data.o := CC = env 'CW_NO_SHADOW=1' $(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc + # Files in fp, port/fp subdirectories that need base.il inline template IL= \ __flt_decim.o \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/sparcv9/gen/ascii_strcasecmp.s Thu Aug 12 14:55:22 2010 -0700 @@ -0,0 +1,348 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * The ascii_strcasecmp() function is a case insensitive versions of strcmp(). + * It assumes the ASCII character set and ignores differences in case + * when comparing lower and upper case characters. In other words, it + * behaves as if both strings had been converted to lower case using + * tolower() in the "C" locale on each byte, and the results had then + * been compared using strcmp(). + * + * The assembly code below is an optimized version of the following C + * reference: + * + * static const char charmap[] = { + * '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + * '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + * '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + * '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + * '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + * '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + * '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + * '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + * '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + * '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + * '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + * '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + * '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + * '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + * '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + * '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + * '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + * '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + * '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + * '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + * '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', + * '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', + * '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', + * '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', + * '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + * '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + * '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + * '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', + * }; + * + * int + * ascii_strcasecmp(const char *s1, const char *s2) + * { + * const unsigned char *cm = (const unsigned char *)charmap; + * const unsigned char *us1 = (const unsigned char *)s1; + * const unsigned char *us2 = (const unsigned char *)s2; + * + * while (cm[*us1] == cm[*us2++]) + * if (*us1++ == '\0') + * return (0); + * return (cm[*us1] - cm[*(us2 - 1)]); + * } + * + * The following algorithm, from a 1987 news posting by Alan Mycroft, is + * used for finding null bytes in a word: + * + * #define has_null(word) ((word - 0x01010101) & (~word & 0x80808080)) + * + * The following algorithm is used for a wordwise tolower() operation: + * + * unsigned int + * parallel_tolower (unsigned int x) + * { + * unsigned int p; + * unsigned int q; + * + * unsigned int m1 = 0x80808080; + * unsigned int m2 = 0x3f3f3f3f; + * unsigned int m3 = 0x25252525; + * + * q = x & ~m1;// newb = byte & 0x7F + * p = q + m2; // newb > 0x5A --> MSB set + * q = q + m3; // newb < 0x41 --> MSB clear + * p = p & ~q; // newb > 0x40 && newb < 0x5B --> MSB set + * q = m1 & ~x;// byte < 0x80 --> 0x80 + * q = p & q; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x80,else 0 + * q = q >> 2; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x20,else 0 + * return (x + q); // translate uppercase characters to lowercase + * } + * + * Both algorithms have been tested exhaustively for all possible 2^32 inputs. + */ + +#include <sys/asm_linkage.h> + + ! The first part of this algorithm walks through the beginning of + ! both strings a byte at a time until the source ptr is aligned to + ! a word boundary. During these steps, the bytes are translated to + ! lower-case if they are upper-case, and are checked against + ! the source string. + + ENTRY(ascii_strcasecmp) + + .align 32 + + save %sp, -SA(WINDOWSIZE), %sp + subcc %i0, %i1, %i2 ! s1 == s2 ? + bz,pn %ncc, .stringsequal ! yup, done, strings equal + andcc %i0, 3, %i3 ! s1 word-aligned ? + bz,pn %ncc, .s1aligned1 ! yup + sethi %hi(0x80808080), %i4 ! start loading Mycroft's magic1 + + ldub [%i1 + %i2], %i0 ! s1[0] + ldub [%i1], %g1 ! s2[0] + sub %i0, 'A', %l0 ! transform for faster uppercase check + sub %g1, 'A', %l1 ! transform for faster uppercase check + cmp %l0, ('Z' - 'A') ! s1[0] uppercase? + bleu,a .noxlate11 ! yes + add %i0, ('a' - 'A'), %i0 ! s1[0] = tolower(s1[0]) +.noxlate11: + cmp %l1, ('Z' - 'A') ! s2[0] uppercase? + bleu,a .noxlate12 ! yes + add %g1, ('a' - 'A'), %g1 ! s2[0] = tolower(s2[0]) +.noxlate12: + subcc %i0, %g1, %i0 ! tolower(s1[0]) != tolower(s2[0]) ? + bne,pn %ncc, .done ! yup, done + inc %i1 ! s1++, s2++ + addcc %i0, %g1, %i0 ! s1[0] == 0 ? + bz,pn %ncc, .done ! yup, done, strings equal + cmp %i3, 3 ! s1 aligned now? + bz %ncc, .s1aligned2 ! yup + sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 + + ldub [%i1 + %i2], %i0 ! s1[1] + ldub [%i1], %g1 ! s2[1] + sub %i0, 'A', %l0 ! transform for faster uppercase check + sub %g1, 'A', %l1 ! transform for faster uppercase check + cmp %l0, ('Z' - 'A') ! s1[1] uppercase? + bleu,a .noxlate21 ! yes + add %i0, ('a' - 'A'), %i0 ! s1[1] = tolower(s1[1]) +.noxlate21: + cmp %l1, ('Z' - 'A') ! s2[1] uppercase? + bleu,a .noxlate22 ! yes + add %g1, ('a' - 'A'), %g1 ! s2[1] = tolower(s2[1]) +.noxlate22: + subcc %i0, %g1, %i0 ! tolower(s1[1]) != tolower(s2[1]) ? + bne,pn %ncc, .done ! yup, done + inc %i1 ! s1++, s2++ + addcc %i0, %g1, %i0 ! s1[1] == 0 ? + bz,pn %ncc, .done ! yup, done, strings equal + cmp %i3, 2 ! s1 aligned now? + bz %ncc, .s1aligned3 ! yup + or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 + + ldub [%i1 + %i2], %i0 ! s1[2] + ldub [%i1], %g1 ! s2[2] + sub %i0, 'A', %l0 ! transform for faster uppercase check + sub %g1, 'A', %l1 ! transform for faster uppercase check + cmp %l0, ('Z' - 'A') ! s1[2] uppercase? + bleu,a .noxlate31 ! yes + add %i0, ('a' - 'A'), %i0 ! s1[2] = tolower(s1[2]) +.noxlate31: + cmp %l1, ('Z' - 'A') ! s2[2] uppercase? + bleu,a .noxlate32 ! yes + add %g1, ('a' - 'A'), %g1 ! s2[2] = tolower(s2[2]) +.noxlate32: + subcc %i0, %g1, %i0 ! tolower(s1[2]) != tolower(s2[2]) ? + bne,pn %ncc, .done ! yup, done + inc %i1 ! s1++, s2++ + addcc %i0, %g1, %i0 ! s1[2] == 0 ? + bz,pn %ncc, .done ! yup, done, strings equal + or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 + ba .s1aligned4 ! s1 aligned now + andcc %i1, 3, %i3 ! s2 word-aligned ? + + ! Here, we initialize our checks for a zero byte and decide + ! whether or not we can optimize further if we're fortunate + ! enough to have a word aligned desintation + +.s1aligned1: + sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 +.s1aligned2: + or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 +.s1aligned3: + or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 + andcc %i1, 3, %i3 ! s2 word aligned ? +.s1aligned4: + sethi %hi(0x3f3f3f3f), %l2 ! load m2 for parallel tolower() + sethi %hi(0x25252525), %l3 ! load m3 for parallel tolower() + or %l2, %lo(0x3f3f3f3f),%l2! finish loading m2 + bz .word4 ! yup, s2 word-aligned + or %l3, %lo(0x25252525),%l3! finish loading m3 + + add %i2, %i3, %i2 ! start adjusting offset s1-s2 + sll %i3, 3, %l6 ! shift factor for left shifts + andn %i1, 3, %i1 ! round s1 pointer down to next word + sub %g0, %l6, %l7 ! shift factor for right shifts + orn %i3, %g0, %i3 ! generate all ones + lduw [%i1], %i0 ! new lower word from s2 + srl %i3, %l6, %i3 ! mask for fixing up bytes + sll %i0, %l6, %g1 ! partial unaligned word from s2 + orn %i0, %i3, %i0 ! force start bytes to non-zero + nop ! pad to align loop to 16-byte boundary + nop ! pad to align loop to 16-byte boundary + + ! This is the comparision procedure used if the destination is not + ! word aligned, if it is, we use word4 & cmp4 + +.cmp: + andn %i4, %i0, %l4 ! ~word & 0x80808080 + sub %i0, %i5, %l5 ! word - 0x01010101 + andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 + bz,a,pt %ncc, .doload ! null byte in previous aligned s2 word + lduw [%i1 + 4], %i0 ! load next aligned word from s2 +.doload: + srl %i0, %l7, %i3 ! byte 1 from new aligned word from s2 + or %g1, %i3, %g1 ! merge to get unaligned word from s2 + lduw [%i1 + %i2], %i3 ! x1 = word from s1 + andn %i3, %i4, %l0 ! q1 = x1 & ~m1 + andn %g1, %i4, %l4 ! q2 = x2 & ~m1 + add %l0, %l2, %l1 ! p1 = q1 + m2 + add %l4, %l2, %l5 ! p2 = q2 + m2 + add %l0, %l3, %l0 ! q1 = q1 + m3 + add %l4, %l3, %l4 ! q2 = q2 + m3 + andn %l1, %l0, %l1 ! p1 = p1 & ~q1 + andn %l5, %l4, %l5 ! p2 = p2 & ~q2 + andn %i4, %i3, %l0 ! q1 = m1 & ~x1 + andn %i4, %g1, %l4 ! q2 = m1 & ~x2 + and %l0, %l1, %l0 ! q1 = p1 & q1 + and %l4, %l5, %l4 ! q2 = p2 & q2 + srl %l0, 2, %l0 ! q1 = q1 >> 2 + srl %l4, 2, %l4 ! q2 = q2 >> 2 + add %l0, %i3, %i3 ! lowercase word from s1 + add %l4, %g1, %g1 ! lowercase word from s2 + cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? + bne %icc, .wordsdiffer ! yup, now find byte that is different + add %i1, 4, %i1 ! s1+=4, s2+=4 + andn %i4, %i3, %l4 ! ~word & 0x80808080 + sub %i3, %i5, %l5 ! word - 0x01010101 + andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 + bz,pt %ncc, .cmp ! no null-byte in s1 yet + sll %i0, %l6, %g1 ! partial unaligned word from s2 + + ! words are equal but the end of s1 has been reached + ! this means the strings must be equal +.stringsequal: + ret ! return + restore %g0, %g0, %o0 ! return 0, i.e. strings are equal + nop ! pad + + + ! we have a word aligned source and destination! This means + ! things get to go fast! + +.word4: + lduw [%i1 + %i2], %i3 ! x1 = word from s1 + +.cmp4: + andn %i3, %i4, %l0 ! q1 = x1 & ~m1 + lduw [%i1], %g1 ! x2 = word from s2 + andn %g1, %i4, %l4 ! q2 = x2 & ~m1 + add %l0, %l2, %l1 ! p1 = q1 + m2 + add %l4, %l2, %l5 ! p2 = q2 + m2 + add %l0, %l3, %l0 ! q1 = q1 + m3 + add %l4, %l3, %l4 ! q2 = q2 + m3 + andn %l1, %l0, %l1 ! p1 = p1 & ~q1 + andn %l5, %l4, %l5 ! p2 = p2 & ~q2 + andn %i4, %i3, %l0 ! q1 = m1 & ~x1 + andn %i4, %g1, %l4 ! q2 = m1 & ~x2 + and %l0, %l1, %l0 ! q1 = p1 & q1 + and %l4, %l5, %l4 ! q2 = p2 & q2 + srl %l0, 2, %l0 ! q1 = q1 >> 2 + srl %l4, 2, %l4 ! q2 = q2 >> 2 + add %l0, %i3, %i3 ! lowercase word from s1 + add %l4, %g1, %g1 ! lowercase word from s2 + cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? + bne,pn %icc, .wordsdiffer ! yup, now find mismatching character + add %i1, 4, %i1 ! s1+=4, s2+=4 + andn %i4, %i3, %l4 ! ~word & 0x80808080 + sub %i3, %i5, %l5 ! word - 0x01010101 + andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 + bz,a,pt %icc, .cmp4 ! no null-byte in s1 yet + lduw [%i1 + %i2], %i3 ! load word from s1 + + ! words are equal but the end of s1 has been reached + ! this means the strings must be equal +.stringsequal4: + ret ! return + restore %g0, %g0, %o0 ! return 0, i.e. strings are equal + +.wordsdiffer: + srl %g1, 24, %i2 ! first byte of mismatching word in s2 + srl %i3, 24, %i1 ! first byte of mismatching word in s1 + subcc %i1, %i2, %i0 ! *s1-*s2 + bnz,pn %ncc, .done ! bytes differ, return difference + srl %g1, 16, %i2 ! second byte of mismatching word in s2 + andcc %i1, 0xff, %i0 ! *s1 == 0 ? + bz,pn %ncc, .done ! yup + + ! we know byte 1 is equal, so can compare bytes 1,2 as a group + + srl %i3, 16, %i1 ! second byte of mismatching word in s1 + subcc %i1, %i2, %i0 ! *s1-*s2 + bnz,pn %ncc, .done ! bytes differ, return difference + srl %g1, 8, %i2 ! third byte of mismatching word in s2 + andcc %i1, 0xff, %i0 ! *s1 == 0 ? + bz,pn %ncc, .done ! yup + + ! we know bytes 1, 2 are equal, so can compare bytes 1,2,3 as a group + + srl %i3, 8, %i1 ! third byte of mismatching word in s1 + subcc %i1, %i2, %i0 ! *s1-*s2 + bnz,pn %ncc, .done ! bytes differ, return difference + andcc %i1, 0xff, %g0 ! *s1 == 0 ? + bz,pn %ncc, .stringsequal ! yup + + ! we know bytes 1,2,3 are equal, so can compare bytes 1,2,3,4 as group + + subcc %i3, %g1, %i0 ! *s1-*s2 + bz,a .done ! bytes differ, return difference + andcc %i3, 0xff, %i0 ! *s1 == 0 ? + +.done: + ret ! return + restore %i0, %g0, %o0 ! return tolower(*s1) - tolower(*s2) + + SET_SIZE(ascii_strcasecmp)
--- a/usr/src/lib/libc/sparcv9/gen/strcasecmp.s Thu Aug 12 14:07:03 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,351 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "strcasecmp.s" - -/* - * The strcasecmp() function is a case insensitive versions of strcmp(). - * It assumes the ASCII character set and ignores differences in case - * when comparing lower and upper case characters. In other words, it - * behaves as if both strings had been converted to lower case using - * tolower() in the "C" locale on each byte, and the results had then - * been compared using strcmp(). - * - * The assembly code below is an optimized version of the following C - * reference: - * - * static const char charmap[] = { - * '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', - * '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', - * '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', - * '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', - * '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', - * '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', - * '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', - * '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', - * '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - * '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', - * '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - * '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - * '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - * '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', - * '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', - * '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', - * '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', - * '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', - * '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', - * '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', - * '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', - * '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', - * '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', - * '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', - * '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', - * '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', - * '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - * '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - * '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - * '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', - * }; - * - * int - * strcasecmp(const char *s1, const char *s2) - * { - * const unsigned char *cm = (const unsigned char *)charmap; - * const unsigned char *us1 = (const unsigned char *)s1; - * const unsigned char *us2 = (const unsigned char *)s2; - * - * while (cm[*us1] == cm[*us2++]) - * if (*us1++ == '\0') - * return (0); - * return (cm[*us1] - cm[*(us2 - 1)]); - * } - * - * The following algorithm, from a 1987 news posting by Alan Mycroft, is - * used for finding null bytes in a word: - * - * #define has_null(word) ((word - 0x01010101) & (~word & 0x80808080)) - * - * The following algorithm is used for a wordwise tolower() operation: - * - * unsigned int - * parallel_tolower (unsigned int x) - * { - * unsigned int p; - * unsigned int q; - * - * unsigned int m1 = 0x80808080; - * unsigned int m2 = 0x3f3f3f3f; - * unsigned int m3 = 0x25252525; - * - * q = x & ~m1;// newb = byte & 0x7F - * p = q + m2; // newb > 0x5A --> MSB set - * q = q + m3; // newb < 0x41 --> MSB clear - * p = p & ~q; // newb > 0x40 && newb < 0x5B --> MSB set - * q = m1 & ~x;// byte < 0x80 --> 0x80 - * q = p & q; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x80,else 0 - * q = q >> 2; // newb > 0x40 && newb < 0x5B && byte < 0x80 -> 0x20,else 0 - * return (x + q); // translate uppercase characters to lowercase - * } - * - * Both algorithms have been tested exhaustively for all possible 2^32 inputs. - */ - -#include <sys/asm_linkage.h> - - ! The first part of this algorithm walks through the beginning of - ! both strings a byte at a time until the source ptr is aligned to - ! a word boundary. During these steps, the bytes are translated to - ! lower-case if they are upper-case, and are checked against - ! the source string. - - ENTRY(strcasecmp) - - .align 32 - - save %sp, -SA(WINDOWSIZE), %sp - subcc %i0, %i1, %i2 ! s1 == s2 ? - bz,pn %ncc, .stringsequal ! yup, done, strings equal - andcc %i0, 3, %i3 ! s1 word-aligned ? - bz,pn %ncc, .s1aligned1 ! yup - sethi %hi(0x80808080), %i4 ! start loading Mycroft's magic1 - - ldub [%i1 + %i2], %i0 ! s1[0] - ldub [%i1], %g1 ! s2[0] - sub %i0, 'A', %l0 ! transform for faster uppercase check - sub %g1, 'A', %l1 ! transform for faster uppercase check - cmp %l0, ('Z' - 'A') ! s1[0] uppercase? - bleu,a .noxlate11 ! yes - add %i0, ('a' - 'A'), %i0 ! s1[0] = tolower(s1[0]) -.noxlate11: - cmp %l1, ('Z' - 'A') ! s2[0] uppercase? - bleu,a .noxlate12 ! yes - add %g1, ('a' - 'A'), %g1 ! s2[0] = tolower(s2[0]) -.noxlate12: - subcc %i0, %g1, %i0 ! tolower(s1[0]) != tolower(s2[0]) ? - bne,pn %ncc, .done ! yup, done - inc %i1 ! s1++, s2++ - addcc %i0, %g1, %i0 ! s1[0] == 0 ? - bz,pn %ncc, .done ! yup, done, strings equal - cmp %i3, 3 ! s1 aligned now? - bz %ncc, .s1aligned2 ! yup - sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 - - ldub [%i1 + %i2], %i0 ! s1[1] - ldub [%i1], %g1 ! s2[1] - sub %i0, 'A', %l0 ! transform for faster uppercase check - sub %g1, 'A', %l1 ! transform for faster uppercase check - cmp %l0, ('Z' - 'A') ! s1[1] uppercase? - bleu,a .noxlate21 ! yes - add %i0, ('a' - 'A'), %i0 ! s1[1] = tolower(s1[1]) -.noxlate21: - cmp %l1, ('Z' - 'A') ! s2[1] uppercase? - bleu,a .noxlate22 ! yes - add %g1, ('a' - 'A'), %g1 ! s2[1] = tolower(s2[1]) -.noxlate22: - subcc %i0, %g1, %i0 ! tolower(s1[1]) != tolower(s2[1]) ? - bne,pn %ncc, .done ! yup, done - inc %i1 ! s1++, s2++ - addcc %i0, %g1, %i0 ! s1[1] == 0 ? - bz,pn %ncc, .done ! yup, done, strings equal - cmp %i3, 2 ! s1 aligned now? - bz %ncc, .s1aligned3 ! yup - or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 - - ldub [%i1 + %i2], %i0 ! s1[2] - ldub [%i1], %g1 ! s2[2] - sub %i0, 'A', %l0 ! transform for faster uppercase check - sub %g1, 'A', %l1 ! transform for faster uppercase check - cmp %l0, ('Z' - 'A') ! s1[2] uppercase? - bleu,a .noxlate31 ! yes - add %i0, ('a' - 'A'), %i0 ! s1[2] = tolower(s1[2]) -.noxlate31: - cmp %l1, ('Z' - 'A') ! s2[2] uppercase? - bleu,a .noxlate32 ! yes - add %g1, ('a' - 'A'), %g1 ! s2[2] = tolower(s2[2]) -.noxlate32: - subcc %i0, %g1, %i0 ! tolower(s1[2]) != tolower(s2[2]) ? - bne,pn %ncc, .done ! yup, done - inc %i1 ! s1++, s2++ - addcc %i0, %g1, %i0 ! s1[2] == 0 ? - bz,pn %ncc, .done ! yup, done, strings equal - or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 - ba .s1aligned4 ! s1 aligned now - andcc %i1, 3, %i3 ! s2 word-aligned ? - - ! Here, we initialize our checks for a zero byte and decide - ! whether or not we can optimize further if we're fortunate - ! enough to have a word aligned desintation - -.s1aligned1: - sethi %hi(0x01010101), %i5 ! start loading Mycroft's magic2 -.s1aligned2: - or %i4, %lo(0x80808080),%i4! finish loading Mycroft's magic1 -.s1aligned3: - or %i5, %lo(0x01010101),%i5! finish loading Mycroft's magic2 - andcc %i1, 3, %i3 ! s2 word aligned ? -.s1aligned4: - sethi %hi(0x3f3f3f3f), %l2 ! load m2 for parallel tolower() - sethi %hi(0x25252525), %l3 ! load m3 for parallel tolower() - or %l2, %lo(0x3f3f3f3f),%l2! finish loading m2 - bz .word4 ! yup, s2 word-aligned - or %l3, %lo(0x25252525),%l3! finish loading m3 - - add %i2, %i3, %i2 ! start adjusting offset s1-s2 - sll %i3, 3, %l6 ! shift factor for left shifts - andn %i1, 3, %i1 ! round s1 pointer down to next word - sub %g0, %l6, %l7 ! shift factor for right shifts - orn %i3, %g0, %i3 ! generate all ones - lduw [%i1], %i0 ! new lower word from s2 - srl %i3, %l6, %i3 ! mask for fixing up bytes - sll %i0, %l6, %g1 ! partial unaligned word from s2 - orn %i0, %i3, %i0 ! force start bytes to non-zero - nop ! pad to align loop to 16-byte boundary - nop ! pad to align loop to 16-byte boundary - - ! This is the comparision procedure used if the destination is not - ! word aligned, if it is, we use word4 & cmp4 - -.cmp: - andn %i4, %i0, %l4 ! ~word & 0x80808080 - sub %i0, %i5, %l5 ! word - 0x01010101 - andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 - bz,a,pt %ncc, .doload ! null byte in previous aligned s2 word - lduw [%i1 + 4], %i0 ! load next aligned word from s2 -.doload: - srl %i0, %l7, %i3 ! byte 1 from new aligned word from s2 - or %g1, %i3, %g1 ! merge to get unaligned word from s2 - lduw [%i1 + %i2], %i3 ! x1 = word from s1 - andn %i3, %i4, %l0 ! q1 = x1 & ~m1 - andn %g1, %i4, %l4 ! q2 = x2 & ~m1 - add %l0, %l2, %l1 ! p1 = q1 + m2 - add %l4, %l2, %l5 ! p2 = q2 + m2 - add %l0, %l3, %l0 ! q1 = q1 + m3 - add %l4, %l3, %l4 ! q2 = q2 + m3 - andn %l1, %l0, %l1 ! p1 = p1 & ~q1 - andn %l5, %l4, %l5 ! p2 = p2 & ~q2 - andn %i4, %i3, %l0 ! q1 = m1 & ~x1 - andn %i4, %g1, %l4 ! q2 = m1 & ~x2 - and %l0, %l1, %l0 ! q1 = p1 & q1 - and %l4, %l5, %l4 ! q2 = p2 & q2 - srl %l0, 2, %l0 ! q1 = q1 >> 2 - srl %l4, 2, %l4 ! q2 = q2 >> 2 - add %l0, %i3, %i3 ! lowercase word from s1 - add %l4, %g1, %g1 ! lowercase word from s2 - cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? - bne %icc, .wordsdiffer ! yup, now find byte that is different - add %i1, 4, %i1 ! s1+=4, s2+=4 - andn %i4, %i3, %l4 ! ~word & 0x80808080 - sub %i3, %i5, %l5 ! word - 0x01010101 - andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 - bz,pt %ncc, .cmp ! no null-byte in s1 yet - sll %i0, %l6, %g1 ! partial unaligned word from s2 - - ! words are equal but the end of s1 has been reached - ! this means the strings must be equal -.stringsequal: - ret ! return - restore %g0, %g0, %o0 ! return 0, i.e. strings are equal - nop ! pad - - - ! we have a word aligned source and destination! This means - ! things get to go fast! - -.word4: - lduw [%i1 + %i2], %i3 ! x1 = word from s1 - -.cmp4: - andn %i3, %i4, %l0 ! q1 = x1 & ~m1 - lduw [%i1], %g1 ! x2 = word from s2 - andn %g1, %i4, %l4 ! q2 = x2 & ~m1 - add %l0, %l2, %l1 ! p1 = q1 + m2 - add %l4, %l2, %l5 ! p2 = q2 + m2 - add %l0, %l3, %l0 ! q1 = q1 + m3 - add %l4, %l3, %l4 ! q2 = q2 + m3 - andn %l1, %l0, %l1 ! p1 = p1 & ~q1 - andn %l5, %l4, %l5 ! p2 = p2 & ~q2 - andn %i4, %i3, %l0 ! q1 = m1 & ~x1 - andn %i4, %g1, %l4 ! q2 = m1 & ~x2 - and %l0, %l1, %l0 ! q1 = p1 & q1 - and %l4, %l5, %l4 ! q2 = p2 & q2 - srl %l0, 2, %l0 ! q1 = q1 >> 2 - srl %l4, 2, %l4 ! q2 = q2 >> 2 - add %l0, %i3, %i3 ! lowercase word from s1 - add %l4, %g1, %g1 ! lowercase word from s2 - cmp %i3, %g1 ! tolower(*s1) != tolower(*s2) ? - bne,pn %icc, .wordsdiffer ! yup, now find mismatching character - add %i1, 4, %i1 ! s1+=4, s2+=4 - andn %i4, %i3, %l4 ! ~word & 0x80808080 - sub %i3, %i5, %l5 ! word - 0x01010101 - andcc %l5, %l4, %g0 ! (word - 0x01010101) & ~word & 0x80808080 - bz,a,pt %icc, .cmp4 ! no null-byte in s1 yet - lduw [%i1 + %i2], %i3 ! load word from s1 - - ! words are equal but the end of s1 has been reached - ! this means the strings must be equal -.stringsequal4: - ret ! return - restore %g0, %g0, %o0 ! return 0, i.e. strings are equal - -.wordsdiffer: - srl %g1, 24, %i2 ! first byte of mismatching word in s2 - srl %i3, 24, %i1 ! first byte of mismatching word in s1 - subcc %i1, %i2, %i0 ! *s1-*s2 - bnz,pn %ncc, .done ! bytes differ, return difference - srl %g1, 16, %i2 ! second byte of mismatching word in s2 - andcc %i1, 0xff, %i0 ! *s1 == 0 ? - bz,pn %ncc, .done ! yup - - ! we know byte 1 is equal, so can compare bytes 1,2 as a group - - srl %i3, 16, %i1 ! second byte of mismatching word in s1 - subcc %i1, %i2, %i0 ! *s1-*s2 - bnz,pn %ncc, .done ! bytes differ, return difference - srl %g1, 8, %i2 ! third byte of mismatching word in s2 - andcc %i1, 0xff, %i0 ! *s1 == 0 ? - bz,pn %ncc, .done ! yup - - ! we know bytes 1, 2 are equal, so can compare bytes 1,2,3 as a group - - srl %i3, 8, %i1 ! third byte of mismatching word in s1 - subcc %i1, %i2, %i0 ! *s1-*s2 - bnz,pn %ncc, .done ! bytes differ, return difference - andcc %i1, 0xff, %g0 ! *s1 == 0 ? - bz,pn %ncc, .stringsequal ! yup - - ! we know bytes 1,2,3 are equal, so can compare bytes 1,2,3,4 as group - - subcc %i3, %g1, %i0 ! *s1-*s2 - bz,a .done ! bytes differ, return difference - andcc %i3, 0xff, %i0 ! *s1 == 0 ? - -.done: - ret ! return - restore %i0, %g0, %o0 ! return tolower(*s1) - tolower(*s2) - - SET_SIZE(strcasecmp)
--- a/usr/src/lib/libcpc/i386/event_pentium.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libcpc/i386/event_pentium.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Routines to capture processor-dependencies in event specification. */ @@ -33,7 +30,6 @@ #include <sys/types.h> #include <string.h> #include <strings.h> -#include <alloca.h> #include <stdlib.h> #include <stdio.h> #include <libintl.h> @@ -407,7 +403,7 @@ pic[0] = pic[1] = NULL; - opts = strcpy(alloca(strlen(spec) + 1), spec); + opts = strdupa(spec); while (*opts != '\0') { const struct keyval *kv; int idx = getsubopt(&opts, tokens, &value); @@ -629,7 +625,8 @@ xpes[0].inv, xpes[1].inv, 0, tokens[D_inv]); flagstostr(buffer, xpes[0].pc, xpes[1].pc, 0, tokens[D_pc]); - } break; + break; + } case CPC_PENTIUM_MMX: case CPC_PENTIUM: { @@ -654,7 +651,8 @@ xcesr.clk[0], xcesr.clk[1], 0, tokens[D_noedge]); flagstostr(buffer, xcesr.pc[0], xcesr.pc[1], 0, tokens[D_pc]); - } break; + break; + } default: return (NULL); }
--- a/usr/src/lib/libcpc/sparc/event_ultra.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libcpc/sparc/event_ultra.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Routines to capture processor-dependencies in event specification. */ @@ -33,7 +30,6 @@ #include <sys/types.h> #include <string.h> #include <strings.h> -#include <alloca.h> #include <stdlib.h> #include <stdio.h> #include <libintl.h> @@ -243,7 +239,7 @@ pic[0] = pic[1] = NULL; - opts = strcpy(alloca(strlen(spec) + 1), spec); + opts = strdupa(spec); while (*opts != '\0') { const struct keyval *kv; int idx = getsubopt(&opts, tokens, &value);
--- a/usr/src/lib/libdtrace/common/dt_decl.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libdtrace/common/dt_decl.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * 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 <limits.h> @@ -703,8 +700,7 @@ char *name; int value; - name = alloca(strlen(s) + 1); - (void) strcpy(name, s); + name = strdupa(s); free(s); if (dsp == NULL)
--- a/usr/src/lib/libdtrace/common/dt_ident.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libdtrace/common/dt_ident.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,12 +20,9 @@ */ /* - * 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/sysmacros.h> #include <strings.h> #include <stdlib.h> @@ -181,8 +178,7 @@ int i = 0; assert(idp->di_iarg != NULL); - s = alloca(strlen(idp->di_iarg) + 1); - (void) strcpy(s, idp->di_iarg); + s = strdupa(idp->di_iarg); if ((p2 = strrchr(s, ')')) != NULL) *p2 = '\0'; /* mark end of parameter list string */
--- a/usr/src/lib/libdtrace/common/dt_parser.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libdtrace/common/dt_parser.c Thu Aug 12 14:55:22 2010 -0700 @@ -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. @@ -21,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" - /* * DTrace D Language Parser * @@ -472,9 +468,9 @@ case DT_NODE_XLATOR: (void) snprintf(buf, len, "translator <%s> (%s)", dt_type_name(dnp->dn_xlator->dx_dst_ctfp, - dnp->dn_xlator->dx_dst_type, n1, sizeof (n1)), + dnp->dn_xlator->dx_dst_type, n1, sizeof (n1)), dt_type_name(dnp->dn_xlator->dx_src_ctfp, - dnp->dn_xlator->dx_src_type, n2, sizeof (n2))); + dnp->dn_xlator->dx_src_type, n2, sizeof (n2))); break; case DT_NODE_PROG: (void) snprintf(buf, len, "%s", "program"); @@ -1440,9 +1436,9 @@ "\t current: %s\n\tprevious: %s\n", dmp->dm_name, dsp->ds_ident, dt_type_name(dtt.dtt_ctfp, dtt.dtt_type, - n1, sizeof (n1)), + n1, sizeof (n1)), dt_type_name(ott.dtt_ctfp, ott.dtt_type, - n2, sizeof (n2))); + n2, sizeof (n2))); } else if (!exists && dt_module_extern(dtp, dmp, dsp->ds_ident, &dtt) == NULL) { xyerror(D_UNKNOWN, @@ -1452,7 +1448,7 @@ dt_dprintf("extern %s`%s type=<%s>\n", dmp->dm_name, dsp->ds_ident, dt_type_name(dtt.dtt_ctfp, dtt.dtt_type, - n1, sizeof (n1))); + n1, sizeof (n1))); } break; } @@ -1756,8 +1752,7 @@ ctf_id_t type; uint_t kind; - name = alloca(strlen(s) + 1); - (void) strcpy(name, s); + name = strdupa(s); free(s); err = dt_decl_type(ddp, &dtt);
--- a/usr/src/lib/libdtrace/common/dt_pragma.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libdtrace/common/dt_pragma.c Thu Aug 12 14:55:22 2010 -0700 @@ -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 <assert.h> #include <strings.h> #include <alloca.h> @@ -337,8 +334,7 @@ "superfluous arguments specified for #pragma %s\n", prname); } - opt = alloca(strlen(dnp->dn_string) + 1); - (void) strcpy(opt, dnp->dn_string); + opt = strdupa(dnp->dn_string); if ((val = strchr(opt, '=')) != NULL) *val++ = '\0';
--- a/usr/src/lib/libdtrace/common/dt_string.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libdtrace/common/dt_string.c Thu Aug 12 14:55:22 2010 -0700 @@ -29,23 +29,6 @@ #include <ctype.h> #include <dt_string.h> -#include <dt_impl.h> - -/* - * Create a copy of string s, but only duplicate the first n bytes. - */ -char * -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); -} /* * Transform string s inline, converting each embedded C escape sequence string
--- a/usr/src/lib/libdtrace/common/dt_string.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libdtrace/common/dt_string.h Thu Aug 12 14:55:22 2010 -0700 @@ -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,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _DT_STRING_H #define _DT_STRING_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <strings.h> @@ -36,7 +33,6 @@ extern "C" { #endif -extern char *strndup(const char *, size_t); extern size_t stresc2chr(char *); extern char *strchr2esc(const char *, size_t); extern const char *strbasename(const char *);
--- a/usr/src/lib/libdtrace/common/dt_subr.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libdtrace/common/dt_subr.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/sysmacros.h> @@ -222,8 +221,7 @@ return (-1); /* invalid function arguments */ *attr = _dtrace_maxattr; - p = alloca(strlen(str) + 1); - (void) strcpy(p, str); + p = strdupa(str); if ((p = dt_getstrattr(p, &q)) == NULL) return (0);
--- a/usr/src/lib/libnsl/dial/sysfiles.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libnsl/dial/sysfiles.c Thu Aug 12 14:55:22 2010 -0700 @@ -19,14 +19,13 @@ * CDDL HEADER END */ +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - #include "mt.h" #include "uucp.h" @@ -64,7 +63,7 @@ static int nextdialers(void); static int nextdevices(void); static int nextsystems(void); -static int getline(FILE *, char *); +static int getaline(FILE *, char *); /* pointer arrays might be dynamically allocated */ static char *Systems[64]; /* list of Systems files */ @@ -189,7 +188,7 @@ } if ((f = fopen(SYSFILES, "rF")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Sysfiles */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -239,7 +238,7 @@ expecttime = EXPECTTIME; if ((f = fopen(DEVCONFIG, "rF")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Devconfig */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -264,7 +263,7 @@ */ static int -getline(FILE *f, char *line) +getaline(FILE *f, char *line) { char *lptr, *lend; lptr = line; @@ -734,7 +733,7 @@ extern char _ProtoCfg[]; if ((f = fopen(CONFIG, "rF")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Config file */ tok = strtok(buf, " \t"); if ((tok != NULL) && (*tok != '#')) {
--- a/usr/src/lib/libpicltree/picltree.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libpicltree/picltree.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This module implements the PTree interface and the PICL to PTree calls */ @@ -2796,12 +2793,10 @@ if (prl == NULL) return (PICL_FAILURE); - path = alloca(strlen(prl) + 1); + path = strdupa(prl); if (path == NULL) return (PICL_FAILURE); - (void) strcpy(path, prl); - plist = NULL; nodename = NULL; baddr = NULL; @@ -2912,10 +2907,9 @@ int npflg; /* namepath flag */ - path = alloca(strlen(piclprl) + 1); + path = strdupa(piclprl); if (path == NULL) return (PICL_FAILURE); - (void) strcpy(path, piclprl); npflg = 1; /* default */ defprop = path;
--- a/usr/src/lib/libproc/common/proc_arg.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libproc/common/proc_arg.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> @@ -180,8 +179,7 @@ *perr = G_BADLWPS; return (NULL); } - core = alloca(strlen(arg) + 1); - (void) strcpy(core, arg); + core = strdupa(arg); if ((Pr = Pfgrab_core(fd, path == NULL ? dirname(core) : path, perr)) != NULL) { if (psp) { @@ -216,8 +214,7 @@ } if ((oflag & PR_ARG_CORES) && (fd = open_core(arg, perr)) != -1) { - core = alloca(strlen(arg) + 1); - (void) strcpy(core, arg); + core = strdupa(arg); if ((Pr = Pfgrab_core(fd, path == NULL ? dirname(core) : path, perr)) != NULL) { if (psp) {
--- a/usr/src/lib/libproc/common/proc_names.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libproc/common/proc_names.c Thu Aug 12 14:55:22 2010 -0700 @@ -28,7 +28,6 @@ #include <string.h> #undef __EXTENSIONS__ #include <signal.h> -#include <alloca.h> #include <errno.h> #include "libproc.h" @@ -613,7 +612,7 @@ char * proc_str2fltset(const char *s, const char *delim, int m, fltset_t *set) { - char *p, *q, *t = alloca(strlen(s) + 1); + char *p, *q, *t; int flt; if (m) { @@ -622,7 +621,7 @@ prfillset(set); } - (void) strcpy(t, s); + t = strdupa(s); for (p = strtok_r(t, delim, &q); p != NULL; p = strtok_r(NULL, delim, &q)) { @@ -646,7 +645,7 @@ char * proc_str2sigset(const char *s, const char *delim, int m, sigset_t *set) { - char *p, *q, *t = alloca(strlen(s) + 1); + char *p, *q, *t; int sig; if (m) { @@ -655,7 +654,7 @@ prfillset(set); } - (void) strcpy(t, s); + t = strdupa(s); for (p = strtok_r(t, delim, &q); p != NULL; p = strtok_r(NULL, delim, &q)) { @@ -679,7 +678,7 @@ char * proc_str2sysset(const char *s, const char *delim, int m, sysset_t *set) { - char *p, *q, *t = alloca(strlen(s) + 1); + char *p, *q, *t; int sys; if (m) { @@ -688,7 +687,7 @@ prfillset(set); } - (void) strcpy(t, s); + t = strdupa(s); for (p = strtok_r(t, delim, &q); p != NULL; p = strtok_r(NULL, delim, &q)) {
--- a/usr/src/lib/libresolv2/include/port_after.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/libresolv2/include/port_after.h Thu Aug 12 14:55:22 2010 -0700 @@ -1,9 +1,7 @@ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. */ - /* * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2001-2003 Internet Software Consortium. @@ -65,7 +63,7 @@ #undef HAS_IN_ADDR6 #define HAVE_SOCKADDR_STORAGE 1 #undef NEED_GETTIMEOFDAY -#undef HAVE_STRNDUP +#define HAVE_STRNDUP #undef USE_FIONBIO_IOCTL #undef INNETGR_ARGS @@ -538,4 +536,4 @@ /* Solaris-specific changes */ #include "sunw_port_after.h" -#endif +#endif /* port_after_h */
--- a/usr/src/lib/nsswitch/files/common/gethostent.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/nsswitch/files/common/gethostent.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <netdb.h> #include "files_common.h" #include <string.h> @@ -42,7 +39,6 @@ static int check_name(nss_XbyY_args_t *, const char *, int, int, const char **, int *, void *, int *); static char *do_aliases(); -static char *strcasestr(const char *as1, const char *as2); nss_status_t __nss_files_XY_hostbyname(); int __nss_files_2herrno(); static int __nss_files_get_addr(int, const char *, int, @@ -680,37 +676,6 @@ return (res); } -/* - * A case-insensitive version of strstr(). - */ -static char * -strcasestr(const char *as1, const char *as2) -{ - int c2; - register const char *tptr; - register const char *s1, *s2; - - s1 = as1; - s2 = as2; - - if (s2 == NULL || *s2 == '\0') - return (0); - - while (*s1) { - if (tolower(*s1++) == tolower(c2 = *s2)) { - tptr = s1; - while ((tolower(c2 = *++s2) == - tolower(*s1++)) && c2 != 0) - ; - if (c2 == 0) - return ((char *)tptr - 1); - s1 = tptr; - s2 = as2; - } - } - return (0); -} - static char * do_aliases(struct hostent *hp, char *abuf, char *end)
--- a/usr/src/lib/print/libpapi-common/common/uri.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/print/libpapi-common/common/uri.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,9 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ /* $Id: uri.c 146 2006-03-24 00:26:54Z njacobs $ */ @@ -37,23 +35,6 @@ #include <errno.h> #include "uri.h" -static char * -strndup(char *string, size_t length) -{ - char *result = NULL; - - if (length > 0) { - length++; - - - if ((result = calloc(1, length)) != NULL) - (void) strlcat(result, string, length); - } - - return (result); -} - - /* * This will handle the following forms: * scheme:scheme_data @@ -91,7 +72,8 @@ string = ptr + 3; /* skip the :// */ if ((path = end = strchr(string, '/')) == NULL) - for (end = string; *end != '\0'; end++); + for (end = string; *end != '\0'; end++) + continue; u->host_part = strndup(string, end - string); @@ -101,7 +83,7 @@ u->user_part = strndup(string, host-string); /* host+1 to end is the host part */ u->host_part = strndup(host + 1, - end - (host+1)); + end - (host+1)); user = string; host++; break; @@ -113,7 +95,7 @@ for (password = user; (password < host - 1); password++) if (*password == ':') { u->password = strndup(password + 1, - host - password - 2); + host - password - 2); break; } u->user = strndup(user, password - user); @@ -146,13 +128,15 @@ if ((query != NULL) && (*query != '\0')) { u->query = strdup(query + 1); end = query; - } else - for (end = path; *end != '\0'; end++); + } else { + for (end = path; *end != '\0'; end++) + continue; + } fragment = strrchr(name, '#'); if ((fragment != NULL) && (*fragment != '\0')) { u->fragment = strndup(fragment + 1, - end - fragment - 1); + end - fragment - 1); end = fragment; } @@ -215,7 +199,7 @@ (uri->query ? uri->query : "")); } else { (void) snprintf(buffer, buflen, "%s:%s", uri->scheme, - uri->scheme_part); + uri->scheme_part); } return (0);
--- a/usr/src/lib/scsi/libses/common/ses_plugin.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/scsi/libses/common/ses_plugin.c Thu Aug 12 14:55:22 2010 -0700 @@ -313,12 +313,9 @@ * Create a local copy of the vendor/product/revision, strip out any * questionable characters, and then attempt to load each plugin. */ - vendor = alloca(strlen(libscsi_vendor(tp->st_target)) + 1); - product = alloca(strlen(libscsi_product(tp->st_target)) + 1); - revision = alloca(strlen(libscsi_revision(tp->st_target)) + 1); - (void) strcpy(vendor, libscsi_vendor(tp->st_target)); - (void) strcpy(product, libscsi_product(tp->st_target)); - (void) strcpy(revision, libscsi_revision(tp->st_target)); + vendor = strdupa(libscsi_vendor(tp->st_target)); + product = strdupa(libscsi_product(tp->st_target)); + revision = strdupa(libscsi_revision(tp->st_target)); ses_plugin_cleanstr(vendor); ses_plugin_cleanstr(product);
--- a/usr/src/lib/scsi/libsmp/common/smp_plugin.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/scsi/libsmp/common/smp_plugin.c Thu Aug 12 14:55:22 2010 -0700 @@ -31,7 +31,6 @@ #include <scsi/libsmp.h> #include <scsi/libsmp_plugin.h> -#include <alloca.h> #include <dlfcn.h> #include <link.h> #include <dirent.h> @@ -319,18 +318,13 @@ return (0); if (tp->st_component_vendor != NULL) { - c_vendor = alloca(strlen(tp->st_component_vendor) + 1); - (void) strcpy(c_vendor, tp->st_component_vendor); + c_vendor = strdupa(tp->st_component_vendor); smp_plugin_cleanstr(c_vendor); } - vendor = alloca(strlen(tp->st_vendor) + 1); - product = alloca(strlen(tp->st_product) + 1); - revision = alloca(strlen(tp->st_revision) + 1); - - (void) strcpy(vendor, tp->st_vendor); - (void) strcpy(product, tp->st_product); - (void) strcpy(revision, tp->st_revision); + vendor = strdupa(tp->st_vendor); + product = strdupa(tp->st_product); + revision = strdupa(tp->st_revision); smp_plugin_cleanstr(vendor); smp_plugin_cleanstr(product);
--- a/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile Thu Aug 12 14:55:22 2010 -0700 @@ -19,14 +19,16 @@ # CDDL HEADER END # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # include ../Makefile.com +# With compiling with gcc, the symbol table goes over +# the limit for Kpic, so we add -KPIC here. +$(__GNUC)sparc_C_PICFLAGS = -K PIC +$(__GNUC)sparc_CC_PICFLAGS = -KPIC + DYNFLAGS += -R/usr/lib/smbsrv install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
--- a/usr/src/tools/cscope-fast/command.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/tools/cscope-fast/command.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ /* * cscope - interactive C symbol or text cross-reference @@ -235,7 +231,7 @@ } if (c != '\r' && c != '\n' && c != KEY_ENTER && c != KEY_BREAK && - getline(newpat, COLS - sizeof (appendprompt), c, + getaline(newpat, COLS - sizeof (appendprompt), c, NO) > 0) { shellpath(filename, sizeof (filename), newpat); if ((file = fopen(filename, s)) == NULL) { @@ -256,7 +252,7 @@ case '<': /* read lines from a file */ (void) move(PRLINE, 0); (void) addstr(readprompt); - if (getline(newpat, COLS - sizeof (readprompt), '\0', + if (getaline(newpat, COLS - sizeof (readprompt), '\0', NO) > 0) { clearprompt(); shellpath(filename, sizeof (filename), newpat); @@ -278,7 +274,7 @@ /* get the shell command */ (void) move(PRLINE, 0); (void) addstr(pipeprompt); - if (getline(newpat, + if (getaline(newpat, COLS - sizeof (pipeprompt), '\0', NO) == 0) { clearprompt(); return (NO); @@ -391,7 +387,7 @@ } else { (void) move(PRLINE, 0); (void) addstr(selectionprompt); - if (getline(newpat, + if (getaline(newpat, COLS - sizeof (selectionprompt), commandc, NO) > 0 && (i = atoi(newpat)) > 0) { @@ -402,7 +398,7 @@ } else if (isprint(commandc)) { /* this is the start of a pattern */ ispat: - if (getline(newpat, COLS - fldcolumn - 1, commandc, + if (getaline(newpat, COLS - fldcolumn - 1, commandc, caseless) > 0) { (void) strcpy(pattern, newpat); resetcmd(); /* reset history */ @@ -412,7 +408,7 @@ /* prompt for the new text */ (void) move(PRLINE, 0); (void) addstr(toprompt); - (void) getline(newpat, + (void) getaline(newpat, COLS - sizeof (toprompt), '\0', NO); } /* search for the pattern */ @@ -594,7 +590,7 @@ clearprompt(); (void) move(PRLINE, 0); (void) addstr(selectionprompt); - if (getline(buf, + if (getaline(buf, COLS - sizeof (selectionprompt), c, NO) > 0 && (i = atoi(buf)) > 0) {
--- a/usr/src/tools/cscope-fast/global.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/tools/cscope-fast/global.h Thu Aug 12 14:55:22 2010 -0700 @@ -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,23 +18,20 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - /* * cscope - interactive C symbol cross-reference * * global type, data, and function definitions */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - #include <ctype.h> /* isalpha, isdigit, etc. */ #include <signal.h> /* SIGINT and SIGQUIT */ #include <stdio.h> /* standard I/O package */ @@ -273,7 +269,7 @@ void catchint(int sig); int ungetch(int c); int mygetch(void); -int getline(char s[], size_t size, int firstchar, BOOL iscaseless); +int getaline(char s[], size_t size, int firstchar, BOOL iscaseless); void askforchar(void); void askforreturn(void); void shellpath(char *out, int limit, char *in);
--- a/usr/src/tools/cscope-fast/input.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/tools/cscope-fast/input.c Thu Aug 12 14:55:22 2010 -0700 @@ -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,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ /* * cscope - interactive C symbol cross-reference @@ -91,7 +87,7 @@ /* get a line from the terminal in non-canonical mode */ int -getline(char s[], size_t size, int firstchar, BOOL iscaseless) +getaline(char s[], size_t size, int firstchar, BOOL iscaseless) { int c, i = 0; int j;
--- a/usr/src/ucbcmd/users/users.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/ucbcmd/users/users.c Thu Aug 12 14:55:22 2010 -0700 @@ -1,20 +1,16 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * users */ @@ -28,7 +24,6 @@ static char **names; static char **namp; -static char *strndup(char *p, int n); static int scmp(const void *p, const void *q); static void summary(void); @@ -59,7 +54,7 @@ if (nusers == bufflen) { bufflen *= 2; names = (char **)realloc(names, - bufflen * sizeof (char *)); + bufflen * sizeof (char *)); namp = names + nusers; } *namp++ = strndup(utmpx->ut_name, sizeof (utmpx->ut_name)); @@ -72,17 +67,6 @@ return (0); } -static char * -strndup(char *p, int n) -{ - - register char *x; - x = malloc(n + 1); - (void) strlcpy(x, p, n + 1); - return (x); - -} - static int scmp(const void *p, const void *q) {
--- a/usr/src/uts/common/inet/ipf/ipf.h Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/uts/common/inet/ipf/ipf.h Thu Aug 12 14:55:22 2010 -0700 @@ -6,15 +6,12 @@ * @(#)ipf.h 1.12 6/5/96 * $Id: ipf.h,v 2.71.2.7 2005/06/12 07:18:31 darrenr Exp $ * - * 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. */ #ifndef __IPF_H__ #define __IPF_H__ -#pragma ident "%Z%%M% %I% %E% SMI" - #if defined(__osf__) # define radix_mask ipf_radix_mask # define radix_node ipf_radix_node @@ -208,7 +205,7 @@ extern int getport __P((struct frentry *, char *, u_short *)); extern int getportproto __P((char *, int)); extern int getproto __P((char *)); -extern char *getline __P((char *, size_t, FILE *, int *)); +extern char *getaline __P((char *, size_t, FILE *, int *)); extern int genmask __P((char *, u_32_t *)); extern char *getnattype __P((struct nat *, int)); extern char *getsumd __P((u_32_t));
--- a/usr/src/uts/common/io/audio/drv/audioemu10k/dsp/asm10k.c Thu Aug 12 14:07:03 2010 -0700 +++ b/usr/src/uts/common/io/audio/drv/audioemu10k/dsp/asm10k.c Thu Aug 12 14:55:22 2010 -0700 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -167,7 +166,7 @@ static char *infile; static int -getline(FILE *input, char **tokens) +getaline(FILE *input, char **tokens) { char *s, *ls; static char *stmt = NULL, *lasts = NULL; @@ -1040,7 +1039,7 @@ init_compiler(); - while ((tokcnt = getline(input, tokens)) != -1) { + while ((tokcnt = getaline(input, tokens)) != -1) { /* skip empty lines */ if (tokcnt == 0) { continue;