defined QSE_PATH_MAX

added more operators to qse_ip4ad_t for c++
This commit is contained in:
hyung-hwan 2018-01-17 04:38:21 +00:00
parent 825cf63d04
commit 8ce346e1ed
10 changed files with 141 additions and 13 deletions

31
qse/configure vendored
View File

@ -21043,6 +21043,37 @@ fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PATH_MAX" >&5
$as_echo_n "checking for PATH_MAX... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <limits.h>
int
main ()
{
;;;;;;;;;;
PATH_MAX
;
return 0;
}
_ACEOF
qse_cv_path_max="`$ac_cv_prog_CPP conftest.c | awk '/;;;;;;;;;;/ { start=1 } /^(0|1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9)*/ { if (start == 1) { print $0; start++; } }'`"
if test "x${qse_cv_path_max}" = "x"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not defined" >&5
$as_echo "not defined" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${qse_cv_path_max}" >&5
$as_echo "${qse_cv_path_max}" >&6; }
cat >>confdefs.h <<_ACEOF
#define QSE_PATH_MAX ${qse_cv_path_max}
_ACEOF
fi
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.

View File

@ -380,6 +380,25 @@ AC_TRY_LINK(
[AC_MSG_RESULT(no)]
)
dnl check the defined value of PATH_MAX in limits.h.
dnl look for a numeric value of 2 or more digits after preprocessing.
AC_MSG_CHECKING([for PATH_MAX])
AC_LANG_CONFTEST([
AC_LANG_PROGRAM(
[#include <limits.h>],
[;;;;;;;;;;
PATH_MAX])
])
qse_cv_path_max="`$ac_cv_prog_CPP conftest.c | awk '/;;;;;;;;;;/ { start=1 } /^(0|1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9)*/ { if (start == 1) { print $0; start++; } }'`"
if test "x${qse_cv_path_max}" = "x"
then
dnl either not defined or defined to a non-numeric value
AC_MSG_RESULT(not defined)
else
AC_MSG_RESULT(${qse_cv_path_max})
AC_DEFINE_UNQUOTED(QSE_PATH_MAX, ${qse_cv_path_max}, [PATH_MAX])
fi
dnl check the size of primitive data types
AC_CHECK_SIZEOF(char,,[[]])
AC_CHECK_SIZEOF(short,,[[]])

View File

@ -29,6 +29,7 @@
#include <qse/types.h>
#include <qse/macros.h>
#include <qse/cmn/hton.h>
typedef struct qse_ip4ad_t qse_ip4ad_t;
typedef struct qse_ip6ad_t qse_ip6ad_t;
@ -37,13 +38,88 @@ typedef struct qse_ip6ad_t qse_ip6ad_t;
struct qse_ip4ad_t
{
qse_uint32_t value;
#if defined(__cplusplus)
bool operator== (const qse_ip4ad_t& peer) const { return this->value == peer.value; }
bool operator!= (const qse_ip4ad_t& peer) const { return this->value != peer.value; }
bool operator< (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) < qse_ntoh32(peer.value); }
bool operator<= (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) <= qse_ntoh32(peer.value); }
bool operator> (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) > qse_ntoh32(peer.value); }
bool operator>= (const qse_ip4ad_t& peer) const { return qse_ntoh32(this->value) >= qse_ntoh32(peer.value); }
/* i don't define a constructor so that it can be used within a struct
* with no constructor.
* struct xxx { qse_ip4ad_t addr; }
* since xxx doesn't have a constructor, some compilers complain of
* ill-formed constructor or deleted default contructor.
*/
qse_ip4ad_t& operator= (qse_ip4ad_t v)
{
this->value = v.value;
return *this;
}
qse_ip4ad_t& operator+= (qse_ip4ad_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value));
return *this;
}
qse_ip4ad_t& operator-= (qse_ip4ad_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value));
return *this;
}
qse_ip4ad_t operator+ (qse_ip4ad_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) + qse_ntoh32(v.value));
return x;
}
qse_ip4ad_t operator- (qse_ip4ad_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) - qse_ntoh32(v.value));
return x;
}
qse_ip4ad_t& operator= (qse_uint32_t v)
{
this->value = qse_hton32(v);
return *this;
}
qse_ip4ad_t& operator+= (qse_uint32_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) + v);
return *this;
}
qse_ip4ad_t& operator-= (qse_uint32_t v)
{
this->value = qse_hton32(qse_ntoh32(this->value) - v);
return *this;
}
qse_ip4ad_t operator+ (qse_uint32_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) + v);
return x;
}
qse_ip4ad_t operator- (qse_uint32_t v) const
{
qse_ip4ad_t x;
x.value = qse_hton32(qse_ntoh32(this->value) - v);
return x;
}
#endif
};
struct qse_ip6ad_t
{
qse_uint8_t value[16];
};
#include <qse/unpack.h>
#define QSE_IP4AD_IN_LOOPBACK(addr) ((((addr)->value) & QSE_CONST_HTON32(0xFF000000)) == QSE_CONST_HTON32(0x7F000000))
#if defined(__cplusplus)
extern "C" {
#endif

View File

@ -172,8 +172,6 @@ QSE_EXPORT qse_char_t* qse_getcliparams (
int index
);
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE int qse_getncliparams (qse_cli_t* cli) { return cli->nparams; }
#else

View File

@ -34,6 +34,10 @@
#include <qse/types.h>
#include <qse/macros.h>
#if !defined(QSE_PATH_MAX)
# define QSE_PATH_MAX 1024
#endif
enum qse_canonpath_flag_t
{
/** if the final output is . logically, return an empty path */

View File

@ -945,6 +945,9 @@
/* Patch level */
#undef QSE_PACKAGE_VERSION_PATCH
/* PATH_MAX */
#undef QSE_PATH_MAX
/* Define if pthread_cond_t is signed */
#undef QSE_PTHREAD_MUTEX_T_IS_SIGNED

View File

@ -316,9 +316,11 @@ QSE_EXPORT void* qse_fs_getxtn (
qse_fs_t* fs
);
QSE_EXPORT qse_fs_errnum_t qse_fs_geterrnum (
qse_fs_t* fs
);
#if defined(QSE_HAVE_INLINE)
static QSE_INLINE qse_fs_errnum_t qse_fs_geterrnum (qse_fs_t* fs) { return fs->errnum; }
#else
# define qse_fs_geterrnum(fs) ((fs)->errnum)
#endif
QSE_EXPORT int qse_fs_getopt (
qse_fs_t* fs,

View File

@ -149,14 +149,14 @@ QSE_EXPORT qse_sio_t* qse_sio_open (
qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t xtnsize, /**< extension size in bytes */
const qse_char_t* file, /**< file name */
int flags /**< number OR'ed of #qse_sio_flag_t */
int flags /**< number OR'ed of #qse_sio_flag_t */
);
QSE_EXPORT qse_sio_t* qse_sio_openstd (
qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t xtnsize, /**< extension size in bytes */
qse_sio_std_t std, /**< standard I/O identifier */
int flags /**< number OR'ed of #qse_sio_flag_t */
int flags /**< number OR'ed of #qse_sio_flag_t */
);
/**

View File

@ -26,11 +26,6 @@
#include "fs-prv.h"
qse_fs_errnum_t qse_fs_geterrnum (qse_fs_t* fs)
{
return fs->errnum;
}
qse_fs_errnum_t qse_fs_syserrtoerrnum (qse_fs_t* fs, qse_fs_syserr_t e)
{
#if defined(_WIN32)