refactored fio

This commit is contained in:
hyung-hwan 2019-12-17 08:53:33 +00:00
parent e21d307a8c
commit 4ee4e3fe60
17 changed files with 201 additions and 213 deletions

View File

@ -94,6 +94,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
@ -166,8 +167,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
ac/compile ac/config.guess ac/config.sub ac/install-sh \
ac/ltmain.sh ac/missing
ac/compile ac/config.guess ac/config.sub ac/depcomp \
ac/install-sh ac/ltmain.sh ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)

1
hawk/aclocal.m4 vendored
View File

@ -1197,6 +1197,7 @@ m4_include([m4/ax_check_sign.m4])
m4_include([m4/ax_cxx_namespace.m4])
m4_include([m4/ax_numval.m4])
m4_include([m4/ax_pthread.m4])
m4_include([m4/hawk_try_cflags.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
m4_include([m4/ltsugar.m4])

View File

@ -94,6 +94,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac

58
hawk/configure vendored
View File

@ -17225,6 +17225,37 @@ fi
CFLAGS="$CFLAGS -DHAWK_HAVE_CFG_H"
CXXFLAGS="$CXXFLAGS -DHAWK_HAVE_CFG_H"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fshort-wchar" >&5
$as_echo_n "checking whether the compiler supports -fshort-wchar... " >&6; }
if ${ac_cv_cflags__fshort_wchar+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_hawk_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -fshort-wchar"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int main(int argc, char **argv) { return 0; }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_cflags__fshort_wchar=yes
else
ac_cv_cflags__fshort_wchar=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ac_hawk_try_cflags_saved
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags__fshort_wchar" >&5
$as_echo "$ac_cv_cflags__fshort_wchar" >&6; }
if test $ac_cv_cflags__fshort_wchar = yes; then :
EXTRACFLAGS="$EXTRACFLAGS -fshort-wchar"
fi
# Check whether --enable-largefile was given.
if test "${enable_largefile+set}" = set; then :
enableval=$enable_largefile;
@ -22335,7 +22366,7 @@ $as_echo "#define HAWK_ENABLE_UNICODE 1" >>confdefs.h
CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
CXXFLAGS="$CXXFLAGS -DUNICODE -D_UNICODE"
fi
elif test "${enable_unicode}" = "yes:2"
elif test "${enable_unicode}" = "yes:2" -o "{enable_unicode}" = "yes"
then
$as_echo "#define HAWK_UNICODE_SIZE 2" >>confdefs.h
@ -22348,33 +22379,26 @@ $as_echo "#define HAWK_ENABLE_UNICODE 1" >>confdefs.h
CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
CXXFLAGS="$CXXFLAGS -DUNICODE -D_UNICODE"
fi
elif test "${enable_unicode}" = "yes"
if test "${ac_cv_cflags__fshort_wchar}" = "yes"
then
$as_echo "#define HAWK_UNICODE_SIZE 1" >>confdefs.h
$as_echo "#define HAWK_ENABLE_UNICODE 1" >>confdefs.h
if test "${platform_win32}" = "yes"
then
CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
CXXFLAGS="$CXXFLAGS -DUNICODE -D_UNICODE"
CFLAGS="$CFLAGS -fshort-wchar"
CXXFLAGS="$CXXFLAGS -fshort-wchar"
fi
elif test "${enable_unicode}" = "no:4"
then
$as_echo "#define HAWK_UNICODE_SIZE 4" >>confdefs.h
elif test "${enable_unicode}" = "no:2"
then
else
$as_echo "#define HAWK_UNICODE_SIZE 2" >>confdefs.h
else
$as_echo "#define HAWK_UNICODE_SIZE 1" >>confdefs.h
if test "${ac_cv_cflags__fshort_wchar}" = "yes"
then
CFLAGS="$CFLAGS -fshort-wchar"
CXXFLAGS="$CXXFLAGS -fshort-wchar"
fi
fi
# Check whether --enable-full-liw was given.

View File

@ -60,6 +60,9 @@ dnl indicate the existence of config.h
CFLAGS="$CFLAGS -DHAWK_HAVE_CFG_H"
CXXFLAGS="$CXXFLAGS -DHAWK_HAVE_CFG_H"
HAWK_TRY_CFLAGS([-fshort-wchar])
dnl HAWK_TRY_CFLAGS([-fno-short-wchar])
dnl make visible the 64-bit interface to the file system
AC_SYS_LARGEFILE()
@ -734,7 +737,7 @@ then
[CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"]
[CXXFLAGS="$CXXFLAGS -DUNICODE -D_UNICODE"]
fi
elif test "${enable_unicode}" = "yes:2"
elif test "${enable_unicode}" = "yes:2" -o "{enable_unicode}" = "yes"
then
AC_DEFINE([HAWK_UNICODE_SIZE],[2],[Unicode character type size])
AC_DEFINE([HAWK_ENABLE_UNICODE],[1],[Use the unicode character type as the default character type])
@ -743,23 +746,23 @@ then
[CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"]
[CXXFLAGS="$CXXFLAGS -DUNICODE -D_UNICODE"]
fi
elif test "${enable_unicode}" = "yes"
if test "${ac_cv_cflags__fshort_wchar}" = "yes"
then
AC_DEFINE([HAWK_UNICODE_SIZE],[1],[Unicode character type size])
AC_DEFINE([HAWK_ENABLE_UNICODE],[1],[Use the unicode character type as the default character type])
if test "${platform_win32}" = "yes"
then
[CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"]
[CXXFLAGS="$CXXFLAGS -DUNICODE -D_UNICODE"]
[CFLAGS="$CFLAGS -fshort-wchar"]
[CXXFLAGS="$CXXFLAGS -fshort-wchar"]
fi
elif test "${enable_unicode}" = "no:4"
then
AC_DEFINE([HAWK_UNICODE_SIZE],[4],[Unicode character type size])
elif test "${enable_unicode}" = "no:2"
then
AC_DEFINE([HAWK_UNICODE_SIZE],[2],[Unicode character type size])
else
AC_DEFINE([HAWK_UNICODE_SIZE],[1],[Unicode character type size])
dnl no:2, no, or anything else
AC_DEFINE([HAWK_UNICODE_SIZE],[2],[Unicode character type size])
if test "${ac_cv_cflags__fshort_wchar}" = "yes"
then
[CFLAGS="$CFLAGS -fshort-wchar"]
[CXXFLAGS="$CXXFLAGS -fshort-wchar"]
fi
fi
dnl ===== enable-full-liw =====

View File

@ -113,6 +113,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac

View File

@ -48,6 +48,11 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum)
HAWK_T("I/O error"),
HAWK_T("buffer full"),
HAWK_T("encoding conversion error"),
HAWK_T("not directory"),
HAWK_T("resource temporarily unavailable"),
HAWK_T("interrupted"),
HAWK_T("broken pipe"),
HAWK_T("in progress"),
HAWK_T("cannot open '${0}'"),
HAWK_T("cannot read '${0}'"),

View File

@ -61,7 +61,7 @@ enum
};
#include "syserr.h"
IMPLEMENT_SYSERR_TO_ERRNUM (fio, FIO)
IMPLEMENT_SYSERR_TO_ERRNUM (hawk, HAWK)
#if defined(_WIN32)
@ -116,18 +116,16 @@ static dossetfilesizel_t dos_set_file_size_l = HAWK_NULL;
#endif
hawk_fio_t* hawk_fio_open (
hawk_t* hawk, hawk_oow_t xtnsize,
const hawk_ooch_t* path, int flags, int mode)
hawk_fio_t* hawk_fio_open (hawk_gem_t* gem, hawk_oow_t xtnsize, const hawk_ooch_t* path, int flags, int mode)
{
hawk_fio_t* fio;
fio = (hawk_fio_t*)hawk_allocmem(hawk, HAWK_SIZEOF(hawk_fio_t) + xtnsize);
fio = (hawk_fio_t*)hawk_gem_allocmem(gem, HAWK_SIZEOF(hawk_fio_t) + xtnsize);
if (fio)
{
if (hawk_fio_init (fio, hawk, path, flags, mode) <= -1)
if (hawk_fio_init (fio, gem, path, flags, mode) <= -1)
{
hawk_freemem (hawk, fio);
hawk_gem_freemem (gem, fio);
return HAWK_NULL;
}
else HAWK_MEMSET (fio + 1, 0, xtnsize);
@ -138,10 +136,10 @@ hawk_fio_t* hawk_fio_open (
void hawk_fio_close (hawk_fio_t* fio)
{
hawk_fio_fini (fio);
hawk_freemem (fio->hawk, fio);
hawk_gem_freemem (fio->gem, fio);
}
int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int flags, int mode)
int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, int flags, int mode)
{
hawk_fio_hnd_t handle;
@ -171,13 +169,13 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
#endif
HAWK_MEMSET (fio, 0, HAWK_SIZEOF(*fio));
fio->hawk = hawk;
fio->gem = gem;
if (!(flags & (HAWK_FIO_READ | HAWK_FIO_WRITE | HAWK_FIO_APPEND | HAWK_FIO_HANDLE)))
{
/* one of HAWK_FIO_READ, HAWK_FIO_WRITE, HAWK_FIO_APPEND,
* and HAWK_FIO_HANDLE must be specified */
fio->errnum = HAWK_FIO_EINVAL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_EINVAL);
return -1;
}
@ -190,7 +188,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
{
handle = *(hawk_fio_hnd_t*)path;
/* do not specify an invalid handle value */
HAWK_ASSERT (hawk, handle != INVALID_HANDLE_VALUE);
/*HAWK_ASSERT (hawk, handle != INVALID_HANDLE_VALUE);*/
if (handle == GetStdHandle (STD_INPUT_HANDLE))
fio->status |= STATUS_WIN32_STDIN;
@ -314,13 +312,13 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
}
if (handle == INVALID_HANDLE_VALUE)
{
fio->errnum = syserr_to_errnum(GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return -1;
}
}
else
{
fio->errnum = syserr_to_errnum(e);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(e));
return -1;
}
}
@ -330,7 +328,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
#if 0
if (GetFileType(handle) == FILE_TYPE_UNKNOWN)
{
fio->errnum = syserr_to_errnum(GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
CloseHandle (handle);
return -1;
}
@ -366,74 +364,57 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
{
path_mb = path_mb_buf;
ml = HAWK_COUNTOF(path_mb_buf);
px = hawk_wcstombs (path, &wl, path_mb, &ml);
px = hawk_gem_convutobcstr(fio->gem, path, &wl, path_mb, &ml);
if (px == -2)
{
/* the static buffer is too small.
* dynamically allocate a buffer */
path_mb = hawk_wcstombsdup (path, HAWK_NULL, mmgr);
if (path_mb == HAWK_NULL)
{
fio->errnum = HAWK_FIO_ENOMEM;
return -1;
}
path_mb = hawk_gem_duputobcstr(fio->gem, path, HAWK_NUL);
if (path_mb == HAWK_NULL) return -1;
}
else if (px <= -1)
{
fio->errnum = HAWK_FIO_EINVAL;
return -1;
}
}
#endif
if (flags & HAWK_FIO_APPEND)
fio->status |= STATUS_APPEND;
if (flags & HAWK_FIO_APPEND) fio->status |= STATUS_APPEND;
if (flags & HAWK_FIO_CREATE)
{
if (flags & HAWK_FIO_EXCLUSIVE)
{
open_action = OPEN_ACTION_FAIL_IF_EXISTS |
OPEN_ACTION_CREATE_IF_NEW;
open_action = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
}
else if (flags & HAWK_FIO_TRUNCATE)
{
open_action = OPEN_ACTION_REPLACE_IF_EXISTS |
OPEN_ACTION_CREATE_IF_NEW;
open_action = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
}
else
{
open_action = OPEN_ACTION_CREATE_IF_NEW |
OPEN_ACTION_OPEN_IF_EXISTS;
open_action = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS;
}
}
else if (flags & HAWK_FIO_TRUNCATE)
{
open_action = OPEN_ACTION_REPLACE_IF_EXISTS |
OPEN_ACTION_FAIL_IF_NEW;
open_action = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
}
else
{
open_action = OPEN_ACTION_OPEN_IF_EXISTS |
OPEN_ACTION_FAIL_IF_NEW;
open_action = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
}
open_mode = OPEN_FLAGS_NOINHERIT;
if (flags & HAWK_FIO_SYNC)
open_mode |= OPEN_FLAGS_WRITE_THROUGH;
if (flags & HAWK_FIO_SYNC) open_mode |= OPEN_FLAGS_WRITE_THROUGH;
if ((flags & HAWK_FIO_NOSHREAD) && (flags & HAWK_FIO_NOSHWRITE))
open_mode |= OPEN_SHARE_DENYREADWRITE;
else if (flags & HAWK_FIO_NOSHREAD)
open_mode |= OPEN_SHARE_DENYREAD;
else if (flags & HAWK_FIO_NOSHWRITE)
open_mode |= OPEN_SHARE_DENYWRITE;
else
open_mode |= OPEN_SHARE_DENYNONE;
if ((flags & HAWK_FIO_NOSHREAD) && (flags & HAWK_FIO_NOSHWRITE)) open_mode |= OPEN_SHARE_DENYREADWRITE;
else if (flags & HAWK_FIO_NOSHREAD) open_mode |= OPEN_SHARE_DENYREAD;
else if (flags & HAWK_FIO_NOSHWRITE) open_mode |= OPEN_SHARE_DENYWRITE;
else open_mode |= OPEN_SHARE_DENYNONE;
if ((flags & HAWK_FIO_READ) &&
(flags & HAWK_FIO_WRITE)) open_mode |= OPEN_ACCESS_READWRITE;
if ((flags & HAWK_FIO_READ) && (flags & HAWK_FIO_WRITE)) open_mode |= OPEN_ACCESS_READWRITE;
else if (flags & HAWK_FIO_READ) open_mode |= OPEN_ACCESS_READONLY;
else if (flags & HAWK_FIO_WRITE) open_mode |= OPEN_ACCESS_WRITEONLY;
@ -477,12 +458,12 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
#if defined(HAWK_OOCH_IS_BCH)
/* nothing to do */
#else
if (path_mb != path_mb_buf) hawk_freemem (hawk->awk, path_mb);
if (path_mb != path_mb_buf) hawk_gem_freemem (fio->gem, path_mb);
#endif
if (ret != NO_ERROR)
{
fio->errnum = syserr_to_errnum(ret);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(ret));
return -1;
}
}
@ -493,7 +474,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
{
handle = *(hawk_fio_hnd_t*)path;
/* do not specify an invalid handle value */
HAWK_ASSERT (hawk, handle >= 0);
/*HAWK_ASSERT (hawk, handle >= 0);*/
}
else
{
@ -516,21 +497,16 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
{
path_mb = path_mb_buf;
ml = HAWK_COUNTOF(path_mb_buf);
px = hawk_wcstombs (path, &wl, path_mb, &ml);
px = hawk_gem_convutobcstr(fio->gem, path, &wl, path_mb, &ml);
if (px == -2)
{
/* static buffer size not enough.
* switch to dynamic allocation */
path_mb = hawk_wcstombsdup (path, HAWK_NULL, mmgr);
if (path_mb == HAWK_NULL)
{
fio->errnum = HAWK_FIO_ENOMEM;
return -1;
}
path_mb = hawk_gem_duputobcstr(fio->gem, path, HAWK_NULL);
if (path_mb == HAWK_NULL) return -1;
}
else if (px <= -1)
{
fio->errnum = HAWK_FIO_EINVAL;
return -1;
}
}
@ -568,12 +544,12 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
#if defined(HAWK_OOCH_IS_BCH)
/* nothing to do */
#else
if (path_mb != path_mb_buf) hawk_freemem (hawk->awk, path_mb);
if (path_mb != path_mb_buf) hawk_gem_freemem (fio->gem, path_mb);
#endif
if (handle <= -1)
{
fio->errnum = syserr_to_errnum (errno);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return -1;
}
}
@ -583,7 +559,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
if (flags & HAWK_FIO_HANDLE)
{
/* TODO: implement this */
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return -1;
}
else
@ -608,35 +584,29 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
{
path_mb = path_mb_buf;
ml = HAWK_COUNTOF(path_mb_buf);
px = hawk_wcstombs (path, &wl, path_mb, &ml);
px = hawk_convutobcstr(fio->gem, path, &wl, path_mb, &ml);
if (px == -2)
{
/* the static buffer is too small.
* allocate a buffer */
path_mb = hawk_wcstombsdup (path, mmgr);
if (path_mb == HAWK_NULL)
{
fio->errnum = HAWK_FIO_ENOMEM;
return -1;
}
path_mb = hawk_duputobcstr(fio->gem, path, mmgr);
if (path_mb == HAWK_NULL) return -1;
}
else if (px <= -1)
{
fio->errnum = HAWK_FIO_EINVAL;
return -1;
}
}
#endif
rab = (struct RAB*)hawk_allocmem(hawk, HAWK_SIZEOF(*rab) + HAWK_SIZEOF(*fab));
rab = (struct RAB*)hawk_gem_allocmem(fio->gem, HAWK_SIZEOF(*rab) + HAWK_SIZEOF(*fab));
if (rab == HAWK_NULL)
{
#if defined(HAWK_OOCH_IS_BCH)
/* nothing to do */
#else
if (path_mb != path_mb_buf) hawk_freemem (hawk, path_mb);
if (path_mb != path_mb_buf) hawk_gem_freemem (fio->gem, path_mb);
#endif
fio->errnum = HAWK_FIO_ENOMEM;
return -1;
}
@ -680,9 +650,9 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
#if defined(HAWK_OOCH_IS_BCH)
/* nothing to do */
#else
if (path_mb != path_mb_buf) hawk_freemem (hawk, path_mb);
if (path_mb != path_mb_buf) hawk_gem_freemem (fio->gem, path_mb);
#endif
fio->errnum = syserr_to_errnum (r0);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(r0));
return -1;
}
@ -693,16 +663,16 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
#if defined(HAWK_OOCH_IS_BCH)
/* nothing to do */
#else
if (path_mb != path_mb_buf) hawk_freemem (hawk, path_mb);
if (path_mb != path_mb_buf) hawk_gem_freemem (fio->gem, path_mb);
#endif
fio->errnum = syserr_to_errnum (r0);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(r0));
return -1;
}
#if defined(HAWK_OOCH_IS_BCH)
/* nothing to do */
#else
if (path_mb != path_mb_buf) hawk_freemem (hawk, path_mb);
if (path_mb != path_mb_buf) hawk_gem_freemem (fio->gem, path_mb);
#endif
handle = rab;
@ -714,7 +684,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
{
handle = *(hawk_fio_hnd_t*)path;
/* do not specify an invalid handle value */
HAWK_ASSERT (hawk, handle >= 0);
/*HAWK_ASSERT (hawk, handle >= 0);*/
}
else
{
@ -736,21 +706,17 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
{
path_mb = path_mb_buf;
ml = HAWK_COUNTOF(path_mb_buf);
px = hawk_conv_ucstr_to_bcstr_with_cmgr(path, &wl, path_mb, &ml, hawk_getcmgr(fio->hawk));
px = hawk_conv_ucstr_to_bcstr_with_cmgr(path, &wl, path_mb, &ml, fio->gem->cmgr);
if (px == -2)
{
/* the static buffer is too small.
* allocate a buffer */
path_mb = hawk_duputobcstr(fio->hawk, path, HAWK_NULL);
if (path_mb == HAWK_NULL)
{
fio->errnum = HAWK_FIO_ENOMEM;
return -1;
}
path_mb = hawk_gem_duputobcstr(fio->gem, path, HAWK_NULL);
if (path_mb == HAWK_NULL) return -1;
}
else if (px <= -1)
{
fio->errnum = HAWK_FIO_EINVAL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_EINVAL);
return -1;
}
}
@ -800,12 +766,12 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_t* hawk, const hawk_ooch_t* path, int f
#else
if (path_mb != path_mb_buf && path_mb != path)
{
hawk_freemem (hawk, path_mb);
hawk_gem_freemem (fio->gem, path_mb);
}
#endif
if (handle == -1)
{
fio->errnum = syserr_to_errnum(errno);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return -1;
}
else
@ -849,19 +815,13 @@ void hawk_fio_fini (hawk_fio_t* fio)
struct RAB* rab = (struct RAB*)fio->handle;
sys$disconnect (rab, 0, 0);
sys$close ((struct FAB*)(rab + 1), 0, 0);
hawk_freemem (fio->hawk, fio->handle);
hawk_gem_freemem (fio->gem, fio->handle);
#else
HAWK_CLOSE (fio->handle);
#endif
}
}
hawk_fio_errnum_t hawk_fio_geterrnum (const hawk_fio_t* fio)
{
return fio->errnum;
}
hawk_fio_hnd_t hawk_fio_gethnd (const hawk_fio_t* fio)
{
return fio->handle;
@ -881,7 +841,7 @@ hawk_fio_off_t hawk_fio_seek (hawk_fio_t* fio, hawk_fio_off_t offset, hawk_fio_o
LARGE_INTEGER y;
#endif
HAWK_ASSERT (fio->hawk, HAWK_SIZEOF(offset) <= HAWK_SIZEOF(x.QuadPart));
/* HAWK_ASSERT (fio->hawk, HAWK_SIZEOF(offset) <= HAWK_SIZEOF(x.QuadPart));*/
#if defined(_WIN64)
x.QuadPart = offset;
@ -899,7 +859,7 @@ hawk_fio_off_t hawk_fio_seek (hawk_fio_t* fio, hawk_fio_off_t offset, hawk_fio_o
fio->handle, x.LowPart, &x.HighPart, seek_map[origin]);
if (x.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return (hawk_fio_off_t)-1;
}
return (hawk_fio_off_t)x.QuadPart;
@ -919,7 +879,7 @@ hawk_fio_off_t hawk_fio_seek (hawk_fio_t* fio, hawk_fio_off_t offset, hawk_fio_o
LONGLONG pos, newpos;
APIRET ret;
HAWK_ASSERT (fio->hawk, HAWK_SIZEOF(offset) >= HAWK_SIZEOF(pos));
/*HAWK_ASSERT (fio->hawk, HAWK_SIZEOF(offset) >= HAWK_SIZEOF(pos));*/
pos.ulLo = (ULONG)(offset&0xFFFFFFFFlu);
pos.ulHi = (ULONG)(offset>>32);
@ -927,7 +887,7 @@ hawk_fio_off_t hawk_fio_seek (hawk_fio_t* fio, hawk_fio_off_t offset, hawk_fio_o
ret = dos_set_file_ptr_l (fio->handle, pos, seek_map[origin], &newpos);
if (ret != NO_ERROR)
{
fio->errnum = syserr_to_errnum (ret);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(ret));
return (hawk_fio_off_t)-1;
}
@ -942,7 +902,7 @@ hawk_fio_off_t hawk_fio_seek (hawk_fio_t* fio, hawk_fio_off_t offset, hawk_fio_o
ret = DosSetFilePtr (fio->handle, offset, seek_map[origin], &newpos);
if (ret != NO_ERROR)
{
fio->errnum = syserr_to_errnum (ret);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(ret));
return (hawk_fio_off_t)-1;
}
@ -963,7 +923,7 @@ hawk_fio_off_t hawk_fio_seek (hawk_fio_t* fio, hawk_fio_off_t offset, hawk_fio_o
#elif defined(vms) || defined(__vms)
/* TODO: */
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return (hawk_fio_off_t)-1;
#else
static int seek_map[] =
@ -982,7 +942,7 @@ hawk_fio_off_t hawk_fio_seek (hawk_fio_t* fio, hawk_fio_off_t offset, hawk_fio_o
&tmp,
seek_map[origin]) == -1)
{
fio->errnum = syserr_to_errnum (errno);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return (hawk_fio_off_t)-1;
}
@ -1000,7 +960,7 @@ int hawk_fio_truncate (hawk_fio_t* fio, hawk_fio_off_t size)
if (hawk_fio_seek (fio, size, HAWK_FIO_BEGIN) == (hawk_fio_off_t)-1) return -1;
if (SetEndOfFile(fio->handle) == FALSE)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return -1;
}
return 0;
@ -1029,7 +989,7 @@ int hawk_fio_truncate (hawk_fio_t* fio, hawk_fio_off_t size)
if (ret != NO_ERROR)
{
fio->errnum = syserr_to_errnum (ret);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(ret));
return -1;
}
return 0;
@ -1038,7 +998,7 @@ int hawk_fio_truncate (hawk_fio_t* fio, hawk_fio_off_t size)
int n;
n = chsize (fio->handle, size);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#elif defined(vms) || defined(__vms)
@ -1049,7 +1009,7 @@ int hawk_fio_truncate (hawk_fio_t* fio, hawk_fio_off_t size)
if ((r0 = sys$rewind (rab, 0, 0)) != RMS$_NORMAL ||
(r0 = sys$truncate (rab, 0, 0)) != RMS$_NORMAL)
{
fio->errnum = syserr_to_errnum (r0);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(r0));
return -1;
}
@ -1059,11 +1019,11 @@ int hawk_fio_truncate (hawk_fio_t* fio, hawk_fio_off_t size)
int n;
n = HAWK_FTRUNCATE (fio->handle, size);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#else
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return -1;
#endif
}
@ -1084,7 +1044,7 @@ hawk_ooi_t hawk_fio_read (hawk_fio_t* fio, void* buf, hawk_oow_t size)
* assuming that ERROR_BROKEN_PIPE doesn't occur with normal
* input streams, i treat the condition as a normal EOF indicator. */
if ((fio->status & STATUS_WIN32_STDIN) && e == ERROR_BROKEN_PIPE) return 0;
fio->errnum = syserr_to_errnum (e);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(e));
return -1;
}
return (hawk_ooi_t)count;
@ -1098,7 +1058,7 @@ hawk_ooi_t hawk_fio_read (hawk_fio_t* fio, void* buf, hawk_oow_t size)
ret = DosRead (fio->handle, buf, (ULONG)size, &count);
if (ret != NO_ERROR)
{
fio->errnum = syserr_to_errnum (ret);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(ret));
return -1;
}
return (hawk_ooi_t)count;
@ -1109,7 +1069,7 @@ hawk_ooi_t hawk_fio_read (hawk_fio_t* fio, void* buf, hawk_oow_t size)
if (size > (HAWK_TYPE_MAX(hawk_ooi_t) & HAWK_TYPE_MAX(unsigned int)))
size = HAWK_TYPE_MAX(hawk_ooi_t) & HAWK_TYPE_MAX(unsigned int);
n = read (fio->handle, buf, size);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#elif defined(vms) || defined(__vms)
@ -1125,7 +1085,7 @@ hawk_ooi_t hawk_fio_read (hawk_fio_t* fio, void* buf, hawk_oow_t size)
r0 = sys$get (rab, 0, 0);
if (r0 != RMS$_NORMAL)
{
fio->errnum = syserr_to_errnum (r0);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(r0));
return -1;
}
@ -1135,7 +1095,7 @@ hawk_ooi_t hawk_fio_read (hawk_fio_t* fio, void* buf, hawk_oow_t size)
hawk_ooi_t n;
if (size > HAWK_TYPE_MAX(hawk_ooi_t)) size = HAWK_TYPE_MAX(hawk_ooi_t);
n = HAWK_READ (fio->handle, buf, size);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#endif
}
@ -1164,7 +1124,7 @@ hawk_ooi_t hawk_fio_write (hawk_fio_t* fio, const void* data, hawk_oow_t size)
if (WriteFile (fio->handle,
data, (DWORD)size, &count, HAWK_NULL) == FALSE)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return -1;
}
return (hawk_ooi_t)count;
@ -1201,7 +1161,7 @@ hawk_ooi_t hawk_fio_write (hawk_fio_t* fio, const void* data, hawk_oow_t size)
(PVOID)data, (ULONG)size, &count);
if (ret != NO_ERROR)
{
fio->errnum = syserr_to_errnum (ret);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(ret));
return -1;
}
return (hawk_ooi_t)count;
@ -1212,7 +1172,7 @@ hawk_ooi_t hawk_fio_write (hawk_fio_t* fio, const void* data, hawk_oow_t size)
if (size > (HAWK_TYPE_MAX(hawk_ooi_t) & HAWK_TYPE_MAX(unsigned int)))
size = HAWK_TYPE_MAX(hawk_ooi_t) & HAWK_TYPE_MAX(unsigned int);
n = write (fio->handle, data, size);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#elif defined(vms) || defined(__vms)
@ -1228,7 +1188,7 @@ hawk_ooi_t hawk_fio_write (hawk_fio_t* fio, const void* data, hawk_oow_t size)
r0 = sys$put (rab, 0, 0);
if (r0 != RMS$_NORMAL)
{
fio->errnum = syserr_to_errnum (r0);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(r0));
return -1;
}
@ -1239,7 +1199,7 @@ hawk_ooi_t hawk_fio_write (hawk_fio_t* fio, const void* data, hawk_oow_t size)
hawk_ooi_t n;
if (size > HAWK_TYPE_MAX(hawk_ooi_t)) size = HAWK_TYPE_MAX(hawk_ooi_t);
n = HAWK_WRITE (fio->handle, data, size);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#endif
}
@ -1263,7 +1223,7 @@ static int get_devname_from_handle (
psapi = LoadLibrary (HAWK_T("PSAPI.DLL"));
if (!psapi)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return -1;
}
@ -1271,7 +1231,7 @@ static int get_devname_from_handle (
GetProcAddress (psapi, HAWK_BT("GetMappedFileName"));
if (!getmappedfilename)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
FreeLibrary (psapi);
return -1;
}
@ -1287,7 +1247,7 @@ static int get_devname_from_handle (
);
if (map == NULL)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
FreeLibrary (psapi);
return -1;
}
@ -1296,7 +1256,7 @@ static int get_devname_from_handle (
mem = MapViewOfFile (map, FILE_MAP_READ, 0, 0, 1);
if (mem == NULL)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
CloseHandle (map);
FreeLibrary (psapi);
return -1;
@ -1305,7 +1265,7 @@ static int get_devname_from_handle (
olen = getmappedfilename (GetCurrentProcess(), mem, buf, len);
if (olen == 0)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
UnmapViewOfFile (mem);
CloseHandle (map);
FreeLibrary (psapi);
@ -1338,7 +1298,7 @@ static int get_volname_from_handle (
if (n == 0 /* error */ ||
n > HAWK_COUNTOF(drives) /* buffer small */)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return -1;
}
@ -1389,7 +1349,7 @@ int hawk_fio_chmod (hawk_fio_t* fio, int mode)
if (!(mode & HAWK_FIO_WUSR)) flags = FILE_ATTRIBUTE_READONLY;
if (SetFileAttributes (name, flags) == FALSE)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return -1;
}
return 0;
@ -1412,7 +1372,7 @@ int hawk_fio_chmod (hawk_fio_t* fio, int mode)
#endif
if (n != NO_ERROR)
{
fio->errnum = syserr_to_errnum (n);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(n));
return -1;
}
@ -1426,7 +1386,7 @@ int hawk_fio_chmod (hawk_fio_t* fio, int mode)
#endif
if (n != NO_ERROR)
{
fio->errnum = syserr_to_errnum (n);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(n));
return -1;
}
@ -1442,23 +1402,23 @@ int hawk_fio_chmod (hawk_fio_t* fio, int mode)
/* TODO: fchmod not available. find a way to do this
return fchmod (fio->handle, permission); */
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return -1;
#elif defined(vms) || defined(__vms)
/* TODO: */
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return (hawk_fio_off_t)-1;
#elif defined(HAVE_FCHMOD)
int n;
n = HAWK_FCHMOD (fio->handle, mode);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#else
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return -1;
#endif
@ -1470,7 +1430,7 @@ int hawk_fio_sync (hawk_fio_t* fio)
if (FlushFileBuffers (fio->handle) == FALSE)
{
fio->errnum = syserr_to_errnum (GetLastError());
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(GetLastError()));
return -1;
}
return 0;
@ -1481,7 +1441,7 @@ int hawk_fio_sync (hawk_fio_t* fio)
n = DosResetBuffer (fio->handle);
if (n != NO_ERROR)
{
fio->errnum = syserr_to_errnum (n);
hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(n));
return -1;
}
return 0;
@ -1490,24 +1450,23 @@ int hawk_fio_sync (hawk_fio_t* fio)
int n;
n = fsync (fio->handle);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#elif defined(vms) || defined(__vms)
/* TODO: */
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return (hawk_fio_off_t)-1;
#elif defined(HAVE_FSYNC)
int n;
n = HAWK_FSYNC(fio->handle);
if (n <= -1) fio->errnum = syserr_to_errnum (errno);
if (n <= -1) hawk_gem_seterrnum (fio->gem, HAWK_NULL, syserr_to_errnum(errno));
return n;
#else
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return -1;
#endif
}
@ -1519,7 +1478,7 @@ int hawk_fio_lock (hawk_fio_t* fio, hawk_fio_lck_t* lck, int flags)
* fl.l_type = F_RDLCK, F_WRLCK;
* HAWK_FCNTL (fio->handle, F_SETLK, &fl);
*/
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return -1;
}
@ -1530,7 +1489,7 @@ int hawk_fio_unlock (hawk_fio_t* fio, hawk_fio_lck_t* lck, int flags)
* fl.l_type = F_UNLCK;
* HAWK_FCNTL (fio->handle, F_SETLK, &fl);
*/
fio->errnum = HAWK_FIO_ENOIMPL;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_ENOIMPL);
return -1;
}

