More patches from pbatard to reduce warnings, etc.

This commit is contained in:
R. Bernstein
2012-03-03 20:11:14 -05:00
parent d0018220cc
commit 2022037807
13 changed files with 134 additions and 84 deletions

View File

@@ -1,5 +1,8 @@
/*
Copyright (C) 2006, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
filemode.h -- file modes common definitions
Copyright (C) 2005, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1985, 1990, 1993, 1998-2000 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,62 +18,117 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This file contains definitions to fill in for differences or
deficiencies to OS or compiler irregularities. If this file is
included other routines can be more portable.
*/
#ifndef __CDIO_PORTABLE_H__
#define __CDIO_PORTABLE_H__
#ifndef __FILEMODE_H__
#define __FILEMODE_H__
#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__)
# include "config.h"
# define __CDIO_CONFIG_H__ 1
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#if !defined(HAVE_FTRUNCATE)
# if defined ( WIN32 )
# define ftruncate chsize
#ifndef S_IRUSR
# ifdef S_IREAD
# define S_IRUSR S_IREAD
# else
# define S_IRUSR 00400
# endif
#endif /*HAVE_FTRUNCATE*/
#if !defined(HAVE_SNPRINTF)
# if defined ( MSVC )
# define snprintf _snprintf
# endif
#endif /*HAVE_SNPRINTF*/
#if !defined(HAVE_VSNPRINTF)
# if defined ( MSVC )
# define snprintf _vsnprintf
# endif
#endif /*HAVE_SNPRINTF*/
#if !defined(HAVE_DRAND48) && defined(HAVE_RAND)
# define drand48() (rand() / (double)RAND_MAX)
#endif
#ifdef MSVC
# include <io.h>
# ifndef S_ISBLK
# define _S_IFBLK 0060000 /* Block Special */
# define S_ISBLK(x) (x & _S_IFBLK)
#ifndef S_IWUSR
# ifdef S_IWRITE
# define S_IWUSR S_IWRITE
# else
# define S_IWUSR 00200
# endif
# ifndef S_ISCHR
# define _S_IFCHR 0020000 /* character special */
# define S_ISCHR(x) (x & _S_IFCHR)
# endif
#endif /*MSVC*/
#ifdef HAVE_MEMSET
# define BZERO(ptr, size) memset(ptr, 0, size)
#elif HAVE_BZERO
# define BZERO(ptr, size) bzero(ptr, size)
#else
#error You need either memset or bzero
#endif
#endif /* __CDIO_PORTABLE_H__ */
#ifndef S_IXUSR
# ifdef S_IEXEC
# define S_IXUSR S_IEXEC
# else
# define S_IXUSR 00100
# endif
#endif
#ifndef S_IRGRP
# define S_IRGRP (S_IRUSR >> 3)
#endif
#ifndef S_IWGRP
# define S_IWGRP (S_IWUSR >> 3)
#endif
#ifndef S_IXGRP
# define S_IXGRP (S_IXUSR >> 3)
#endif
#ifndef S_IROTH
# define S_IROTH (S_IRUSR >> 6)
#endif
#ifndef S_IWOTH
# define S_IWOTH (S_IWUSR >> 6)
#endif
#ifndef S_IXOTH
# define S_IXOTH (S_IXUSR >> 6)
#endif
#ifdef STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISMPB
# undef S_ISMPC
# undef S_ISNWK
# undef S_ISREG
# undef S_ISSOCK
#endif /* STAT_MACROS_BROKEN. */
#if !defined S_IFBLK && defined _WIN32
# define S_IFBLK 0x3000
#endif
#if !defined S_IFIFO && defined _WIN32
# define S_IFIFO 0x1000
#endif
#if !defined S_ISBLK && defined S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#endif
#if !defined S_ISCHR && defined S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
#if !defined S_ISDIR && defined S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined S_ISREG && defined S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined S_ISFIFO && defined S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined HAVE_S_ISLNK
# if !defined S_ISLNK && defined S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) ((void)m, 0)
# endif
#endif
#if !defined HAVE_S_ISSOCK
# if !defined S_ISSOCK && defined S_IFSOCK
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# else
# define S_ISSOCK(m) ((void)m, 0)
# endif
#endif
#if !defined S_ISMPB && defined S_IFMPB /* V7 */
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
#endif
#if !defined S_ISNWK && defined S_IFNWK /* HP/UX */
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
#if !defined S_ISDOOR && defined S_IFDOOR /* Solaris 2.5 and up */
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
#endif
#if !defined S_ISCTG && defined S_IFCTG /* MassComp */
# define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
#endif
#endif /* __FILEMODE_H__ */