Fixing bug 375985. Add compile time assertions to NSPR. r=wtchang@gmail.com

This commit is contained in:
jwatt%jwatt.org 2007-04-02 09:05:50 +00:00
Родитель bafe9e32c8
Коммит a149a724b5
1 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -48,6 +48,21 @@ typedef PRInt32 PRErrorCode;
#include "prerr.h"
/*
** Compile-time assert. "condition" must be a constant expression.
** The macro should be used only once per source line in places where
** a "typedef" declaration is allowed.
** For stringification of the line numbers where the macro is used we need some
** macro indirection. IMPL is required to get macro-expansion of __LINE__ to
** its integer value so that IMPL2 will stringify the number, not "__LINE__".
*/
#define PR_STATIC_ASSERT(condition) \
PR_STATIC_ASSERT_IMPL(condition, __LINE__)
#define PR_STATIC_ASSERT_IMPL(condition, line) \
PR_STATIC_ASSERT_IMPL2(condition, line)
#define PR_STATIC_ASSERT_IMPL2(condition, line) \
typedef int pr_static_assert_line_##line[(condition) ? 1 : -1]
/*
** Set error will preserve an error condition within a thread context.
** The values stored are the NSPR (platform independent) translation of