summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/lib
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2004-06-10 19:05:38 +0000
committerpeter <peter@FreeBSD.org>2004-06-10 19:05:38 +0000
commit1ca65160a61129882a143f867124863e87679616 (patch)
treed3d085ec0a7cefbb1c0b360471aa7446b54be77c /contrib/cvs/lib
parent023c667a2ba65987f6b66cda4d0f75b4daf0600d (diff)
parent8416bda1d23bda4666a5b880a9d78eccaa640036 (diff)
downloadFreeBSD-src-1ca65160a61129882a143f867124863e87679616.zip
FreeBSD-src-1ca65160a61129882a143f867124863e87679616.tar.gz
This commit was generated by cvs2svn to compensate for changes in r130303,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/cvs/lib')
-rw-r--r--contrib/cvs/lib/ChangeLog28
-rw-r--r--contrib/cvs/lib/Makefile.am4
-rw-r--r--contrib/cvs/lib/Makefile.in7
-rw-r--r--contrib/cvs/lib/system.h76
-rw-r--r--contrib/cvs/lib/xsize.h108
5 files changed, 184 insertions, 39 deletions
diff --git a/contrib/cvs/lib/ChangeLog b/contrib/cvs/lib/ChangeLog
index ae64487..fa9d4a9 100644
--- a/contrib/cvs/lib/ChangeLog
+++ b/contrib/cvs/lib/ChangeLog
@@ -1,3 +1,31 @@
+2004-05-28 Derek Price <derek@ximbiot.com>
+
+ * xsize.h: New file from GNULIB.
+ * Makefile.am (libcvs_a_SOURCES): Add xsize.h.
+
+2004-05-15 Derek Price <derek@ximbiot.com>
+
+ * libcvs.dsp: Header file list updated.
+ * libcvs.dep: Regenerated for "libcvs.dsp" changes.
+ * libcvs.mak: Regenerated for "libcvs.dsp" changes.
+ (Patch from Conrad Pino <conrad@pino.com>.)
+
+2004-05-13 Derek Price <derek@ximbiot.com>
+
+ * .cvsignore: Changed for "libcvs.dsp" changes.
+ * libcvs.dsp: Added for "../cvsnt.dsw" changes.
+ * libcvs.dep: Added for "libcvs.dsp" addition.
+ * libcvs.mak: Added for "libcvs.dsp" addition.
+ (Patch from Conrad Pino <conrad@pino.com>.)
+
+2004-04-20 Derek Price <derek@ximbiot.com>
+
+ * system.h: Correct comments.
+
+2004-04-19 Derek Price <derek@ximbiot.com>
+
+ * system.h: Gratuitous reformatting.
+
2004-04-07 Derek Price <derek@ximbiot.com>
* regex.c: Revise "FREE_VAR" macro to eliminate C4090/C4022 warnings
diff --git a/contrib/cvs/lib/Makefile.am b/contrib/cvs/lib/Makefile.am
index 9409b9a..91cdeea 100644
--- a/contrib/cvs/lib/Makefile.am
+++ b/contrib/cvs/lib/Makefile.am
@@ -85,8 +85,12 @@ EXTRA_DIST = \
.cvsignore \
ChangeLog.fsf \
build_lib.com \
+ libcvs.dep libcvs.dsp libcvs.mak \
xgssapi.h
+# For the xsize module from GNULIB.
+libcvs_a_SOURCES += xsize.h
+
# Until Automake gets its act together
distclean-local:
rm -f fnmatch.h
diff --git a/contrib/cvs/lib/Makefile.in b/contrib/cvs/lib/Makefile.in
index a8ff862..012d089 100644
--- a/contrib/cvs/lib/Makefile.in
+++ b/contrib/cvs/lib/Makefile.in
@@ -166,6 +166,8 @@ noinst_LIBRARIES = libcvs.a
# Also should look into unifying regular expression matching in CVS
# with the diff library (perhaps to have the caller, CVS, do the
# matching?)
+
+# For the xsize module from GNULIB.
libcvs_a_SOURCES = \
argmatch.c \
getdate.y \
@@ -189,14 +191,15 @@ libcvs_a_SOURCES = \
system.h \
wait.h \
xselect.h \
- xtime.h
-
+ xtime.h\
+xsize.h
libcvs_a_LIBADD = @LIBOBJS@
EXTRA_DIST = \
.cvsignore \
ChangeLog.fsf \
build_lib.com \
+ libcvs.dep libcvs.dsp libcvs.mak \
xgssapi.h
subdir = lib
diff --git a/contrib/cvs/lib/system.h b/contrib/cvs/lib/system.h
index 4b25d31..a18dff8 100644
--- a/contrib/cvs/lib/system.h
+++ b/contrib/cvs/lib/system.h
@@ -289,7 +289,7 @@ int utime ();
#ifdef STDC_HEADERS
-#include <stdlib.h>
+# include <stdlib.h>
#else
char *getenv ();
char *malloc ();
@@ -300,7 +300,7 @@ extern int errno;
/* SunOS4 apparently does not define this in stdlib.h. */
#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
+# define EXIT_FAILURE 1
#endif
/* check for POSIX signals */
@@ -323,26 +323,26 @@ extern int errno;
/* Under OS/2, this must be included _after_ stdio.h; that's why we do
it here. */
#ifdef USE_OWN_TCPIP_H
-#include "tcpip.h"
+# include "tcpip.h"
#endif
#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+# include <fcntl.h>
#else
-#include <sys/file.h>
+# include <sys/file.h>
#endif
#ifndef SEEK_SET
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
+# define SEEK_SET 0
+# define SEEK_CUR 1
+# define SEEK_END 2
#endif
#ifndef F_OK
-#define F_OK 0
-#define X_OK 1
-#define W_OK 2
-#define R_OK 4
+# define F_OK 0
+# define X_OK 1
+# define W_OK 2
+# define R_OK 4
#endif
#if HAVE_DIRENT_H
@@ -367,7 +367,7 @@ extern int errno;
#define convert_blocks(b, k) ((k) ? ((b) + 1) / 2 : (b))
#ifndef S_ISLNK
-#define lstat stat
+# define lstat stat
#endif
/*
@@ -375,13 +375,13 @@ extern int errno;
* because "config.h" is always included last.
*/
#ifndef S_IWRITE
-#define S_IWRITE 0000200 /* write permission, owner */
+# define S_IWRITE 0000200 /* write permission, owner */
#endif
#ifndef S_IWGRP
-#define S_IWGRP 0000020 /* write permission, grougroup */
+# define S_IWGRP 0000020 /* write permission, grougroup */
#endif
#ifndef S_IWOTH
-#define S_IWOTH 0000002 /* write permission, other */
+# define S_IWOTH 0000002 /* write permission, other */
#endif
/* Under non-UNIX operating systems (MS-DOS, WinNT, MacOS), many filesystem
@@ -390,71 +390,71 @@ extern int errno;
can hang their own definitions. */
#ifndef CVS_ACCESS
-#define CVS_ACCESS access
+# define CVS_ACCESS access
#endif
#ifndef CVS_CHDIR
-#define CVS_CHDIR chdir
+# define CVS_CHDIR chdir
#endif
#ifndef CVS_CREAT
-#define CVS_CREAT creat
+# define CVS_CREAT creat
#endif
#ifndef CVS_FOPEN
-#define CVS_FOPEN fopen
+# define CVS_FOPEN fopen
#endif
#ifndef CVS_FDOPEN
-#define CVS_FDOPEN fdopen
+# define CVS_FDOPEN fdopen
#endif
#ifndef CVS_MKDIR
-#define CVS_MKDIR mkdir
+# define CVS_MKDIR mkdir
#endif
#ifndef CVS_OPEN
-#define CVS_OPEN open
+# define CVS_OPEN open
#endif
#ifndef CVS_READDIR
-#define CVS_READDIR readdir
+# define CVS_READDIR readdir
#endif
#ifndef CVS_CLOSEDIR
-#define CVS_CLOSEDIR closedir
+# define CVS_CLOSEDIR closedir
#endif
#ifndef CVS_OPENDIR
-#define CVS_OPENDIR opendir
+# define CVS_OPENDIR opendir
#endif
#ifndef CVS_RENAME
-#define CVS_RENAME rename
+# define CVS_RENAME rename
#endif
#ifndef CVS_RMDIR
-#define CVS_RMDIR rmdir
+# define CVS_RMDIR rmdir
#endif
#ifndef CVS_STAT
-#define CVS_STAT stat
+# define CVS_STAT stat
#endif
/* Open question: should CVS_STAT be lstat by default? We need
to use lstat in order to handle symbolic links correctly with
the PreservePermissions option. -twp */
#ifndef CVS_LSTAT
-#define CVS_LSTAT lstat
+# define CVS_LSTAT lstat
#endif
#ifndef CVS_UNLINK
-#define CVS_UNLINK unlink
+# define CVS_UNLINK unlink
#endif
/* Wildcard matcher. Should be case-insensitive if the system is. */
#ifndef CVS_FNMATCH
-#define CVS_FNMATCH fnmatch
+# define CVS_FNMATCH fnmatch
#endif
#ifdef WIN32
@@ -483,7 +483,7 @@ extern int errno;
#ifdef FILENAMES_CASE_INSENSITIVE
# if defined (__CYGWIN32__) || defined (WOE32)
- /* Under Windows NT, filenames are case-insensitive, and both / and \
+ /* Under Windows, filenames are case-insensitive, and both / and \
are path component separators. */
# define FOLD_FN_CHAR(c) (WNT_filename_classes[(unsigned char) (c)])
extern unsigned char WNT_filename_classes[];
@@ -492,12 +492,14 @@ extern unsigned char WNT_filename_classes[];
# define ISDIRSEP(c) (FOLD_FN_CHAR(c) == '/')
# define ISABSOLUTE(s) (ISDIRSEP(s[0]) || FOLD_FN_CHAR(s[0]) >= 'a' && FOLD_FN_CHAR(s[0]) <= 'z' && s[1] == ':' && ISDIRSEP(s[2]))
# else /* ! WOE32 */
- /* As far as I know, both Cygwin and Macintosh OS X can make it here,
+ /* As far as I know, just Macintosh OS X can make it here,
* but since the OS X fold just folds a-z into A-Z or visa-versa, I'm just
- * using it for Cygwin too. The var name below could probably use a
- * rename.
+ * allowing it to be used for any case insensitive system which we aren't
+ * yet making other specific folds or exceptions for (basically, anything
+ * case insensitive other than Windows, where \ and C:\ style absolute paths
+ * also need to be accounted for).
*
- * Under Mac OS X & Cygwin, filenames are case-insensitive.
+ * Under Mac OS X, filenames are case-insensitive.
*/
# define FOLD_FN_CHAR(c) (OSX_filename_classes[(unsigned char) (c)])
extern unsigned char OSX_filename_classes[];
diff --git a/contrib/cvs/lib/xsize.h b/contrib/cvs/lib/xsize.h
new file mode 100644
index 0000000..7634c6d
--- /dev/null
+++ b/contrib/cvs/lib/xsize.h
@@ -0,0 +1,108 @@
+/* xsize.h -- Checked size_t computations.
+
+ Copyright (C) 2003 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _XSIZE_H
+#define _XSIZE_H
+
+/* Get size_t. */
+#include <stddef.h>
+
+/* Get SIZE_MAX. */
+#include <limits.h>
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+/* The size of memory objects is often computed through expressions of
+ type size_t. Example:
+ void* p = malloc (header_size + n * element_size).
+ These computations can lead to overflow. When this happens, malloc()
+ returns a piece of memory that is way too small, and the program then
+ crashes while attempting to fill the memory.
+ To avoid this, the functions and macros in this file check for overflow.
+ The convention is that SIZE_MAX represents overflow.
+ malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
+ implementation that uses mmap --, it's recommended to use size_overflow_p()
+ or size_in_bounds_p() before invoking malloc().
+ The example thus becomes:
+ size_t size = xsum (header_size, xtimes (n, element_size));
+ void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
+*/
+
+/* Convert an arbitrary value >= 0 to type size_t. */
+#define xcast_size_t(N) \
+ ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
+
+/* Sum of two sizes, with overflow check. */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum (size_t size1, size_t size2)
+{
+ size_t sum = size1 + size2;
+ return (sum >= size1 ? sum : SIZE_MAX);
+}
+
+/* Sum of three sizes, with overflow check. */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum3 (size_t size1, size_t size2, size_t size3)
+{
+ return xsum (xsum (size1, size2), size3);
+}
+
+/* Sum of four sizes, with overflow check. */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
+{
+ return xsum (xsum (xsum (size1, size2), size3), size4);
+}
+
+/* Maximum of two sizes, with overflow check. */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xmax (size_t size1, size_t size2)
+{
+ /* No explicit check is needed here, because for any n:
+ max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */
+ return (size1 >= size2 ? size1 : size2);
+}
+
+/* Multiplication of a count with an element size, with overflow check.
+ The count must be >= 0 and the element size must be > 0.
+ This is a macro, not an inline function, so that it works correctly even
+ when N is of a wider tupe and N > SIZE_MAX. */
+#define xtimes(N, ELSIZE) \
+ ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
+
+/* Check for overflow. */
+#define size_overflow_p(SIZE) \
+ ((SIZE) == SIZE_MAX)
+/* Check against overflow. */
+#define size_in_bounds_p(SIZE) \
+ ((SIZE) != SIZE_MAX)
+
+#endif /* _XSIZE_H */
OpenPOWER on IntegriCloud