[glib] Require POSIX.1 (1990) compliance on unix
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Require POSIX.1 (1990) compliance on unix
- Date: Wed, 20 Nov 2013 21:31:57 +0000 (UTC)
commit 3981cddbf8659458be9f863151314cd0fd1682bf
Author: Dan Winship <danw gnome org>
Date: Sat Oct 19 13:03:59 2013 -0400
Require POSIX.1 (1990) compliance on unix
Assume unix platforms support the original POSIX.1 standard.
Specifically, assume that if G_OS_UNIX, then we have chown(),
getcwd(), getgrgid(), getpwuid(), link(), <grp.h>, <pwd.h>,
<sys/types.h>, <sys/uio.h>, <sys/wait.h>, and <unistd.h>.
Additionally, since all versions of Windows that we care about also
have <sys/types.h>, we can remove HAVE_SYS_TYPES_H checks everywhere.
Also remove one include of <sys/times.h>, and the corresponding
configure check, since the include is not currently needed (and may
always have just been a typo for <sys/time.h>).
https://bugzilla.gnome.org/show_bug.cgi?id=710519
config.h.win32.in | 33 ---------------------------------
configure.ac | 34 ++++++++++++++--------------------
gio/gfile.c | 3 ---
gio/glocalfile.c | 2 +-
gio/glocalfileinfo.c | 16 +++++++---------
gio/glocalfileinfo.h | 2 --
gio/glocalfileoutputstream.c | 2 +-
gio/glocalvfs.c | 4 ++--
gio/gsocket.c | 2 +-
glib/gbacktrace.c | 15 +++++----------
glib/gfileutils.c | 6 ------
glib/gthread-posix.c | 9 +++------
glib/gutils.c | 9 ++++-----
13 files changed, 38 insertions(+), 99 deletions(-)
---
diff --git a/config.h.win32.in b/config.h.win32.in
index 51b22f8..c20231e 100644
--- a/config.h.win32.in
+++ b/config.h.win32.in
@@ -109,9 +109,6 @@
/* define to 1 if Carbon is available */
/* #undef HAVE_CARBON */
-/* Define to 1 if you have the `chown' function. */
-/* #undef HAVE_CHOWN */
-
/* Define to 1 if you have the `clock_gettime' function. */
/* #undef HAVE_CLOCK_GETTIME */
@@ -189,27 +186,18 @@
/* we have the futex(2) system call */
/* #undef HAVE_FUTEX */
-/* Define to 1 if you have the `getcwd' function. */
-#define HAVE_GETCWD 1
-
/* Define to 1 if you have the `getc_unlocked' function. */
/* #undef HAVE_GETC_UNLOCKED */
/* Define to 1 if you have the `getfsstat' function. */
/* #undef HAVE_GETFSSTAT */
-/* Define to 1 if you have the `getgrgid' function. */
-/* #undef HAVE_GETGRGID */
-
/* Define to 1 if you have the `getmntent_r' function. */
/* #undef HAVE_GETMNTENT_R */
/* Define to 1 if you have the `getprotobyname_r' function. */
/* #undef HAVE_GETPROTOBYNAME_R */
-/* Define to 1 if you have the `getpwuid' function. */
-/* #undef HAVE_GETPWUID */
-
/* Define to 1 if you have the `getresuid' function. */
/* #undef HAVE_GETRESUID */
@@ -225,9 +213,6 @@
/* define to use system printf */
/* #undef HAVE_GOOD_PRINTF */
-/* Define to 1 if you have the <grp.h> header file. */
-/* #undef HAVE_GRP_H */
-
/* Define to 1 if you have the `hasmntopt' function. */
/* #undef HAVE_HASMNTOPT */
@@ -311,9 +296,6 @@
/* Define if libelf is available */
/* #undef HAVE_LIBELF */
-/* Define to 1 if you have the `link' function. */
-/* #undef HAVE_LINK */
-
/* Define to 1 if you have the <linux/magic.h> header file. */
/* #undef HAVE_LINUX_MAGIC_H */
@@ -405,9 +387,6 @@
/* Define to 1 if the system has the type `ptrdiff_t'. */
#define HAVE_PTRDIFF_T 1
-/* Define to 1 if you have the <pwd.h> header file. */
-/* #undef HAVE_PWD_H */
-
/* Define to 1 if you have the `readlink' function. */
/* #undef HAVE_READLINK */
@@ -629,9 +608,6 @@
/* Define to 1 if you have the <sys/sysctl.h> header file. */
/* #undef HAVE_SYS_SYSCTL_H */
-/* Define to 1 if you have the <sys/times.h> header file. */
-/* #undef HAVE_SYS_TIMES_H */
-
/* Define to 1 if you have the <sys/time.h> header file. */
#ifndef _MSC_VER
#define HAVE_SYS_TIME_H 1
@@ -639,12 +615,6 @@
/* #undef HAVE_SYS_TIME_H */
#endif /* _MSC_VER */
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <sys/uio.h> header file. */
-/* #undef HAVE_SYS_UIO_H */
-
/* Define to 1 if you have the <sys/vfstab.h> header file. */
/* #undef HAVE_SYS_VFSTAB_H */
@@ -654,9 +624,6 @@
/* Define to 1 if you have the <sys/vmount.h> header file. */
/* #undef HAVE_SYS_VMOUNT_H */
-/* Define to 1 if you have the <sys/wait.h> header file. */
-/* #undef HAVE_SYS_WAIT_H */
-
/* Define to 1 if you have the <sys/xattr.h> header file. */
/* #undef HAVE_SYS_XATTR_H */
diff --git a/configure.ac b/configure.ac
index 608c3d0..1f3e7b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -772,14 +772,14 @@ fi
# check for header files
-AC_CHECK_HEADERS([dirent.h pwd.h grp.h sys/param.h sys/poll.h sys/resource.h])
-AC_CHECK_HEADERS([sys/time.h sys/times.h sys/wait.h unistd.h])
-AC_CHECK_HEADERS([sys/select.h sys/types.h stdint.h inttypes.h sched.h malloc.h])
+AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/resource.h])
+AC_CHECK_HEADERS([sys/select.h stdint.h inttypes.h sched.h malloc.h])
AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h])
AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h])
-AC_CHECK_HEADERS([sys/uio.h])
-AC_CHECK_HEADERS([linux/magic.h])
-AC_CHECK_HEADERS([sys/prctl.h])
+AC_CHECK_HEADERS([linux/magic.h sys/prctl.h])
+
+# Some versions of MSC lack these
+AC_CHECK_HEADERS([dirent.h sys/time.h unistd.h])
# We don't care about this, but we need to keep including it in
# glibconfig.h for backward compatibility
@@ -925,9 +925,7 @@ AS_IF([test $ac_cv_sizeof_ssize_t = $ac_cv_sizeof_int &&
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
int main ()
{
ssize_t s = 1;
@@ -949,9 +947,7 @@ int main ()
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
int main ()
{
ssize_t s = 1;
@@ -964,10 +960,9 @@ int main ()
AC_MSG_RESULT($glib_ssize_type)
# Check for some functions
-AC_CHECK_FUNCS(lstat strsignal vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv
getc_unlocked readlink symlink fdwalk memmem)
-AC_CHECK_FUNCS(chown lchmod lchown fchmod fchown link utimes getgrgid getpwuid getresuid)
+AC_CHECK_FUNCS(lstat strsignal vsnprintf stpcpy strcasecmp strncasecmp poll vasprintf setenv unsetenv
getc_unlocked readlink symlink fdwalk memmem)
+AC_CHECK_FUNCS(lchmod lchown fchmod fchown utimes getresuid)
AC_CHECK_FUNCS(getmntent_r setmntent endmntent hasmntopt getfsstat getvfsstat fallocate)
-# Check for high-resolution sleep functions
case $host_os in aix*) ac_cv_func_splice=no ;; esac # AIX splice() is something else
AC_CHECK_FUNCS(splice)
AC_CHECK_FUNCS(prlimit)
@@ -1005,9 +1000,6 @@ AC_CHECK_FUNCS(_NSGetEnviron)
AC_CHECK_FUNCS(newlocale uselocale strtod_l strtoll_l strtoull_l)
-AC_FUNC_VSNPRINTF_C99
-AC_FUNC_PRINTF_UNIX98
-
# Internet address families
if test $glib_native_win32 = yes; then
glib_inet_includes=["
@@ -1181,6 +1173,8 @@ AC_TRY_COMPILE([#include <fcntl.h>
#
# Check whether to use an included printf
#
+AC_FUNC_VSNPRINTF_C99
+AC_FUNC_PRINTF_UNIX98
AC_ARG_ENABLE(included-printf,
[AS_HELP_STRING([--enable-included-printf],
@@ -2145,7 +2139,7 @@ glib_save_LIBS="$LIBS"
# to always be linked with the thread libs on some platforms.
# LIBS="$LIBS $G_THREAD_LIBS"
AC_CHECK_FUNCS(localtime_r gmtime_r)
-AS_IF([ test "$ac_cv_header_pwd_h" = "yes"], [
+AS_IF([ test "$glib_native_win32" != "yes"], [
AC_CACHE_CHECK([for posix getpwuid_r],
ac_cv_func_posix_getpwuid_r,
[AC_TRY_RUN([
@@ -2184,7 +2178,7 @@ int main () {
fi
fi
])
-AS_IF([ test "$ac_cv_header_grp_h" = "yes"], [
+AS_IF([ test "$glib_native_win32" != "yes"], [
AC_CACHE_CHECK([for posix getgrgid_r],
ac_cv_func_posix_getgrgid_r,
[AC_TRY_RUN([
diff --git a/gio/gfile.c b/gio/gfile.c
index 9e9d79d..4fabec1 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -41,9 +41,6 @@
#include <string.h>
#include <sys/types.h>
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
#include "gfile.h"
#include "glib/gstdio.h"
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index b9bec8a..862d2fb 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -143,7 +143,7 @@ g_local_file_class_init (GLocalFileClass *klass)
G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
-#ifdef HAVE_CHOWN
+#ifdef G_OS_UNIX
g_file_attribute_info_list_add (list,
G_FILE_ATTRIBUTE_UNIX_UID,
G_FILE_ATTRIBUTE_TYPE_UINT32,
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index efcafc3..5e60bf8 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -24,6 +24,8 @@
#include "config.h"
+#include <glib.h>
+
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
@@ -35,10 +37,8 @@
#endif
#include <fcntl.h>
#include <errno.h>
-#ifdef HAVE_GRP_H
+#ifdef G_OS_UNIX
#include <grp.h>
-#endif
-#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_SELINUX
@@ -2158,7 +2158,7 @@ set_unix_mode (char *filename,
return TRUE;
}
-#ifdef HAVE_CHOWN
+#ifdef G_OS_UNIX
static gboolean
set_unix_uid_gid (char *filename,
const GFileAttributeValue *uid_value,
@@ -2442,7 +2442,7 @@ _g_local_file_info_set_attribute (char *filename,
if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) == 0)
return set_unix_mode (filename, flags, &value, error);
-#ifdef HAVE_CHOWN
+#ifdef G_OS_UNIX
else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_UID) == 0)
return set_unix_uid_gid (filename, &value, NULL, flags, error);
else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_GID) == 0)
@@ -2519,13 +2519,11 @@ _g_local_file_info_set_attributes (char *filename,
GError **error)
{
GFileAttributeValue *value;
-#ifdef HAVE_CHOWN
+#ifdef G_OS_UNIX
GFileAttributeValue *uid, *gid;
-#endif
#ifdef HAVE_UTIMES
GFileAttributeValue *mtime, *mtime_usec, *atime, *atime_usec;
#endif
-#if defined (HAVE_CHOWN) || defined (HAVE_UTIMES)
GFileAttributeStatus status;
#endif
gboolean res;
@@ -2555,7 +2553,7 @@ _g_local_file_info_set_attributes (char *filename,
}
#endif
-#ifdef HAVE_CHOWN
+#ifdef G_OS_UNIX
/* Group uid and gid setting into one call
* Change ownership before permissions, since ownership changes can
change permissions (e.g. setuid)
diff --git a/gio/glocalfileinfo.h b/gio/glocalfileinfo.h
index 6d35be5..feb3c56 100644
--- a/gio/glocalfileinfo.h
+++ b/gio/glocalfileinfo.h
@@ -26,9 +26,7 @@
#include <gio/gfileinfo.h>
#include <gio/gfile.h>
#include <sys/stat.h>
-#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
-#endif
G_BEGIN_DECLS
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
index 6504472..b50dada 100644
--- a/gio/glocalfileoutputstream.c
+++ b/gio/glocalfileoutputstream.c
@@ -265,7 +265,7 @@ _g_local_file_output_stream_really_close (GLocalFileOutputStream *file,
if (g_cancellable_set_error_if_cancelled (cancellable, error))
goto err_out;
-#ifdef HAVE_LINK
+#ifdef G_OS_UNIX
/* create original -> backup link, the original is then renamed over */
if (g_unlink (file->priv->backup_filename) != 0 &&
errno != ENOENT)
diff --git a/gio/glocalvfs.c b/gio/glocalvfs.c
index f2eaea2..9319be2 100644
--- a/gio/glocalvfs.c
+++ b/gio/glocalvfs.c
@@ -28,7 +28,7 @@
#include "gvfs.h"
#include <gio/gdummyfile.h>
#include <sys/types.h>
-#ifdef HAVE_PWD_H
+#ifdef G_OS_UNIX
#include <pwd.h>
#endif
#include <string.h>
@@ -155,7 +155,7 @@ g_local_vfs_parse_name (GVfs *vfs,
user_prefix = g_strdup (g_get_home_dir ());
else
{
-#ifdef HAVE_PWD_H
+#ifdef G_OS_UNIX
struct passwd *passwd_file_entry;
char *user_name;
diff --git a/gio/gsocket.c b/gio/gsocket.c
index 714e0b3..6a7e092 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -48,7 +48,7 @@
# include <sys/filio.h>
#endif
-#ifdef HAVE_SYS_UIO_H
+#ifdef G_OS_UNIX
#include <sys/uio.h>
#endif
diff --git a/glib/gbacktrace.c b/glib/gbacktrace.c
index a9451c8..5501c60 100644
--- a/glib/gbacktrace.c
+++ b/glib/gbacktrace.c
@@ -40,24 +40,19 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
-#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif
#include <sys/types.h>
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
#include <time.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#include <sys/wait.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif /* HAVE_SYS_SELECT_H */
+#endif
-#include <string.h> /* for bzero on BSD systems */
+#include <string.h>
#ifdef G_OS_WIN32
# define STRICT /* Strict typing, please */
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 90fb405..233d299 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -2477,11 +2477,6 @@ g_get_current_dir (void)
if (max_len == 0)
max_len = (G_PATH_LENGTH == -1) ? 2048 : G_PATH_LENGTH;
-#if !defined(HAVE_GETCWD)
- buffer = g_new (gchar, max_len + 1);
- *buffer = 0;
- dir = getwd (buffer);
-#else
while (max_len < G_MAXULONG / 2)
{
g_free (buffer);
@@ -2494,7 +2489,6 @@ g_get_current_dir (void)
max_len *= 2;
}
-#endif /* !sun || !HAVE_GETCWD */
if (!dir || !*buffer)
{
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index c7b68a0..f5037d0 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -54,12 +54,9 @@
#include <errno.h>
#include <pthread.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <sys/time.h>
+#include <unistd.h>
+
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
diff --git a/glib/gutils.c b/glib/gutils.c
index 70301a1..1395757 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -29,6 +29,7 @@
*/
#include "config.h"
+#include "glibconfig.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -42,7 +43,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef HAVE_PWD_H
+#ifdef G_OS_UNIX
#include <pwd.h>
#endif
#include <sys/types.h>
@@ -603,7 +604,7 @@ g_get_user_database_entry (void)
{
static UserDatabaseEntry e;
-#ifdef HAVE_PWD_H
+#ifdef G_OS_UNIX
{
struct passwd *pw = NULL;
gpointer buffer = NULL;
@@ -718,7 +719,7 @@ g_get_user_database_entry (void)
g_free (buffer);
}
-#else /* !HAVE_PWD_H */
+#endif /* G_OS_UNIX */
#ifdef G_OS_WIN32
{
@@ -733,8 +734,6 @@ g_get_user_database_entry (void)
}
#endif /* G_OS_WIN32 */
-#endif /* !HAVE_PWD_H */
-
if (!e.user_name)
e.user_name = g_strdup ("somebody");
if (!e.real_name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]