Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade to libeio 2012-11-02

  • Loading branch information...
commit a2637e803e74f57f337101be83b3ae4a4c86be42 1 parent 8ce40c5
@FooBarWidget FooBarWidget authored
View
4 ext/libeio/Changes
@@ -68,5 +68,9 @@ TODO: maybe work around 3.996gb barrier in pread/pwrite as well, maybe readahead
by implementing a working directory abstraction.
- make readahead emulation behave more like actual readahead by never failing.
- added EIO_LSEEK (untested).
+ - added EIO_FALLOC_FL_PUNCH_HOLE.
- wtf. etp_proc returned 0, and no compiler ever complained.
+ - remove pread/pwrite emulation, as the only system that lacked them
+ (cygwin) provides them for a while now.
+ - provide pread/pwrite implementations for win32.
View
305 ext/libeio/ecb.h
@@ -30,6 +30,9 @@
#ifndef ECB_H
#define ECB_H
+/* 16 bits major, 16 bits minor */
+#define ECB_VERSION 0x00010002
+
#ifdef _WIN32
typedef signed char int8_t;
typedef unsigned char uint8_t;
@@ -44,8 +47,22 @@
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
+ #ifdef _WIN64
+ #define ECB_PTRSIZE 8
+ typedef uint64_t uintptr_t;
+ typedef int64_t intptr_t;
+ #else
+ #define ECB_PTRSIZE 4
+ typedef uint32_t uintptr_t;
+ typedef int32_t intptr_t;
+ #endif
#else
#include <inttypes.h>
+ #if UINTMAX_MAX > 0xffffffffU
+ #define ECB_PTRSIZE 8
+ #else
+ #define ECB_PTRSIZE 4
+ #endif
#endif
/* many compilers define _GNUC_ to some versions but then only implement
@@ -63,16 +80,32 @@
#endif
#endif
+#define ECB_C (__STDC__+0) /* this assumes that __STDC__ is either empty or a number */
+#define ECB_C99 (__STDC_VERSION__ >= 199901L)
+#define ECB_C11 (__STDC_VERSION__ >= 201112L)
+#define ECB_CPP (__cplusplus+0)
+#define ECB_CPP11 (__cplusplus >= 201103L)
+
+#if ECB_CPP
+ #define ECB_EXTERN_C extern "C"
+ #define ECB_EXTERN_C_BEG ECB_EXTERN_C {
+ #define ECB_EXTERN_C_END }
+#else
+ #define ECB_EXTERN_C extern
+ #define ECB_EXTERN_C_BEG
+ #define ECB_EXTERN_C_END
+#endif
+
/*****************************************************************************/
/* ECB_NO_THREADS - ecb is not used by multiple threads, ever */
/* ECB_NO_SMP - ecb might be used in multiple threads, but only on a single cpu */
#if ECB_NO_THREADS
-# define ECB_NO_SMP 1
+ #define ECB_NO_SMP 1
#endif
-#if ECB_NO_THREADS || ECB_NO_SMP
+#if ECB_NO_SMP
#define ECB_MEMORY_FENCE do { } while (0)
#endif
@@ -80,39 +113,55 @@
#if ECB_GCC_VERSION(2,5) || defined __INTEL_COMPILER || (__llvm__ && __GNUC__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110
#if __i386 || __i386__
#define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory")
- #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */
- #define ECB_MEMORY_FENCE_RELEASE do { } while (0) /* unlikely to change in future cpus */
+ #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory")
+ #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("")
#elif __amd64 || __amd64__ || __x86_64 || __x86_64__
- #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory")
- #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("lfence" : : : "memory")
- #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("sfence") /* play safe - not needed in any current cpu */
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory")
+ #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory")
+ #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("")
#elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__
- #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory")
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory")
#elif defined __ARM_ARCH_6__ || defined __ARM_ARCH_6J__ \
|| defined __ARM_ARCH_6K__ || defined __ARM_ARCH_6ZK__
#define ECB_MEMORY_FENCE __asm__ __volatile__ ("mcr p15,0,%0,c7,c10,5" : : "r" (0) : "memory")
#elif defined __ARM_ARCH_7__ || defined __ARM_ARCH_7A__ \
- || defined __ARM_ARCH_7M__ || defined __ARM_ARCH_7R__
- #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory")
+ || defined __ARM_ARCH_7M__ || defined __ARM_ARCH_7R__
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory")
#elif __sparc || __sparc__
- #define ECB_MEMORY_FENCE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad | " : : : "memory")
- #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory")
- #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore")
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory")
+ #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory")
+ #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore")
#elif defined __s390__ || defined __s390x__
#define ECB_MEMORY_FENCE __asm__ __volatile__ ("bcr 15,0" : : : "memory")
#elif defined __mips__
- #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory")
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory")
#elif defined __alpha__
- #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory")
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory")
+ #elif defined __hppa__
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory")
+ #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("")
+ #elif defined __ia64__
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mf" : : : "memory")
#endif
#endif
#endif
#ifndef ECB_MEMORY_FENCE
- #if ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__
+ #if ECB_GCC_VERSION(4,7)
+ /* see comment below (stdatomic.h) about the C11 memory model. */
+ #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST)
+
+ /* The __has_feature syntax from clang is so misdesigned that we cannot use it
+ * without risking compile time errors with other compilers. We *could*
+ * define our own ecb_clang_has_feature, but I just can't be bothered to work
+ * around this shit time and again.
+ * #elif defined __clang && __has_feature (cxx_atomic)
+ * // see comment below (stdatomic.h) about the C11 memory model.
+ * #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST)
+ */
+
+ #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__
#define ECB_MEMORY_FENCE __sync_synchronize ()
- /*#define ECB_MEMORY_FENCE_ACQUIRE ({ char dummy = 0; __sync_lock_test_and_set (&dummy, 1); }) */
- /*#define ECB_MEMORY_FENCE_RELEASE ({ char dummy = 1; __sync_lock_release (&dummy ); }) */
#elif _MSC_VER >= 1400 /* VC++ 2005 */
#pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier)
#define ECB_MEMORY_FENCE _ReadWriteBarrier ()
@@ -132,6 +181,21 @@
#endif
#ifndef ECB_MEMORY_FENCE
+ #if ECB_C11 && !defined __STDC_NO_ATOMICS__
+ /* we assume that these memory fences work on all variables/all memory accesses, */
+ /* not just C11 atomics and atomic accesses */
+ #include <stdatomic.h>
+ /* Unfortunately, neither gcc 4.7 nor clang 3.1 generate any instructions for */
+ /* any fence other than seq_cst, which isn't very efficient for us. */
+ /* Why that is, we don't know - either the C11 memory model is quite useless */
+ /* for most usages, or gcc and clang have a bug */
+ /* I *currently* lean towards the latter, and inefficiently implement */
+ /* all three of ecb's fences as a seq_cst fence */
+ #define ECB_MEMORY_FENCE atomic_thread_fence (memory_order_seq_cst)
+ #endif
+#endif
+
+#ifndef ECB_MEMORY_FENCE
#if !ECB_AVOID_PTHREADS
/*
* if you get undefined symbol references to pthread_mutex_lock,
@@ -159,8 +223,6 @@
/*****************************************************************************/
-#define ECB_C99 (__STDC_VERSION__ >= 199901L)
-
#if __cplusplus
#define ecb_inline static inline
#elif ECB_GCC_VERSION(2,5)
@@ -208,11 +270,16 @@ typedef int ecb_bool;
#endif
#define ecb_noinline ecb_attribute ((__noinline__))
-#define ecb_noreturn ecb_attribute ((__noreturn__))
#define ecb_unused ecb_attribute ((__unused__))
#define ecb_const ecb_attribute ((__const__))
#define ecb_pure ecb_attribute ((__pure__))
+#if ECB_C11
+ #define ecb_noreturn _Noreturn
+#else
+ #define ecb_noreturn ecb_attribute ((__noreturn__))
+#endif
+
#if ECB_GCC_VERSION(4,3)
#define ecb_artificial ecb_attribute ((__artificial__))
#define ecb_hot ecb_attribute ((__hot__))
@@ -312,6 +379,11 @@ typedef int ecb_bool;
}
#endif
+ecb_function_ ecb_bool ecb_is_pot32 (uint32_t x) ecb_const;
+ecb_function_ ecb_bool ecb_is_pot32 (uint32_t x) { return !(x & (x - 1)); }
+ecb_function_ ecb_bool ecb_is_pot64 (uint64_t x) ecb_const;
+ecb_function_ ecb_bool ecb_is_pot64 (uint64_t x) { return !(x & (x - 1)); }
+
ecb_function_ uint8_t ecb_bitrev8 (uint8_t x) ecb_const;
ecb_function_ uint8_t ecb_bitrev8 (uint8_t x)
{
@@ -405,14 +477,32 @@ ecb_inline uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (
#endif
/* try to tell the compiler that some condition is definitely true */
-#define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0)
+#define ecb_assume(cond) if (!(cond)) ecb_unreachable (); else 0
ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const;
ecb_inline unsigned char
ecb_byteorder_helper (void)
{
- const uint32_t u = 0x11223344;
- return *(unsigned char *)&u;
+ /* the union code still generates code under pressure in gcc, */
+ /* but less than using pointers, and always seems to */
+ /* successfully return a constant. */
+ /* the reason why we have this horrible preprocessor mess */
+ /* is to avoid it in all cases, at least on common architectures */
+ /* or when using a recent enough gcc version (>= 4.6) */
+#if __i386 || __i386__ || _M_X86 || __amd64 || __amd64__ || _M_X64
+ return 0x44;
+#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ return 0x44;
+#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ return 0x11;
+#else
+ union
+ {
+ uint32_t i;
+ uint8_t c;
+ } u = { 0x11223344 };
+ return u.c;
+#endif
}
ecb_inline ecb_bool ecb_big_endian (void) ecb_const;
@@ -453,5 +543,172 @@ ecb_inline ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () ==
#define ecb_array_length(name) (sizeof (name) / sizeof (name [0]))
#endif
+/*******************************************************************************/
+/* floating point stuff, can be disabled by defining ECB_NO_LIBM */
+
+/* basically, everything uses "ieee pure-endian" floating point numbers */
+/* the only noteworthy exception is ancient armle, which uses order 43218765 */
+#if 0 \
+ || __i386 || __i386__ \
+ || __amd64 || __amd64__ || __x86_64 || __x86_64__ \
+ || __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ \
+ || defined __arm__ && defined __ARM_EABI__ \
+ || defined __s390__ || defined __s390x__ \
+ || defined __mips__ \
+ || defined __alpha__ \
+ || defined __hppa__ \
+ || defined __ia64__ \
+ || defined _M_IX86 || defined _M_AMD64 || defined _M_IA64
+ #define ECB_STDFP 1
+ #include <string.h> /* for memcpy */
+#else
+ #define ECB_STDFP 0
+ #include <math.h> /* for frexp*, ldexp* */
+#endif
+
+#ifndef ECB_NO_LIBM
+
+ /* convert a float to ieee single/binary32 */
+ ecb_function_ uint32_t ecb_float_to_binary32 (float x) ecb_const;
+ ecb_function_ uint32_t
+ ecb_float_to_binary32 (float x)
+ {
+ uint32_t r;
+
+ #if ECB_STDFP
+ memcpy (&r, &x, 4);
+ #else
+ /* slow emulation, works for anything but -0 */
+ uint32_t m;
+ int e;
+
+ if (x == 0e0f ) return 0x00000000U;
+ if (x > +3.40282346638528860e+38f) return 0x7f800000U;
+ if (x < -3.40282346638528860e+38f) return 0xff800000U;
+ if (x != x ) return 0x7fbfffffU;
+
+ m = frexpf (x, &e) * 0x1000000U;
+
+ r = m & 0x80000000U;
+
+ if (r)
+ m = -m;
+
+ if (e <= -126)
+ {
+ m &= 0xffffffU;
+ m >>= (-125 - e);
+ e = -126;
+ }
+
+ r |= (e + 126) << 23;
+ r |= m & 0x7fffffU;
+ #endif
+
+ return r;
+ }
+
+ /* converts an ieee single/binary32 to a float */
+ ecb_function_ float ecb_binary32_to_float (uint32_t x) ecb_const;
+ ecb_function_ float
+ ecb_binary32_to_float (uint32_t x)
+ {
+ float r;
+
+ #if ECB_STDFP
+ memcpy (&r, &x, 4);
+ #else
+ /* emulation, only works for normals and subnormals and +0 */
+ int neg = x >> 31;
+ int e = (x >> 23) & 0xffU;
+
+ x &= 0x7fffffU;
+
+ if (e)
+ x |= 0x800000U;
+ else
+ e = 1;
+
+ /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */
+ r = ldexpf (x * (0.5f / 0x800000U), e - 126);
+
+ r = neg ? -r : r;
+ #endif
+
+ return r;
+ }
+
+ /* convert a double to ieee double/binary64 */
+ ecb_function_ uint64_t ecb_double_to_binary64 (double x) ecb_const;
+ ecb_function_ uint64_t
+ ecb_double_to_binary64 (double x)
+ {
+ uint64_t r;
+
+ #if ECB_STDFP
+ memcpy (&r, &x, 8);
+ #else
+ /* slow emulation, works for anything but -0 */
+ uint64_t m;
+ int e;
+
+ if (x == 0e0 ) return 0x0000000000000000U;
+ if (x > +1.79769313486231470e+308) return 0x7ff0000000000000U;
+ if (x < -1.79769313486231470e+308) return 0xfff0000000000000U;
+ if (x != x ) return 0X7ff7ffffffffffffU;
+
+ m = frexp (x, &e) * 0x20000000000000U;
+
+ r = m & 0x8000000000000000;;
+
+ if (r)
+ m = -m;
+
+ if (e <= -1022)
+ {
+ m &= 0x1fffffffffffffU;
+ m >>= (-1021 - e);
+ e = -1022;
+ }
+
+ r |= ((uint64_t)(e + 1022)) << 52;
+ r |= m & 0xfffffffffffffU;
+ #endif
+
+ return r;
+ }
+
+ /* converts an ieee double/binary64 to a double */
+ ecb_function_ double ecb_binary64_to_double (uint64_t x) ecb_const;
+ ecb_function_ double
+ ecb_binary64_to_double (uint64_t x)
+ {
+ double r;
+
+ #if ECB_STDFP
+ memcpy (&r, &x, 8);
+ #else
+ /* emulation, only works for normals and subnormals and +0 */
+ int neg = x >> 63;
+ int e = (x >> 52) & 0x7ffU;
+
+ x &= 0xfffffffffffffU;
+
+ if (e)
+ x |= 0x10000000000000U;
+ else
+ e = 1;
+
+ /* we distrust ldexp a bit and do the 2**-53 scaling by an extra multiply */
+ r = ldexp (x * (0.5 / 0x10000000000000U), e - 1022);
+
+ r = neg ? -r : r;
+ #endif
+
+ return r;
+ }
+
+#endif
+
#endif
View
111 ext/libeio/eio.c
@@ -134,6 +134,41 @@ static void eio_destroy (eio_req *req);
#define statvfs(path,buf) EIO_ENOSYS ()
#define fstatvfs(fd,buf) EIO_ENOSYS ()
+ #define pread(fd,buf,count,offset) eio__pread (fd, buf, count, offset)
+ #define pwrite(fd,buf,count,offset) eio__pwrite (fd, buf, count, offset)
+
+ #if __GNUC__
+ typedef long long eio_off_t; /* signed for compatibility to msvc */
+ #else
+ typedef __int64 eio_off_t; /* unsigned not supported by msvc */
+ #endif
+
+ static eio_ssize_t
+ eio__pread (int fd, void *buf, eio_ssize_t count, eio_off_t offset)
+ {
+ OVERLAPPED o = { 0 };
+ DWORD got;
+
+ o.Offset = offset;
+ o.OffsetHigh = offset >> 32;
+
+ return ReadFile ((HANDLE)EIO_FD_TO_WIN32_HANDLE (fd), buf, count, &got, &o)
+ ? got : -1;
+ }
+
+ static eio_ssize_t
+ eio__pwrite (int fd, void *buf, eio_ssize_t count, eio_off_t offset)
+ {
+ OVERLAPPED o = { 0 };
+ DWORD got;
+
+ o.Offset = offset;
+ o.OffsetHigh = offset >> 32;
+
+ return WriteFile ((HANDLE)EIO_FD_TO_WIN32_HANDLE (fd), buf, count, &got, &o)
+ ? got : -1;
+ }
+
/* rename() uses MoveFile, which fails to overwrite */
#define rename(old,neu) eio__rename (old, neu)
@@ -381,15 +416,6 @@ static xmutex_t reslock;
static xmutex_t reqlock;
static xcond_t reqwait;
-#if !HAVE_PREADWRITE
-/*
- * make our pread/pwrite emulation safe against themselves, but not against
- * normal read/write by using a mutex. slows down execution a lot,
- * but that's your problem, not mine.
- */
-static xmutex_t preadwritelock;
-#endif
-
typedef struct etp_worker
{
struct tmpbuf tmpbuf;
@@ -578,7 +604,7 @@ etp_start_thread (void)
X_LOCK (wrklock);
- if (thread_create (&wrk->tid, etp_proc, (void *)wrk))
+ if (xthread_create (&wrk->tid, etp_proc, (void *)wrk))
{
wrk->prev = &wrk_first;
wrk->next = wrk_first.next;
@@ -945,45 +971,6 @@ int eio_poll (void)
/*****************************************************************************/
/* work around various missing functions */
-#if !HAVE_PREADWRITE
-# undef pread
-# undef pwrite
-# define pread eio__pread
-# define pwrite eio__pwrite
-
-static eio_ssize_t
-eio__pread (int fd, void *buf, size_t count, off_t offset)
-{
- eio_ssize_t res;
- off_t ooffset;
-
- X_LOCK (preadwritelock);
- ooffset = lseek (fd, 0, SEEK_CUR);
- lseek (fd, offset, SEEK_SET);
- res = read (fd, buf, count);
- lseek (fd, ooffset, SEEK_SET);
- X_UNLOCK (preadwritelock);
-
- return res;
-}
-
-static eio_ssize_t
-eio__pwrite (int fd, void *buf, size_t count, off_t offset)
-{
- eio_ssize_t res;
- off_t ooffset;
-
- X_LOCK (preadwritelock);
- ooffset = lseek (fd, 0, SEEK_CUR);
- lseek (fd, offset, SEEK_SET);
- res = write (fd, buf, count);
- lseek (fd, ooffset, SEEK_SET);
- X_UNLOCK (preadwritelock);
-
- return res;
-}
-#endif
-
#ifndef HAVE_UTIMES
# undef utimes
@@ -1933,31 +1920,31 @@ eio__scandir (eio_req *req, etp_worker *self)
#endif
#ifdef DT_CHR
case DT_CHR: ent->type = EIO_DT_CHR; break;
- #endif
+ #endif
#ifdef DT_MPC
case DT_MPC: ent->type = EIO_DT_MPC; break;
- #endif
+ #endif
#ifdef DT_DIR
case DT_DIR: ent->type = EIO_DT_DIR; break;
- #endif
+ #endif
#ifdef DT_NAM
case DT_NAM: ent->type = EIO_DT_NAM; break;
- #endif
+ #endif
#ifdef DT_BLK
case DT_BLK: ent->type = EIO_DT_BLK; break;
- #endif
+ #endif
#ifdef DT_MPB
case DT_MPB: ent->type = EIO_DT_MPB; break;
- #endif
+ #endif
#ifdef DT_REG
case DT_REG: ent->type = EIO_DT_REG; break;
- #endif
+ #endif
#ifdef DT_NWK
case DT_NWK: ent->type = EIO_DT_NWK; break;
- #endif
+ #endif
#ifdef DT_CMP
case DT_CMP: ent->type = EIO_DT_CMP; break;
- #endif
+ #endif
#ifdef DT_LNK
case DT_LNK: ent->type = EIO_DT_LNK; break;
#endif
@@ -2242,6 +2229,8 @@ X_THREAD_PROC (etp_proc)
X_LOCK (wrklock);
etp_worker_free (self);
X_UNLOCK (wrklock);
+
+ return 0;
}
/*****************************************************************************/
@@ -2249,10 +2238,6 @@ X_THREAD_PROC (etp_proc)
int ecb_cold
eio_init (void (*want_poll)(void), void (*done_poll)(void))
{
-#if !HAVE_PREADWRITE
- X_MUTEX_CREATE (preadwritelock);
-#endif
-
return etp_init (want_poll, done_poll);
}
@@ -2262,7 +2247,7 @@ eio_api_destroy (eio_req *req)
free (req);
}
-#define REQ(rtype) \
+#define REQ(rtype) \
eio_req *req; \
\
req = (eio_req *)calloc (1, sizeof *req); \
View
13 ext/libeio/eio.h
@@ -6,14 +6,14 @@
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, 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 EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
@@ -170,7 +170,9 @@ enum
/* eio_fallocate flags */
enum
{
- EIO_FALLOC_FL_KEEP_SIZE = 1 /* MUST match the value in linux/falloc.h */
+ /* these MUST match the value in linux/falloc.h */
+ EIO_FALLOC_FL_KEEP_SIZE = 1,
+ EIO_FALLOC_FL_PUNCH_HOLE = 2
};
/* timestamps and differences - feel free to use double in your code directly */
@@ -195,12 +197,11 @@ enum
/* these use wd + ptr1, but are emulated */
EIO_REALPATH,
- EIO_STATVFS,
EIO_READDIR,
/* all the following requests use wd + ptr1 as path in xxxat functions */
EIO_OPEN,
- EIO_STAT, EIO_LSTAT,
+ EIO_STAT, EIO_LSTAT, EIO_STATVFS,
EIO_TRUNCATE,
EIO_UTIME,
EIO_CHMOD,
View
16 ext/libeio/libeio.m4
@@ -62,22 +62,6 @@ int main (void)
],ac_cv_fdatasync=yes,ac_cv_fdatasync=no)])
test $ac_cv_fdatasync = yes && AC_DEFINE(HAVE_FDATASYNC, 1, fdatasync(2) is available)
-AC_CACHE_CHECK(for pread and pwrite, ac_cv_preadwrite, [AC_LINK_IFELSE([
-#include <unistd.h>
-int main (void)
-{
- int fd = 0;
- size_t count = 1;
- char buf;
- off_t offset = 1;
- ssize_t res;
- res = pread (fd, &buf, count, offset);
- res = pwrite (fd, &buf, count, offset);
- return 0;
-}
-],ac_cv_preadwrite=yes,ac_cv_preadwrite=no)])
-test $ac_cv_preadwrite = yes && AC_DEFINE(HAVE_PREADWRITE, 1, pread(2) and pwrite(2) are available)
-
AC_CACHE_CHECK(for sendfile, ac_cv_sendfile, [AC_LINK_IFELSE([
# include <sys/types.h>
#if __linux
View
4 ext/libeio/xthread.h
@@ -51,7 +51,7 @@ typedef pthread_t xthread_t;
#define X_THREAD_ATFORK(a,b,c)
static int
-thread_create (xthread_t *tid, void *(*proc)(void *), void *arg)
+xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg)
{
int retval;
pthread_attr_t attr;
@@ -132,7 +132,7 @@ typedef pthread_t xthread_t;
#endif
static int
-thread_create (xthread_t *tid, void *(*proc)(void *), void *arg)
+xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg)
{
int retval;
sigset_t fullsigset, oldsigset;

0 comments on commit a2637e8

Please sign in to comment.
Something went wrong with that request. Please try again.