Mercurial > hg > octave-jordi > gnulib-hg
changeset 6267:58c87cabeb1c
* modules/verify: New file.
* lib/verify.h: New file.
* MODULES.html.sh (Diagnostics <assert.h>): New section,
with "verify" module.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 22 Sep 2005 22:56:28 +0000 |
parents | 197ea7971323 |
children | 18ae925055f9 |
files | MODULES.html.sh lib/verify.h modules/verify |
diffstat | 3 files changed, 88 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1424,6 +1424,16 @@ func_wrap H2 func_echo "$element" + element="Diagnostics <assert.h>" + element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"` + func_section_wrap ansic_enh_assert_diagnostics + func_wrap H3 + func_echo "$element" + + func_begin_table + func_module verify + func_end_table + element="Memory management functions <stdlib.h>" element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"` func_section_wrap ansic_enh_stdlib_memory
new file mode 100644 --- /dev/null +++ b/lib/verify.h @@ -0,0 +1,57 @@ +/* Compile-time assert-like macros. + + Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert and Jim Meyering. */ + +#ifndef VERIFY_H +# define VERIFY_H 1 + +# define GL_CONCAT0(x, y) x##y +# define GL_CONCAT(x, y) GL_CONCAT0 (x, y) + +/* A type that is valid if and only if R is nonzero. + R should be an integer constant expression. + verify_type__ and verify_error_if_negative_size__ are symbols that + are private to this header file. */ + +# define verify_type__(R) \ + struct { int verify_error_if_negative_size__ : (R) ? 1 : -1; } + +/* Verify requirement R at compile-time, as a declaration. + R should be an integer constant expression. + Unlike assert, there is no run-time overhead. + + The implementation uses __LINE__ to lessen the probability of + generating a warning that verify_function_NNN is multiply declared. + However, even if two declarations in different files have the same + __LINE__, the multiple declarations are still valid C89 and C99 + code because they simply redeclare the same external function, so + no conforming compiler will reject them outright. */ + +# define verify(R) \ + extern verify_type__ (R) GL_CONCAT (verify_function_, __LINE__) (void) + +/* Verify requirement R at compile-time, as an expression. + R should be an integer constant expression. + Unlike assert, there is no run-time overhead. + This macro can be used in some contexts where verify cannot, and vice versa. + Return void. */ + +# define verify_expr(R) ((void) ((verify_type__ (R) *) 0)) + +#endif
new file mode 100644 --- /dev/null +++ b/modules/verify @@ -0,0 +1,21 @@ +Description: +Compile-time assert-like macros. + +Files: +lib/verify.h + +Depends-on: + +configure.ac: + +Makefile.am: +lib_SOURCES += verify.h + +Include: +"verify.h" + +License: +GPL + +Maintainer: +Paul Eggert, Jim Meyering