FreeBSD compat
authorChris Rees <utisoft@gmail.com>
Mon, 24 Jan 2011 16:03:36 +0000 (17:03 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 24 Jan 2011 16:04:59 +0000 (17:04 +0100)
Signed-off-by: Chris Rees <utisoft@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
include/libbb.h
include/platform.h
libbb/getpty.c

index 6e37b8d04578b7fc8084925d79592ea41ce80fd4..aa7944a5d6cc7c459d6f35066d732243e145667a 100644 (file)
 #include <time.h>
 #include <unistd.h>
 #include <sys/param.h>
+#ifndef HAVE_CLEARENV
+# define clearenv() do { if (environ) environ[0] = NULL; } while (0)
+#endif
+#ifndef HAVE_FDATASYNC
+# define fdatasync fsync
+#endif
 #ifdef HAVE_MNTENT_H
 # include <mntent.h>
 #endif
index bbbc0a9b692fca5c0aade27d768c8efae4afc64b..2bc88c391a9904f7c1e46de4e386f0d09fdccfb7 100644 (file)
 /* Assume all these functions exist by default.  Platforms where it is not
  * true will #undef them below.
  */
+#define HAVE_CLEARENV 1
+#define HAVE_FDATASYNC 1
 #define HAVE_FDPRINTF 1
 #define HAVE_MEMRCHR 1
 #define HAVE_MKDTEMP 1
+#define HAVE_PTSNAME_R 1
 #define HAVE_SETBIT 1
 #define HAVE_SIGHANDLER_T 1
 #define HAVE_STRCASESTR 1
@@ -253,7 +256,10 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
 #if (defined __digital__ && defined __unix__) \
  || defined __APPLE__ \
  || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
+# undef HAVE_CLEARENV
+# undef HAVE_FDATASYNC
 # undef HAVE_MNTENT_H
+# undef HAVE_PTSNAME_R
 # undef HAVE_SYS_STATFS_H
 # undef HAVE_SIGHANDLER_T
 #else
index ea653b0b6c335b0a1fdc13d8f9bd02165971828b..6a15cff2fb36bcddd0ad2e58ebf119cba8c4660a 100644 (file)
@@ -19,7 +19,7 @@ int FAST_FUNC xgetpty(char *line)
        if (p > 0) {
                grantpt(p); /* chmod+chown corresponding slave pty */
                unlockpt(p); /* (what does this do?) */
-#if 0 /* if ptsname_r is not available... */
+#ifndef HAVE_PTSNAME_R
                const char *name;
                name = ptsname(p); /* find out the name of slave pty */
                if (!name) {