summaryrefslogtreecommitdiff
path: root/src/common/nullpo.h
diff options
context:
space:
mode:
authorValaris <Valaris@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-01-29 16:10:48 +0000
committerValaris <Valaris@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-01-29 16:10:48 +0000
commit620e60eebce2c1f35c5c9a82f6ca365b316587f5 (patch)
tree38a39e0415f419d9a49ae456ed0e26654c23d559 /src/common/nullpo.h
parenta2675f07d7da22a7c6ae11f545bf8f671e785a82 (diff)
downloadhercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.gz
hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.bz2
hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.xz
hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.zip
AS OF SVN REV. 5901, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5094 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/nullpo.h')
-rw-r--r--src/common/nullpo.h237
1 files changed, 237 insertions, 0 deletions
diff --git a/src/common/nullpo.h b/src/common/nullpo.h
new file mode 100644
index 000000000..66d984224
--- /dev/null
+++ b/src/common/nullpo.h
@@ -0,0 +1,237 @@
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#ifndef _NULLPO_H_
+#define _NULLPO_H_
+
+
+#define NULLPO_CHECK 1
+ // �S�̂̃X�C�b�`��錾���Ă���w�b�_�������
+ // �����Ɉړ����Ă����������
+
+#ifndef __NETBSD__
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2
+# define __func__ __FUNCTION__
+# else
+# define __func__ ""
+# endif
+#endif
+#endif
+
+#ifdef _WIN32
+#define __attribute__(x) /* nothing */
+#endif
+
+
+#define NLP_MARK __FILE__, __LINE__, __func__
+
+/*----------------------------------------------------------------------------
+ * Macros
+ *----------------------------------------------------------------------------
+ */
+/*======================================
+ * Null�`�F�b�N �y�� ���o�͌� return
+ *�E�W�J�����if�Ƃ�return�����o��̂�
+ * ��s�P�̂Ŏg���Ă��������B
+ *�Enullpo_ret(x = func());
+ * �̂悤�Ȏg�p�@���z�肵�Ă��܂��B
+ *--------------------------------------
+ * nullpo_ret(t)
+ * �߂�l 0�Œ�
+ * [����]
+ * t �`�F�b�N�Ώ�
+ *--------------------------------------
+ * nullpo_retv(t)
+ * �߂�l �Ȃ�
+ * [����]
+ * t �`�F�b�N�Ώ�
+ *--------------------------------------
+ * nullpo_retr(ret, t)
+ * �߂�l �w��
+ * [����]
+ * ret return(ret);
+ * t �`�F�b�N�Ώ�
+ *--------------------------------------
+ * nullpo_ret_f(t, fmt, ...)
+ * �ڍ׏��o�͗p
+ * �߂�l 0
+ * [����]
+ * t �`�F�b�N�Ώ�
+ * fmt ... vprintf�ɓn�����
+ * ���l��֌W�ϐ��̏����o���Ȃǂ�
+ *--------------------------------------
+ * nullpo_retv_f(t, fmt, ...)
+ * �ڍ׏��o�͗p
+ * �߂�l �Ȃ�
+ * [����]
+ * t �`�F�b�N�Ώ�
+ * fmt ... vprintf�ɓn�����
+ * ���l��֌W�ϐ��̏����o���Ȃǂ�
+ *--------------------------------------
+ * nullpo_retr_f(ret, t, fmt, ...)
+ * �ڍ׏��o�͗p
+ * �߂�l �w��
+ * [����]
+ * ret return(ret);
+ * t �`�F�b�N�Ώ�
+ * fmt ... vprintf�ɓn�����
+ * ���l��֌W�ϐ��̏����o���Ȃǂ�
+ *--------------------------------------
+ */
+
+#if NULLPO_CHECK
+
+#define nullpo_ret(t) \
+ if (nullpo_chk(NLP_MARK, (void *)(t))) {return(0);}
+
+#define nullpo_retv(t) \
+ if (nullpo_chk(NLP_MARK, (void *)(t))) {return;}
+
+#define nullpo_retr(ret, t) \
+ if (nullpo_chk(NLP_MARK, (void *)(t))) {return(ret);}
+
+#define nullpo_retb(t) \
+ if (nullpo_chk(NLP_MARK, (void *)(t))) {break;}
+
+// �•ψ����}�N���Ɋւ�������R���p�C��
+#if __STDC_VERSION__ >= 199901L
+/* C99�ɑΉ� */
+#define nullpo_ret_f(t, fmt, ...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return(0);}
+
+#define nullpo_retv_f(t, fmt, ...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return;}
+
+#define nullpo_retr_f(ret, t, fmt, ...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return(ret);}
+
+#define nullpo_retb_f(t, fmt, ...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {break;}
+
+#elif __GNUC__ >= 2
+/* GCC�p */
+#define nullpo_ret_f(t, fmt, args...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return(0);}
+
+#define nullpo_retv_f(t, fmt, args...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return;}
+
+#define nullpo_retr_f(ret, t, fmt, args...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return(ret);}
+
+#define nullpo_retb_f(t, fmt, args...) \
+ if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {break;}
+
+#else
+
+/* ���̑��̏ꍇ�E�E�E orz */
+
+#endif
+
+#else /* NULLPO_CHECK */
+/* No Nullpo check */
+
+// if((t)){;}
+// �ǂ����@���v���‚��Ȃ������̂ŁE�E�E����̍�ł��B
+// �ꉞ���[�j���O�͏o�Ȃ��͂�
+
+#define nullpo_ret(t) if((t)){;}
+#define nullpo_retv(t) if((t)){;}
+#define nullpo_retr(ret, t) if((t)){;}
+#define nullpo_retb(t) if((t)){;}
+
+// �•ψ����}�N���Ɋւ�������R���p�C��
+#if __STDC_VERSION__ >= 199901L
+/* C99�ɑΉ� */
+#define nullpo_ret_f(t, fmt, ...) if((t)){;}
+#define nullpo_retv_f(t, fmt, ...) if((t)){;}
+#define nullpo_retr_f(ret, t, fmt, ...) if((t)){;}
+#define nullpo_retb_f(t, fmt, ...) if((t)){;}
+
+#elif __GNUC__ >= 2
+/* GCC�p */
+#define nullpo_ret_f(t, fmt, args...) if((t)){;}
+#define nullpo_retv_f(t, fmt, args...) if((t)){;}
+#define nullpo_retr_f(ret, t, fmt, args...) if((t)){;}
+#define nullpo_retb_f(t, fmt, args...) if((t)){;}
+
+#else
+/* ���̑��̏ꍇ�E�E�E orz */
+#endif
+
+#endif /* NULLPO_CHECK */
+
+/*----------------------------------------------------------------------------
+ * Functions
+ *----------------------------------------------------------------------------
+ */
+/*======================================
+ * nullpo_chk
+ * Null�`�F�b�N �y�� ���o��
+ * [����]
+ * file __FILE__
+ * line __LINE__
+ * func __func__ (�֐���)
+ * �����ɂ� NLP_MARK ���g���Ƃ悢
+ * target �`�F�b�N�Ώ�
+ * [�Ԃ�l]
+ * 0 OK
+ * 1 NULL
+ *--------------------------------------
+ */
+int nullpo_chk(const char *file, int line, const char *func, const void *target);
+
+
+/*======================================
+ * nullpo_chk_f
+ * Null�`�F�b�N �y�� �ڍׂȏ��o��
+ * [����]
+ * file __FILE__
+ * line __LINE__
+ * func __func__ (�֐���)
+ * �����ɂ� NLP_MARK ���g���Ƃ悢
+ * target �`�F�b�N�Ώ�
+ * fmt ... vprintf�ɓn�����
+ * ���l��֌W�ϐ��̏����o���Ȃǂ�
+ * [�Ԃ�l]
+ * 0 OK
+ * 1 NULL
+ *--------------------------------------
+ */
+int nullpo_chk_f(const char *file, int line, const char *func, const void *target,
+ const char *fmt, ...)
+ __attribute__((format(printf,5,6)));
+
+
+/*======================================
+ * nullpo_info
+ * nullpo���o��
+ * [����]
+ * file __FILE__
+ * line __LINE__
+ * func __func__ (�֐���)
+ * �����ɂ� NLP_MARK ���g���Ƃ悢
+ *--------------------------------------
+ */
+void nullpo_info(const char *file, int line, const char *func);
+
+
+/*======================================
+ * nullpo_info_f
+ * nullpo�ڍ׏��o��
+ * [����]
+ * file __FILE__
+ * line __LINE__
+ * func __func__ (�֐���)
+ * �����ɂ� NLP_MARK ���g���Ƃ悢
+ * fmt ... vprintf�ɓn�����
+ * ���l��֌W�ϐ��̏����o���Ȃǂ�
+ *--------------------------------------
+ */
+void nullpo_info_f(const char *file, int line, const char *func,
+ const char *fmt, ...)
+ __attribute__((format(printf,4,5)));
+
+
+#endif