/*	
 *	include/assert.h
 *
 *	CLiP - Common Library for P/ECE
 *	Copyright (C) 2012-2016 Naoyuki Sawa
 *
 *	* Thu Jul 20 06:10:41 JST 2006 Naoyuki Sawa
 *	- 怴婯嶌惉丅
 *	  杮僼傽僀儖傪嶌惉偟偨棟桼偼丄clipstd.h偺僐儊儞僩傪嶲徠偟偰偔偩偝偄丅
 *	* Tue Jan 03 22:25:06 JST 2012 Naoyuki Sawa
 *	- assert偺桳岠/柍岠傪丄NDEBUG僔儞儃儖偱愗傝懼偊傞傛偆偵曄峏偟傑偟偨丅
 *	* Sat Jan 14 00:03:29 JST 2012 Naoyuki Sawa
 *	- assert儅僋儘偑丄die()偺戙傝偵丄die3()傪巊梡偡傞傛偆偵曄峏偟傑偟偨丅
 *	  徻嵶偼丄clipmisc.h偺摨擔偺僐儊儞僩傪嶲徠偟偰偔偩偝偄丅
 *	* Wed Nov 18 21:37:53 JST 2015 Naoyuki Sawa
 *	- 'extern "C" {'乣'}'偱埻傒傑偟偨丅.cpp傪娷傓Win32僾儘僕僃僋僩偐傜傕僀儞僋儖乕僪弌棃傞傛偆偵偡傞偨傔偱偡丅
 *	* Sun Oct 23 10:04:30 JST 2016 Naoyuki Sawa
 *	- _Static_assert偲static_assert傪捛壛偟傑偟偨丅
 *	  偙傟傑偱偼static_assert偑柍偐偭偨偨傔偵丄惷揑側専嵏傪幚峴帪偵峴偭偰偄傞張棟偑奺儌僕儏乕儖撪偵婔偮偐桳傞偺偱偡偑丄
 *	  崱夞static_assert傪捛壛偟偨偺偱丄奺儌僕儏乕儖撪偺忋婰偺傛偆側張棟傪丄弴師static_assert偵抲偒姺偊偰峴偔梊掕偱偡丅
 *	* Thu Nov 17 21:56:29 JST 2016 Naoyuki Sawa
 *	- assert()儅僋儘偺幚憰傪曄峏偟傑偟偨丅(曄峏偟偨僼傽僀儖偼丄clippce.c偲include/assert.h偱偡丅)
 *	  徻嵶偼丄clippce.c撪偺new_assert_isr()偺幚憰晹偺僐儊儞僩傪嶲徠偟偰壓偝偄丅
 *	* Fri Dec 02 22:30:56 JST 2016 Naoyuki Sawa
 *	- assert()偑巊梡偡傞僜僼僩僂僃傾椺奜偺斣崋傪丄0斣佀3斣偵曄峏偟傑偟偨丅
 *	  曄峏偟偨棟桼偺徻嵶偼丄clippce.c撪偺乽assert()儅僋儘偺僒億乕僩儖乕僠儞乿偺摨擔偺僐儊儞僩傪嶲徠偟偰壓偝偄丅
 */
#ifndef _ASSERT_H
#define _ASSERT_H

