Skip to content

Commit 07636f6

Browse files
committed
Auto merge of #3036 - LegionMammal978:iso-c-funcs, r=JohnTitor
Add missing string-to-number functions from ISO C These should be the observable API changes: - ISO C90 function `atol()` is added to all `fuchsia`, `unix`, `vxworks`, `wasi`, and `windows` targets. - ISO C90 function `atof()` is added to `android`, `redox`, and `vxworks`. - ISO C99 functions `atoll()`, `strtoll()`, and `strtoull()` are added to all `fuchsia`, `unix`, `vxworks`, `wasi`, and `windows` targets. Also, I wasn't exactly sure where to insert the new functions, so I just tried to place them near related functions.
2 parents 6a5c07f + 6a58758 commit 07636f6

File tree

22 files changed

+44
-16
lines changed

22 files changed

+44
-16
lines changed

libc-test/semver/android.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,7 +2854,10 @@ arphdr
28542854
arpreq
28552855
arpreq_old
28562856
atexit
2857+
atof
28572858
atoi
2859+
atol
2860+
atoll
28582861
bind
28592862
blkcnt_t
28602863
blksize_t
@@ -3504,7 +3507,9 @@ strtod
35043507
strtof
35053508
strtok
35063509
strtol
3510+
strtoll
35073511
strtoul
3512+
strtoull
35083513
strxfrm
35093514
suseconds_t
35103515
swapoff

libc-test/semver/apple.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,6 @@ arc4random
18181818
arc4random_buf
18191819
arc4random_uniform
18201820
arphdr
1821-
atof
18221821
attrgroup_t
18231822
attribute_set_t
18241823
attrlist

libc-test/semver/dragonfly.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,6 @@ arc4random
12211221
arc4random_buf
12221222
arc4random_uniform
12231223
arphdr
1224-
atof
12251224
backtrace
12261225
backtrace_symbols
12271226
backtrace_symbols_fd

libc-test/semver/freebsd.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,6 @@ arc4random
14931493
arc4random_buf
14941494
arc4random_uniform
14951495
arphdr
1496-
atof
14971496
au_asid_t
14981497
au_id_t
14991498
au_mask_t

libc-test/semver/fuchsia.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,9 @@ accept4
11681168
acct
11691169
aiocb
11701170
atof
1171+
atoi
1172+
atol
1173+
atoll
11711174
blkcnt64_t
11721175
brk
11731176
clearenv
@@ -1366,6 +1369,8 @@ stat64
13661369
statfs
13671370
statfs64
13681371
statvfs64
1372+
strtoll
1373+
strtoull
13691374
swapoff
13701375
swapon
13711376
sync

libc-test/semver/linux.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,6 @@ arpd_request
28682868
arphdr
28692869
arpreq
28702870
arpreq_old
2871-
atof
28722871
blkcnt64_t
28732872
brk
28742873
bsearch

libc-test/semver/netbsd.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,6 @@ arc4random
11661166
arc4random_buf
11671167
arc4random_uniform
11681168
arphdr
1169-
atof
11701169
bsearch
11711170
chflags
11721171
chroot

libc-test/semver/openbsd.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,6 @@ arc4random
977977
arc4random_buf
978978
arc4random_uniform
979979
arphdr
980-
atof
981980
backtrace
982981
backtrace_symbols
983982
backtrace_symbols_fd

libc-test/semver/unix.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,10 @@ access
451451
addrinfo
452452
alarm
453453
atexit
454+
atof
454455
atoi
456+
atol
457+
atoll
455458
bind
456459
blkcnt_t
457460
blksize_t
@@ -818,7 +821,9 @@ strtod
818821
strtof
819822
strtok
820823
strtol
824+
strtoll
821825
strtoul
826+
strtoull
822827
strxfrm
823828
suseconds_t
824829
symlink

libc-test/semver/windows.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ aligned_free
152152
atexit
153153
atof
154154
atoi
155+
atol
156+
atoll
155157
bind
156158
c_char
157159
c_double
@@ -307,7 +309,9 @@ strtod
307309
strtof
308310
strtok
309311
strtol
312+
strtoll
310313
strtoul
314+
strtoull
311315
strxfrm
312316
system
313317
time

