wasi-libc/libc-bottom-half/headers/public
Dan Gohman bdfbb54520
Call populate_environ only if we actually need environment variables. (#109)
* Link `populate_environ` only if we actually need environment variables.

This avoids linking in the environment variable initialization code,
and the __wasi_environ_sizes_get and __wasi_environ_get imports, in
programs that don't use environment variables.

This also removes the "___environ" (three underscores) alias symbol,
which is only in musl for backwards compatibility.

* Switch to //-style comments.

* If malloc fails, don't leave `__environ` pointing to an uninitialized buffer.

* Fix a memory leak if one malloc succeeds and the other fails.

* Use calloc to handle multiplication overflow.

This also handles the NULL terminator.

* Don't initialize __environ until everything has succeeded.

* Avoid leaking in case __wasi_environ_get fails.

* Handle overflow in the add too.

* Add #include <stdlib.h> for malloc etc.

* If the environment is empty, don't allocate any memory.
2019-10-22 06:02:44 -07:00
..
netinet WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
sys WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
wasi Call populate_environ only if we actually need environment variables. (#109) 2019-10-22 06:02:44 -07:00
__errno_values.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__fd_set.h Implement FD_SET, FD_CLR, etc. 2019-04-23 15:01:23 -07:00
__function___isatty.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__header_bits_signal.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__header_dirent.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__header_fcntl.h Move the mode_t macros into their own header. 2019-05-10 12:37:49 -07:00
__header_netinet_in.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__header_poll.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__header_stdlib.h Miscellaneous cleanups (#113) 2019-10-18 13:53:13 -07:00
__header_string.h Miscellaneous cleanups (#113) 2019-10-18 13:53:13 -07:00
__header_sys_ioctl.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__header_sys_resource.h Declare getrusage. 2019-04-22 11:41:40 -07:00
__header_sys_socket.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__header_sys_stat.h Move the mode_t macros into their own header. 2019-05-10 12:37:49 -07:00
__header_time.h Define TIME_UTC to be 1. 2019-05-01 12:52:28 -07:00
__header_unistd.h Move the SEEK_* macros into their own header and use it from fcntl.h. 2019-05-09 09:11:43 -07:00
__macro_FD_SETSIZE.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__mode_t.h Move the mode_t macros into their own header. 2019-05-10 12:37:49 -07:00
__seek.h Move the SEEK_* macros into their own header and use it from fcntl.h. 2019-05-09 09:11:43 -07:00
__struct_dirent.h WASI libc's dirent does have t_type, so define _DIRENT_HAVE_D_TYPE. 2019-08-29 10:22:03 -07:00
__struct_in6_addr.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_in_addr.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_iovec.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_msghdr.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_pollfd.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_rusage.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_sockaddr_in6.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_sockaddr_in.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_sockaddr_storage.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_sockaddr_un.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_sockaddr.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_timeval.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_tm.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__struct_tms.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_clockid_t.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_DIR.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_fd_set.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_in_addr_t.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_in_port_t.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_nfds_t.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_sa_family_t.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_sigset_t.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
__typedef_socklen_t.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
dirent.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
errno.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
fcntl.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
poll.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
stdlib.h Miscellaneous cleanups (#113) 2019-10-18 13:53:13 -07:00
string.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
time.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00
unistd.h WASI libc prototype implementation. 2019-03-27 07:59:55 -07:00