added qse_setintrhandler() & qse_clearintrhandler()
This commit is contained in:
@ -2,6 +2,7 @@ pkgincludedir = $(includedir)/qse/sys
|
||||
|
||||
pkginclude_HEADERS = \
|
||||
cnd.h \
|
||||
intr.h \
|
||||
mtx.h \
|
||||
rwl.h \
|
||||
thr.h
|
||||
|
@ -117,7 +117,7 @@ am__can_run_installinfo = \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__pkginclude_HEADERS_DIST = cnd.h mtx.h rwl.h thr.h \
|
||||
am__pkginclude_HEADERS_DIST = cnd.h intr.h mtx.h rwl.h thr.h \
|
||||
SocketAddress.hpp
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
@ -344,7 +344,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkginclude_HEADERS = cnd.h mtx.h rwl.h thr.h $(am__append_1)
|
||||
pkginclude_HEADERS = cnd.h intr.h mtx.h rwl.h thr.h $(am__append_1)
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -24,8 +24,8 @@
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_CND_H_
|
||||
#define _QSE_CMN_CND_H_
|
||||
#ifndef _QSE_SYS_CND_H_
|
||||
#define _QSE_SYS_CND_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
@ -100,45 +100,44 @@ struct qse_cnd_t
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
qse_cnd_t* qse_cnd_open (
|
||||
QSE_EXPORT qse_cnd_t* qse_cnd_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize
|
||||
);
|
||||
|
||||
void qse_cnd_close (
|
||||
QSE_EXPORT void qse_cnd_close (
|
||||
qse_cnd_t* cnd
|
||||
);
|
||||
|
||||
int qse_cnd_init (
|
||||
QSE_EXPORT int qse_cnd_init (
|
||||
qse_cnd_t* cnd,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
void qse_cnd_fini (
|
||||
QSE_EXPORT void qse_cnd_fini (
|
||||
qse_cnd_t* cnd
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_cnd_getmmgr (
|
||||
QSE_EXPORT qse_mmgr_t* qse_cnd_getmmgr (
|
||||
qse_cnd_t* cnd
|
||||
);
|
||||
|
||||
void* qse_cnd_getxtn (
|
||||
QSE_EXPORT void* qse_cnd_getxtn (
|
||||
qse_cnd_t* cnd
|
||||
);
|
||||
|
||||
void qse_cnd_signal (
|
||||
QSE_EXPORT void qse_cnd_signal (
|
||||
qse_cnd_t* cond
|
||||
);
|
||||
|
||||
void qse_cnd_broadcast (
|
||||
QSE_EXPORT void qse_cnd_broadcast (
|
||||
qse_cnd_t* cond
|
||||
);
|
||||
|
||||
void qse_cnd_wait (
|
||||
qse_cnd_t* cond,
|
||||
qse_mtx_t* mutex,
|
||||
qse_ntime_t* waiting_time
|
||||
QSE_EXPORT void qse_cnd_wait (
|
||||
qse_cnd_t* cond,
|
||||
qse_mtx_t* mutex,
|
||||
const qse_ntime_t* waiting_time
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
52
qse/include/qse/sys/intr.h
Normal file
52
qse/include/qse/sys/intr.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EQSERESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _QSE_SYS_INTR_H_
|
||||
#define _QSE_SYS_INTR_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/** \file
|
||||
* This file provides simple console interrupt handler management routines.
|
||||
*/
|
||||
|
||||
typedef void (*qse_intr_handler_t) (void *arg);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
QSE_EXPORT void qse_setintrhandler (qse_intr_handler_t handler, void* arg);
|
||||
QSE_EXPORT void qse_clearintrhandler (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -25,8 +25,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _QSE_CMN_MTX_H_
|
||||
#define _QSE_CMN_MTX_H_
|
||||
#ifndef _QSE_SYS_MTX_H_
|
||||
#define _QSE_SYS_MTX_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
@ -92,38 +92,38 @@ struct qse_mtx_t
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_mtx_t* qse_mtx_open (
|
||||
QSE_EXPORT qse_mtx_t* qse_mtx_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize
|
||||
);
|
||||
|
||||
void qse_mtx_close (
|
||||
QSE_EXPORT void qse_mtx_close (
|
||||
qse_mtx_t* mtx
|
||||
);
|
||||
|
||||
int qse_mtx_init (
|
||||
QSE_EXPORT int qse_mtx_init (
|
||||
qse_mtx_t* mtx,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
void qse_mtx_fini (
|
||||
QSE_EXPORT void qse_mtx_fini (
|
||||
qse_mtx_t* mtx
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_mtx_getmmgr (
|
||||
QSE_EXPORT qse_mmgr_t* qse_mtx_getmmgr (
|
||||
qse_mtx_t* mtx
|
||||
);
|
||||
|
||||
void* qse_mtx_getxtn (
|
||||
QSE_EXPORT void* qse_mtx_getxtn (
|
||||
qse_mtx_t* mtx
|
||||
);
|
||||
|
||||
int qse_mtx_lock (
|
||||
qse_mtx_t* mtx,
|
||||
qse_ntime_t* waiting_time
|
||||
QSE_EXPORT int qse_mtx_lock (
|
||||
qse_mtx_t* mtx,
|
||||
const qse_ntime_t* waiting_time
|
||||
);
|
||||
|
||||
int qse_mtx_unlock (
|
||||
QSE_EXPORT int qse_mtx_unlock (
|
||||
qse_mtx_t* mtx
|
||||
);
|
||||
|
||||
|
@ -59,49 +59,49 @@ typedef struct qse_rwl_t qse_rwl_t;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_rwl_t* qse_rwl_open (
|
||||
QSE_EXPORT qse_rwl_t* qse_rwl_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize,
|
||||
int flags
|
||||
);
|
||||
|
||||
void qse_rwl_close (
|
||||
QSE_EXPORT void qse_rwl_close (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
int qse_rwl_init (
|
||||
QSE_EXPORT int qse_rwl_init (
|
||||
qse_rwl_t* rwl,
|
||||
qse_mmgr_t* mmgr,
|
||||
int flags
|
||||
);
|
||||
|
||||
void qse_rwl_fini (
|
||||
QSE_EXPORT void qse_rwl_fini (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_rwl_getmmgr (
|
||||
QSE_EXPORT qse_mmgr_t* qse_rwl_getmmgr (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
void* qse_rwl_getxtn (
|
||||
QSE_EXPORT void* qse_rwl_getxtn (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
int qse_rwl_lockr (
|
||||
qse_rwl_t* rwl,
|
||||
qse_ntime_t* waiting_time
|
||||
QSE_EXPORT int qse_rwl_lockr (
|
||||
qse_rwl_t* rwl,
|
||||
const qse_ntime_t* waiting_time
|
||||
);
|
||||
|
||||
int qse_rwl_unlockr (
|
||||
QSE_EXPORT int qse_rwl_unlockr (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
int qse_rwl_lockw (
|
||||
qse_rwl_t* rwl,
|
||||
qse_ntime_t* waiting_time
|
||||
QSE_EXPORT int qse_rwl_lockw (
|
||||
qse_rwl_t* rwl,
|
||||
const qse_ntime_t* waiting_time
|
||||
);
|
||||
|
||||
int qse_rwl_unlockw (
|
||||
QSE_EXPORT int qse_rwl_unlockw (
|
||||
qse_rwl_t* rwl
|
||||
);
|
||||
|
||||
|
@ -61,16 +61,20 @@ typedef enum qse_thr_flag_t qse_thr_flag_t;
|
||||
#if defined(_WIN32)
|
||||
/* <winnt.h> => typedef PVOID HANDLE; */
|
||||
typedef void* qse_thr_hnd_t;
|
||||
#elif defined(__OS2__)
|
||||
|
||||
/* not implemented */
|
||||
# error not implemented
|
||||
#elif defined(__OS2__)
|
||||
/* typedef unsigned long LHANDLE
|
||||
* typedef LHANDLE TID */
|
||||
typedef unsigned long qse_thr_hnd_t;
|
||||
|
||||
#elif defined(__DOS__)
|
||||
/* not implemented */
|
||||
# error not implemented
|
||||
|
||||
#elif defined(__BEOS__)
|
||||
/*typedef thread_id qse_thr_hnd_t;*/
|
||||
typdef qse_int32_t qse_thr_hnd_t;
|
||||
|
||||
#else
|
||||
#if (QSE_SIZEOF_PTHREAD_T == QSE_SIZEOF_INT)
|
||||
#if defined(QSE_PTHREAD_T_IS_SIGNED)
|
||||
@ -98,7 +102,7 @@ extern "C" {
|
||||
* pointed to by \a routine is executed when qse_thr_start() is called.
|
||||
*
|
||||
*/
|
||||
qse_thr_t* qse_thr_open (
|
||||
QSE_EXPORT qse_thr_t* qse_thr_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize,
|
||||
qse_thr_routine_t routine
|
||||
@ -108,29 +112,29 @@ qse_thr_t* qse_thr_open (
|
||||
* The qse_thr_close() function destroys a thread object. Make sure that the
|
||||
* thread routine has been terminated properly.
|
||||
*/
|
||||
void qse_thr_close (
|
||||
QSE_EXPORT void qse_thr_close (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
int qse_thr_init (
|
||||
QSE_EXPORT int qse_thr_init (
|
||||
qse_thr_t* thr,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_thr_routine_t routine
|
||||
);
|
||||
|
||||
void qse_thr_fini (
|
||||
QSE_EXPORT void qse_thr_fini (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
qse_mmgr_t* qse_thr_getmmgr (
|
||||
QSE_EXPORT qse_mmgr_t* qse_thr_getmmgr (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
void* qse_thr_getxtn (
|
||||
QSE_EXPORT void* qse_thr_getxtn (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
qse_size_t qse_thr_getstacksize (
|
||||
QSE_EXPORT qse_size_t qse_thr_getstacksize (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
@ -138,7 +142,7 @@ qse_size_t qse_thr_getstacksize (
|
||||
* The qse_thr_setstacksize() function sets the stack size of a thread.
|
||||
* It must be called before a thread routine gets started.
|
||||
*/
|
||||
void qse_thr_setstacksize (
|
||||
QSE_EXPORT void qse_thr_setstacksize (
|
||||
qse_thr_t* thr,
|
||||
qse_size_t num
|
||||
);
|
||||
@ -154,7 +158,7 @@ void qse_thr_setstacksize (
|
||||
*
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_thr_start (
|
||||
QSE_EXPORT int qse_thr_start (
|
||||
qse_thr_t* thr,
|
||||
int flags, /**< 0 or bitwise-or of QSE_THR_NEW_ROUTINE and QSE_THR_DETACHED */
|
||||
...
|
||||
@ -164,50 +168,50 @@ int qse_thr_start (
|
||||
* The qse_thr_stop() function aborts a thread.
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_thr_stop (qse_thr_t* thr);
|
||||
QSE_EXPORT int qse_thr_stop (qse_thr_t* thr);
|
||||
|
||||
/**
|
||||
* The qse_thr_join() function waits for thread termination.
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_thr_join (qse_thr_t* thr);
|
||||
QSE_EXPORT int qse_thr_join (qse_thr_t* thr);
|
||||
|
||||
/**
|
||||
* The qse_thr_detach() function detaches a thread.
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_thr_detach (qse_thr_t* thr);
|
||||
QSE_EXPORT int qse_thr_detach (qse_thr_t* thr);
|
||||
|
||||
/**
|
||||
* The qse_thr_kill() function sends a signal to a thread.
|
||||
*/
|
||||
int qse_thr_kill (qse_thr_t* thr, int sig);
|
||||
QSE_EXPORT int qse_thr_kill (qse_thr_t* thr, int sig);
|
||||
|
||||
/**
|
||||
* The qse_thr_blocksig() function causes a therad to block the signal \a sig.
|
||||
*/
|
||||
int qse_thr_blocksig (qse_thr_t* thr, int sig);
|
||||
QSE_EXPORT int qse_thr_blocksig (qse_thr_t* thr, int sig);
|
||||
|
||||
/**
|
||||
* The qse_thr_unblocksig() function causes a therad to unblock the signal \a sig.
|
||||
*/
|
||||
int qse_thr_unblocksig (qse_thr_t* thr, int sig);
|
||||
QSE_EXPORT int qse_thr_unblocksig (qse_thr_t* thr, int sig);
|
||||
|
||||
/**
|
||||
* The qse_thr_blockallsigs() function causes a therad to block all signals.
|
||||
*/
|
||||
int qse_thr_blockallsigs (qse_thr_t* thr);
|
||||
QSE_EXPORT int qse_thr_blockallsigs (qse_thr_t* thr);
|
||||
|
||||
/**
|
||||
* The qse_thr_unblockallsigs() function causes a therad to unblock all signals.
|
||||
*/
|
||||
int qse_thr_unblockallsigs (qse_thr_t* thr);
|
||||
QSE_EXPORT int qse_thr_unblockallsigs (qse_thr_t* thr);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_thr_gethnd() function returns the native thread handle.
|
||||
*/
|
||||
qse_thr_hnd_t qse_thr_gethnd (
|
||||
QSE_EXPORT qse_thr_hnd_t qse_thr_gethnd (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
@ -216,14 +220,14 @@ qse_thr_hnd_t qse_thr_gethnd (
|
||||
* that has been terminated. If no thread routine has been started and
|
||||
* terminated, 0 is returned.
|
||||
*/
|
||||
int qse_thr_getretcode (
|
||||
QSE_EXPORT int qse_thr_getretcode (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_thr_state() function returns the current state.
|
||||
*/
|
||||
qse_thr_state_t qse_thr_getstate (
|
||||
QSE_EXPORT qse_thr_state_t qse_thr_getstate (
|
||||
qse_thr_t* thr
|
||||
);
|
||||
|
||||
@ -231,7 +235,7 @@ qse_thr_state_t qse_thr_getstate (
|
||||
* The qse_getcurthrhnd() function returns the native handle to the
|
||||
* calling thread.
|
||||
*/
|
||||
qse_thr_hnd_t qse_getcurthrhnd (void);
|
||||
QSE_EXPORT qse_thr_hnd_t qse_getcurthrhnd (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user