ClickHouse/dbms/src/IO/AIO.h

77 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#if defined(__linux__)
2018-08-21 17:25:00 +00:00
#include <boost/noncopyable.hpp>
/// https://stackoverflow.com/questions/20759750/resolving-redefinition-of-timespec-in-time-h
#define timespec linux_timespec
2018-06-18 02:15:19 +00:00
#define timeval linux_timeval
2018-06-18 02:16:00 +00:00
#define itimerspec linux_itimerspec
2018-06-18 02:17:00 +00:00
#define sigset_t linux_sigset_t
#include <linux/aio_abi.h>
2018-06-18 02:17:00 +00:00
#undef timespec
2018-06-18 02:15:19 +00:00
#undef timeval
2018-06-18 02:16:00 +00:00
#undef itimerspec
2018-06-18 02:17:00 +00:00
#undef sigset_t
/** Small wrappers for asynchronous I/O.
*/
int io_setup(unsigned nr, aio_context_t * ctxp);
int io_destroy(aio_context_t ctx);
/// last argument is an array of pointers technically speaking
int io_submit(aio_context_t ctx, long nr, struct iocb * iocbpp[]);
int io_getevents(aio_context_t ctx, long min_nr, long max_nr, io_event * events, struct timespec * timeout);
struct AIOContext : private boost::noncopyable
{
aio_context_t ctx;
AIOContext(unsigned int nr_events = 128);
~AIOContext();
};
2019-02-07 15:08:45 +00:00
#elif defined(__FreeBSD__)
#include <boost/noncopyable.hpp>
#include <aio.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
typedef struct kevent io_event;
typedef int aio_context_t;
struct iocb {
struct aiocb aio;
long aio_data;
};
int io_setup(void);
int io_destroy(void);
/// last argument is an array of pointers technically speaking
int io_submit(int ctx, long nr, struct iocb * iocbpp[]);
int io_getevents(int ctx, long min_nr, long max_nr, struct kevent * events, struct timespec * timeout);
struct AIOContext : private boost::noncopyable
{
int ctx;
AIOContext(unsigned int nr_events = 128);
~AIOContext();
};
#endif