From caf8efd320929b6917032847aa4fa79fe76cfb45 Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Sat, 27 Jan 2018 20:09:52 +0200 Subject: [PATCH] libc: add strtonum(3) from openbsd. mdb, zfs and some fm topo code had their own strtonum()s which were renamed. --- include/stdlib.h | 1 + kernel/fs/zfs/dsl_deadlist.c | 4 +- kernel/fs/zfs/dsl_scan.c | 2 +- kernel/fs/zfs/dsl_userhold.c | 2 +- kernel/fs/zfs/spa_errlog.c | 8 +- kernel/fs/zfs/spa_misc.c | 2 +- kernel/fs/zfs/sys/spa.h | 2 +- kernel/fs/zfs/zfs_vfsops.c | 2 +- lib/libc/Makefile | 2 +- lib/libc/strtonum.3 | 152 +++++++++++++++++++++++ usr/src/cmd/mdb/common/mdb/mdb_cmds.c | 2 +- usr/src/cmd/mdb/common/mdb/mdb_evset.c | 2 +- usr/src/cmd/mdb/common/mdb/mdb_lex.l | 14 +-- usr/src/cmd/mdb/common/mdb/mdb_modapi.c | 2 +- usr/src/cmd/mdb/common/mdb/mdb_string.c | 2 +- usr/src/cmd/mdb/common/mdb/mdb_string.h | 2 +- usr/src/lib/fm/topo/modules/common/pcibus/util.c | 2 +- usr/src/lib/fm/topo/modules/common/pcibus/util.h | 2 +- usr/src/lib/libc/amd64/Makefile | 1 + usr/src/lib/libc/i386/Makefile.com | 1 + usr/src/lib/libc/port/gen/strtonum.c | 65 ++++++++++ usr/src/lib/libc/port/mapfile-vers | 1 + usr/src/pkg/manifests/system-library.man3.inc | 1 + 23 files changed, 248 insertions(+), 26 deletions(-) create mode 100644 lib/libc/strtonum.3 create mode 100644 usr/src/lib/libc/port/gen/strtonum.c diff --git a/include/stdlib.h b/include/stdlib.h index fb76d2b982..b330087809 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -286,6 +286,7 @@ extern char *ulltostr(unsigned long long, char *); extern uint32_t arc4random(void); extern void arc4random_buf(void *, size_t); extern uint32_t arc4random_uniform(uint32_t); +long long strtonum(const char *, long long, long long, const char **); #endif /* !_STRICT_SYBMOLS */ diff --git a/kernel/fs/zfs/dsl_deadlist.c b/kernel/fs/zfs/dsl_deadlist.c index 203815a750..ff06c9e93c 100644 --- a/kernel/fs/zfs/dsl_deadlist.c +++ b/kernel/fs/zfs/dsl_deadlist.c @@ -85,7 +85,7 @@ dsl_deadlist_load_tree(dsl_deadlist_t *dl) zap_cursor_retrieve(&zc, &za) == 0; zap_cursor_advance(&zc)) { dsl_deadlist_entry_t *dle = kmem_alloc(sizeof (*dle), KM_SLEEP); - dle->dle_mintxg = strtonum(za.za_name, NULL); + dle->dle_mintxg = zfs_strtonum(za.za_name, NULL); VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, za.za_first_integer)); avl_add(&dl->dl_tree, dle); @@ -490,7 +490,7 @@ dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx) for (zap_cursor_init(&zc, dl->dl_os, obj); zap_cursor_retrieve(&zc, &za) == 0; zap_cursor_advance(&zc)) { - uint64_t mintxg = strtonum(za.za_name, NULL); + uint64_t mintxg = zfs_strtonum(za.za_name, NULL); dsl_deadlist_insert_bpobj(dl, za.za_first_integer, mintxg, tx); VERIFY3U(0, ==, zap_remove_int(dl->dl_os, obj, mintxg, tx)); } diff --git a/kernel/fs/zfs/dsl_scan.c b/kernel/fs/zfs/dsl_scan.c index e476689e40..ccd9eb4c39 100644 --- a/kernel/fs/zfs/dsl_scan.c +++ b/kernel/fs/zfs/dsl_scan.c @@ -1365,7 +1365,7 @@ dsl_scan_visit(dsl_scan_t *scn, dmu_tx_t *tx) dsl_dataset_t *ds; uint64_t dsobj; - dsobj = strtonum(za.za_name, NULL); + dsobj = zfs_strtonum(za.za_name, NULL); VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, scn->scn_phys.scn_queue_obj, dsobj, tx)); diff --git a/kernel/fs/zfs/dsl_userhold.c b/kernel/fs/zfs/dsl_userhold.c index 54a15e1669..a0484a0cd9 100644 --- a/kernel/fs/zfs/dsl_userhold.c +++ b/kernel/fs/zfs/dsl_userhold.c @@ -340,7 +340,7 @@ static int dsl_dataset_hold_obj_string(dsl_pool_t *dp, const char *dsobj, void *tag, dsl_dataset_t **dsp) { - return (dsl_dataset_hold_obj(dp, strtonum(dsobj, NULL), tag, dsp)); + return (dsl_dataset_hold_obj(dp, zfs_strtonum(dsobj, NULL), tag, dsp)); } static int diff --git a/kernel/fs/zfs/spa_errlog.c b/kernel/fs/zfs/spa_errlog.c index 168f3acc2e..8ce780537a 100644 --- a/kernel/fs/zfs/spa_errlog.c +++ b/kernel/fs/zfs/spa_errlog.c @@ -73,13 +73,13 @@ bookmark_to_name(zbookmark_phys_t *zb, char *buf, size_t len) static void name_to_bookmark(char *buf, zbookmark_phys_t *zb) { - zb->zb_objset = strtonum(buf, &buf); + zb->zb_objset = zfs_strtonum(buf, &buf); ASSERT(*buf == ':'); - zb->zb_object = strtonum(buf + 1, &buf); + zb->zb_object = zfs_strtonum(buf + 1, &buf); ASSERT(*buf == ':'); - zb->zb_level = (int)strtonum(buf + 1, &buf); + zb->zb_level = (int)zfs_strtonum(buf + 1, &buf); ASSERT(*buf == ':'); - zb->zb_blkid = strtonum(buf + 1, &buf); + zb->zb_blkid = zfs_strtonum(buf + 1, &buf); ASSERT(*buf == '\0'); } #endif diff --git a/kernel/fs/zfs/spa_misc.c b/kernel/fs/zfs/spa_misc.c index 1aebbca741..6555d4eee5 100644 --- a/kernel/fs/zfs/spa_misc.c +++ b/kernel/fs/zfs/spa_misc.c @@ -1481,7 +1481,7 @@ zfs_panic_recover(const char *fmt, ...) * lowercase hexadecimal numbers that don't overflow. */ uint64_t -strtonum(const char *str, char **nptr) +zfs_strtonum(const char *str, char **nptr) { uint64_t val = 0; char c; diff --git a/kernel/fs/zfs/sys/spa.h b/kernel/fs/zfs/sys/spa.h index c96c001da5..0243c3effd 100644 --- a/kernel/fs/zfs/sys/spa.h +++ b/kernel/fs/zfs/sys/spa.h @@ -829,7 +829,7 @@ extern int spa_maxblocksize(spa_t *spa); extern void zfs_blkptr_verify(spa_t *spa, const blkptr_t *bp); extern int spa_mode(spa_t *spa); -extern uint64_t strtonum(const char *str, char **nptr); +extern uint64_t zfs_strtonum(const char *str, char **nptr); extern char *spa_his_ievent_table[]; diff --git a/kernel/fs/zfs/zfs_vfsops.c b/kernel/fs/zfs/zfs_vfsops.c index b2b5e086b9..c3ce34aba2 100644 --- a/kernel/fs/zfs/zfs_vfsops.c +++ b/kernel/fs/zfs/zfs_vfsops.c @@ -629,7 +629,7 @@ fuidstr_to_sid(zfsvfs_t *zfsvfs, const char *fuidstr, uint64_t fuid; const char *domain; - fuid = strtonum(fuidstr, NULL); + fuid = zfs_strtonum(fuidstr, NULL); domain = zfs_fuid_find_by_idx(zfsvfs, FUID_INDEX(fuid)); if (domain) diff --git a/lib/libc/Makefile b/lib/libc/Makefile index ef31b8d91f..9f1ab963cd 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -1,7 +1,7 @@ MAN= accept.2 bind.2 connect.2 getpeername.2 getsockname.2 getsockopt.2 \ listen.2 recv.2 send.2 shutdown.2 socket.2 socketpair.2 \ CMSG_DATA.3 alloca.3 err.3 fts.3 malloc.3 readdir.3 sockatmark.3 \ - posix_memalign.3 setmode.3 valloc.3 uname.3 unvis.3 vis.3 + strtonum.3 posix_memalign.3 setmode.3 valloc.3 uname.3 unvis.3 vis.3 # no source yet. NOOBJ= diff --git a/lib/libc/strtonum.3 b/lib/libc/strtonum.3 new file mode 100644 index 0000000000..43df0edc78 --- /dev/null +++ b/lib/libc/strtonum.3 @@ -0,0 +1,152 @@ +.\" $OpenBSD: strtonum.3,v 1.18 2016/02/07 20:50:24 mmcc Exp $ +.\" +.\" Copyright (c) 2004 Ted Unangst +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: February 7 2016 $ +.Dt STRTONUM 3 +.Os +.Sh NAME +.Nm strtonum +.Nd reliably convert string value to an integer +.Sh SYNOPSIS +.In stdlib.h +.Ft long long +.Fo strtonum +.Fa "const char *nptr" +.Fa "long long minval" +.Fa "long long maxval" +.Fa "const char **errstr" +.Fc +.Sh DESCRIPTION +The +.Fn strtonum +function converts the string in +.Fa nptr +to a +.Li long long +value. +The +.Fn strtonum +function was designed to facilitate safe, robust programming +and overcome the shortcomings of the +.Xr atoi 3 +and +.Xr strtol 3 +family of interfaces. +.Pp +The string may begin with an arbitrary amount of whitespace +(as determined by +.Xr isspace 3 ) +followed by a single optional +.Ql + +or +.Ql - +sign. +.Pp +The remainder of the string is converted to a +.Li long long +value according to base 10. +.Pp +The value obtained is then checked against the provided +.Fa minval +and +.Fa maxval +bounds. +If +.Fa errstr +is non-null, +.Fn strtonum +stores an error string in +.Fa *errstr +indicating the failure. +.Sh RETURN VALUES +The +.Fn strtonum +function returns the result of the conversion, +unless the value would exceed the provided bounds or is invalid. +On error, 0 is returned, +.Va errno +is set, and +.Fa errstr +will point to an error message. +.Fa *errstr +will be set to +.Dv NULL +on success; +this fact can be used to differentiate +a successful return of 0 from an error. +.Sh EXAMPLES +Using +.Fn strtonum +correctly is meant to be simpler than the alternative functions. +.Bd -literal -offset indent +int iterations; +const char *errstr; + +iterations = strtonum(optarg, 1, 64, &errstr); +if (errstr != NULL) + errx(1, "number of iterations is %s: %s", errstr, optarg); +.Ed +.Pp +The above example will guarantee that the value of iterations is between +1 and 64 (inclusive). +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ERANGE +The given string was out of range. +.It Bq Er EINVAL +The given string did not consist solely of digit characters. +.It Bq Er EINVAL +.Ar minval +was larger than +.Ar maxval . +.El +.Pp +If an error occurs, +.Fa errstr +will be set to one of the following strings: +.Pp +.Bl -tag -width "too largeXX" -compact +.It Qq too large +The result was larger than the provided maximum value. +.It Qq too small +The result was smaller than the provided minimum value. +.It Qq invalid +The string did not consist solely of digit characters. +.El +.Sh SEE ALSO +.Xr atof 3 , +.Xr atoi 3 , +.Xr atol 3 , +.Xr atoll 3 , +.Xr sscanf 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +.Fn strtonum +is an +.Ox +extension. +The existing alternatives, such as +.Xr atoi 3 +and +.Xr strtol 3 , +are either impossible or difficult to use safely. +.Sh HISTORY +The +.Fn strtonum +function first appeared in +.Ox 3.6 . diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c index 646f2f7b34..537c96ff13 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c @@ -2550,7 +2550,7 @@ cmd_delete(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) spec.spec_base = mdb_get_dot(); else if (argv->a_type == MDB_TYPE_STRING && strcmp(argv->a_un.a_str, "all") != 0) - spec.spec_id = (int)(intmax_t)strtonum(argv->a_un.a_str, 10); + spec.spec_id = (int)(intmax_t)mdb_strtonum(argv->a_un.a_str, 10); else if (argv->a_type == MDB_TYPE_IMMEDIATE) spec.spec_id = (int)(intmax_t)argv->a_un.a_val; diff --git a/usr/src/cmd/mdb/common/mdb/mdb_evset.c b/usr/src/cmd/mdb/common/mdb/mdb_evset.c index a30b29b6c8..09e8f96615 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_evset.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_evset.c @@ -110,7 +110,7 @@ cmd_evset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) } } else if (argv->a_un.a_str[0] != '-') { idv[idc++] = (int)(intmax_t) - strtonum(argv->a_un.a_str, 10); + mdb_strtonum(argv->a_un.a_str, 10); } else return (DCMD_USAGE); } else diff --git a/usr/src/cmd/mdb/common/mdb/mdb_lex.l b/usr/src/cmd/mdb/common/mdb/mdb_lex.l index 60e3b4cced..fceb68ee3a 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_lex.l +++ b/usr/src/cmd/mdb/common/mdb/mdb_lex.l @@ -318,7 +318,7 @@ RGX_COMMENT "//".*\n * Immediate value -- in the format list, all immediates * are assumed to be in decimal. */ - yylval.l_immediate = strtonum(yytext, 10); + yylval.l_immediate = mdb_strtonum(yytext, 10); return (MDB_TOK_IMMEDIATE); } @@ -417,7 +417,7 @@ RGX_COMMENT "//".*\n /* * Binary immediate value. */ - yylval.l_immediate = strtonum(yytext + 2, 2); + yylval.l_immediate = mdb_strtonum(yytext + 2, 2); return (MDB_TOK_IMMEDIATE); } @@ -426,7 +426,7 @@ RGX_COMMENT "//".*\n /* * Octal immediate value. */ - yylval.l_immediate = strtonum(yytext + 2, 8); + yylval.l_immediate = mdb_strtonum(yytext + 2, 8); return (MDB_TOK_IMMEDIATE); } @@ -445,7 +445,7 @@ RGX_COMMENT "//".*\n if ((p = strsplit(yytext, '.')) == NULL) yyerror("internal scanning error -- expected '.'\n"); - d = (double)strtonum(yytext + 2, 10); + d = (double)mdb_strtonum(yytext + 2, 10); for (i = 0; (c = *p++) != '\0'; i++) d = d * 10 + c - '0'; @@ -463,7 +463,7 @@ RGX_COMMENT "//".*\n /* * Decimal immediate value. */ - yylval.l_immediate = strtonum(yytext + 2, 10); + yylval.l_immediate = mdb_strtonum(yytext + 2, 10); return (MDB_TOK_IMMEDIATE); } @@ -472,7 +472,7 @@ RGX_COMMENT "//".*\n /* * Hexadecimal value. */ - yylval.l_immediate = strtonum(yytext + 2, 16); + yylval.l_immediate = mdb_strtonum(yytext + 2, 16); return (MDB_TOK_IMMEDIATE); } @@ -490,7 +490,7 @@ RGX_COMMENT "//".*\n MDB_TGT_OBJ_EVERY, yytext, &sym, NULL) == 0) yylval.l_immediate = (uintmax_t)sym.st_value; else - yylval.l_immediate = strtonum(yytext, mdb.m_radix); + yylval.l_immediate = mdb_strtonum(yytext, mdb.m_radix); return (MDB_TOK_IMMEDIATE); } diff --git a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c index e1a5dd09ba..b87b2162c3 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c @@ -246,7 +246,7 @@ mdb_strtoull(const char *s) } } - return (strtonum(s, radix)); + return (mdb_strtonum(s, radix)); } size_t diff --git a/usr/src/cmd/mdb/common/mdb/mdb_string.c b/usr/src/cmd/mdb/common/mdb/mdb_string.c index b961114f2b..92a0a3f888 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_string.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_string.c @@ -110,7 +110,7 @@ numtostr(uintmax_t uvalue, int base, uint_t flags) * error message and longjmp back to the main loop using yyerror(). */ uintmax_t -strtonum(const char *s, int base) +mdb_strtonum(const char *s, int base) { uintmax_t multmax = (uintmax_t)ULLONG_MAX / (uintmax_t)(uint_t)base; uintmax_t val = 0; diff --git a/usr/src/cmd/mdb/common/mdb/mdb_string.h b/usr/src/cmd/mdb/common/mdb/mdb_string.h index 2373103423..571af93317 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_string.h +++ b/usr/src/cmd/mdb/common/mdb/mdb_string.h @@ -42,7 +42,7 @@ extern "C" { #define NTOS_SHOWBASE 0x8 /* Show base under appropriate circumstances */ extern const char *numtostr(uintmax_t, int, uint_t); -extern uintmax_t strtonum(const char *, int); +extern uintmax_t mdb_strtonum(const char *, int); extern ulong_t strntoul(const char *, size_t, int); extern int strisnum(const char *); extern int strisbasenum(const char *); diff --git a/usr/src/lib/fm/topo/modules/common/pcibus/util.c b/usr/src/lib/fm/topo/modules/common/pcibus/util.c index cab50058ff..da45d52c4b 100644 --- a/usr/src/lib/fm/topo/modules/common/pcibus/util.c +++ b/usr/src/lib/fm/topo/modules/common/pcibus/util.c @@ -50,7 +50,7 @@ child_range_add(topo_mod_t *mp, tnode_t *tn, const char *cnm, } ulong_t -strtonum(topo_mod_t *mp, char *str, int *err) +topo_strtonum(topo_mod_t *mp, char *str, int *err) { ulong_t r; char *e; diff --git a/usr/src/lib/fm/topo/modules/common/pcibus/util.h b/usr/src/lib/fm/topo/modules/common/pcibus/util.h index 8dda2b6304..c6ed8b8b17 100644 --- a/usr/src/lib/fm/topo/modules/common/pcibus/util.h +++ b/usr/src/lib/fm/topo/modules/common/pcibus/util.h @@ -39,7 +39,7 @@ extern int child_range_add(topo_mod_t *, tnode_t *, const char *, topo_instance_t, topo_instance_t); extern int labelmethod_inherit(topo_mod_t *, tnode_t *, nvlist_t *, nvlist_t **); -extern ulong_t strtonum(topo_mod_t *, char *, int *); +extern ulong_t topo_strtonum(topo_mod_t *, char *, int *); extern tnode_t *tnode_create(topo_mod_t *, tnode_t *, const char *, topo_instance_t, void *); diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index 22ebe4915b..81237dc6f5 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -559,6 +559,7 @@ PORTGEN= \ strtoimax.o \ strtok.o \ strtok_r.o \ + strtonum.o \ strtoumax.o \ swab.o \ swapctl.o \ diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index 355a8e2eca..89163635f5 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -596,6 +596,7 @@ PORTGEN= \ strtoimax.o \ strtok.o \ strtok_r.o \ + strtonum.o \ strtoumax.o \ swab.o \ swapctl.o \ diff --git a/usr/src/lib/libc/port/gen/strtonum.c b/usr/src/lib/libc/port/gen/strtonum.c new file mode 100644 index 0000000000..fdfc72aa77 --- /dev/null +++ b/usr/src/lib/libc/port/gen/strtonum.c @@ -0,0 +1,65 @@ +/* $OpenBSD: strtonum.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */ + +/* + * Copyright (c) 2004 Ted Unangst and Todd Miller + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +#define INVALID 1 +#define TOOSMALL 2 +#define TOOLARGE 3 + +long long +strtonum(const char *numstr, long long minval, long long maxval, + const char **errstrp) +{ + long long ll = 0; + int error = 0; + char *ep; + struct errval { + const char *errstr; + int err; + } ev[4] = { + { NULL, 0 }, + { "invalid", EINVAL }, + { "too small", ERANGE }, + { "too large", ERANGE }, + }; + + ev[0].err = errno; + errno = 0; + if (minval > maxval) { + error = INVALID; + } else { + ll = strtoll(numstr, &ep, 10); + if (numstr == ep || *ep != '\0') + error = INVALID; + else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval) + error = TOOSMALL; + else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval) + error = TOOLARGE; + } + if (errstrp != NULL) + *errstrp = ev[error].errstr; + errno = ev[error].err; + if (error) + ll = 0; + + return (ll); +} diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index 027905bb48..ef66eba533 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -4076,6 +4076,7 @@ $endif getmode; b64_ntop; b64_pton; + strtonum; global: # FIXME: new symbols for our OS, but here pending a name. diff --git a/usr/src/pkg/manifests/system-library.man3.inc b/usr/src/pkg/manifests/system-library.man3.inc index 7daff3905e..474f35d7ac 100644 --- a/usr/src/pkg/manifests/system-library.man3.inc +++ b/usr/src/pkg/manifests/system-library.man3.inc @@ -24,6 +24,7 @@ file path=usr/share/man/man3/alloca.3 file path=usr/share/man/man3/malloc.3 file path=usr/share/man/man3/posix_memalign.3 file path=usr/share/man/man3/setmode.3 +file path=usr/share/man/man3/strtonum.3 file path=usr/share/man/man3/uname.3 file path=usr/share/man/man3/unvis.3 file path=usr/share/man/man3/valloc.3 -- 2.11.4.GIT