diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-25 00:29:16 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-25 00:29:16 -0800 |
commit | f46a5e3cdea380494554b0bd11782c8a4dabdc66 (patch) | |
tree | 365cb7401664f819e6dc5080d16581e303077517 | |
parent | a61708f6ca5df1dd17a6bad6a72003b08474ed6e (diff) | |
download | txr-f46a5e3cdea380494554b0bd11782c8a4dabdc66.tar.gz txr-f46a5e3cdea380494554b0bd11782c8a4dabdc66.tar.bz2 txr-f46a5e3cdea380494554b0bd11782c8a4dabdc66.zip |
* configure: Added feature tests for makedev, link/symlink/readlink,
mkdir and mknod.
* eval.c (eval_init): Wrap #ifdefs around the registrations of
the wrappers for these functions.
* stream.c (mkdir_wrap): Wrap in #ifdef HAVE_MKDIR, and
provide a Windows version if HAVE_MKDIR is missing, but
HAVE_WINDOWS_H is true.
(makedev_wrap, major_wrap, minor_wrap): Wrap with #if HAVE_MAKEDEV.
(mknod): Use #if HAVE_MKNOD.
(symlink_wrap, link_wrap, readlink_wrap): Wrap with #if HAVE_SYMLINK.
-rw-r--r-- | ChangeLog | 15 | ||||
-rwxr-xr-x | configure | 89 | ||||
-rw-r--r-- | eval.c | 11 | ||||
-rw-r--r-- | stream.c | 26 |
4 files changed, 138 insertions, 3 deletions
@@ -1,3 +1,18 @@ +2014-02-25 Kaz Kylheku <kaz@kylheku.com> + + * configure: Added feature tests for makedev, link/symlink/readlink, + mkdir and mknod. + + * eval.c (eval_init): Wrap #ifdefs around the registrations of + the wrappers for these functions. + + * stream.c (mkdir_wrap): Wrap in #ifdef HAVE_MKDIR, and + provide a Windows version if HAVE_MKDIR is missing, but + HAVE_WINDOWS_H is true. + (makedev_wrap, major_wrap, minor_wrap): Wrap with #if HAVE_MAKEDEV. + (mknod): Use #if HAVE_MKNOD. + (symlink_wrap, link_wrap, readlink_wrap): Wrap with #if HAVE_SYMLINK. + 2014-02-24 Kaz Kylheku <kaz@kylheku.com> * debug.c (debug): Fix 2013-12-02 regression, which leaves the @@ -1584,6 +1584,95 @@ else have_posix_sigs=y fi +printf "Checking for makedev ... " + +cat > conftest.c <<! +#include <sys/types.h> + +int main(void) +{ + int d = makedev(1, 2); + int j = major(d); + int n = minor(d); + return 0; +} +! +rm -f conftest$exe +if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" + printf "#define HAVE_MAKEDEV 1\n" >> config.h +fi + +printf "Checking for link, symlink and readlink ... " + +cat > conftest.c <<! +#include <unistd.h> + +int main(void) +{ + int e1 = symlink("a", "b"); + int e2 = link("c", "d"); + char buf[256]; + ssize_t foo = readlink("e", buf, sizeof buf); + return 0; +} +! +rm -f conftest$exe +if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" + printf "#define HAVE_SYMLINK 1\n" >> config.h + have_unistd=y +fi + +printf "Checking for POSIX mkdir ... " + +cat > conftest.c <<! +#included "config.h" +#include <sys/stat.h> +#if HAVE_WINDOWS_H +#include <windows.h> +#endif + +int main(void) +{ + int e = mkdir("a", 0); + return 0; +} +! +rm -f conftest$exe +if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" +cat conftest.err +exit 1 + printf "#define HAVE_MKDIR 1\n" >> config.h +fi + +printf "Checking for mknod ... " + +cat > conftest.c <<! +#include <unistd.h> + +int main(void) +{ + int e = mknod("a", 0, 0); + return 0; +} +! +rm -f conftest$exe +if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" + printf "#define HAVE_MKNOD 1\n" >> config.h + have_unistd=y +fi + # # Dependent variables # @@ -3591,17 +3591,24 @@ void eval_init(void) reg_fun(intern(lit("daemon"), user_package), func_n2(daemon_wrap)); #endif -#ifdef HAVE_SYS_STAT +#if HAVE_MKDIR || HAVE_WINDOWS_H reg_fun(intern(lit("mkdir"), user_package), func_n2o(mkdir_wrap, 1)); #endif -#ifdef HAVE_UNISTD_H reg_fun(intern(lit("chdir"), user_package), func_n1(chdir_wrap)); reg_fun(intern(lit("pwd"), user_package), func_n0(getcwd_wrap)); + +#if HAVE_MKDEV reg_fun(intern(lit("makedev"), user_package), func_n2(makedev_wrap)); reg_fun(intern(lit("minor"), user_package), func_n1(minor_wrap)); reg_fun(intern(lit("major"), user_package), func_n1(major_wrap)); +#endif + +#if HAVE_MKNOD reg_fun(intern(lit("mknod"), user_package), func_n3(mknod_wrap)); +#endif + +#if HAVE_SYMLINK reg_fun(intern(lit("symlink"), user_package), func_n2(symlink_wrap)); reg_fun(intern(lit("link"), user_package), func_n2(link_wrap)); reg_fun(intern(lit("readlink"), user_package), func_n1(readlink_wrap)); @@ -2378,7 +2378,7 @@ val rename_path(val from, val to) return t; } -#if HAVE_SYS_STAT +#if HAVE_MKDIR val mkdir_wrap(val path, val mode) { char *u8path = utf8_dup_to(c_str(path)); @@ -2391,6 +2391,18 @@ val mkdir_wrap(val path, val mode) return t; } +#elif HAVE_WINDOWS_H +val mkdir_wrap(val path, val mode) +{ + int err = _wmkdir(c_str(path)); + + (void) mode; + if (err < 0) + uw_throwf(file_error_s, lit("mkdir ~a: ~a/~s"), + path, num(errno), string_utf8(strerror(errno)), nao); + + return t; +} #endif #if HAVE_UNISTD_H @@ -2430,6 +2442,8 @@ val getcwd_wrap(void) } } +#if HAVE_MAKEDEV + val makedev_wrap(val major, val minor) { return num(makedev(c_num(major), c_num(minor))); @@ -2445,6 +2459,10 @@ val major_wrap(val dev) return num(major(c_num(dev))); } +#endif + +#if HAVE_MKNOD + val mknod_wrap(val path, val mode, val dev) { char *u8path = utf8_dup_to(c_str(path)); @@ -2459,6 +2477,10 @@ val mknod_wrap(val path, val mode, val dev) return t; } +#endif + +#if HAVE_SYMLINK + val symlink_wrap(val target, val to) { char *u8target = utf8_dup_to(c_str(target)); @@ -2516,6 +2538,8 @@ val readlink_wrap(val path) #endif +#endif + void stream_init(void) { protect(&std_input, &std_output, &std_debug, &std_error, &std_null, (val *) 0); |