diff --git a/src/cmd/ksh93/data/builtins.c b/src/cmd/ksh93/data/builtins.c index dc1132fcb016..d018e59be414 100644 --- a/src/cmd/ksh93/data/builtins.c +++ b/src/cmd/ksh93/data/builtins.c @@ -47,6 +47,7 @@ #undef basename #undef dirname +#undef mktemp /* undo possible map-libc mktemp => _ast_mktemp */ /* * IMPORTANT: The order of these struct members must be synchronous @@ -127,7 +128,6 @@ const struct shtable3 shtab_builtins[] = "type", NV_BLTIN|BLT_ENV, bltin(whence), "whence", NV_BLTIN|BLT_ENV, bltin(whence), #ifdef SHOPT_CMDLIB_HDR -#undef mktemp /* undo possible map-libc mktemp => _ast_mktemp */ #include SHOPT_CMDLIB_HDR #else #if SHOPT_ALL_LIBCMD diff --git a/src/lib/libast/Mamfile b/src/lib/libast/Mamfile index 41159a76c82c..a22f6f09202e 100644 --- a/src/lib/libast/Mamfile +++ b/src/lib/libast/Mamfile @@ -138,6 +138,12 @@ make install virtual exec - invoke_iffe %{<} done + note * ast_random.h * + make FEATURE/random + makp features/random + exec - invoke_iffe %{<} + done + note * sig.h: AST replacement for make FEATURE/sig makp features/sig.sh @@ -187,6 +193,7 @@ make install virtual make FEATURE/map make features/map.c prev sig.h + prev FEATURE/random prev FEATURE/api prev FEATURE/eaccess prev FEATURE/options @@ -576,12 +583,6 @@ make install virtual exec - invoke_iffe %{<} -I. done - note * ast_random.h * - make FEATURE/random - makp features/random - exec - invoke_iffe %{<} - done - note * copy most of the FEATURE/* results above to canonically named header files; separating note * this allows all of the above tests, which don't depend on each other, to run in parallel diff --git a/src/lib/libast/features/map.c b/src/lib/libast/features/map.c index b51316e2a10e..2574dcb485fc 100644 --- a/src/lib/libast/features/map.c +++ b/src/lib/libast/features/map.c @@ -30,12 +30,20 @@ #include "FEATURE/options" #include "FEATURE/eaccess" #include "FEATURE/api" +#include "FEATURE/random" #include #if _opt_map_libc && !defined(_map_libc) #define _map_libc 1 #endif +/* + * NOTE: for conditionally compiled AST functions, the preprocessor directives below + * must be kept in sync with the directives in the corresponding C source files, so + * that the rename is not done if the AST version of the function is not compiled + * in; otherwise a build with _map_libc defined will fail with linking errors. + */ + int main(void) { @@ -59,6 +67,20 @@ main(void) printf("\n"); printf("#define _map_libc 1\n"); #endif +#if _map_libc +#if !_lib_arc4random + printf("#undef arc4random\n"); + printf("#define arc4random _ast_arc4random\n"); +#endif +#if !_lib_arc4random_buf + printf("#undef arc4random_buf\n"); + printf("#define arc4random_buf _ast_arc4random_buf\n"); +#endif +#if !_lib_arc4random_uniform + printf("#undef arc4random_uniform\n"); + printf("#define arc4random_uniform _ast_arc4random_uniform\n"); +#endif +#endif #if _map_libc || defined(__linux__) printf("#undef basename\n"); printf("#define basename _ast_basename\n"); @@ -110,8 +132,10 @@ main(void) printf("#undef sigunblock\n"); printf("#define sigunblock _ast_sigunblock\n"); #if _map_libc +#if !_lib_memdup printf("#undef memdup\n"); printf("#define memdup _ast_memdup\n"); +#endif printf("#undef memhash\n"); printf("#define memhash _ast_memhash\n"); printf("#undef memsum\n"); @@ -158,6 +182,8 @@ main(void) printf("#define pathfind _ast_pathfind\n"); printf("#undef pathgetlink\n"); printf("#define pathgetlink _ast_pathgetlink\n"); + printf("#undef pathicase\n"); + printf("#define pathicase _ast_pathicase\n"); printf("#undef pathinclude\n"); printf("#define pathinclude _ast_pathinclude\n"); printf("#undef pathkey\n"); @@ -251,21 +277,27 @@ main(void) printf("#undef regsubfree\n"); printf("#define regsubfree _ast_regsubfree\n"); #if _map_libc +#if !(_std_remove || !_lib_unlink) printf("#undef remove\n"); printf("#define remove _ast_remove\n"); printf("extern int remove(const char*);\n"); +#endif printf("#undef resolvepath\n"); printf("#define resolvepath _ast_resolvepath\n"); printf("extern int resolvepath(const char*, char*, size_t);\n"); +#if !_lib_setenv printf("#undef setenv\n"); printf("#define setenv _ast_setenv\n"); printf("extern int setenv(const char*, const char*, int);\n"); +#endif printf("#undef setenviron\n"); printf("#define setenviron _ast_setenviron\n"); printf("#undef sigcritical\n"); printf("#define sigcritical _ast_sigcritical\n"); +#if !_lib_stracmp printf("#undef stracmp\n"); printf("#define stracmp _ast_stracmp\n"); +#endif printf("#undef strcopy\n"); printf("#define strcopy _ast_strcopy\n"); printf("#undef strelapsed\n"); @@ -288,12 +320,16 @@ main(void) printf("#define strhash _ast_strhash\n"); printf("#undef strkey\n"); printf("#define strkey _ast_strkey\n"); +#if !_lib_strlcat printf("#undef strlcat\n"); printf("#define strlcat _ast_strlcat\n"); printf("extern size_t strlcat(char*, const char*, size_t);\n"); +#endif +#if !_lib_strlcpy printf("#undef strlcpy\n"); printf("#define strlcpy _ast_strlcpy\n"); printf("extern size_t strlcpy(char*, const char*, size_t);\n"); +#endif printf("#undef strlook\n"); printf("#define strlook _ast_strlook\n"); printf("#undef strmatch\n"); @@ -304,8 +340,10 @@ main(void) printf("#define strmode _ast_strmode\n"); #endif #if _map_libc +#if !_lib_strnacmp printf("#undef strnacmp\n"); printf("#define strnacmp _ast_strnacmp\n"); +#endif printf("#undef strncopy\n"); printf("#define strncopy _ast_strncopy\n"); printf("#undef strntod\n"); @@ -365,8 +403,10 @@ main(void) printf("#define wordexp _ast_wordexp\n"); printf("#undef wordfree\n"); printf("#define wordfree _ast_wordfree\n"); +#if !_lib_unsetenv printf("#undef unsetenv\n"); printf("#define unsetenv _ast_unsetenv\n"); +#endif #endif /* we always use the libast strdup implementation */ printf("#undef strdup\n"); @@ -472,11 +512,9 @@ main(void) do { for (s = t; *t && *t != ' '; t++); - printf("#define %-.*s _ast_%-.*s\n", t - s, s, t - s, s); + printf("#define %-.*s _ast_%-.*s\n", (int)(t - s), s, (int)(t - s), s); } while (*t++); } #endif - printf("\n"); - printf("#undef extern\n"); return 0; } diff --git a/src/lib/libast/features/random b/src/lib/libast/features/random index 3827b9f86205..a9b858650648 100644 --- a/src/lib/libast/features/random +++ b/src/lib/libast/features/random @@ -38,7 +38,7 @@ tst note{ does arc4random(3) become predictable after forking }end output{ pid_t child; uint32_t r[3], r2[3]; /* create data file */ - while (*t = *f++ && t < &file[PATHSIZE-4]) + while ((*t = *f++) && t < &file[PATHSIZE-4]) t++; *t++ = '.', *t++ = 'D', *t = 0; if ((fd = open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0) diff --git a/src/lib/libast/man/strperm.3 b/src/lib/libast/man/strperm.3 index 8aff82d8ddb6..6b11afb7b6d1 100644 --- a/src/lib/libast/man/strperm.3 +++ b/src/lib/libast/man/strperm.3 @@ -55,7 +55,7 @@ not 0 then is set to point to the first unrecognized character in .IR s . .PP -A tape device specification is composed of one or more +A file permission expression is composed of one or more .I who-op-permission terms separated by .BR , .