src/fuchsia/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3402,11 +3402,16 @@ extern "C" {
34023402
pub fn feof(stream: *mut FILE) -> c_int;
34033403
pub fn ferror(stream: *mut FILE) -> c_int;
34043404
pub fn perror(s: *const c_char);
3405+
pub fn atof(s: *const c_char) -> c_double;
34053406
pub fn atoi(s: *const c_char) -> c_int;
3407+
pub fn atol(s: *const c_char) -> c_long;
3408+
pub fn atoll(s: *const c_char) -> c_longlong;
34063409
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
34073410
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
34083411
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
3412+
pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
34093413
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
3414+
pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
34103415
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
34113416
pub fn malloc(size: size_t) -> *mut c_void;
34123417
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
@@ -3448,7 +3453,6 @@ extern "C" {
34483453
pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
34493454

34503455
pub fn abs(i: c_int) -> c_int;
3451-
pub fn atof(s: *const c_char) -> c_double;
34523456
pub fn labs(i: c_long) -> c_long;
34533457
pub fn rand() -> c_int;
34543458
pub fn srand(seed: c_uint);

src/unix/bsd/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ extern "C" {
613613

614614
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
615615
pub fn abs(i: ::c_int) -> ::c_int;
616-
pub fn atof(s: *const ::c_char) -> ::c_double;
617616
pub fn labs(i: ::c_long) -> ::c_long;
618617
#[cfg_attr(
619618
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),

src/unix/haiku/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,6 @@ extern "C" {
15921592
pub fn _errnop() -> *mut ::c_int;
15931593

15941594
pub fn abs(i: ::c_int) -> ::c_int;
1595-
pub fn atof(s: *const ::c_char) -> ::c_double;
15961595
pub fn labs(i: ::c_long) -> ::c_long;
15971596
pub fn rand() -> ::c_int;
15981597
pub fn srand(seed: ::c_uint);

src/unix/hermit/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,6 @@ extern "C" {
966966
pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int;
967967

968968
pub fn abs(i: ::c_int) -> ::c_int;
969-
pub fn atof(s: *const ::c_char) -> ::c_double;
970969
pub fn labs(i: ::c_long) -> ::c_long;
971970
pub fn rand() -> ::c_int;
972971
pub fn srand(seed: ::c_uint);

src/unix/linux_like/emscripten/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,6 @@ extern "C" {
17631763
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
17641764

17651765
pub fn abs(i: ::c_int) -> ::c_int;
1766-
pub fn atof(s: *const ::c_char) -> ::c_double;
17671766
pub fn labs(i: ::c_long) -> ::c_long;
17681767
pub fn rand() -> ::c_int;
17691768
pub fn srand(seed: ::c_uint);

src/unix/linux_like/linux/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3804,7 +3804,6 @@ extern "C" {
38043804
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
38053805

38063806
pub fn abs(i: ::c_int) -> ::c_int;
3807-
pub fn atof(s: *const ::c_char) -> ::c_double;
38083807
pub fn labs(i: ::c_long) -> ::c_long;
38093808
pub fn rand() -> ::c_int;
38103809
pub fn srand(seed: ::c_uint);

src/unix/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,20 @@ extern "C" {
492492
pub fn ferror(stream: *mut FILE) -> c_int;
493493
pub fn clearerr(stream: *mut FILE);
494494
pub fn perror(s: *const c_char);
495+
pub fn atof(s: *const c_char) -> c_double;
495496
pub fn atoi(s: *const c_char) -> c_int;
497+
pub fn atol(s: *const c_char) -> c_long;
498+
pub fn atoll(s: *const c_char) -> c_longlong;
496499
#[cfg_attr(
497500
all(target_os = "macos", target_arch = "x86"),
498501
link_name = "strtod$UNIX2003"
499502
)]
500503
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
501504
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
502505
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
506+
pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
503507
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
508+
pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
504509
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
505510
pub fn malloc(size: size_t) -> *mut c_void;
506511
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;

src/unix/newlib/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,6 @@ extern "C" {
621621
pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int;
622622

623623
pub fn abs(i: ::c_int) -> ::c_int;
624-
pub fn atof(s: *const ::c_char) -> ::c_double;
625624
pub fn labs(i: ::c_long) -> ::c_long;
626625
pub fn rand() -> ::c_int;
627626
pub fn srand(seed: ::c_uint);

src/unix/solarish/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,6 @@ extern "C" {
27102710

27112711
pub fn abs(i: ::c_int) -> ::c_int;
27122712
pub fn acct(filename: *const ::c_char) -> ::c_int;
2713-
pub fn atof(s: *const ::c_char) -> ::c_double;
27142713
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
27152714
pub fn labs(i: ::c_long) -> ::c_long;
27162715
pub fn rand() -> ::c_int;

src/vxworks/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,11 +1119,16 @@ extern "C" {
11191119
pub fn feof(stream: *mut FILE) -> c_int;
11201120
pub fn ferror(stream: *mut FILE) -> c_int;
11211121
pub fn perror(s: *const c_char);
1122+
pub fn atof(s: *const c_char) -> c_double;
11221123
pub fn atoi(s: *const c_char) -> c_int;
1124+
pub fn atol(s: *const c_char) -> c_long;
1125+
pub fn atoll(s: *const c_char) -> c_longlong;
11231126
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
11241127
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
11251128
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
1129+
pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
11261130
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
1131+
pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
11271132
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
11281133
pub fn malloc(size: size_t) -> *mut c_void;
11291134
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;

src/wasi.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,16 @@ extern "C" {
540540
pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
541541
pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
542542
pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
543-
pub fn atoi(s: *const c_char) -> c_int;
544543
pub fn atof(s: *const c_char) -> c_double;
544+
pub fn atoi(s: *const c_char) -> c_int;
545+
pub fn atol(s: *const c_char) -> c_long;
546+
pub fn atoll(s: *const c_char) -> c_longlong;
545547
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
546548
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
547549
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
550+
pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
548551
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
552+
pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
549553

550554
pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
551555
pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;

src/windows/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,16 @@ extern "C" {
329329
pub fn feof(stream: *mut FILE) -> c_int;
330330
pub fn ferror(stream: *mut FILE) -> c_int;
331331
pub fn perror(s: *const c_char);
332+
pub fn atof(s: *const c_char) -> c_double;
332333
pub fn atoi(s: *const c_char) -> c_int;
334+
pub fn atol(s: *const c_char) -> c_long;
335+
pub fn atoll(s: *const c_char) -> c_longlong;
333336
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
334337
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
335338
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
339+
pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
336340
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
341+
pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
337342
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
338343
pub fn malloc(size: size_t) -> *mut c_void;
339344
pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
@@ -374,7 +379,6 @@ extern "C" {
374379
pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
375380

376381
pub fn abs(i: c_int) -> c_int;
377-
pub fn atof(s: *const c_char) -> c_double;
378382
pub fn labs(i: c_long) -> c_long;
379383
pub fn rand() -> c_int;
380384
pub fn srand(seed: c_uint);

0 commit comments

Comments
 (0)