View File

@ -776,6 +776,11 @@ enum hawk_errnum_t
HAWK_EIOERR, /**< I/O error */
HAWK_EBUFFULL, /**< buffer full */
HAWK_EECERR, /**< encoding conversion error */
HAWK_ENOTDIR, /**< not directory */
HAWK_EAGAIN, /**< resource temporarily unavailable */
HAWK_EINTR, /**< interrupted */
HAWK_EPIPE, /**< broken pipe */
HAWK_EINPROG, /**< in progress */
/* mostly parse errors */
HAWK_EOPEN, /**< cannot open '${0}' */

View File

@ -73,28 +73,6 @@ enum hawk_fio_flag_t
HAWK_FIO_SEQUENTIAL = (1 << 28) /* hint that access is sequential */
};
enum hawk_fio_errnum_t
{
HAWK_FIO_ENOERR = 0, /**< no error */
HAWK_FIO_EOTHER, /**< other error */
HAWK_FIO_ENOIMPL, /**< not implemented */
HAWK_FIO_ESYSERR, /**< subsystem(system call) error */
HAWK_FIO_EINTERN, /**< internal error */
HAWK_FIO_ENOMEM, /**< out of memory */
HAWK_FIO_EINVAL, /**< invalid parameter */
HAWK_FIO_EACCES, /**< access denied */
HAWK_FIO_EPERM, /**< operation not permitted */
HAWK_FIO_ENOENT, /**< no such file */
HAWK_FIO_EEXIST, /**< already exist */
HAWK_FIO_ENOTDIR, /**< not a directory */
HAWK_FIO_EINTR, /**< interrupted */
HAWK_FIO_EPIPE, /**< broken pipe */
HAWK_FIO_EINPROG, /**< in progress */
HAWK_FIO_EAGAIN /**< resource not available temporarily */
};
typedef enum hawk_fio_errnum_t hawk_fio_errnum_t;
enum hawk_fio_std_t
{
HAWK_FIO_STDIN = 0,
@ -152,8 +130,7 @@ typedef struct hawk_fio_lck_t hawk_fio_lck_t;
struct hawk_fio_t
{
hawk_t* hawk;
hawk_fio_errnum_t errnum;
hawk_gem_t* gem;
hawk_fio_hnd_t handle;
int status;
};
@ -188,7 +165,7 @@ extern "C" {
* parameter when #HAWK_FIO_TEMPORARY is set.
*/
HAWK_EXPORT hawk_fio_t* hawk_fio_open (
hawk_t* hawk,
hawk_gem_t* gem,
hawk_oow_t xtnsize,
const hawk_ooch_t* path,
int flags,
@ -207,7 +184,7 @@ HAWK_EXPORT void hawk_fio_close (
*/
HAWK_EXPORT int hawk_fio_init (
hawk_fio_t* fio,
hawk_t* hawk,
hawk_gem_t* gem,
const hawk_ooch_t* path,
int flags,
int mode
@ -227,10 +204,6 @@ static HAWK_INLINE void* hawk_fio_getxtn (hawk_fio_t* fio) { return (void*)(fio
#define hawk_fio_getxtn(awk) ((void*)((hawk_fio_t*)(fio) + 1))
#endif
HAWK_EXPORT hawk_fio_errnum_t hawk_fio_geterrnum (
const hawk_fio_t* fio
);
/**
* The hawk_fio_gethnd() function returns the native file handle.
*/

View File

@ -54,7 +54,7 @@ static hawk_ooi_t pio_output (
hawk_tio_t* tio, hawk_tio_cmd_t cmd, void* buf, hawk_oow_t size);
#include "syserr.h"
IMPLEMENT_SYSERR_TO_ERRNUM (pio, PIO)
IMPLEMENT_SYSERR_TO_ERRNUM (hawk, HAWK)
static hawk_pio_errnum_t tio_errnum_to_pio_errnum (hawk_tio_t* tio)
{

View File

@ -39,8 +39,10 @@
# define __SYSERRTYPE__(obj) obj
# define __SYSERRNUM__(obj,num) (obj E_ ## num)
#else
# define __SYSERRTYPE__(obj) hawk_ ## obj ## _errnum_t
# define __SYSERRNUM__(obj,num) (HAWK_ ## obj ## _ ## num)
/*# define __SYSERRTYPE__(obj) hawk_ ## obj ## _errnum_t
# define __SYSERRNUM__(obj,num) (HAWK_ ## obj ## _ ## num)*/
# define __SYSERRTYPE__(obj) obj ## _errnum_t
# define __SYSERRNUM__(obj,num) (obj ## _ ## num)
#endif
#if defined(_WIN32)

View File

@ -0,0 +1,10 @@
AC_DEFUN([HAWK_TRY_CFLAGS], [
AS_VAR_PUSHDEF([ac_var], ac_cv_cflags_[[$1]])
AC_CACHE_CHECK([whether the compiler supports $1], ac_var, [
ac_hawk_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS $1"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv) { return 0; }]])], [AS_VAR_SET(ac_var,yes)], [AS_VAR_SET(ac_var,no)])
CFLAGS=$ac_hawk_try_cflags_saved])
AS_IF([test AS_VAR_GET(ac_var) = yes], [m4_default([$2], [EXTRACFLAGS="$EXTRACFLAGS $1"])], [$3])
AS_VAR_POPDEF([ac_var])
])

View File

@ -97,6 +97,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac

View File

@ -94,6 +94,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac

View File

@ -94,6 +94,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac