summaryrefslogtreecommitdiff
path: root/src/common/nullpo.h
diff options
context:
space:
mode:
author(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-11-04 23:25:09 +0000
committer(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-11-04 23:25:09 +0000
commit195dffc20af1fb32c7e4119988911b72955aeabc (patch)
treeb60d2a5e72d64dc5fc21eb9ce0962631e774a4c9 /src/common/nullpo.h
downloadhercules-195dffc20af1fb32c7e4119988911b72955aeabc.tar.gz
hercules-195dffc20af1fb32c7e4119988911b72955aeabc.tar.bz2
hercules-195dffc20af1fb32c7e4119988911b72955aeabc.tar.xz
hercules-195dffc20af1fb32c7e4119988911b72955aeabc.zip
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/athena@2 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/nullpo.h')
-rw-r--r--src/common/nullpo.h222
1 files changed, 222 insertions, 0 deletions
diff --git a/src/common/nullpo.h b/src/common/nullpo.h
new file mode 100644
index 000000000..6365cf02d
--- /dev/null
+++ b/src/common/nullpo.h
@@ -0,0 +1,222 @@
+#ifndef _NULLPO_H_
+#define _NULLPO_H_
+
+
+#define NULLPO_CHECK 1
+ // �S�̂̃X�C�b�`��錾���Ă���w�b�_�������
+ // �����Ɉړ����Ă����������
+
+
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2
+# define __func__ __FUNCTION__
+# else
+# define __func__ ""
+# 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);}
+
+
+// �•ψ����}�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);}
+
+#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);}
+
+#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)){;}
+
+// �•ψ����}�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)){;}
+
+#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)){;}
+
+#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