#ifdef  __cplusplus
extern "C" {
#endif//__cplusplus

//{{2012/01/03:曄峏
//#define assert	ASSERT	/* ASSERT()儅僋儘偼clipmisc.h偱掕媊偝傟偰偄傑偡丅 */
//伀2012/01/03:曄峏
//伀* Tue Jan 03 22:25:06 JST 2012 Naoyuki Sawa
//伀- 偙傟傑偱丄assert偼ASSERT偲摨偠偔丄DEBUG僔儞儃儖偑掕媊偝傟偰偄傞偲偒偵桳岠偲偟偰偄傑偟偨丅
//伀  偟偐偟丄CLiP巊梡僾儘僕僃僋僩傪DEBUG價儖僪偡傞偙偲偼傎偲傫偳柍偄偨傔丄assert傕ASSERT傕傎傏巊偄摴偑偁傝傑偣傫偱偟偨丅
//伀  尦乆DEBUG僔儞儃儖偼丄CLiP儔僀僽儔儕奐敪弶婜偺DEBUG價儖僪偵棙梡偟偨偺傒偱丄尰嵼偼DEBUG價儖僪偺専徹偼峴偭偰偄傑偣傫丅
//伀- 崱夞丄Lua儔僀僽儔儕偺巊梡偵偁偨傝丄API僠僃僢僋偑assert偱峴傢傟偰偄傞偨傔丄assert傪桳岠偵偟偨偄偲峫偊傑偟偨丅
//伀  偟偐偟丄忋婰偺棟桼偵傛傝丄CLiP巊梡僾儘僕僃僋僩偱assert傪桳岠偵偡傞偙偲偼擄偟偄偲偄偆栤戣偑敪惗偟傑偟偨丅
//伀  assert傪桳岠偵偟偨偗傟偽丄DEBUG價儖僪偵偡傞偟偐曽朄偑柍偔丄幚梡揑偱側偄偨傔偱偡丅
//伀- 偦偙偱崱屻丄assert偼ASSERT偲堘偭偰丄NDEBUG僔儞儃儖偑掕媊偝傟偰偄側偄偲偒偵桳岠偲偡傞傛偆偵曄峏偟傑偟偨丅
//伀  昗弨C儔僀僽儔儕偺巇條偵弨嫆偡傞傛偆偵偟偨傢偗偱丄偦偺娤揰偐傜傕朷傑偟偄偼偢偱偡丅
//伀- 屄暿偺CLiP巊梡僾儘僕僃僋僩偱assert傪桳岠偵偟偨偄応崌丄DEBUG價儖僪偵偡傞昁梫偼偁傝傑偣傫丅
//伀  屄暿偺CLiP巊梡僾儘僕僃僋僩偺Makefile偱丄埲壓偺傛偆偵掕媊偟偰偔偩偝偄丅
//伀	APP_CFLAGS = -D"NDEBUG -UNDEBUG"
//伀  偙傟偼丄gcc33.exe偵懳偟偰埲壓偺傛偆偵堷偒搉偝傟丄clip.mk撪偱巜掕偝傟偰偄傞-DNDEBUG傪丄枹掕媊偵栠偟傑偡丅
//伀	gcc33.exe -S -x c -Wall -DPIECE -I..\clip -I..\clip\include -O2 -DNDEBUG -DNDEBUG -UNDEBUG -IC:\usr\PIECE\include main.$
//伀	                                                                         ~~~~~~~~~~~~~~~~~
//伀  扨弮偵乽APP_CFLAGS = -UNDEBUG乿偲巜掕偱偒側偄棟桼偼丄pcc33.exe偑-U僆僾僔儑儞傪擣幆偟側偄偐傜偱偡丅
//伀  偙偺僥僋僯僢僋偵偮偄偰偼丄test.pce/Makefile撪偺僐儊儞僩傪嶲徠偟偰偔偩偝偄丅
#ifndef NDEBUG
//{{2012/01/14:曄峏
//void die(const char* fmt, ...) __attribute__((noreturn));
//#define assert(f)	((void)((f) || (die(__FILE__ "(%d): %s", __LINE__, #f), 0)))
//伀2012/01/14:曄峏
//void die3(const char* file, int line, const char* f) __attribute__((noreturn));
//#define assert(f)	((void)((f) || (die3(__FILE__, __LINE__, #f), 0)))
//伀2016/11/17曄峏:assert()儅僋儘偺幚憰傪曄峏偟傑偟偨丅(曄峏偟偨僼傽僀儖偼丄clippce.c偲include/assert.h偱偡丅)
//#define assert(expr)	asm /*volatile*/ ("ld.w\t%%r9,%0\n\tint\t0\n\t.word\t%1\n\t.half\t%2" : : "r"(expr),"i"(__FILE__),"i"(__LINE__) : /*"cc",*/"%r9")	//揥奐僐乕僪偺徻嵶偵偮偄偰偼丄clippce.c撪偺new_assert_isr()偺幚憰晹偺僐儊儞僩傪嶲徠偟偰壓偝偄丅
//			//  ~~~~~~~~~~~~弌椡僆儁儔儞僪偑柍偄asm偼埫栙偱volatile偲尒側偝傟傞偺偱柧帵晄梫丅   ~~~億僀儞僞傕"m"偱偼側偔"i"偱巜掕偡傞帠偵拲堄偣傛丅"m"偱巜掕偡傞偲億僀儞僞傊偺億僀儞僞偵揥奐偝傟偰偟傑偆丅
//伀2016/12/02曄峏:assert()偑巊梡偡傞僜僼僩僂僃傾椺奜偺斣崋傪丄0斣佀3斣偵曄峏偟傑偟偨丅
#define assert(expr)	asm /*volatile*/ ("ld.w\t%%r9,%0\n\tint\t3\n\t.word\t%1\n\t.half\t%2" : : "r"(expr),"i"(__FILE__),"i"(__LINE__) : /*"cc",*/"%r9")	//揥奐僐乕僪偺徻嵶偵偮偄偰偼丄clippce.c撪偺new_assert_isr()偺幚憰晹偺僐儊儞僩傪嶲徠偟偰壓偝偄丅
			//  ~~~~~~~~~~~~弌椡僆儁儔儞僪偑柍偄asm偼埫栙偱volatile偲尒側偝傟傞偺偱柧帵晄梫丅   ~~~億僀儞僞傕"m"偱偼側偔"i"偱巜掕偡傞帠偵拲堄偣傛丅"m"偱巜掕偡傞偲億僀儞僞傊偺億僀儞僞偵揥奐偝傟偰偟傑偆丅
//}}2016/12/02曄峏:assert()偑巊梡偡傞僜僼僩僂僃傾椺奜偺斣崋傪丄0斣佀3斣偵曄峏偟傑偟偨丅
#else /*NDEBUG*/
#define assert(f)	((void)0)
#endif/*NDEBUG*/
//}}2012/01/03:曄峏

//{{2016/10/23捛壛:_Static_assert偲static_assert傪捛壛偟傑偟偨丅
//劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅
//仩嶲徠帒椏乽cppreference.com - static assert declaration乿(http://en.cppreference.com/w/c/language/_Static_assert)
//劆C > C language > Declarations
//劆static assert declaration
//劆Syntax
//劆丂_Static_assert(expression,message)	(since C11)
//劆丂expression - any integer constant expression
//劆丂message    - any string literal
//劆丂This keyword is also available as convenience macro 乽static_assert乿(http://en.cppreference.com/w/c/error/static_assert), available in the header <assert.h>.
//劆Explanation
//劆丂The constant expression is evaluated at compile time and compared to zero.
//劆丂If it compares equal to zero, a compile-time error occurs and the compiler must display message as part of the error message (except that characters not in basic source character set aren't required to be displayed).
//劆丂Otherwise, if expression does not equal zero, nothing happens; no code is emitted.
//劆Keywords
//劆丂乽_Static_assert乿(http://en.cppreference.com/w/c/keyword/_Static_assert)
//劆Example
//劆丂劆#include <assert.h>
//劆丂劆int main(void) {
//劆丂劆丂//Test if math works.
//劆丂劆丂static_assert(2 + 2 == 4, "Whoa dude!"); //or _Static_assert(...
//劆丂劆丂//This will produce an error at compile time.
//劆丂劆丂static_assert(sizeof(int) < sizeof(char), "this program requires that int is less than char");
//劆丂劆}
//劆References
//劆丂丒C11 standard (ISO/IEC 9899:2011):
//劆丂丂丒6.7.10 Static assertions (p: 145)
//劆丂丂丒7.2 Diagnostics <assert.h> (p: 186-187)
//劆See also
//劆丂乽C++ documentation乿(http://en.cppreference.com/w/cpp/language/static_assert) for Static Assertion
#define _Static_assert(expression,message) typedef char __Static_assert__[(expression)?1:-1]	//尩枾偵偼'_Static_assert'偼C11偺僉乕儚乕僪偱偁偭偰儅僋儘偱偼側偄偺偱偡偑丄摉儔僀僽儔儕偱偼儅僋儘偲偟偰幚憰偡傞帠偵偟傑偟偨丅儅僋儘偱偺幚憰曽朄偵偮偄偰偼丄乽Windows Dev Center - C_ASSERT macro乿(https://msdn.microsoft.com/en-us/library/windows/desktop/ms679289(v=vs.85).aspx)傪嶲峫偵偟傑偟偨丅摨偠typedef柤(偙偺応崌偼__Static_assert__)傪暋悢夞巊梡偟偰傕丄摨偠掕媊撪梕側傜偽僄儔乕偵側傜側偄帠傪棙梡偟偰偄傑偡丅
//劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅
//仩嶲徠帒椏乽cppreference.com - static_assert乿(http://en.cppreference.com/w/c/error/static_assert)
//劆C > Error handling
//劆static_assert
//劆丂Defined in header <assert.h>
//劆丂#define static_assert _Static_assert
//劆丂This convenience macro expands to the keyword _Static_assert
//劆Example
//劆丂劆#include <assert.h>
//劆丂劆int main(void) {
//劆丂劆丂static_assert(2 + 2 == 4, "2+2 isn't 4"); //well-formed
//劆丂劆丂static_assert(sizeof(int) < sizeof(char), "this program requires that int is less than char"); //compile-time error
//劆丂劆}
//劆References
//劆丂丒C11 standard (ISO/IEC 9899:2011):
//劆丂丂丒7.2/3 Diagnostics <assert.h> (p: 186)
//劆See also
//劆丂乽C++ documentation乿(http://en.cppreference.com/w/cpp/language/static_assert) for Static Assertion
#define static_assert _Static_assert
//劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅
//}}2016/10/23捛壛:_Static_assert偲static_assert傪捛壛偟傑偟偨丅

#ifdef  __cplusplus
}//extern "C"
#endif//__cplusplus

#endif/*_ASSERT_H*/
