As a result of suggestions made in the email for this case,
I am sending this revised, final version of the proposal
(with additional bugids included and with the description
of getprogname(), setprogname() and __progname included):

===================================================================

1.  Introduction

    This case adds 30 new functions and one global variable
    to the C library, all in the name of compatibility with
    GNU/Linux and FreeBSD.

    The commitment level of the functional interfaces is Committed.

    The release binding is "minor" so they can be implemented
    in Solaris Next/11.  If anyone wants to back-port any of
    these functions to Solaris 10, they should file a separate
    ARC case.

2.  Discussion

    Over the last few years. there have been several bug reports
    (RFEs) filed requesting such functions for Solaris:

    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

    This case goes beyond the bare requests in these bug reports
    and provides generally-useful interfaces that are documented
    in GNU/Linux/BSD manual pages.

    In addition to existing in GNU/Linux/BSD manual pages, many
    of these functions are also specified in the new POSIX standard:
       IEEE Std 1003.1(TM)-2008
       The Open Group Technical Standard
       Base Specifications, Issue 7
    hereinafter referred to as SUSv4.

3.  Details

    Unless stated otherwise, all of the following functions
    are new functions being added to the C library.

    Many of these functions are specified in the new POSIX standard:
         IEEE Std 1003.1(TM)-2008
         The Open Group Technical Standard
         Base Specifications, Issue 7
    hereinafter referred to as SUSv4.

    Others are specified in GNU/Linux man pages or in
    OpenBSD man pages, indicated on a case-by-case basis.

    ===========================================================

    #include <string.h>

    char *strndup(const char *, size_t);
    char *stpcpy(char *restrict, const char *restrict);
    char *stpncpy(char *restrict, const char *restrict, size_t);

    char *strchrnul(const char *, int);
    char *strdupa(const char *);
    char *strndupa(const char *, size_t);

    char *strnstr(const char *s1, const char *s2, size_t n);
    char *strcasestr(const char *s1, const char *s2);

    The strndup(), stpcpy() and stpncpy() functions are specified in SUSv4.
    The strchrnul(). strdupa() and strndupa() functions are GNU/Linux
        extensions.
    The strnstr() and strcasestr() are FreeBSD extensions.

    ===========================================================

    These two existing functions, previously ASCII-only,
    become locale-dependent, as specified in SUSv4:

    #include <string.h>

    int strcasecmp(const char *s1, const char *s2)
    int strncasecmp(const char *s1, const char *s2, size_t n)

    ===========================================================

    #include <poll.h>

    int ppoll(struct pollfd *restrict fds, nfds_t nfds,
        const struct timespec *restrict timeout,
        const sigset_t *restrict sigmask);

    The ppoll() function is a GNU/Linux extension.

    ===========================================================

    #include <stdio.h>

    ssize_t getdelim(char **restrict, size_t *restrict,
            int, FILE *restrict);
    ssize_t getline(char **restrict, size_t *restrict,
            FILE *restrict);

    The getdelim() and getline() functions are specified in SUSv4.

    ===========================================================

    #include <string.h>

    void *memmem(const void *, size_t, const void *, size_t);

    The memmem() function is a GNU/Linux and FreeBSD extension.

    ===========================================================

    #include <stdio.h>

    int fcloseall(void);

    The fcloseall() function is a GNU/Linux and FreeBSD extension.

    ===========================================================

    #include <stdlib.h>

    int clearenv(void);

    The clearenv() function is a GNU/Linux extension.

    ===========================================================

    The semantics of the following existing function have
    changed a bit, as specified in SUSv4:

    #include <stdlib.h>

    char *realpath(const char *file_name, char *resolved_name);

    In particular, the semantics for 'resolved_name' being
    passed in as a NULL pointer have changed.
    Previously, this resulted in failure with errno == EINVAL.
    Now, realpath() allocates a buffer using malloc():
         If resolved_name is a null pointer, the generated pathname
         shall be stored as a null-terminated string in a buffer
         allocated as if by a call to malloc().

    ===========================================================

    #include <stdlib.h>

    char *canonicalize_file_name(const char *path);

    The canonicalize_file_name() function is a GNU/Linux extension.
    It is equivalent to realpath(path, NULL) (see above).

    ===========================================================

    #include <string.h>

    int ffsl(long);
    int ffsll(long long);
    int fls(int);
    int flsl(long);
    int flsll(long long);

    These functions are FreeBSD extensions.

    ===========================================================

    #include <stdlib.h>

    const char *getprogname(void);
    void setprogname(const char *progname);

    In addition, this global variable will be added to libc:
        const char *__progname;

    However, Following FreeBSD's lead, the __progname variable,
    even though it will exist, will not be declared in any header
    file, and it will be versioned as SUNWprivate_1.1.  Applications
    that want to use it will have to declare it explicitly.

    The getprogname() and setprogname() functions and the __progname
    global variable are FreeBSD extensions.

    ===========================================================

    #include <wchar.h>

    wchar_t *wcsdup(const wchar_t *);
    size_t wcsnlen(const wchar_t *, size_t);
    wchar_t *wcpcpy(wchar_t *restrict, const wchar_t *restrict);
    wchar_t *wcpncpy(wchar_t *restrict, const wchar_t *restrict, size_t);
    int wcscasecmp(const wchar_t *, const wchar_t *);
    int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);

    These functions are specified in SUSv4.

    ===========================================================

    int get_nprocs(void);
    int get_nprocs_conf(void);

    The get_nprocs() and get_nprocs_conf() are GNU/Linux extensions
    equivalent, respectively, to:
         sysconf(_SC_NPROCESSORS_ONLN);
         sysconf(_SC_NPROCESSORS_CONF);

    ===========================================================

    Since SUSv4 changes are being made to the system,
    the following definitions are being added to <unistd.h>,
    as specified in SUSv4, because these features already exist:

    _POSIX_THREAD_ROBUST_PRIO_INHERIT
        Implementation supports the Robust Mutex Priority Inheritance
        option.

    _POSIX_THREAD_ROBUST_PRIO_PROTECT
        Implementation supports the Robust Mutex Priority Protection
        option.

    _SC_THREAD_ROBUST_PRIO_INHERIT
    _SC_THREAD_ROBUST_PRIO_PROTECT

    ===========================================================

4.  Manual pages.

    New and modified manual pages will be created from the
    SUSv4 POSIX specifications where the relevant functions
    are defined therein, and from GNU/Linux and FreeBSD
    manual pages otherwise.

_______________________________________________
opensolaris-arc mailing list
opensolaris-arc@opensolaris.org

Reply via email to