diff --git a/deps/uv/LICENSE b/deps/uv/LICENSE index ae9c747dee..65296f4b25 100644 --- a/deps/uv/LICENSE +++ b/deps/uv/LICENSE @@ -36,9 +36,6 @@ The externally maintained libraries used by libuv are: - libev, located at ev/ is copyright Marc Alexander Lehmann, and dual-licensed under the MIT license and GPL2. - - libeio, located at eio/ is copyright Marc Alexander Lehmann, and - dual-licensed under the MIT license and GPL2. - - inet_pton and inet_ntop implementations, contained in src/inet.c, are copyright the Internet Systems Consortium, Inc., and licensed under the ISC license. diff --git a/deps/uv/README.md b/deps/uv/README.md index 6789ffcb0c..e553fe81dd 100644 --- a/deps/uv/README.md +++ b/deps/uv/README.md @@ -36,6 +36,9 @@ http://nodejs.org/ * IPC and socket sharing between processes `uv_write2` +## Community + + * [Mailing list](http://groups.google.com/group/libuv) ## Documentation @@ -43,6 +46,10 @@ http://nodejs.org/ — API documentation in the form of detailed header comments. * [An Introduction to libuv](http://nikhilm.github.com/uvbook/) — An overview of libuv with tutorials. + * [LXJS 2012 talk](http://www.youtube.com/watch?v=nGn60vDSxQ4) - High-level + introductory talk about libuv. + * [Tests and benchmarks](https://github.com/joyent/libuv/tree/master/test) - + API specification and usage examples. ## Build Instructions diff --git a/deps/uv/common.gypi b/deps/uv/common.gypi index 0ffb45e8d4..a222c3240d 100644 --- a/deps/uv/common.gypi +++ b/deps/uv/common.gypi @@ -117,6 +117,11 @@ # POSIX names '_CRT_NONSTDC_NO_DEPRECATE', ], + 'target_conditions': [ + ['target_arch=="x64"', { + 'msvs_configuration_platform': 'x64' + }] + ] }], [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', { 'cflags': [ '-Wall' ], diff --git a/deps/uv/config-unix.mk b/deps/uv/config-unix.mk index b4d1ec8c25..4269dad378 100644 --- a/deps/uv/config-unix.mk +++ b/deps/uv/config-unix.mk @@ -32,6 +32,7 @@ OBJS += src/unix/core.o OBJS += src/unix/dl.o OBJS += src/unix/error.o OBJS += src/unix/fs.o +OBJS += src/unix/getaddrinfo.o OBJS += src/unix/loop.o OBJS += src/unix/loop-watcher.o OBJS += src/unix/pipe.o @@ -41,21 +42,20 @@ OBJS += src/unix/signal.o OBJS += src/unix/stream.o OBJS += src/unix/tcp.o OBJS += src/unix/thread.o +OBJS += src/unix/threadpool.o OBJS += src/unix/timer.o OBJS += src/unix/tty.o OBJS += src/unix/udp.o ifeq (SunOS,$(uname_S)) EV_CONFIG=config_sunos.h -EIO_CONFIG=config_sunos.h CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 -LINKFLAGS+=-lsocket -lnsl -lkstat +LINKFLAGS+=-lkstat -lnsl -lsendfile -lsocket OBJS += src/unix/sunos.o endif ifeq (AIX,$(uname_S)) EV_CONFIG=config_aix.h -EIO_CONFIG=config_aix.h CPPFLAGS += -Isrc/ares/config_aix -D_ALL_SOURCE -D_XOPEN_SOURCE=500 LINKFLAGS+= -lperfstat OBJS += src/unix/aix.o @@ -63,7 +63,6 @@ endif ifeq (Darwin,$(uname_S)) EV_CONFIG=config_darwin.h -EIO_CONFIG=config_darwin.h CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 LINKFLAGS+=-framework CoreServices OBJS += src/unix/darwin.o @@ -73,7 +72,6 @@ endif ifeq (Linux,$(uname_S)) EV_CONFIG=config_linux.h -EIO_CONFIG=config_linux.h CSTDFLAG += -D_GNU_SOURCE LINKFLAGS+=-ldl -lrt OBJS += src/unix/linux/linux-core.o \ @@ -83,7 +81,6 @@ endif ifeq (FreeBSD,$(uname_S)) EV_CONFIG=config_freebsd.h -EIO_CONFIG=config_freebsd.h LINKFLAGS+=-lkvm OBJS += src/unix/freebsd.o OBJS += src/unix/kqueue.o @@ -91,7 +88,6 @@ endif ifeq (DragonFly,$(uname_S)) EV_CONFIG=config_freebsd.h -EIO_CONFIG=config_freebsd.h LINKFLAGS+= OBJS += src/unix/freebsd.o OBJS += src/unix/kqueue.o @@ -99,7 +95,6 @@ endif ifeq (NetBSD,$(uname_S)) EV_CONFIG=config_netbsd.h -EIO_CONFIG=config_netbsd.h LINKFLAGS+=-lkvm OBJS += src/unix/netbsd.o OBJS += src/unix/kqueue.o @@ -107,7 +102,6 @@ endif ifeq (OpenBSD,$(uname_S)) EV_CONFIG=config_openbsd.h -EIO_CONFIG=config_openbsd.h LINKFLAGS+=-lkvm OBJS += src/unix/openbsd.o OBJS += src/unix/kqueue.o @@ -115,7 +109,6 @@ endif ifneq (,$(findstring CYGWIN,$(uname_S))) EV_CONFIG=config_cygwin.h -EIO_CONFIG=config_cygwin.h # We drop the --std=c89, it hides CLOCK_MONOTONIC on cygwin CSTDFLAG = -D_GNU_SOURCE LINKFLAGS+= @@ -135,7 +128,7 @@ endif RUNNER_LIBS= RUNNER_SRC=test/runner-unix.c -uv.a: $(OBJS) src/fs-poll.o src/inet.o src/uv-common.o src/unix/ev/ev.o src/unix/uv-eio.o src/unix/eio/eio.o +uv.a: $(OBJS) src/fs-poll.o src/inet.o src/uv-common.o src/unix/ev/ev.o $(AR) rcs uv.a $^ src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h @@ -147,29 +140,14 @@ src/unix/%.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/in src/unix/ev/ev.o: src/unix/ev/ev.c $(CC) $(CPPFLAGS) $(CFLAGS) -c src/unix/ev/ev.c -o src/unix/ev/ev.o -DEV_CONFIG_H=\"$(EV_CONFIG)\" - -EIO_CPPFLAGS += $(CPPFLAGS) -EIO_CPPFLAGS += -DEIO_CONFIG_H=\"$(EIO_CONFIG)\" -EIO_CPPFLAGS += -DEIO_STACKSIZE=262144 -EIO_CPPFLAGS += -D_GNU_SOURCE - -src/unix/eio/eio.o: src/unix/eio/eio.c - $(CC) $(EIO_CPPFLAGS) $(CFLAGS) -c src/unix/eio/eio.c -o src/unix/eio/eio.o - -src/unix/uv-eio.o: src/unix/uv-eio.c - $(CC) $(CPPFLAGS) -Isrc/unix/eio/ $(CSTDFLAG) $(CFLAGS) -c src/unix/uv-eio.c -o src/unix/uv-eio.o - - clean-platform: -rm -f src/unix/*.o -rm -f src/unix/ev/*.o - -rm -f src/unix/eio/*.o -rm -f src/unix/linux/*.o -rm -rf test/run-tests.dSYM run-benchmarks.dSYM distclean-platform: -rm -f src/unix/*.o -rm -f src/unix/ev/*.o - -rm -f src/unix/eio/*.o -rm -f src/unix/linux/*.o -rm -rf test/run-tests.dSYM run-benchmarks.dSYM diff --git a/deps/uv/gyp_uv b/deps/uv/gyp_uv index 9c719fde56..bdbf495d1f 100755 --- a/deps/uv/gyp_uv +++ b/deps/uv/gyp_uv @@ -45,6 +45,9 @@ if __name__ == '__main__': args.append(os.path.join(uv_root, 'uv.gyp')) common_fn = os.path.join(uv_root, 'common.gypi') options_fn = os.path.join(uv_root, 'options.gypi') + # we force vs 2010 over 2008 which would otherwise be the default for gyp + if not os.environ.get('GYP_MSVS_VERSION'): + os.environ['GYP_MSVS_VERSION'] = '2010' else: args.append(os.path.join(os.path.abspath(uv_root), 'uv.gyp')) common_fn = os.path.join(os.path.abspath(uv_root), 'common.gypi') @@ -69,9 +72,14 @@ if __name__ == '__main__': args.append('-Dgcc_version=%d' % (10 * major + minor)) args.append('-Dclang=%d' % int(is_clang)) - args.append('-Dtarget_arch=ia32') + if not any(a.startswith('-Dtarget_arch') for a in args): + args.append('-Dtarget_arch=ia32') + + if not any(a.startswith('-Dlibrary') for a in args): + args.append('-Dlibrary=static_library') + args.append('-Dcomponent=static_library') - args.append('-Dlibrary=static_library') + gyp_args = list(args) print gyp_args run_gyp(gyp_args) diff --git a/deps/uv/include/uv-private/eio.h b/deps/uv/include/uv-private/eio.h deleted file mode 100644 index 975f7ef8a5..0000000000 --- a/deps/uv/include/uv-private/eio.h +++ /dev/null @@ -1,403 +0,0 @@ -/* - * libeio API header - * - * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann - * All rights reserved. - * - * 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 - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, 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 OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifndef EIO_H_ -#define EIO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -typedef struct eio_req eio_req; -typedef struct eio_dirent eio_dirent; - -typedef int (*eio_cb)(eio_req *req); - -#ifndef EIO_REQ_MEMBERS -# define EIO_REQ_MEMBERS -#endif - -#ifndef EIO_STRUCT_STAT -# ifdef _WIN32 -# define EIO_STRUCT_STAT struct _stati64 -# define EIO_STRUCT_STATI64 -# else -# define EIO_STRUCT_STAT struct stat -# endif -#endif - -#ifdef _WIN32 - typedef int eio_uid_t; - typedef int eio_gid_t; - typedef int eio_mode_t; - #ifdef __MINGW32__ /* no intptr_t */ - typedef ssize_t eio_ssize_t; - #else - typedef intptr_t eio_ssize_t; /* or SSIZE_T */ - #endif - #if __GNUC__ - typedef long long eio_ino_t; - #else - typedef __int64 eio_ino_t; /* unsigned not supported by msvc */ - #endif -#else - typedef uid_t eio_uid_t; - typedef gid_t eio_gid_t; - typedef ssize_t eio_ssize_t; - typedef ino_t eio_ino_t; - typedef mode_t eio_mode_t; -#endif - -#ifndef EIO_STRUCT_STATVFS -# define EIO_STRUCT_STATVFS struct statvfs -#endif - -/* for readdir */ - -/* eio_readdir flags */ -enum -{ - EIO_READDIR_DENTS = 0x01, /* ptr2 contains eio_dirents, not just the (unsorted) names */ - EIO_READDIR_DIRS_FIRST = 0x02, /* dirents gets sorted into a good stat() ing order to find directories first */ - EIO_READDIR_STAT_ORDER = 0x04, /* dirents gets sorted into a good stat() ing order to quickly stat all files */ - EIO_READDIR_FOUND_UNKNOWN = 0x80, /* set by eio_readdir when *_ARRAY was set and any TYPE=UNKNOWN's were found */ - - EIO_READDIR_CUSTOM1 = 0x100, /* for use by apps */ - EIO_READDIR_CUSTOM2 = 0x200 /* for use by apps */ -}; - -/* using "typical" values in the hope that the compiler will do something sensible */ -enum eio_dtype -{ - EIO_DT_UNKNOWN = 0, - EIO_DT_FIFO = 1, - EIO_DT_CHR = 2, - EIO_DT_MPC = 3, /* multiplexed char device (v7+coherent) */ - EIO_DT_DIR = 4, - EIO_DT_NAM = 5, /* xenix special named file */ - EIO_DT_BLK = 6, - EIO_DT_MPB = 7, /* multiplexed block device (v7+coherent) */ - EIO_DT_REG = 8, - EIO_DT_NWK = 9, /* HP-UX network special */ - EIO_DT_CMP = 9, /* VxFS compressed */ - EIO_DT_LNK = 10, - /* DT_SHAD = 11,*/ - EIO_DT_SOCK = 12, - EIO_DT_DOOR = 13, /* solaris door */ - EIO_DT_WHT = 14, - EIO_DT_MAX = 15 /* highest DT_VALUE ever, hopefully */ -}; - -struct eio_dirent -{ - int nameofs; /* offset of null-terminated name string in (char *)req->ptr2 */ - unsigned short namelen; /* size of filename without trailing 0 */ - unsigned char type; /* one of EIO_DT_* */ - signed char score; /* internal use */ - eio_ino_t inode; /* the inode number, if available, otherwise unspecified */ -}; - -/* eio_msync flags */ -enum -{ - EIO_MS_ASYNC = 1, - EIO_MS_INVALIDATE = 2, - EIO_MS_SYNC = 4 -}; - -/* eio_mtouch flags */ -enum -{ - EIO_MT_MODIFY = 1 -}; - -/* eio_sync_file_range flags */ -enum -{ - EIO_SYNC_FILE_RANGE_WAIT_BEFORE = 1, - EIO_SYNC_FILE_RANGE_WRITE = 2, - EIO_SYNC_FILE_RANGE_WAIT_AFTER = 4 -}; - -/* eio_fallocate flags */ -enum -{ - EIO_FALLOC_FL_KEEP_SIZE = 1 /* MUST match the value in linux/falloc.h */ -}; - -/* timestamps and differences - feel free to use double in your code directly */ -typedef double eio_tstamp; - -/* the eio request structure */ -enum -{ - EIO_CUSTOM, - EIO_OPEN, EIO_CLOSE, EIO_DUP2, - EIO_READ, EIO_WRITE, - EIO_READAHEAD, EIO_SENDFILE, - EIO_STAT, EIO_LSTAT, EIO_FSTAT, - EIO_STATVFS, EIO_FSTATVFS, - EIO_TRUNCATE, EIO_FTRUNCATE, - EIO_UTIME, EIO_FUTIME, - EIO_CHMOD, EIO_FCHMOD, - EIO_CHOWN, EIO_FCHOWN, - EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC, EIO_SYNCFS, - EIO_MSYNC, EIO_MTOUCH, EIO_SYNC_FILE_RANGE, EIO_FALLOCATE, - EIO_MLOCK, EIO_MLOCKALL, - EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME, - EIO_MKNOD, EIO_READDIR, - EIO_LINK, EIO_SYMLINK, EIO_READLINK, EIO_REALPATH, - EIO_GROUP, EIO_NOP, - EIO_BUSY -}; - -/* mlockall constants */ -enum -{ - EIO_MCL_CURRENT = 1, - EIO_MCL_FUTURE = 2 -}; - -/* request priorities */ - -enum { - EIO_PRI_MIN = -4, - EIO_PRI_MAX = 4, - EIO_PRI_DEFAULT = 0 -}; - -#define ETP_PRI_MIN EIO_PRI_MIN -#define ETP_PRI_MAX EIO_PRI_MAX - -#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1) - -#define ETP_REQ eio_req - -/* - * a somewhat faster data structure might be nice, but - * with 8 priorities this actually needs <20 insns - * per shift, the most expensive operation. - */ -typedef struct { - ETP_REQ *qs[ETP_NUM_PRI], *qe[ETP_NUM_PRI]; /* qstart, qend */ - int size; -} etp_reqq; - -typedef struct { - etp_reqq res_queue; /* queue of outstanding responses for this channel */ - void *data; /* use this for what you want */ -} eio_channel; - -/* eio request structure */ -/* this structure is mostly read-only */ -/* when initialising it, all members must be zero-initialised */ -struct eio_req -{ - eio_req volatile *next; /* private ETP */ - - eio_ssize_t result; /* result of syscall, e.g. result = read (... */ - off_t offs; /* read, write, truncate, readahead, sync_file_range, fallocate: file offset, mknod: dev_t */ - size_t size; /* read, write, readahead, sendfile, msync, mlock, sync_file_range, fallocate: length */ - void *ptr1; /* all applicable requests: pathname, old name; readdir: optional eio_dirents */ - void *ptr2; /* all applicable requests: new name or memory buffer; readdir: name strings */ - eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */ - eio_tstamp nv2; /* utime, futime: mtime */ - - int type; /* EIO_xxx constant ETP */ - int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */ - long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, sync_file_range, fallocate: flags */ - long int3; /* chown, fchown: gid */ - int errorno; /* errno value on syscall return */ - - eio_channel *channel; /* data used to direct poll callbacks arising from this req */ - -#if defined(__i386) || defined(__amd64) - unsigned char cancelled; -#else - sig_atomic_t cancelled; -#endif - - unsigned char flags; /* private */ - signed char pri; /* the priority */ - - void *data; - eio_cb finish; - void (*destroy)(eio_req *req); /* called when request no longer needed */ - void (*feed)(eio_req *req); /* only used for group requests */ - - EIO_REQ_MEMBERS - - eio_req *grp, *grp_prev, *grp_next, *grp_first; /* private */ -}; - -/* _private_ request flags */ -enum { - EIO_FLAG_PTR1_FREE = 0x01, /* need to free(ptr1) */ - EIO_FLAG_PTR2_FREE = 0x02, /* need to free(ptr2) */ - EIO_FLAG_GROUPADD = 0x04 /* some request was added to the group */ -}; - -/* undocumented/unsupported/private helper */ -/*void eio_page_align (void **addr, size_t *length);*/ - -/* returns < 0 on error, errno set - * need_poll, if non-zero, will be called when results are available - * and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself). - * done_poll is called when the need to poll is gone. - */ -int eio_init (void (*want_poll)(eio_channel *), void (*done_poll)(eio_channel *)); - -/* initialises a channel */ -void eio_channel_init(eio_channel *, void *data); - -/* must be called regularly to handle pending requests */ -/* returns 0 if all requests were handled, -1 if not, or the value of EIO_FINISH if != 0 */ -int eio_poll (eio_channel *channel); - -/* stop polling if poll took longer than duration seconds */ -void eio_set_max_poll_time (eio_tstamp nseconds); -/* do not handle more then count requests in one call to eio_poll_cb */ -void eio_set_max_poll_reqs (unsigned int nreqs); - -/* set minimum required number - * maximum wanted number - * or maximum idle number of threads */ -void eio_set_min_parallel (unsigned int nthreads); -void eio_set_max_parallel (unsigned int nthreads); -void eio_set_max_idle (unsigned int nthreads); -void eio_set_idle_timeout (unsigned int seconds); - -unsigned int eio_nreqs (void); /* number of requests in-flight */ -unsigned int eio_nready (void); /* number of not-yet handled requests */ -unsigned int eio_npending (void); /* number of finished but unhandled requests */ -unsigned int eio_nthreads (void); /* number of worker threads in use currently */ - -/*****************************************************************************/ -/* convenience wrappers */ - -#ifndef EIO_NO_WRAPPERS -eio_req *eio_nop (int pri, eio_cb cb, void *data, eio_channel *channel); /* does nothing except go through the whole process */ -eio_req *eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data, eio_channel *channel); /* ties a thread for this long, simulating busyness */ -eio_req *eio_sync (int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_syncfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_mlock (void *addr, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_close (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */ -eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */ -eio_req *eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_fchmod (int fd, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_open (const char *path, int flags, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_utime (const char *path, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_chmod (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_mkdir (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */ -eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */ -eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */ -eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */ -eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */ -eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */ -eio_req *eio_mknod (const char *path, eio_mode_t mode, dev_t dev, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel); -eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data, eio_channel *channel); -#endif - -/*****************************************************************************/ -/* groups */ - -eio_req *eio_grp (eio_cb cb, void *data, eio_channel *channel); -void eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit); -void eio_grp_limit (eio_req *grp, int limit); -void eio_grp_add (eio_req *grp, eio_req *req); -void eio_grp_cancel (eio_req *grp); /* cancels all sub requests but not the group */ - -/*****************************************************************************/ -/* request api */ - -/* true if the request was cancelled, useful in the invoke callback */ -#define EIO_CANCELLED(req) ((req)->cancelled) - -#define EIO_RESULT(req) ((req)->result) -/* returns a pointer to the result buffer allocated by eio */ -#define EIO_BUF(req) ((req)->ptr2) -#define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req)) -#define EIO_STATVFS_BUF(req) ((EIO_STRUCT_STATVFS *)EIO_BUF(req)) -#define EIO_PATH(req) ((char *)(req)->ptr1) - -/* submit a request for execution */ -void eio_submit (eio_req *req); -/* cancel a request as soon fast as possible, if possible */ -void eio_cancel (eio_req *req); - -/*****************************************************************************/ -/* convenience functions */ - -eio_ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count); -eio_ssize_t eio__pread (int fd, void *buf, size_t count, off_t offset); -eio_ssize_t eio__pwrite (int fd, void *buf, size_t count, off_t offset); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/deps/uv/include/uv-private/ngx-queue.h b/deps/uv/include/uv-private/ngx-queue.h index 201107edba..4bd66fc12f 100644 --- a/deps/uv/include/uv-private/ngx-queue.h +++ b/deps/uv/include/uv-private/ngx-queue.h @@ -17,8 +17,11 @@ struct ngx_queue_s { #define ngx_queue_init(q) \ + do { \ (q)->prev = q; \ - (q)->next = q + (q)->next = q; \ + } \ + while (0) #define ngx_queue_empty(h) \ @@ -26,20 +29,26 @@ struct ngx_queue_s { #define ngx_queue_insert_head(h, x) \ + do { \ (x)->next = (h)->next; \ (x)->next->prev = x; \ (x)->prev = h; \ - (h)->next = x + (h)->next = x; \ + } \ + while (0) #define ngx_queue_insert_after ngx_queue_insert_head #define ngx_queue_insert_tail(h, x) \ + do { \ (x)->prev = (h)->prev; \ (x)->prev->next = x; \ (x)->next = h; \ - (h)->prev = x + (h)->prev = x; \ + } \ + while (0) #define ngx_queue_head(h) \ @@ -65,38 +74,50 @@ struct ngx_queue_s { #if defined(NGX_DEBUG) #define ngx_queue_remove(x) \ + do { \ (x)->next->prev = (x)->prev; \ (x)->prev->next = (x)->next; \ (x)->prev = NULL; \ - (x)->next = NULL + (x)->next = NULL; \ + } \ + while (0) #else #define ngx_queue_remove(x) \ + do { \ (x)->next->prev = (x)->prev; \ - (x)->prev->next = (x)->next + (x)->prev->next = (x)->next; \ + } \ + while (0) #endif #define ngx_queue_split(h, q, n) \ + do { \ (n)->prev = (h)->prev; \ (n)->prev->next = n; \ (n)->next = q; \ (h)->prev = (q)->prev; \ (h)->prev->next = h; \ - (q)->prev = n; + (q)->prev = n; \ + } \ + while (0) #define ngx_queue_add(h, n) \ + do { \ (h)->prev->next = (n)->next; \ (n)->next->prev = (h)->prev; \ (h)->prev = (n)->prev; \ - (h)->prev->next = h; + (h)->prev->next = h; \ + } \ + while (0) #define ngx_queue_data(q, type, link) \ - (type *) ((unsigned char *) q - offsetof(type, link)) + ((type *) ((unsigned char *) q - offsetof(type, link))) #define ngx_queue_foreach(q, h) \ diff --git a/deps/uv/include/uv-private/uv-unix.h b/deps/uv/include/uv-private/uv-unix.h index 71aee366c0..f50142c06e 100644 --- a/deps/uv/include/uv-private/uv-unix.h +++ b/deps/uv/include/uv-private/uv-unix.h @@ -25,7 +25,6 @@ #include "ngx-queue.h" #include "ev.h" -#include "eio.h" #include #include @@ -54,6 +53,13 @@ struct uv__io_s { ev_io io_watcher; }; +struct uv__work { + void (*work)(struct uv__work *w); + void (*done)(struct uv__work *w); + struct uv_loop_s* loop; + ngx_queue_t wq; +}; + #if defined(__linux__) # include "uv-linux.h" #elif defined(__sun) @@ -100,6 +106,7 @@ typedef pthread_t uv_thread_t; typedef pthread_mutex_t uv_mutex_t; typedef pthread_rwlock_t uv_rwlock_t; typedef UV_PLATFORM_SEM_T uv_sem_t; +typedef pthread_cond_t uv_cond_t; /* Platform-specific definitions for uv_spawn support. */ typedef gid_t uv_gid_t; @@ -115,13 +122,10 @@ typedef struct { #define UV_LOOP_PRIVATE_FIELDS \ unsigned long flags; \ - /* Poll result queue */ \ - eio_channel uv_eio_channel; \ struct ev_loop* ev; \ - /* Various thing for libeio. */ \ - uv_async_t uv_eio_want_poll_notifier; \ - uv_async_t uv_eio_done_poll_notifier; \ - uv_idle_t uv_eio_poller; \ + ngx_queue_t wq; \ + uv_mutex_t wq_mutex; \ + uv_async_t wq_async; \ uv_handle_t* closing_handles; \ ngx_queue_t process_handles[1]; \ ngx_queue_t prepare_handles; \ @@ -233,6 +237,7 @@ typedef struct { uint64_t repeat; #define UV_GETADDRINFO_PRIVATE_FIELDS \ + struct uv__work work_req; \ uv_getaddrinfo_cb cb; \ struct addrinfo* hints; \ char* hostname; \ @@ -245,12 +250,22 @@ typedef struct { int errorno; \ #define UV_FS_PRIVATE_FIELDS \ - struct stat statbuf; \ + const char *new_path; \ uv_file file; \ - eio_req* eio; \ + int flags; \ + mode_t mode; \ + void* buf; \ + size_t len; \ + off_t off; \ + uid_t uid; \ + gid_t gid; \ + double atime; \ + double mtime; \ + struct uv__work work_req; \ + struct stat statbuf; \ #define UV_WORK_PRIVATE_FIELDS \ - eio_req* eio; + struct uv__work work_req; #define UV_TTY_PRIVATE_FIELDS \ struct termios orig_termios; \ diff --git a/deps/uv/include/uv-private/uv-win.h b/deps/uv/include/uv-private/uv-win.h index 132339abb2..78dbb96b7d 100644 --- a/deps/uv/include/uv-private/uv-win.h +++ b/deps/uv/include/uv-private/uv-win.h @@ -171,6 +171,10 @@ typedef int (WSAAPI* LPFN_WSARECVFROM) typedef NTSTATUS *PNTSTATUS; #endif +#ifndef RTL_CONDITION_VARIABLE_INIT + typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; +#endif + typedef struct _AFD_POLL_HANDLE_INFO { HANDLE Handle; ULONG Events; @@ -208,6 +212,23 @@ typedef HANDLE uv_sem_t; typedef CRITICAL_SECTION uv_mutex_t; +/* This condition variable implementation is based on the SetEvent solution + * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html + * We could not use the SignalObjectAndWait solution (section 3.4) because + * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and + * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. + */ + +typedef union { + CONDITION_VARIABLE cond_var; + struct { + unsigned int waiters_count; + CRITICAL_SECTION waiters_count_lock; + HANDLE signal_event; + HANDLE broadcast_event; + } fallback; +} uv_cond_t; + typedef union { /* srwlock_ has type SRWLOCK, but not all toolchains define this type in */ /* windows.h. */ diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index 72da68d68b..cebee681f0 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -139,11 +139,13 @@ typedef enum { XX(CHECK, check) \ XX(FS_EVENT, fs_event) \ XX(FS_POLL, fs_poll) \ + XX(HANDLE, handle) \ XX(IDLE, idle) \ XX(NAMED_PIPE, pipe) \ XX(POLL, poll) \ XX(PREPARE, prepare) \ XX(PROCESS, process) \ + XX(STREAM, stream) \ XX(TCP, tcp) \ XX(TIMER, timer) \ XX(TTY, tty) \ @@ -151,6 +153,7 @@ typedef enum { XX(SIGNAL, signal) \ #define UV_REQ_TYPE_MAP(XX) \ + XX(REQ, req) \ XX(CONNECT, connect) \ XX(WRITE, write) \ XX(SHUTDOWN, shutdown) \ @@ -209,7 +212,6 @@ typedef struct uv_fs_s uv_fs_t; typedef struct uv_work_s uv_work_t; /* None of the above. */ -typedef struct uv_counters_s uv_counters_t; typedef struct uv_cpu_info_s uv_cpu_info_t; typedef struct uv_interface_address_s uv_interface_address_t; @@ -386,12 +388,11 @@ struct uv_shutdown_s { #define UV_HANDLE_FIELDS \ - /* read-only */ \ - uv_loop_t* loop; \ /* public */ \ uv_close_cb close_cb; \ void* data; \ /* read-only */ \ + uv_loop_t* loop; \ uv_handle_type type; \ /* private */ \ ngx_queue_t handle_queue; \ @@ -607,12 +608,14 @@ UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); /* Enable/disable Nagle's algorithm. */ UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -/* Enable/disable TCP keep-alive. +/* + * Enable/disable TCP keep-alive. * - * `ms` is the initial delay in seconds, ignored when `enable` is zero. + * `delay` is the initial delay in seconds, ignored when `enable` is zero. */ -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, int enable, - unsigned int delay); +UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, + int enable, + unsigned int delay); /* * This setting applies to Windows only. @@ -937,8 +940,8 @@ UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); struct uv_pipe_s { UV_HANDLE_FIELDS UV_STREAM_FIELDS - UV_PIPE_PRIVATE_FIELDS int ipc; /* non-zero if this pipe is used for passing handles */ + UV_PIPE_PRIVATE_FIELDS }; /* @@ -1564,16 +1567,6 @@ struct uv_fs_poll_s { UV_HANDLE_FIELDS /* Private, don't touch. */ void* poll_ctx; - /* v0.8 ABI compatibility */ - char padding[sizeof(int) - + sizeof(unsigned int) - + sizeof(uint64_t) - + sizeof(char*) - + sizeof(uv_fs_poll_cb) - + sizeof(uv_timer_t) - + sizeof(uv_fs_t*) - + sizeof(uv_statbuf_t) - - sizeof(void*)]; }; UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); @@ -1637,8 +1630,8 @@ UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); struct uv_signal_s { UV_HANDLE_FIELDS uv_signal_cb signal_cb; - UV_SIGNAL_PRIVATE_FIELDS int signum; + UV_SIGNAL_PRIVATE_FIELDS }; /* These functions are no-ops on Windows. */ @@ -1799,6 +1792,36 @@ UV_EXTERN void uv_sem_post(uv_sem_t* sem); UV_EXTERN void uv_sem_wait(uv_sem_t* sem); UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); +/* + * Same goes for the condition variable functions. + */ +UV_EXTERN int uv_cond_init(uv_cond_t* cond); +UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); +UV_EXTERN void uv_cond_signal(uv_cond_t* cond); +UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); +/* Waits on a condition variable without a timeout. + * + * Note: + * 1. callers should be prepared to deal with spurious wakeups. + */ +UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); +/* Waits on a condition variable with a timeout in nano seconds. + * Returns 0 for success or -1 on timeout, * aborts when other errors happen. + * + * Note: + * 1. callers should be prepared to deal with spurious wakeups. + * 2. the granularity of timeout on Windows is never less than one millisecond. + * 3. uv_cond_timedwait takes a relative timeout, not an absolute time. + * 4. the precision of timeout on OSX is never less than one microsecond. + * Here is the reason. + * OSX doesn't support CLOCK_MONOTONIC nor pthread_condattr_setclock() + * (see man pthread_cond_init on OSX). + * An example in man pthread_cond_timedwait on OSX uses gettimeofday() + * and its resolution is a microsecond. + */ +UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, + uint64_t timeout); + /* Runs a function once and only once. Concurrent calls to uv_once() with the * same guard will block all callers except one (it's unspecified which one). * The guard should be initialized statically with the UV_ONCE_INIT macro. @@ -1841,37 +1864,16 @@ union uv_any_req { }; -struct uv_counters_s { - uint64_t async_init; - uint64_t check_init; - uint64_t eio_init; - uint64_t fs_event_init; - uint64_t fs_poll_init; - uint64_t handle_init; - uint64_t idle_init; - uint64_t pipe_init; - uint64_t poll_init; - uint64_t prepare_init; - uint64_t process_init; - uint64_t req_init; - uint64_t stream_init; - uint64_t tcp_init; - uint64_t timer_init; - uint64_t tty_init; - uint64_t udp_init; -}; - - struct uv_loop_s { - UV_LOOP_PRIVATE_FIELDS + /* User data - use this for whatever. */ + void* data; /* The last error */ uv_err_t last_err; /* Loop reference counting */ unsigned int active_handles; ngx_queue_t handle_queue; ngx_queue_t active_reqs; - /* User data - use this for whatever. */ - void* data; + UV_LOOP_PRIVATE_FIELDS }; diff --git a/deps/uv/src/fs-poll.c b/deps/uv/src/fs-poll.c index f71aa842ee..b5b344b920 100644 --- a/deps/uv/src/fs-poll.c +++ b/deps/uv/src/fs-poll.c @@ -103,11 +103,15 @@ int uv_fs_poll_stop(uv_fs_poll_t* handle) { ctx = handle->poll_ctx; assert(ctx != NULL); assert(ctx->parent_handle != NULL); - ctx->parent_handle = NULL; - uv_timer_stop(&ctx->timer_handle); - handle->poll_ctx = NULL; + + /* Close the timer if it's active. If it's inactive, there's a stat request + * in progress and poll_cb will take care of the cleanup. + */ + if (uv__is_active(&ctx->timer_handle)) + uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); + uv__handle_stop(handle); return 0; @@ -123,12 +127,7 @@ static void timer_cb(uv_timer_t* timer, int status) { struct poll_ctx* ctx; ctx = container_of(timer, struct poll_ctx, timer_handle); - - if (ctx->parent_handle == NULL) { /* handle has been stopped or closed */ - uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); - return; - } - + assert(ctx->parent_handle != NULL); assert(ctx->parent_handle->poll_ctx == ctx); ctx->start_time = uv_now(ctx->loop); @@ -171,6 +170,11 @@ static void poll_cb(uv_fs_t* req) { out: uv_fs_req_cleanup(req); + if (ctx->parent_handle == NULL) { /* handle has been stopped by callback */ + uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); + return; + } + /* Reschedule timer, subtract the delay from doing the stat(). */ interval = ctx->interval; interval -= (uv_now(ctx->loop) - ctx->start_time) % interval; diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index 3ad63f1f8e..2237070896 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -299,134 +299,6 @@ int uv_is_active(const uv_handle_t* handle) { } -static int uv_getaddrinfo_done(eio_req* req_) { - uv_getaddrinfo_t* req = req_->data; - struct addrinfo *res = req->res; -#if __sun - size_t hostlen = strlen(req->hostname); -#endif - - req->res = NULL; - - uv__req_unregister(req->loop, req); - - /* see initialization in uv_getaddrinfo() */ - if (req->hints) - free(req->hints); - else if (req->service) - free(req->service); - else if (req->hostname) - free(req->hostname); - else - assert(0); - - if (req->retcode == 0) { - /* OK */ -#if EAI_NODATA /* FreeBSD deprecated EAI_NODATA */ - } else if (req->retcode == EAI_NONAME || req->retcode == EAI_NODATA) { -#else - } else if (req->retcode == EAI_NONAME) { -#endif - uv__set_sys_error(req->loop, ENOENT); /* FIXME compatibility hack */ -#if __sun - } else if (req->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) { - uv__set_sys_error(req->loop, ENOENT); -#endif - } else { - req->loop->last_err.code = UV_EADDRINFO; - req->loop->last_err.sys_errno_ = req->retcode; - } - - req->cb(req, req->retcode, res); - - return 0; -} - - -static void getaddrinfo_thread_proc(eio_req *req_) { - uv_getaddrinfo_t* req = req_->data; - - req->retcode = getaddrinfo(req->hostname, - req->service, - req->hints, - &req->res); -} - - -int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb cb, - const char* hostname, - const char* service, - const struct addrinfo* hints) { - size_t hostname_len; - size_t service_len; - size_t hints_len; - eio_req* req_; - size_t len; - char* buf; - - if (req == NULL || cb == NULL || (hostname == NULL && service == NULL)) - return uv__set_artificial_error(loop, UV_EINVAL); - - uv_eio_init(loop); - - hostname_len = hostname ? strlen(hostname) + 1 : 0; - service_len = service ? strlen(service) + 1 : 0; - hints_len = hints ? sizeof(*hints) : 0; - buf = malloc(hostname_len + service_len + hints_len); - - if (buf == NULL) - return uv__set_artificial_error(loop, UV_ENOMEM); - - uv__req_init(loop, req, UV_GETADDRINFO); - req->loop = loop; - req->cb = cb; - req->res = NULL; - req->hints = NULL; - req->service = NULL; - req->hostname = NULL; - req->retcode = 0; - - /* order matters, see uv_getaddrinfo_done() */ - len = 0; - - if (hints) { - req->hints = memcpy(buf + len, hints, sizeof(*hints)); - len += sizeof(*hints); - } - - if (service) { - req->service = memcpy(buf + len, service, service_len); - len += service_len; - } - - if (hostname) { - req->hostname = memcpy(buf + len, hostname, hostname_len); - len += hostname_len; - } - - req_ = eio_custom(getaddrinfo_thread_proc, - EIO_PRI_DEFAULT, - uv_getaddrinfo_done, - req, - &loop->uv_eio_channel); - - if (req_) - return 0; - - free(buf); - - return uv__set_artificial_error(loop, UV_ENOMEM); -} - - -void uv_freeaddrinfo(struct addrinfo* ai) { - if (ai) - freeaddrinfo(ai); -} - - /* Open a socket in non-blocking close-on-exec mode, atomically if possible. */ int uv__socket(int domain, int type, int protocol) { int sockfd; diff --git a/deps/uv/src/unix/eio/Changes b/deps/uv/src/unix/eio/Changes deleted file mode 100644 index 9d3e3231c1..0000000000 --- a/deps/uv/src/unix/eio/Changes +++ /dev/null @@ -1,63 +0,0 @@ -Revision history for libeio - -TODO: maybe add mincore support? available on at least darwin, solaris, linux, freebsd -TODO: openbsd requires stdint.h for intptr_t - why posix? - -TODO: make mtouch/readdir maybe others cancellable in-request -TODO: fadvise request -1.0 - - fix a deadlock where a wakeup signal could be missed when - a timeout occured at the same time. - - use nonstandard but maybe-working-on-bsd fork technique. - - use fewer time() syscalls when waiting for new requests. - - fix a path-memory-leak in readdir when using the wrappers - (reported by Thomas L. Shinnick). - - support a max_idle value of 0. - - support setting of idle timeout value (eio_set_idle_timeout). - - readdir: correctly handle malloc failures. - - readdir: new flags argument, can return inode - and possibly filetype, can sort in various ways. - - readdir: stop immediately when cancelled, do - not continue reading the directory. - - fix return value of eio_sendfile_sync. - - include sys/mman.h for msync. - - added EIO_STACKSIZE. - - added msync, mtouch support (untested). - - added sync_file_range (untested). - - fixed custom support. - - use a more robust feed-add detection method. - - "outbundled" from IO::AIO. - - eio_set_max_polltime did not properly convert time to ticks. - - tentatively support darwin in sendfile. - - fix freebsd/darwin sendfile. - - also use sendfile emulation for ENOTSUP and EOPNOTSUPP - error codes. - - add OS-independent EIO_MT_* and EIO_MS_* flag enums. - - add eio_statvfs/eio_fstatvfs. - - add eio_mlock/eio_mlockall and OS-independent MCL_* flag enums. - - no longer set errno to 0 before making syscalls, this only lures - people into the trap of believing errno shows success or failure. - - "fix" demo.c so that it works as non-root. - - suppoert utimes seperately from futimes, as some systems have - utimes but not futimes. - - use _POSIX_MEMLOCK_RANGE for mlock. - - do not (errornously) overwrite CFLAGS in configure.ac. - - mknod used int3 for dev_t (ยง2 bit), not offs (64 bit). - - fix memory corruption in eio_readdirx for the flags - combination EIO_READDIR_STAT_ORDER | EIO_READDIR_DIRS_FIRST. - - port to openbsd (another blatantly broken non-UNIX/POSIX platform). - - fix eio_custom prototype. - - work around a Linux (and likely FreeBSD and other kernels) bug - where sendfile would not transfer all the requested bytes on - large transfers, using a heuristic. - - use libecb, and apply lots of minor space optimisations. - - disable sendfile on darwin, broken as everything else. - - add realpath request and implementation. - - cancelled requests will still invoke their request callbacks. - - add fallocate. - - do not acquire any locks when forking. - - incorporated some mingw32 changes by traviscline. - - added syncfs support, using direct syscall. - - set thread name on linux (ps -L/Hcx, top, gdb). - - remove useless use of volatile variables. - diff --git a/deps/uv/src/unix/eio/LICENSE b/deps/uv/src/unix/eio/LICENSE deleted file mode 100644 index 1ed1324d30..0000000000 --- a/deps/uv/src/unix/eio/LICENSE +++ /dev/null @@ -1,36 +0,0 @@ -All files in libeio are Copyright (C)2007,2008 Marc Alexander Lehmann. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS 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 COPYRIGHT -OWNER OR CONTRIBUTORS 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. - -Alternatively, the contents of this package may be used under the terms -of the GNU General Public License ("GPL") version 2 or any later version, -in which case the provisions of the GPL are applicable instead of the -above. If you wish to allow the use of your version of this package only -under the terms of the GPL and not to allow others to use your version of -this file under the BSD license, indicate your decision by deleting the -provisions above and replace them with the notice and other provisions -required by the GPL in this and the other files of this package. If you do -not delete the provisions above, a recipient may use your version of this -file under either the BSD or the GPL. diff --git a/deps/uv/src/unix/eio/Makefile.am b/deps/uv/src/unix/eio/Makefile.am deleted file mode 100644 index e9866c0d5e..0000000000 --- a/deps/uv/src/unix/eio/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -AUTOMAKE_OPTIONS = foreign no-dependencies - -VERSION_INFO = 1:0 - -EXTRA_DIST = LICENSE Changes autogen.sh - -#man_MANS = ev.3 - -include_HEADERS = eio.h - -lib_LTLIBRARIES = libeio.la - -libeio_la_SOURCES = eio.c ecb.h xthread.h config.h -libeio_la_LDFLAGS = -version-info $(VERSION_INFO) - diff --git a/deps/uv/src/unix/eio/aclocal.m4 b/deps/uv/src/unix/eio/aclocal.m4 deleted file mode 100644 index 18abb73686..0000000000 --- a/deps/uv/src/unix/eio/aclocal.m4 +++ /dev/null @@ -1,8957 +0,0 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, -[m4_warning([this file was generated for autoconf 2.67. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically `autoreconf'.])]) - -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -m4_define([_LT_COPYING], [dnl -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -]) - -# serial 56 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. -m4_defun([LT_PREREQ], -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, - [m4_default([$3], - [m4_fatal([Libtool version $1 or higher is required], - 63)])], - [$2])]) - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters -m4_defun([_LT_CHECK_BUILDDIR], -[case `pwd` in - *\ * | *\ *) - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; -esac -]) - - -# LT_INIT([OPTIONS]) -# ------------------ -AC_DEFUN([LT_INIT], -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT -AC_BEFORE([$0], [LT_LANG])dnl -AC_BEFORE([$0], [LT_OUTPUT])dnl -AC_BEFORE([$0], [LTDL_INIT])dnl -m4_require([_LT_CHECK_BUILDDIR])dnl - -dnl Autoconf doesn't catch unexpanded LT_ macros by default: -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 -dnl unless we require an AC_DEFUNed macro: -AC_REQUIRE([LTOPTIONS_VERSION])dnl -AC_REQUIRE([LTSUGAR_VERSION])dnl -AC_REQUIRE([LTVERSION_VERSION])dnl -AC_REQUIRE([LTOBSOLETE_VERSION])dnl -m4_require([_LT_PROG_LTMAIN])dnl - -dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -_LT_SETUP - -# Only expand once: -m4_define([LT_INIT]) -])# LT_INIT - -# Old names: -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -m4_defun([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -]) - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. -m4_defun([_LT_FILEUTILS_DEFAULTS], -[: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} -])# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -m4_defun([_LT_SETUP], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -_LT_DECL([], [host_alias], [0], [The host system])dnl -_LT_DECL([], [host], [0])dnl -_LT_DECL([], [host_os], [0])dnl -dnl -_LT_DECL([], [build_alias], [0], [The build system])dnl -_LT_DECL([], [build], [0])dnl -_LT_DECL([], [build_os], [0])dnl -dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -test -z "$LN_S" && LN_S="ln -s" -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl -dnl -AC_REQUIRE([LT_CMD_MAX_LEN])dnl -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl -dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl - -_LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi -]) -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -_LT_CHECK_OBJDIR - -m4_require([_LT_TAG_COMPILER])dnl -_LT_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - _LT_PATH_MAGIC - fi - ;; -esac - -# Use C for the default configuration in the libtool script -LT_SUPPORTED_TAG([CC]) -_LT_LANG_C_CONFIG -_LT_LANG_DEFAULT_CONFIG -_LT_CONFIG_COMMANDS -])# _LT_SETUP - - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from `configure', and `config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -m4_defun([_LT_PROG_LTMAIN], -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain="$ac_aux_dir/ltmain.sh" -])# _LT_PROG_LTMAIN - - - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL_INIT], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- -m4_defun([_LT_CONFIG_SAVE_COMMANDS], -[_LT_CONFIG_LIBTOOL([$1]) -_LT_CONFIG_LIBTOOL_INIT([$2]) -]) - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. -m4_define([_LT_FORMAT_COMMENT], -[m4_ifval([$1], [ -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) -)]) - - - - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. -m4_define([_LT_DECL], -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], - [m4_ifval([$1], [$1], [$2])]) - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) - m4_ifval([$4], - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) - lt_dict_add_subkey([lt_decl_dict], [$2], - [tagged?], [m4_ifval([$5], [yes], [no])])]) -]) - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_tag_varnames], -[_lt_decl_filter([tagged?], [yes], $@)]) - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- -m4_define([_lt_decl_filter], -[m4_case([$#], - [0], [m4_fatal([$0: too few arguments: $#])], - [1], [m4_fatal([$0: too few arguments: $#: $1])], - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], - [lt_dict_filter([lt_decl_dict], $@)])[]dnl -]) - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- -m4_define([lt_decl_quote_varnames], -[_lt_decl_filter([value], [1], $@)]) - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_dquote_varnames], -[_lt_decl_filter([value], [2], $@)]) - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_varnames_tagged], -[m4_assert([$# <= 2])dnl -_$0(m4_quote(m4_default([$1], [[, ]])), - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) -m4_define([_lt_decl_varnames_tagged], -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_all_varnames], -[_$0(m4_quote(m4_default([$1], [[, ]])), - m4_if([$2], [], - m4_quote(lt_decl_varnames), - m4_quote(m4_shift($@))))[]dnl -]) -m4_define([_lt_decl_all_varnames], -[lt_join($@, lt_decl_varnames_tagged([$1], - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl -]) - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME -# must have a single quote delimited value for this to work. -m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script -m4_defun([_LT_LIBTOOL_TAGS], -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags="_LT_TAGS"dnl -]) - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name -m4_define([_LT_LIBTOOL_DECLARE], -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], - [description])))[]dnl -m4_pushdef([_libtool_name], - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), - [0], [_libtool_name=[$]$1], - [1], [_libtool_name=$lt_[]$1], - [2], [_libtool_name=$lt_[]$1], - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl -]) - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. -m4_defun([_LT_LIBTOOL_CONFIG_VARS], -[m4_foreach([_lt_var], - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- -m4_define([_LT_LIBTOOL_TAG_VARS], -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -m4_defun([_LT_CONFIG_COMMANDS], -[AC_PROVIDE_IFELSE([LT_OUTPUT], - dnl If the libtool generation code has been placed in $CONFIG_LT, - dnl instead of duplicating it all over again into config.status, - dnl then we will have config.status run $CONFIG_LT later, so it - dnl needs to know what name is stored there: - [AC_CONFIG_COMMANDS([libtool], - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], - dnl If the libtool generation code is destined for config.status, - dnl expand the accumulated commands and init code now: - [AC_CONFIG_COMMANDS([libtool], - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) -])#_LT_CONFIG_COMMANDS - - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], -[ - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -_LT_CONFIG_STATUS_DECLARATIONS -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\[$]0 --fallback-echo"')dnl " - lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` - ;; -esac - -_LT_OUTPUT_LIBTOOL_INIT -]) - - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -AC_DEFUN([LT_OUTPUT], -[: ${CONFIG_LT=./config.lt} -AC_MSG_NOTICE([creating $CONFIG_LT]) -cat >"$CONFIG_LT" <<_LTEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate a libtool stub with the current configuration. - -lt_cl_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AS_SHELL_SANITIZE -_AS_PREPARE - -exec AS_MESSAGE_FD>&1 -exec AS_MESSAGE_LOG_FD>>config.log -{ - echo - AS_BOX([Running $as_me.]) -} >&AS_MESSAGE_LOG_FD - -lt_cl_help="\ -\`$as_me' creates a local libtool stub from the current configuration, -for use in further configure time tests before the real libtool is -generated. - -Usage: $[0] [[OPTIONS]] - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - -Report bugs to ." - -lt_cl_version="\ -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) -configured by $[0], generated by m4_PACKAGE_STRING. - -Copyright (C) 2008 Free Software Foundation, Inc. -This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." - -while test $[#] != 0 -do - case $[1] in - --version | --v* | -V ) - echo "$lt_cl_version"; exit 0 ;; - --help | --h* | -h ) - echo "$lt_cl_help"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --quiet | --q* | --silent | --s* | -q ) - lt_cl_silent=: ;; - - -*) AC_MSG_ERROR([unrecognized option: $[1] -Try \`$[0] --help' for more information.]) ;; - - *) AC_MSG_ERROR([unrecognized argument: $[1] -Try \`$[0] --help' for more information.]) ;; - esac - shift -done - -if $lt_cl_silent; then - exec AS_MESSAGE_FD>/dev/null -fi -_LTEOF - -cat >>"$CONFIG_LT" <<_LTEOF -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AC_MSG_NOTICE([creating $ofile]) -_LT_OUTPUT_LIBTOOL_COMMANDS -AS_EXIT(0) -_LTEOF -chmod +x "$CONFIG_LT" - -# configure is writing to config.log, but config.lt does its own redirection, -# appending to config.log, which fails on DOS, as config.log is still kept -# open by configure. Here we exec the FD to /dev/null, effectively closing -# config.log, so it can be properly (re)opened and appended to by config.lt. -if test "$no_create" != yes; then - lt_cl_success=: - test "$silent" = yes && - lt_config_lt_args="$lt_config_lt_args --quiet" - exec AS_MESSAGE_LOG_FD>/dev/null - $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false - exec AS_MESSAGE_LOG_FD>>config.log - $lt_cl_success || AS_EXIT(1) -fi -])# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -m4_defun([_LT_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_CONFIG_SAVE_COMMANDS([ - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl - m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -_LT_COPYING -_LT_LIBTOOL_TAGS - -# ### BEGIN LIBTOOL CONFIG -_LT_LIBTOOL_CONFIG_VARS -_LT_LIBTOOL_TAG_VARS -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - _LT_PROG_LTMAIN - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_XSI_SHELLFNS - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -], -[cat <<_LT_EOF >> "$ofile" - -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded -dnl in a comment (ie after a #). -# ### BEGIN LIBTOOL TAG CONFIG: $1 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) -# ### END LIBTOOL TAG CONFIG: $1 -_LT_EOF -])dnl /m4_if -], -[m4_if([$1], [], [ - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile'], []) -])dnl /_LT_CONFIG_SAVE_COMMANDS -])# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' -AC_DEFUN([LT_SUPPORTED_TAG], []) - - -# C support is built-in for now -m4_define([_LT_LANG_C_enabled], []) -m4_define([_LT_TAGS], []) - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -AC_DEFUN([LT_LANG], -[AC_BEFORE([$0], [LT_OUTPUT])dnl -m4_case([$1], - [C], [_LT_LANG(C)], - [C++], [_LT_LANG(CXX)], - [Java], [_LT_LANG(GCJ)], - [Fortran 77], [_LT_LANG(F77)], - [Fortran], [_LT_LANG(FC)], - [Windows Resource], [_LT_LANG(RC)], - [m4_ifdef([_LT_LANG_]$1[_CONFIG], - [_LT_LANG($1)], - [m4_fatal([$0: unsupported language: "$1"])])])dnl -])# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -m4_defun([_LT_LANG], -[m4_ifdef([_LT_LANG_]$1[_enabled], [], - [LT_SUPPORTED_TAG([$1])dnl - m4_append([_LT_TAGS], [$1 ])dnl - m4_define([_LT_LANG_]$1[_enabled], [])dnl - _LT_LANG_$1_CONFIG($1)])dnl -])# _LT_LANG - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -m4_defun([_LT_LANG_DEFAULT_CONFIG], -[AC_PROVIDE_IFELSE([AC_PROG_CXX], - [LT_LANG(CXX)], - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) - -AC_PROVIDE_IFELSE([AC_PROG_F77], - [LT_LANG(F77)], - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) - -AC_PROVIDE_IFELSE([AC_PROG_FC], - [LT_LANG(FC)], - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) - -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal -dnl pulling things in needlessly. -AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], - [LT_LANG(GCJ)], - [m4_ifdef([AC_PROG_GCJ], - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([A][M_PROG_GCJ], - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([LT_PROG_GCJ], - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) - -AC_PROVIDE_IFELSE([LT_PROG_RC], - [LT_LANG(RC)], - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) -])# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) -dnl AC_DEFUN([AC_LIBTOOL_F77], []) -dnl AC_DEFUN([AC_LIBTOOL_FC], []) -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) - - -# _LT_TAG_COMPILER -# ---------------- -m4_defun([_LT_TAG_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -m4_defun([_LT_COMPILER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -m4_defun([_LT_LINKER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* -])# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ - case $host_os in - rhapsody* | darwin*) - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) - AC_CHECK_TOOL([LIPO], [lipo], [:]) - AC_CHECK_TOOL([OTOOL], [otool], [:]) - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) - _LT_DECL([], [DSYMUTIL], [1], - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) - _LT_DECL([], [NMEDIT], [1], - [Tool to change global to local symbols on Mac OS X]) - _LT_DECL([], [LIPO], [1], - [Tool to manipulate fat objects and archives on Mac OS X]) - _LT_DECL([], [OTOOL], [1], - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) - _LT_DECL([], [OTOOL64], [1], - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) - - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], - [lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi]) - AC_CACHE_CHECK([for -exported_symbols_list linker flag], - [lt_cv_ld_exported_symbols_list], - [lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [lt_cv_ld_exported_symbols_list=yes], - [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS="$save_LDFLAGS" - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- -# Checks for linker and compiler features on darwin -m4_defun([_LT_DARWIN_LINKER_FEATURES], -[ - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_automatic, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=echo - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - m4_if([$1], [CXX], -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi -],[]) - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi -]) - -# _LT_SYS_MODULE_PATH_AIX -# ----------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_SHELL_INIT - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[_LT_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$lt_ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -ECHO=${lt_ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<_LT_EOF -[$]* -_LT_EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$lt_ECHO"; then - if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if { echo_test_string=`eval $cmd`; } 2>/dev/null && - { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null - then - break - fi - done - fi - - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : - else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$ECHO" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - ECHO='print -r' - elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - ECHO='printf %s\n' - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - ECHO=echo - fi - fi - fi - fi - fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -lt_ECHO=$ECHO -if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(lt_ECHO) -]) -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], - [An echo program that does not interpret backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_ENABLE_LOCK -# --------------- -m4_defun([_LT_ENABLE_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AS_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" -])# _LT_ENABLE_LOCK - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[AC_CHECK_TOOL(AR, ar, false) -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1]) - -AC_CHECK_TOOL(STRIP, strip, :) -test -z "$STRIP" && STRIP=: -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) - -AC_CHECK_TOOL(RANLIB, ranlib, :) -test -z "$RANLIB" && RANLIB=: -_LT_DECL([], [RANLIB], [1], - [Commands used to install an old-style archive]) - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi -_LT_DECL([], [old_postinstall_cmds], [2]) -_LT_DECL([], [old_postuninstall_cmds], [2]) -_LT_TAGDECL([], [old_archive_cmds], [2], - [Commands used to build an old-style archive]) -])# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([_LT_COMPILER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $RM conftest* -]) - -if test x"[$]$2" = xyes; then - m4_if([$5], , :, [$5]) -else - m4_if([$6], , :, [$6]) -fi -])# _LT_COMPILER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -AC_DEFUN([_LT_LINKER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - m4_if([$4], , :, [$4]) -else - m4_if([$5], , :, [$5]) -fi -])# _LT_LINKER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) - - -# LT_CMD_MAX_LEN -#--------------- -AC_DEFUN([LT_CMD_MAX_LEN], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ - = "XX$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -max_cmd_len=$lt_cv_sys_max_cmd_len -_LT_DECL([], [max_cmd_len], [0], - [What is the maximum length of a command?]) -])# LT_CMD_MAX_LEN - -# Old name: -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) - - -# _LT_HEADER_DLFCN -# ---------------- -m4_defun([_LT_HEADER_DLFCN], -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl -])# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -m4_defun([_LT_TRY_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -[#line __oline__ "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -}] -_LT_EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -AC_DEFUN([LT_SYS_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -_LT_DECL([dlopen_support], [enable_dlopen], [0], - [Whether dlopen is supported]) -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], - [Whether dlopen of programs is supported]) -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], - [Whether dlopen of statically linked programs is supported]) -])# LT_SYS_DLOPEN_SELF - -# Old name: -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -m4_defun([_LT_COMPILER_C_O], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* -]) -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], - [Does compiler simultaneously support -c and -o options?]) -])# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -m4_defun([_LT_COMPILER_FILE_LOCKS], -[m4_require([_LT_ENABLE_LOCK])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_COMPILER_C_O([$1]) - -hard_links="nottested" -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) -])# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -m4_defun([_LT_CHECK_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -_LT_DECL([], [objdir], [0], - [The name of the directory that contains temporary libtool files])dnl -m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", - [Define to the sub-directory in which libtool stores uninstalled libraries.]) -])# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || - test -n "$_LT_TAGVAR(runpath_var, $1)" || - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -_LT_TAGDECL([], [hardcode_action], [0], - [How to hardcode a shared library path into an executable]) -])# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -m4_defun([_LT_CMD_STRIPLIB], -[m4_require([_LT_DECL_EGREP]) -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) -_LT_DECL([], [striplib], [1]) -])# _LT_CMD_STRIPLIB - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -m4_defun([_LT_SYS_DYNAMIC_LINKER], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_OBJDUMP])dnl -m4_require([_LT_DECL_SED])dnl -AC_MSG_CHECKING([dynamic linker characteristics]) -m4_if([$1], - [], [ -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` - else - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[[lt_foo]]++; } - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } -}'` - sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[[4-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[123]]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix[[3-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - -_LT_DECL([], [variables_saved_for_relink], [1], - [Variables whose values should be saved in libtool wrapper scripts and - restored at link time]) -_LT_DECL([], [need_lib_prefix], [0], - [Do we need the "lib" prefix for modules?]) -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) -_LT_DECL([], [version_type], [0], [Library versioning type]) -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) -_LT_DECL([], [shlibpath_overrides_runpath], [0], - [Is shlibpath searched before the hard-coded library search path?]) -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) -_LT_DECL([], [library_names_spec], [1], - [[List of archive names. First name is the real one, the rest are links. - The last name is the one that the linker finds with -lNAME]]) -_LT_DECL([], [soname_spec], [1], - [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [postinstall_cmds], [2], - [Command to use after installation of a shared archive]) -_LT_DECL([], [postuninstall_cmds], [2], - [Command to use after uninstallation of a shared archive]) -_LT_DECL([], [finish_cmds], [2], - [Commands used to finish a libtool library installation in a directory]) -_LT_DECL([], [finish_eval], [1], - [[As "finish_cmds", except a single script fragment to be evaled but - not shown]]) -_LT_DECL([], [hardcode_into_libs], [0], - [Whether we should hardcode library paths into libraries]) -_LT_DECL([], [sys_lib_search_path_spec], [2], - [Compile-time system search path for libraries]) -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], - [Run-time system search path for libraries]) -])# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program which can recognize shared library -AC_DEFUN([_LT_PATH_TOOL_PREFIX], -[m4_require([_LT_DECL_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="m4_if([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -_LT_DECL([], [MAGIC_CMD], [0], - [Used to examine libraries when file_magic_cmd begins with "file"])dnl -])# _LT_PATH_TOOL_PREFIX - -# Old name: -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) - - -# _LT_PATH_MAGIC -# -------------- -# find a file program which can recognize a shared library -m4_defun([_LT_PATH_MAGIC], -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([LT_PATH_LD], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_ARG_WITH([gnu-ld], - [AS_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no])dnl - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[[3-9]]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | netbsdelf*-gnu) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -_LT_DECL([], [deplibs_check_method], [1], - [Method to check whether dependent libraries are shared objects]) -_LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method == "file_magic"]) -])# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -AC_DEFUN([LT_PATH_NM], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi]) -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) - AC_SUBST([DUMPBIN]) - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm -AC_SUBST([NM]) -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl - -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], - [lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) - cat conftest.out >&AS_MESSAGE_LOG_FD - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest*]) -])# LT_PATH_NM - -# Old names: -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_PROG_NM], []) -dnl AC_DEFUN([AC_PROG_NM], []) - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -AC_SUBST([LIBM]) -])# LT_LIB_M - -# Old name: -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_CHECK_LIBM], []) - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -m4_defun([_LT_COMPILER_NO_RTTI], -[m4_require([_LT_TAG_COMPILER])dnl - -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], - [Compiler flag to turn off builtin functions]) -])# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_NM])dnl -AC_REQUIRE([LT_PATH_LD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_TAG_COMPILER])dnl - -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK ['"\ -" {last_section=section; section=\$ 3};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx]" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[[]] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi - -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], - [Take the output of nm and produce a listing of raw symbols and C names]) -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], - [Transform the output of nm in a proper C declaration]) -_LT_DECL([global_symbol_to_c_name_address], - [lt_cv_sys_global_symbol_to_c_name_address], [1], - [Transform the output of nm in a C name address pair]) -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], - [Transform the output of nm in a C name address pair when lib prefix is needed]) -]) # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -m4_defun([_LT_COMPILER_PIC], -[m4_require([_LT_TAG_COMPILER])dnl -_LT_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_TAGVAR(lt_prog_compiler_static, $1)= - -AC_MSG_CHECKING([for $compiler option to produce PIC]) -m4_if([$1], [CXX], [ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix[[4-9]]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xlc* | xlC*) - # IBM XL 8.0 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd* | netbsdelf*-gnu) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - hpux9* | hpux10* | hpux11*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xl*) - # IBM XL C 8.0/Fortran 10.1 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - *Sun\ F*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - esac - ;; - esac - ;; - - newsos6) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - rdos*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" - ;; -esac -AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], - [Additional compiler flags for building library objects]) - -# -# Check to make sure the static flag actually works. -# -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) -])# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -m4_defun([_LT_LINKER_SHLIBS], -[AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -m4_if([$1], [CXX], [ - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix[[4-9]]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - ;; - linux* | k*bsd*-gnu) - _LT_TAGVAR(link_all_deplibs, $1)=no - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] -], [ - runpath_var= - _LT_TAGVAR(allow_undefined_flag, $1)= - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(archive_cmds, $1)= - _LT_TAGVAR(archive_expsym_cmds, $1)= - _LT_TAGVAR(compiler_needs_object, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(hardcode_automatic, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= - _LT_TAGVAR(hardcode_libdir_separator, $1)= - _LT_TAGVAR(hardcode_minus_L, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(inherit_rpath, $1)=no - _LT_TAGVAR(link_all_deplibs, $1)=unknown - _LT_TAGVAR(module_cmds, $1)= - _LT_TAGVAR(module_expsym_cmds, $1)= - _LT_TAGVAR(old_archive_from_new_cmds, $1)= - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_TAGVAR(thread_safe_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. -dnl Note also adjust exclude_expsyms for C++ above. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - linux* | k*bsd*-gnu) - _LT_TAGVAR(link_all_deplibs, $1)=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[[3-9]]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag= - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - _LT_TAGVAR(whole_archive_flag_spec, $1)= - tmp_sharedflag='--shared' ;; - xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd* | netbsdelf*-gnu) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - _LT_TAGVAR(link_all_deplibs, $1)=no - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - bsdi[[45]]*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE(int foo(void) {}, - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - ) - LDFLAGS="$save_LDFLAGS" - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd* | netbsdelf*-gnu) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - fi - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' - ;; - esac - fi - fi -]) -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld - -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl -_LT_DECL([], [extract_expsyms_cmds], [2], - [The commands to extract the exported symbol list from a shared archive]) - -# -# Do we need to explicitly link libc? -# -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_MSG_CHECKING([whether -lc should be explicitly linked in]) - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) - ;; - esac - fi - ;; -esac - -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], - [Whether or not to add -lc for building shared libraries]) -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], - [enable_shared_with_static_runtimes], [0], - [Whether or not to disallow shared libs when runtime libs are static]) -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], - [Compiler flag to allow reflexive dlopens]) -_LT_TAGDECL([], [whole_archive_flag_spec], [1], - [Compiler flag to generate shared objects directly from archives]) -_LT_TAGDECL([], [compiler_needs_object], [1], - [Whether the compiler copes with passing no objects directly]) -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], - [Create an old-style archive from a shared archive]) -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], - [Create a temporary old-style archive to link instead of a shared archive]) -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) -_LT_TAGDECL([], [archive_expsym_cmds], [2]) -_LT_TAGDECL([], [module_cmds], [2], - [Commands used to build a loadable module if different from building - a shared archive.]) -_LT_TAGDECL([], [module_expsym_cmds], [2]) -_LT_TAGDECL([], [with_gnu_ld], [1], - [Whether we are building with GNU ld or not]) -_LT_TAGDECL([], [allow_undefined_flag], [1], - [Flag that allows shared libraries with undefined symbols to be built]) -_LT_TAGDECL([], [no_undefined_flag], [1], - [Flag that enforces no undefined symbols]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], - [Flag to hardcode $libdir into a binary during linking. - This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) -_LT_TAGDECL([], [hardcode_libdir_separator], [1], - [Whether we need a single "-rpath" flag with a separated argument]) -_LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary]) -_LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting ${shlibpath_var} if the - library is relocated]) -_LT_TAGDECL([], [hardcode_minus_L], [0], - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_automatic], [0], - [Set to "yes" if building a shared library automatically hardcodes DIR - into the library and all subsequent libraries and executables linked - against it]) -_LT_TAGDECL([], [inherit_rpath], [0], - [Set to yes if linker adds runtime paths of dependent libraries - to runtime path list]) -_LT_TAGDECL([], [link_all_deplibs], [0], - [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [fix_srcfile_path], [1], - [Fix the shell variable $srcfile for the compiler]) -_LT_TAGDECL([], [always_export_symbols], [0], - [Set to "yes" if exported symbols are required]) -_LT_TAGDECL([], [export_symbols_cmds], [2], - [The commands to list exported symbols]) -_LT_TAGDECL([], [exclude_expsyms], [1], - [Symbols that should not be listed in the preloaded symbols]) -_LT_TAGDECL([], [include_expsyms], [1], - [Symbols that must always be exported]) -_LT_TAGDECL([], [prelink_cmds], [2], - [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [file_list_spec], [1], - [Specify filename containing input files]) -dnl FIXME: Not yet implemented -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], -dnl [Compiler flag to generate thread safe objects]) -])# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_C_CONFIG], -[m4_require([_LT_DECL_EGREP])dnl -lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - -_LT_TAG_COMPILER -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - LT_SYS_DLOPEN_SELF - _LT_CMD_STRIPLIB - - # Report which library types will actually be built - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_CONFIG($1) -fi -AC_LANG_POP -CC="$lt_save_CC" -])# _LT_LANG_C_CONFIG - - -# _LT_PROG_CXX -# ------------ -# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ -# compiler, we have our own version here. -m4_defun([_LT_PROG_CXX], -[ -pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) -AC_PROG_CXX -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -else - _lt_caught_CXX_error=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_CXX - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_CXX], []) - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[AC_REQUIRE([_LT_PROG_CXX])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_LANG_PUSH(C++) -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(compiler_needs_object, $1)=no -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - else - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - LT_PATH_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) - _LT_TAGVAR(ld_shlibs, $1)=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - freebsd[[12]]*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - freebsd-elf*) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - gnu*) - ;; - - hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' - fi - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ - $RANLIB $oldlib' - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 will use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - xl*) - # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=echo - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - case $host in - osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - ;; - *) - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - fi - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - - _LT_TAGVAR(GCC, $1)="$GXX" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - CC=$lt_save_CC - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -AC_LANG_POP -])# _LT_LANG_CXX_CONFIG - - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -# Dependencies to place before and after the object being linked: -_LT_TAGVAR(predep_objects, $1)= -_LT_TAGVAR(postdep_objects, $1)= -_LT_TAGVAR(predeps, $1)= -_LT_TAGVAR(postdeps, $1)= -_LT_TAGVAR(compiler_lib_search_path, $1)= - -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF -int a; -void foo (void) { a = 0; } -_LT_EOF -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer*4 a - a=0 - return - end -_LT_EOF -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer a - a=0 - return - end -_LT_EOF -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF -public class foo { - private int a; - public void bar (void) { - a = 0; - } -}; -_LT_EOF -]) -dnl Parse the compiler output and extract the necessary -dnl objects, libraries and library flags. -if AC_TRY_EVAL(ac_compile); then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case $p in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - else - prev= - fi - - if test "$pre_test_object_deps_done" = no; then - case $p in - -L* | -R*) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" - else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)="${prev}${p}" - else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" - fi - fi - ;; - - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)="$p" - else - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" - fi - else - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)="$p" - else - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling $1 test program" -fi - -$RM -f confest.$objext - -# PORTME: override above test on systems where it is broken -m4_if([$1], [CXX], -[case $host_os in -interix[[3-9]]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - _LT_TAGVAR(predep_objects,$1)= - _LT_TAGVAR(postdep_objects,$1)= - _LT_TAGVAR(postdeps,$1)= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac -]) - -case " $_LT_TAGVAR(postdeps, $1) " in -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; -esac - _LT_TAGVAR(compiler_lib_search_dirs, $1)= -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], - [The directories searched by this compiler when creating a shared library]) -_LT_TAGDECL([], [predep_objects], [1], - [Dependencies to place before and after the objects being linked to - create a shared library]) -_LT_TAGDECL([], [postdep_objects], [1]) -_LT_TAGDECL([], [predeps], [1]) -_LT_TAGDECL([], [postdeps], [1]) -_LT_TAGDECL([], [compiler_lib_search_path], [1], - [The library search path used internally by the compiler when linking - a shared library]) -])# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_PROG_F77 -# ------------ -# Since AC_PROG_F77 is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_F77], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) -AC_PROG_F77 -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_F77 - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_F77], []) - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_F77_CONFIG], -[AC_REQUIRE([_LT_PROG_F77])dnl -AC_LANG_PUSH(Fortran 77) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the F77 compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_F77" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${F77-"f77"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - GCC=$G77 - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$G77" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_F77" != yes - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _LT_PROG_FC -# ----------- -# Since AC_PROG_FC is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_FC], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) -AC_PROG_FC -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_FC - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_FC], []) - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_FC_CONFIG], -[AC_REQUIRE([_LT_PROG_FC])dnl -AC_LANG_PUSH(Fortran) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for fc test sources. -ac_ext=${ac_fc_srcext-f} - -# Object file extension for compiled fc test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the FC compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_FC" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${FC-"f95"} - compiler=$CC - GCC=$ac_cv_fc_compiler_gnu - - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_FC" != yes - -AC_LANG_POP -])# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GCJ_CONFIG], -[AC_REQUIRE([LT_PROG_GCJ])dnl -AC_LANG_SAVE - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds - -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC="$lt_save_CC" -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_RC_CONFIG], -[AC_REQUIRE([LT_PROG_RC])dnl -AC_LANG_SAVE - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' - -# Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - -if test -n "$compiler"; then - : - _LT_CONFIG($1) -fi - -GCC=$lt_save_GCC -AC_LANG_RESTORE -CC="$lt_save_CC" -])# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- -AC_DEFUN([LT_PROG_GCJ], -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], - [AC_CHECK_TOOL(GCJ, gcj,) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS)])])[]dnl -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) - - -# LT_PROG_RC -# ---------- -AC_DEFUN([LT_PROG_RC], -[AC_CHECK_TOOL(RC, windres,) -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_RC], []) - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_EGREP], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_REQUIRE([AC_PROG_FGREP])dnl -test -z "$GREP" && GREP=grep -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) -_LT_DECL([], [EGREP], [1], [An ERE matcher]) -_LT_DECL([], [FGREP], [1], [A literal string matcher]) -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too -AC_SUBST([GREP]) -]) - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_OBJDUMP], -[AC_CHECK_TOOL(OBJDUMP, objdump, false) -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) -AC_SUBST([OBJDUMP]) -]) - - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -m4_defun([_LT_DECL_SED], -[AC_PROG_SED -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) -])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_SED], []) - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -m4_defun([_LT_CHECK_SHELL_FEATURES], -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -AC_MSG_RESULT([$xsi_shell]) -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) - -AC_MSG_CHECKING([whether the shell understands "+="]) -lt_shell_append=no -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -AC_MSG_RESULT([$lt_shell_append]) -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl -])# _LT_CHECK_SHELL_FEATURES - - -# _LT_PROG_XSI_SHELLFNS -# --------------------- -# Bourne and XSI compatible variants of some useful shell functions. -m4_defun([_LT_PROG_XSI_SHELLFNS], -[case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $[*] )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - -dnl func_dirname_and_basename -dnl A portable version of this function is already defined in general.m4sh -dnl so there is no need for it here. - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[[^=]]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$[@]"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]+=\$[2]" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]=\$$[1]\$[2]" -} - -_LT_EOF - ;; - esac -]) - -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltoptions.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) - - -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) -# ------------------------------------------ -m4_define([_LT_MANGLE_OPTION], -[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) - - -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) -# --------------------------------------- -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a -# matching handler defined, dispatch to it. Other OPTION-NAMEs are -# saved as a flag. -m4_define([_LT_SET_OPTION], -[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl -m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), - _LT_MANGLE_DEFUN([$1], [$2]), - [m4_warning([Unknown $1 option `$2'])])[]dnl -]) - - -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) -# ------------------------------------------------------------ -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -m4_define([_LT_IF_OPTION], -[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) - - -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) -# ------------------------------------------------------- -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME -# are set. -m4_define([_LT_UNLESS_OPTIONS], -[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), - [m4_define([$0_found])])])[]dnl -m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 -])[]dnl -]) - - -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) -# ---------------------------------------- -# OPTION-LIST is a space-separated list of Libtool options associated -# with MACRO-NAME. If any OPTION has a matching handler declared with -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about -# the unknown option and exit. -m4_defun([_LT_SET_OPTIONS], -[# Set options -m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [_LT_SET_OPTION([$1], _LT_Option)]) - -m4_if([$1],[LT_INIT],[ - dnl - dnl Simply set some default values (i.e off) if boolean options were not - dnl specified: - _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no - ]) - _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no - ]) - dnl - dnl If no reference was made to various pairs of opposing options, then - dnl we run the default mode handler for the pair. For example, if neither - dnl `shared' nor `disable-shared' was passed, we enable building of shared - dnl archives by default: - _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) - _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], - [_LT_ENABLE_FAST_INSTALL]) - ]) -])# _LT_SET_OPTIONS - - - -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) -# ----------------------------------------- -m4_define([_LT_MANGLE_DEFUN], -[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) - - -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) -# ----------------------------------------------- -m4_define([LT_OPTION_DEFINE], -[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl -])# LT_OPTION_DEFINE - - -# dlopen -# ------ -LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes -]) - -AU_DEFUN([AC_LIBTOOL_DLOPEN], -[_LT_SET_OPTION([LT_INIT], [dlopen]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `dlopen' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) - - -# win32-dll -# --------- -# Declare package support for building win32 dll's. -LT_OPTION_DEFINE([LT_INIT], [win32-dll], -[enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; -esac - -test -z "$AS" && AS=as -_LT_DECL([], [AS], [0], [Assembler program])dnl - -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl - -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl -])# win32-dll - -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -_LT_SET_OPTION([LT_INIT], [win32-dll]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `win32-dll' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) - - -# _LT_ENABLE_SHARED([DEFAULT]) -# ---------------------------- -# implement the --enable-shared flag, and supports the `shared' and -# `disable-shared' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_SHARED], -[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) - - _LT_DECL([build_libtool_libs], [enable_shared], [0], - [Whether or not to build shared libraries]) -])# _LT_ENABLE_SHARED - -LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) -]) - -AC_DEFUN([AC_DISABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], [disable-shared]) -]) - -AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_SHARED], []) -dnl AC_DEFUN([AM_DISABLE_SHARED], []) - - - -# _LT_ENABLE_STATIC([DEFAULT]) -# ---------------------------- -# implement the --enable-static flag, and support the `static' and -# `disable-static' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_STATIC], -[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]_LT_ENABLE_STATIC_DEFAULT) - - _LT_DECL([build_old_libs], [enable_static], [0], - [Whether or not to build static libraries]) -])# _LT_ENABLE_STATIC - -LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) -]) - -AC_DEFUN([AC_DISABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], [disable-static]) -]) - -AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_STATIC], []) -dnl AC_DEFUN([AM_DISABLE_STATIC], []) - - - -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) -# ---------------------------------- -# implement the --enable-fast-install flag, and support the `fast-install' -# and `disable-fast-install' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_FAST_INSTALL], -[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([fast-install], - [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) - -_LT_DECL([fast_install], [enable_fast_install], [0], - [Whether or not to optimize for fast installation])dnl -])# _LT_ENABLE_FAST_INSTALL - -LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) - -# Old names: -AU_DEFUN([AC_ENABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `fast-install' option into LT_INIT's first parameter.]) -]) - -AU_DEFUN([AC_DISABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `disable-fast-install' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) -dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) - - -# _LT_WITH_PIC([MODE]) -# -------------------- -# implement the --with-pic flag, and support the `pic-only' and `no-pic' -# LT_INIT options. -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -m4_define([_LT_WITH_PIC], -[AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) - -test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) - -_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl -])# _LT_WITH_PIC - -LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) - -# Old name: -AU_DEFUN([AC_LIBTOOL_PICMODE], -[_LT_SET_OPTION([LT_INIT], [pic-only]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `pic-only' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) - - -m4_define([_LTDL_MODE], []) -LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], - [m4_define([_LTDL_MODE], [nonrecursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [recursive], - [m4_define([_LTDL_MODE], [recursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [subproject], - [m4_define([_LTDL_MODE], [subproject])]) - -m4_define([_LTDL_TYPE], []) -LT_OPTION_DEFINE([LTDL_INIT], [installable], - [m4_define([_LTDL_TYPE], [installable])]) -LT_OPTION_DEFINE([LTDL_INIT], [convenience], - [m4_define([_LTDL_TYPE], [convenience])]) - -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. -m4_define([lt_join], -[m4_if([$#], [1], [], - [$#], [2], [[$2]], - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) -m4_define([_lt_join], -[m4_if([$#$2], [2], [], - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. -m4_define([lt_car], [[$1]]) -m4_define([lt_cdr], -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], - [$#], 1, [], - [m4_dquote(m4_shift($@))])]) -m4_define([lt_unquote], $1) - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. -m4_define([lt_append], -[m4_define([$1], - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. -m4_define([lt_combine], -[m4_if(m4_eval([$# > 3]), [1], - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl -[[m4_foreach([_Lt_prefix], [$2], - [m4_foreach([_Lt_suffix], - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. -m4_define([lt_if_append_uniq], -[m4_ifdef([$1], - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], - [lt_append([$1], [$2], [$3])$4], - [$5])], - [lt_append([$1], [$2], [$3])$4])]) - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- -m4_define([lt_dict_add], -[m4_define([$1($2)], [$3])]) - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- -m4_define([lt_dict_add_subkey], -[m4_define([$1($2:$3)], [$4])]) - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- -m4_define([lt_dict_fetch], -[m4_ifval([$3], - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- -m4_define([lt_if_dict_fetch], -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], - [$5], - [$6])]) - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- -m4_define([lt_dict_filter], -[m4_if([$5], [], [], - [lt_join(m4_quote(m4_default([$4], [[, ]])), - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl -]) - -# ltversion.m4 -- version numbers -*- Autoconf -*- -# -# Copyright (C) 2004 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# Generated from ltversion.in. - -# serial 3017 ltversion.m4 -# This file is part of GNU Libtool - -m4_define([LT_PACKAGE_VERSION], [2.2.6b]) -m4_define([LT_PACKAGE_REVISION], [1.3017]) - -AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.2.6b' -macro_revision='1.3017' -_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) -_LT_DECL(, macro_revision, 0) -]) - -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004. -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 4 lt~obsolete.m4 - -# These exist entirely to fool aclocal when bootstrapping libtool. -# -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) -# which have later been changed to m4_define as they aren't part of the -# exported API, or moved to Autoconf or Automake where they belong. -# -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us -# using a macro with the same name in our local m4/libtool.m4 it'll -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define -# and doesn't know about Autoconf macros at all.) -# -# So we provide this file, which has a silly filename so it's always -# included after everything else. This provides aclocal with the -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything -# because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. -# -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. -# Yes, that means every name once taken will need to remain here until -# we give up compatibility with versions before 1.7, at which point -# we need to keep only those names which we still refer to. - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) - -m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) -m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) -m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) -m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) -m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) -m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) -m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) -m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) -m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) -m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) -m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) -m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) -m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) -m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) -m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) -m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) -m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) -m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) -m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) -m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) -m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) -m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) -m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) -m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) -m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) -m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) -m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) -m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) -m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) -m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) -m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) -m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) -m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) -m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) -m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) -m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) -m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) -m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) -m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) -m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) -m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) -m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) -m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) -m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) -m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) - -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.11' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.1], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.1])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 9 - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 10 - -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], UPC, [depcc="$UPC" am_compiler_list=], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - am__universal=false - m4_case([$1], [CC], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac], - [CXX], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac]) - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -#serial 5 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Autoconf 2.62 quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 16 - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.62])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AM_PROG_MKDIR_P])dnl -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl -]) -_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The `parallel-tests' driver may need to know about EXEEXT, so add the -dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro -dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -]) - -dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi -AC_SUBST(install_sh)]) - -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- -# From Jim Meyering - -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# AM_MAINTAINER_MODE([DEFAULT-MODE]) -# ---------------------------------- -# Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless `enable' is passed literally. -# For symmetry, `disable' may be passed as well. Anyway, the user -# can override the default with the --enable/--disable switch. -AC_DEFUN([AM_MAINTAINER_MODE], -[m4_case(m4_default([$1], [disable]), - [enable], [m4_define([am_maintainer_other], [disable])], - [disable], [m4_define([am_maintainer_other], [enable])], - [m4_define([am_maintainer_other], [enable]) - m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) - dnl maintainer-mode's default is 'disable' unless 'enable' is passed - AC_ARG_ENABLE([maintainer-mode], -[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful - (and sometimes confusing) to the casual installer], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) - AC_MSG_RESULT([$USE_MAINTAINER_MODE]) - AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) - MAINT=$MAINTAINER_MODE_TRUE - AC_SUBST([MAINT])dnl -] -) - -AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 6 - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi -]) - -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_MKDIR_P -# --------------- -# Check for `mkdir -p'. -AC_DEFUN([AM_PROG_MKDIR_P], -[AC_PREREQ([2.60])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, -dnl while keeping a definition of mkdir_p for backward compatibility. -dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. -dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of -dnl Makefile.ins that do not define MKDIR_P, so we do our own -dnl adjustment using top_builddir (which is defined more often than -dnl MKDIR_P). -AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl -case $mkdir_p in - [[\\/$]]* | ?:[[\\/]]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac -]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# ------------------------------ -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) - -# _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; -esac - -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT(yes)]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor `install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir - -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - diff --git a/deps/uv/src/unix/eio/autogen.sh b/deps/uv/src/unix/eio/autogen.sh deleted file mode 100755 index 8056ee7f9b..0000000000 --- a/deps/uv/src/unix/eio/autogen.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -autoreconf --install --symlink --force diff --git a/deps/uv/src/unix/eio/config.h.in b/deps/uv/src/unix/eio/config.h.in deleted file mode 100644 index 73e9dd07d2..0000000000 --- a/deps/uv/src/unix/eio/config.h.in +++ /dev/null @@ -1,86 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* fdatasync(2) is available */ -#undef HAVE_FDATASYNC - -/* futimes(2) is available */ -#undef HAVE_FUTIMES - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* posix_fadvise(2) is available */ -#undef HAVE_POSIX_FADVISE - -/* posix_madvise(2) is available */ -#undef HAVE_POSIX_MADVISE - -/* pread(2) and pwrite(2) are available */ -#undef HAVE_PREADWRITE - -/* readahead(2) is available (linux) */ -#undef HAVE_READAHEAD - -/* sendfile(2) is available and supported */ -#undef HAVE_SENDFILE - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* sync_file_range(2) is available */ -#undef HAVE_SYNC_FILE_RANGE - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* utimes(2) is available */ -#undef HAVE_UTIMES - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS diff --git a/deps/uv/src/unix/eio/config_aix.h b/deps/uv/src/unix/eio/config_aix.h deleted file mode 100644 index 9e21e53da8..0000000000 --- a/deps/uv/src/unix/eio/config_aix.h +++ /dev/null @@ -1,84 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fdatasync(2) is available */ -/* #undef HAVE_FDATASYNC */ - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* futimes(2) is available */ -/* #undef HAVE_FUTIMES */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -/* #undef HAVE_READAHEAD */ - -/* sendfile(2) is available and supported */ -/* #undef HAVE_SENDFILE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available */ -/* #undef HAVE_SYNC_FILE_RANGE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.0" diff --git a/deps/uv/src/unix/eio/config_cygwin.h b/deps/uv/src/unix/eio/config_cygwin.h deleted file mode 100644 index f64e7fe441..0000000000 --- a/deps/uv/src/unix/eio/config_cygwin.h +++ /dev/null @@ -1,80 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fdatasync(2) is available */ -#define HAVE_FDATASYNC 1 - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* futimes(2) is available */ -#define HAVE_FUTIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -/* #undef HAVE_READAHEAD */ - -/* sendfile(2) is available and supported */ -/* #undef HAVE_SENDFILE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available */ -/* #undef HAVE_SYNC_FILE_RANGE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.0" diff --git a/deps/uv/src/unix/eio/config_darwin.h b/deps/uv/src/unix/eio/config_darwin.h deleted file mode 100644 index f406759e09..0000000000 --- a/deps/uv/src/unix/eio/config_darwin.h +++ /dev/null @@ -1,141 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fallocate(2) is available */ -/* #undef HAVE_FALLOCATE */ - -/* fdatasync(2) is available */ -#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 -#define HAVE_FDATASYNC 1 -#else -#define HAVE_FDATASYNC 0 -#endif - -/* futimes(2) is available */ -#define HAVE_FUTIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* posix_fadvise(2) is available */ -/* #undef HAVE_POSIX_FADVISE */ - -/* posix_madvise(2) is available */ -#define HAVE_POSIX_MADVISE 1 - -/* prctl(PR_SET_NAME) is available */ -/* #undef HAVE_PRCTL_SET_NAME */ - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -/* #undef HAVE_READAHEAD */ - -/* sendfile(2) is available and supported */ -#define HAVE_SENDFILE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available */ -/* #undef HAVE_SYNC_FILE_RANGE */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_PRCTL_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* syscall(__NR_syncfs) is available */ -/* #undef HAVE_SYS_SYNCFS */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# define _ALL_SOURCE 1 -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 -#endif - - -/* Version number of package */ -#define VERSION "1.0" - -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ diff --git a/deps/uv/src/unix/eio/config_freebsd.h b/deps/uv/src/unix/eio/config_freebsd.h deleted file mode 100644 index 3c93d260f7..0000000000 --- a/deps/uv/src/unix/eio/config_freebsd.h +++ /dev/null @@ -1,81 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fdatasync(2) is available */ -/* #undef HAVE_FDATASYNC */ - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* futimes(2) is available */ -#define HAVE_FUTIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -/* #undef HAVE_READAHEAD */ - -/* sendfile(2) is available and supported */ -#define HAVE_SENDFILE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available */ -/* #undef HAVE_SYNC_FILE_RANGE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.0" diff --git a/deps/uv/src/unix/eio/config_linux.h b/deps/uv/src/unix/eio/config_linux.h deleted file mode 100644 index e7a0d6e7ae..0000000000 --- a/deps/uv/src/unix/eio/config_linux.h +++ /dev/null @@ -1,94 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -#include -#include - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fdatasync(2) is available */ -#define HAVE_FDATASYNC 1 - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* futimes(2) is available but we make the syscall directly. */ -#undef HAVE_FUTIMES - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -#define HAVE_READAHEAD 1 - -/* sendfile(2) is available and supported */ -#define HAVE_SENDFILE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available if kernel >= 2.6.17 and glibc >= 2.6 */ -#if LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6) -#define HAVE_SYNC_FILE_RANGE 1 -#else -#define HAVE_SYNC_FILE_RANGE 0 -#endif - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.0" diff --git a/deps/uv/src/unix/eio/config_netbsd.h b/deps/uv/src/unix/eio/config_netbsd.h deleted file mode 100644 index 31f18e6046..0000000000 --- a/deps/uv/src/unix/eio/config_netbsd.h +++ /dev/null @@ -1,81 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fdatasync(2) is available */ -/* #undef HAVE_FDATASYNC */ - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* futimes(2) is available */ -#define HAVE_FUTIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -/* #undef HAVE_READAHEAD */ - -/* sendfile(2) is available and supported */ -#define HAVE_SENDFILE 0 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available */ -/* #undef HAVE_SYNC_FILE_RANGE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.0" diff --git a/deps/uv/src/unix/eio/config_openbsd.h b/deps/uv/src/unix/eio/config_openbsd.h deleted file mode 100644 index a73b8a8830..0000000000 --- a/deps/uv/src/unix/eio/config_openbsd.h +++ /dev/null @@ -1,137 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fallocate(2) is available */ -/* #undef HAVE_FALLOCATE */ - -/* fdatasync(2) is available */ -/* #undef HAVE_FDATASYNC */ - -/* futimes(2) is available */ -#define HAVE_FUTIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* posix_fadvise(2) is available */ -/* #undef HAVE_POSIX_FADVISE */ - -/* posix_madvise(2) is available */ -#define HAVE_POSIX_MADVISE 1 - -/* prctl(PR_SET_NAME) is available */ -/* #undef HAVE_PRCTL_SET_NAME */ - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -/* #undef HAVE_READAHEAD */ - -/* sendfile(2) is available and supported */ -/* #undef HAVE_SENDFILE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available */ -/* #undef HAVE_SYNC_FILE_RANGE */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_PRCTL_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* syscall(__NR_syncfs) is available */ -/* #undef HAVE_SYS_SYNCFS */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# define _ALL_SOURCE 1 -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 -#endif - - -/* Version number of package */ -#define VERSION "1.0" - -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ diff --git a/deps/uv/src/unix/eio/config_sunos.h b/deps/uv/src/unix/eio/config_sunos.h deleted file mode 100644 index 546926fcb5..0000000000 --- a/deps/uv/src/unix/eio/config_sunos.h +++ /dev/null @@ -1,84 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* fdatasync(2) is available */ -#define HAVE_FDATASYNC 1 - -/* utimes(2) is available */ -#define HAVE_UTIMES 1 - -/* futimes(2) is available */ -#define HAVE_FUTIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* pread(2) and pwrite(2) are available */ -#define HAVE_PREADWRITE 1 - -/* readahead(2) is available (linux) */ -/* #undef HAVE_READAHEAD */ - -/* sendfile(2) is available and supported */ -/* #undef HAVE_SENDFILE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* sync_file_range(2) is available */ -/* #undef HAVE_SYNC_FILE_RANGE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libeio" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.0" diff --git a/deps/uv/src/unix/eio/configure.ac b/deps/uv/src/unix/eio/configure.ac deleted file mode 100644 index 9faffad538..0000000000 --- a/deps/uv/src/unix/eio/configure.ac +++ /dev/null @@ -1,22 +0,0 @@ -AC_PREREQ(2.59) -AC_INIT -AC_CONFIG_SRCDIR([eio.h]) -AC_CONFIG_HEADERS([config.h]) - -AM_INIT_AUTOMAKE(libeio,1.0) -AM_MAINTAINER_MODE - -AC_GNU_SOURCE - -AC_PROG_LIBTOOL - -AC_PROG_CC - -if test "x$GCC" = xyes ; then - CFLAGS="-O3 $CFLAGS" -fi - -m4_include([libeio.m4]) - -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/deps/uv/src/unix/eio/demo.c b/deps/uv/src/unix/eio/demo.c deleted file mode 100644 index cbef59557f..0000000000 --- a/deps/uv/src/unix/eio/demo.c +++ /dev/null @@ -1,194 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "eio.h" - -int respipe [2]; - -void -want_poll (void) -{ - char dummy; - printf ("want_poll ()\n"); - write (respipe [1], &dummy, 1); -} - -void -done_poll (void) -{ - char dummy; - printf ("done_poll ()\n"); - read (respipe [0], &dummy, 1); -} - -void -event_loop (void) -{ - // an event loop. yeah. - struct pollfd pfd; - pfd.fd = respipe [0]; - pfd.events = POLLIN; - - printf ("\nentering event loop\n"); - while (eio_nreqs ()) - { - poll (&pfd, 1, -1); - printf ("eio_poll () = %d\n", eio_poll ()); - } - printf ("leaving event loop\n"); -} - -int -res_cb (eio_req *req) -{ - printf ("res_cb(%d|%s) = %d\n", req->type, req->data ? req->data : "?", EIO_RESULT (req)); - - if (req->result < 0) - abort (); - - return 0; -} - -int -readdir_cb (eio_req *req) -{ - char *buf = (char *)EIO_BUF (req); - - printf ("readdir_cb = %d\n", EIO_RESULT (req)); - - if (EIO_RESULT (req) < 0) - return 0; - - while (EIO_RESULT (req)--) - { - printf ("readdir = <%s>\n", buf); - buf += strlen (buf) + 1; - } - - return 0; -} - -int -stat_cb (eio_req *req) -{ - struct stat *buf = EIO_STAT_BUF (req); - - if (req->type == EIO_FSTAT) - printf ("fstat_cb = %d\n", EIO_RESULT (req)); - else - printf ("stat_cb(%s) = %d\n", EIO_PATH (req), EIO_RESULT (req)); - - if (!EIO_RESULT (req)) - printf ("stat size %d perm 0%o\n", buf->st_size, buf->st_mode & 0777); - - return 0; -} - -int -read_cb (eio_req *req) -{ - unsigned char *buf = (unsigned char *)EIO_BUF (req); - - printf ("read_cb = %d (%02x%02x%02x%02x %02x%02x%02x%02x)\n", - EIO_RESULT (req), - buf [0], buf [1], buf [2], buf [3], - buf [4], buf [5], buf [6], buf [7]); - - return 0; -} - -int last_fd; - -int -open_cb (eio_req *req) -{ - printf ("open_cb = %d\n", EIO_RESULT (req)); - - last_fd = EIO_RESULT (req); - - return 0; -} - -int -main (void) -{ - printf ("pipe ()\n"); - if (pipe (respipe)) abort (); - - printf ("eio_init ()\n"); - if (eio_init (want_poll, done_poll)) abort (); - - do - { - /* avoid relative paths yourself(!) */ - eio_mkdir ("eio-test-dir", 0777, 0, res_cb, "mkdir"); - eio_nop (0, res_cb, "nop"); - event_loop (); - - eio_stat ("eio-test-dir", 0, stat_cb, "stat"); - eio_lstat ("eio-test-dir", 0, stat_cb, "stat"); - eio_open ("eio-test-dir/eio-test-file", O_RDWR | O_CREAT, 0777, 0, open_cb, "open"); - eio_symlink ("test", "eio-test-dir/eio-symlink", 0, res_cb, "symlink"); - eio_mknod ("eio-test-dir/eio-fifo", S_IFIFO, 0, 0, res_cb, "mknod"); - event_loop (); - - eio_utime ("eio-test-dir", 12345.678, 23456.789, 0, res_cb, "utime"); - eio_futime (last_fd, 92345.678, 93456.789, 0, res_cb, "futime"); - eio_chown ("eio-test-dir", getuid (), getgid (), 0, res_cb, "chown"); - eio_fchown (last_fd, getuid (), getgid (), 0, res_cb, "fchown"); - eio_fchmod (last_fd, 0723, 0, res_cb, "fchmod"); - eio_readdir ("eio-test-dir", 0, 0, readdir_cb, "readdir"); - eio_readdir ("/nonexistant", 0, 0, readdir_cb, "readdir"); - eio_fstat (last_fd, 0, stat_cb, "stat"); - eio_write (last_fd, "test\nfail\n", 10, 4, 0, res_cb, "write"); - event_loop (); - - eio_read (last_fd, 0, 8, 0, EIO_PRI_DEFAULT, read_cb, "read"); - eio_readlink ("eio-test-dir/eio-symlink", 0, res_cb, "readlink"); - event_loop (); - - eio_dup2 (1, 2, EIO_PRI_DEFAULT, res_cb, "dup"); // dup stdout to stderr - eio_chmod ("eio-test-dir", 0765, 0, res_cb, "chmod"); - eio_ftruncate (last_fd, 9, 0, res_cb, "ftruncate"); - eio_fdatasync (last_fd, 0, res_cb, "fdatasync"); - eio_fsync (last_fd, 0, res_cb, "fsync"); - eio_sync (0, res_cb, "sync"); - eio_busy (0.5, 0, res_cb, "busy"); - event_loop (); - - eio_sendfile (1, last_fd, 4, 5, 0, res_cb, "sendfile"); // write "test\n" to stdout - eio_fstat (last_fd, 0, stat_cb, "stat"); - event_loop (); - - eio_truncate ("eio-test-dir/eio-test-file", 6, 0, res_cb, "truncate"); - eio_readahead (last_fd, 0, 64, 0, res_cb, "readahead"); - event_loop (); - - eio_close (last_fd, 0, res_cb, "close"); - eio_link ("eio-test-dir/eio-test-file", "eio-test-dir/eio-test-file-2", 0, res_cb, "link"); - event_loop (); - - eio_rename ("eio-test-dir/eio-test-file", "eio-test-dir/eio-test-file-renamed", 0, res_cb, "rename"); - event_loop (); - - eio_unlink ("eio-test-dir/eio-fifo", 0, res_cb, "unlink"); - eio_unlink ("eio-test-dir/eio-symlink", 0, res_cb, "unlink"); - eio_unlink ("eio-test-dir/eio-test-file-2", 0, res_cb, "unlink"); - eio_unlink ("eio-test-dir/eio-test-file-renamed", 0, res_cb, "unlink"); - event_loop (); - - eio_rmdir ("eio-test-dir", 0, res_cb, "rmdir"); - event_loop (); - } - while (0); - - return 0; -} - diff --git a/deps/uv/src/unix/eio/ecb.h b/deps/uv/src/unix/eio/ecb.h deleted file mode 100644 index a4aabc1091..0000000000 --- a/deps/uv/src/unix/eio/ecb.h +++ /dev/null @@ -1,370 +0,0 @@ -/* - * libecb - http://software.schmorp.de/pkg/libecb - * - * Copyright (ยฉ) 2009-2011 Marc Alexander Lehmann - * Copyright (ยฉ) 2011 Emanuele Giaquinta - * All rights reserved. - * - * 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 - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, 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 OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ECB_H -#define ECB_H - -#ifdef _WIN32 - typedef signed char int8_t; - typedef unsigned char uint8_t; - typedef signed short int16_t; - typedef unsigned short uint16_t; - typedef signed int int32_t; - typedef unsigned int uint32_t; - #if __GNUC__ - typedef signed long long int64_t; - typedef unsigned long long uint64_t; - #else /* _MSC_VER || __BORLANDC__ */ - typedef signed __int64 int64_t; - typedef unsigned __int64 uint64_t; - #endif -#else - #include -#endif - -/* many compilers define _GNUC_ to some versions but then only implement - * what their idiot authors think are the "more important" extensions, - * causing enourmous grief in return for some better fake benchmark numbers. - * or so. - * we try to detect these and simply assume they are not gcc - if they have - * an issue with that they should have done it right in the first place. - */ -#ifndef ECB_GCC_VERSION - #if !defined(__GNUC_MINOR__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__llvm__) || defined(__clang__) - #define ECB_GCC_VERSION(major,minor) 0 - #else - #define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) - #endif -#endif - -/*****************************************************************************/ - -#ifndef ECB_MEMORY_FENCE - #if ECB_GCC_VERSION(2,5) - #if defined(__x86) || defined(__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 */ - #elif __amd64 - #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 */ - #endif - #endif -#endif - -#ifndef ECB_MEMORY_FENCE - #if ECB_GCC_VERSION(4,4) - #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 () - #define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier () /* according to msdn, _ReadBarrier is not a load fence */ - #define ECB_MEMORY_FENCE_RELEASE _WriteBarrier () - #elif defined(_WIN32) - #include - #define ECB_MEMORY_FENCE MemoryBarrier () /* actually just xchg on x86... scary */ - #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE - #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE - #endif -#endif - -#ifndef ECB_MEMORY_FENCE - /* - * if you get undefined symbol references to pthread_mutex_lock, - * or failure to find pthread.h, then you should implement - * the ECB_MEMORY_FENCE operations for your cpu/compiler - * OR proide pthread.h and link against the posix thread library - * of your system. - */ - #include - - static pthread_mutex_t ecb_mf_lock = PTHREAD_MUTEX_INITIALIZER; - #define ECB_MEMORY_FENCE do { pthread_mutex_lock (&ecb_mf_lock); pthread_mutex_unlock (&ecb_mf_lock); } while (0) - #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE - #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE -#endif - -/*****************************************************************************/ - -#define ECB_C99 (__STDC_VERSION__ >= 199901L) - -#if __cplusplus - #define ecb_inline static inline -#elif ECB_GCC_VERSION(2,5) - #define ecb_inline static __inline__ -#elif ECB_C99 - #define ecb_inline static inline -#else - #define ecb_inline static -#endif - -#if ECB_GCC_VERSION(3,3) - #define ecb_restrict __restrict__ -#elif ECB_C99 - #define ecb_restrict restrict -#else - #define ecb_restrict -#endif - -typedef int ecb_bool; - -#define ECB_CONCAT_(a, b) a ## b -#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) -#define ECB_STRINGIFY_(a) # a -#define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) - -#define ecb_function_ ecb_inline - -#if ECB_GCC_VERSION(3,1) - #define ecb_attribute(attrlist) __attribute__(attrlist) - #define ecb_is_constant(expr) __builtin_constant_p (expr) - #define ecb_expect(expr,value) __builtin_expect ((expr),(value)) - #define ecb_prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) -#else - #define ecb_attribute(attrlist) - #define ecb_is_constant(expr) 0 - #define ecb_expect(expr,value) (expr) - #define ecb_prefetch(addr,rw,locality) -#endif - -/* no emulation for ecb_decltype */ -#if ECB_GCC_VERSION(4,5) - #define ecb_decltype(x) __decltype(x) -#elif ECB_GCC_VERSION(3,0) - #define ecb_decltype(x) __typeof(x) -#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_GCC_VERSION(4,3) - #define ecb_artificial ecb_attribute ((__artificial__)) - #define ecb_hot ecb_attribute ((__hot__)) - #define ecb_cold ecb_attribute ((__cold__)) -#else - #define ecb_artificial - #define ecb_hot - #define ecb_cold -#endif - -/* put around conditional expressions if you are very sure that the */ -/* expression is mostly true or mostly false. note that these return */ -/* booleans, not the expression. */ -#define ecb_expect_false(expr) ecb_expect (!!(expr), 0) -#define ecb_expect_true(expr) ecb_expect (!!(expr), 1) -/* for compatibility to the rest of the world */ -#define ecb_likely(expr) ecb_expect_true (expr) -#define ecb_unlikely(expr) ecb_expect_false (expr) - -/* count trailing zero bits and count # of one bits */ -#if ECB_GCC_VERSION(3,4) - /* we assume int == 32 bit, long == 32 or 64 bit and long long == 64 bit */ - #define ecb_ld32(x) (__builtin_clz (x) ^ 31) - #define ecb_ld64(x) (__builtin_clzll (x) ^ 63) - #define ecb_ctz32(x) __builtin_ctz (x) - #define ecb_ctz64(x) __builtin_ctzll (x) - #define ecb_popcount32(x) __builtin_popcount (x) - /* no popcountll */ -#else - ecb_function_ int ecb_ctz32 (uint32_t x) ecb_const; - ecb_function_ int - ecb_ctz32 (uint32_t x) - { - int r = 0; - - x &= ~x + 1; /* this isolates the lowest bit */ - -#if ECB_branchless_on_i386 - r += !!(x & 0xaaaaaaaa) << 0; - r += !!(x & 0xcccccccc) << 1; - r += !!(x & 0xf0f0f0f0) << 2; - r += !!(x & 0xff00ff00) << 3; - r += !!(x & 0xffff0000) << 4; -#else - if (x & 0xaaaaaaaa) r += 1; - if (x & 0xcccccccc) r += 2; - if (x & 0xf0f0f0f0) r += 4; - if (x & 0xff00ff00) r += 8; - if (x & 0xffff0000) r += 16; -#endif - - return r; - } - - ecb_function_ int ecb_ctz64 (uint64_t x) ecb_const; - ecb_function_ int - ecb_ctz64 (uint64_t x) - { - int shift = x & 0xffffffffU ? 0 : 32; - return ecb_ctz32 (x >> shift) + shift; - } - - ecb_function_ int ecb_popcount32 (uint32_t x) ecb_const; - ecb_function_ int - ecb_popcount32 (uint32_t x) - { - x -= (x >> 1) & 0x55555555; - x = ((x >> 2) & 0x33333333) + (x & 0x33333333); - x = ((x >> 4) + x) & 0x0f0f0f0f; - x *= 0x01010101; - - return x >> 24; - } - - /* you have the choice beetween something with a table lookup, */ - /* something using lots of bit arithmetic and a simple loop */ - /* we went for the loop */ - ecb_function_ int ecb_ld32 (uint32_t x) ecb_const; - ecb_function_ int ecb_ld32 (uint32_t x) - { - int r = 0; - - if (x >> 16) { x >>= 16; r += 16; } - if (x >> 8) { x >>= 8; r += 8; } - if (x >> 4) { x >>= 4; r += 4; } - if (x >> 2) { x >>= 2; r += 2; } - if (x >> 1) { r += 1; } - - return r; - } - - ecb_function_ int ecb_ld64 (uint64_t x) ecb_const; - ecb_function_ int ecb_ld64 (uint64_t x) - { - int r = 0; - - if (x >> 32) { x >>= 32; r += 32; } - - return r + ecb_ld32 (x); - } -#endif - -/* popcount64 is only available on 64 bit cpus as gcc builtin */ -/* so for this version we are lazy */ -ecb_function_ int ecb_popcount64 (uint64_t x) ecb_const; -ecb_function_ int -ecb_popcount64 (uint64_t x) -{ - return ecb_popcount32 (x) + ecb_popcount32 (x >> 32); -} - -ecb_inline uint8_t ecb_rotl8 (uint8_t x, unsigned int count) ecb_const; -ecb_inline uint8_t ecb_rotr8 (uint8_t x, unsigned int count) ecb_const; -ecb_inline uint16_t ecb_rotl16 (uint16_t x, unsigned int count) ecb_const; -ecb_inline uint16_t ecb_rotr16 (uint16_t x, unsigned int count) ecb_const; -ecb_inline uint32_t ecb_rotl32 (uint32_t x, unsigned int count) ecb_const; -ecb_inline uint32_t ecb_rotr32 (uint32_t x, unsigned int count) ecb_const; -ecb_inline uint64_t ecb_rotl64 (uint64_t x, unsigned int count) ecb_const; -ecb_inline uint64_t ecb_rotr64 (uint64_t x, unsigned int count) ecb_const; - -ecb_inline uint8_t ecb_rotl8 (uint8_t x, unsigned int count) { return (x >> ( 8 - count)) | (x << count); } -ecb_inline uint8_t ecb_rotr8 (uint8_t x, unsigned int count) { return (x << ( 8 - count)) | (x >> count); } -ecb_inline uint16_t ecb_rotl16 (uint16_t x, unsigned int count) { return (x >> (16 - count)) | (x << count); } -ecb_inline uint16_t ecb_rotr16 (uint16_t x, unsigned int count) { return (x << (16 - count)) | (x >> count); } -ecb_inline uint32_t ecb_rotl32 (uint32_t x, unsigned int count) { return (x >> (32 - count)) | (x << count); } -ecb_inline uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); } -ecb_inline uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); } -ecb_inline uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); } - -#if ECB_GCC_VERSION(4,3) - #define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16) - #define ecb_bswap32(x) __builtin_bswap32 (x) - #define ecb_bswap64(x) __builtin_bswap64 (x) -#else - ecb_function_ uint16_t ecb_bswap16 (uint16_t x) ecb_const; - ecb_function_ uint16_t - ecb_bswap16 (uint16_t x) - { - return ecb_rotl16 (x, 8); - } - - ecb_function_ uint32_t ecb_bswap32 (uint32_t x) ecb_const; - ecb_function_ uint32_t - ecb_bswap32 (uint32_t x) - { - return (((uint32_t)ecb_bswap16 (x)) << 16) | ecb_bswap16 (x >> 16); - } - - ecb_function_ uint64_t ecb_bswap64 (uint64_t x) ecb_const; - ecb_function_ uint64_t - ecb_bswap64 (uint64_t x) - { - return (((uint64_t)ecb_bswap32 (x)) << 32) | ecb_bswap32 (x >> 32); - } -#endif - -#if ECB_GCC_VERSION(4,5) - #define ecb_unreachable() __builtin_unreachable () -#else - /* this seems to work fine, but gcc always emits a warning for it :/ */ - ecb_function_ void ecb_unreachable (void) ecb_noreturn; - ecb_function_ void ecb_unreachable (void) { } -#endif - -/* try to tell the compiler that some condition is definitely true */ -#define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0) - -ecb_function_ unsigned char ecb_byteorder_helper (void) ecb_const; -ecb_function_ unsigned char -ecb_byteorder_helper (void) -{ - const uint32_t u = 0x11223344; - return *(unsigned char *)&u; -} - -ecb_function_ ecb_bool ecb_big_endian (void) ecb_const; -ecb_function_ ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; } -ecb_function_ ecb_bool ecb_little_endian (void) ecb_const; -ecb_function_ ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; } - -#if ECB_GCC_VERSION(3,0) || ECB_C99 - #define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0)) -#else - #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n))) -#endif - -#if ecb_cplusplus_does_not_suck - /* does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) */ - template - static inline int ecb_array_length (const T (&arr)[N]) - { - return N; - } -#else - #define ecb_array_length(name) (sizeof (name) / sizeof (name [0])) -#endif - -#endif - diff --git a/deps/uv/src/unix/eio/eio.3 b/deps/uv/src/unix/eio/eio.3 deleted file mode 100644 index ec5bde33e1..0000000000 --- a/deps/uv/src/unix/eio/eio.3 +++ /dev/null @@ -1,3428 +0,0 @@ -.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sh \" Subsection heading -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX -.. -.\} -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "LIBEIO 3" -.TH LIBEIO 3 "2008-05-11" "libeio-1.0" "libeio - truly asynchronous POSIX I/O" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -libev \- a high performance full\-featured event loop written in C -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -.Vb 1 -\& #include -.Ve -.Sh "\s-1EXAMPLE\s0 \s-1PROGRAM\s0" -.IX Subsection "EXAMPLE PROGRAM" -.Vb 2 -\& // a single header file is required -\& #include -\& -\& // every watcher type has its own typedef\*(Aqd struct -\& // with the name ev_ -\& ev_io stdin_watcher; -\& ev_timer timeout_watcher; -\& -\& // all watcher callbacks have a similar signature -\& // this callback is called when data is readable on stdin -\& static void -\& stdin_cb (EV_P_ struct ev_io *w, int revents) -\& { -\& puts ("stdin ready"); -\& // for one\-shot events, one must manually stop the watcher -\& // with its corresponding stop function. -\& ev_io_stop (EV_A_ w); -\& -\& // this causes all nested ev_loop\*(Aqs to stop iterating -\& ev_unloop (EV_A_ EVUNLOOP_ALL); -\& } -\& -\& // another callback, this time for a time\-out -\& static void -\& timeout_cb (EV_P_ struct ev_timer *w, int revents) -\& { -\& puts ("timeout"); -\& // this causes the innermost ev_loop to stop iterating -\& ev_unloop (EV_A_ EVUNLOOP_ONE); -\& } -\& -\& int -\& main (void) -\& { -\& // use the default event loop unless you have special needs -\& struct ev_loop *loop = ev_default_loop (0); -\& -\& // initialise an io watcher, then start it -\& // this one will watch for stdin to become readable -\& ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); -\& ev_io_start (loop, &stdin_watcher); -\& -\& // initialise a timer watcher, then start it -\& // simple non\-repeating 5.5 second timeout -\& ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.); -\& ev_timer_start (loop, &timeout_watcher); -\& -\& // now wait for events to arrive -\& ev_loop (loop, 0); -\& -\& // unloop was called, so exit -\& return 0; -\& } -.Ve -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -The newest version of this document is also available as an html-formatted -web page you might find easier to navigate when reading it for the first -time: . -.PP -Libev is an event loop: you register interest in certain events (such as a -file descriptor being readable or a timeout occurring), and it will manage -these event sources and provide your program with events. -.PP -To do this, it must take more or less complete control over your process -(or thread) by executing the \fIevent loop\fR handler, and will then -communicate events via a callback mechanism. -.PP -You register interest in certain events by registering so-called \fIevent -watchers\fR, which are relatively small C structures you initialise with the -details of the event, and then hand it over to libev by \fIstarting\fR the -watcher. -.Sh "\s-1FEATURES\s0" -.IX Subsection "FEATURES" -Libev supports \f(CW\*(C`select\*(C'\fR, \f(CW\*(C`poll\*(C'\fR, the Linux-specific \f(CW\*(C`epoll\*(C'\fR, the -BSD-specific \f(CW\*(C`kqueue\*(C'\fR and the Solaris-specific event port mechanisms -for file descriptor events (\f(CW\*(C`ev_io\*(C'\fR), the Linux \f(CW\*(C`inotify\*(C'\fR interface -(for \f(CW\*(C`ev_stat\*(C'\fR), relative timers (\f(CW\*(C`ev_timer\*(C'\fR), absolute timers -with customised rescheduling (\f(CW\*(C`ev_periodic\*(C'\fR), synchronous signals -(\f(CW\*(C`ev_signal\*(C'\fR), process status change events (\f(CW\*(C`ev_child\*(C'\fR), and event -watchers dealing with the event loop mechanism itself (\f(CW\*(C`ev_idle\*(C'\fR, -\&\f(CW\*(C`ev_embed\*(C'\fR, \f(CW\*(C`ev_prepare\*(C'\fR and \f(CW\*(C`ev_check\*(C'\fR watchers) as well as -file watchers (\f(CW\*(C`ev_stat\*(C'\fR) and even limited support for fork events -(\f(CW\*(C`ev_fork\*(C'\fR). -.PP -It also is quite fast (see this -benchmark comparing it to libevent -for example). -.Sh "\s-1CONVENTIONS\s0" -.IX Subsection "CONVENTIONS" -Libev is very configurable. In this manual the default (and most common) -configuration will be described, which supports multiple event loops. For -more info about various configuration options please have a look at -\&\fB\s-1EMBED\s0\fR section in this manual. If libev was configured without support -for multiple event loops, then all functions taking an initial argument of -name \f(CW\*(C`loop\*(C'\fR (which is always of type \f(CW\*(C`struct ev_loop *\*(C'\fR) will not have -this argument. -.Sh "\s-1TIME\s0 \s-1REPRESENTATION\s0" -.IX Subsection "TIME REPRESENTATION" -Libev represents time as a single floating point number, representing the -(fractional) number of seconds since the (\s-1POSIX\s0) epoch (somewhere near -the beginning of 1970, details are complicated, don't ask). This type is -called \f(CW\*(C`ev_tstamp\*(C'\fR, which is what you should use too. It usually aliases -to the \f(CW\*(C`double\*(C'\fR type in C, and when you need to do any calculations on -it, you should treat it as some floatingpoint value. Unlike the name -component \f(CW\*(C`stamp\*(C'\fR might indicate, it is also used for time differences -throughout libev. -.SH "GLOBAL FUNCTIONS" -.IX Header "GLOBAL FUNCTIONS" -These functions can be called anytime, even before initialising the -library in any way. -.IP "ev_tstamp ev_time ()" 4 -.IX Item "ev_tstamp ev_time ()" -Returns the current time as libev would use it. Please note that the -\&\f(CW\*(C`ev_now\*(C'\fR function is usually faster and also often returns the timestamp -you actually want to know. -.IP "ev_sleep (ev_tstamp interval)" 4 -.IX Item "ev_sleep (ev_tstamp interval)" -Sleep for the given interval: The current thread will be blocked until -either it is interrupted or the given time interval has passed. Basically -this is a subsecond-resolution \f(CW\*(C`sleep ()\*(C'\fR. -.IP "int ev_version_major ()" 4 -.IX Item "int ev_version_major ()" -.PD 0 -.IP "int ev_version_minor ()" 4 -.IX Item "int ev_version_minor ()" -.PD -You can find out the major and minor \s-1ABI\s0 version numbers of the library -you linked against by calling the functions \f(CW\*(C`ev_version_major\*(C'\fR and -\&\f(CW\*(C`ev_version_minor\*(C'\fR. If you want, you can compare against the global -symbols \f(CW\*(C`EV_VERSION_MAJOR\*(C'\fR and \f(CW\*(C`EV_VERSION_MINOR\*(C'\fR, which specify the -version of the library your program was compiled against. -.Sp -These version numbers refer to the \s-1ABI\s0 version of the library, not the -release version. -.Sp -Usually, it's a good idea to terminate if the major versions mismatch, -as this indicates an incompatible change. Minor versions are usually -compatible to older versions, so a larger minor version alone is usually -not a problem. -.Sp -Example: Make sure we haven't accidentally been linked against the wrong -version. -.Sp -.Vb 3 -\& assert (("libev version mismatch", -\& ev_version_major () == EV_VERSION_MAJOR -\& && ev_version_minor () >= EV_VERSION_MINOR)); -.Ve -.IP "unsigned int ev_supported_backends ()" 4 -.IX Item "unsigned int ev_supported_backends ()" -Return the set of all backends (i.e. their corresponding \f(CW\*(C`EV_BACKEND_*\*(C'\fR -value) compiled into this binary of libev (independent of their -availability on the system you are running on). See \f(CW\*(C`ev_default_loop\*(C'\fR for -a description of the set values. -.Sp -Example: make sure we have the epoll method, because yeah this is cool and -a must have and can we have a torrent of it please!!!11 -.Sp -.Vb 2 -\& assert (("sorry, no epoll, no sex", -\& ev_supported_backends () & EVBACKEND_EPOLL)); -.Ve -.IP "unsigned int ev_recommended_backends ()" 4 -.IX Item "unsigned int ev_recommended_backends ()" -Return the set of all backends compiled into this binary of libev and also -recommended for this platform. This set is often smaller than the one -returned by \f(CW\*(C`ev_supported_backends\*(C'\fR, as for example kqueue is broken on -most BSDs and will not be autodetected unless you explicitly request it -(assuming you know what you are doing). This is the set of backends that -libev will probe for if you specify no backends explicitly. -.IP "unsigned int ev_embeddable_backends ()" 4 -.IX Item "unsigned int ev_embeddable_backends ()" -Returns the set of backends that are embeddable in other event loops. This -is the theoretical, all-platform, value. To find which backends -might be supported on the current system, you would need to look at -\&\f(CW\*(C`ev_embeddable_backends () & ev_supported_backends ()\*(C'\fR, likewise for -recommended ones. -.Sp -See the description of \f(CW\*(C`ev_embed\*(C'\fR watchers for more info. -.IP "ev_set_allocator (void *(*cb)(void *ptr, long size))" 4 -.IX Item "ev_set_allocator (void *(*cb)(void *ptr, long size))" -Sets the allocation function to use (the prototype is similar \- the -semantics are identical to the \f(CW\*(C`realloc\*(C'\fR C89/SuS/POSIX function). It is -used to allocate and free memory (no surprises here). If it returns zero -when memory needs to be allocated (\f(CW\*(C`size != 0\*(C'\fR), the library might abort -or take some potentially destructive action. -.Sp -Since some systems (at least OpenBSD and Darwin) fail to implement -correct \f(CW\*(C`realloc\*(C'\fR semantics, libev will use a wrapper around the system -\&\f(CW\*(C`realloc\*(C'\fR and \f(CW\*(C`free\*(C'\fR functions by default. -.Sp -You could override this function in high-availability programs to, say, -free some memory if it cannot allocate memory, to use a special allocator, -or even to sleep a while and retry until some memory is available. -.Sp -Example: Replace the libev allocator with one that waits a bit and then -retries (example requires a standards-compliant \f(CW\*(C`realloc\*(C'\fR). -.Sp -.Vb 6 -\& static void * -\& persistent_realloc (void *ptr, size_t size) -\& { -\& for (;;) -\& { -\& void *newptr = realloc (ptr, size); -\& -\& if (newptr) -\& return newptr; -\& -\& sleep (60); -\& } -\& } -\& -\& ... -\& ev_set_allocator (persistent_realloc); -.Ve -.IP "ev_set_syserr_cb (void (*cb)(const char *msg));" 4 -.IX Item "ev_set_syserr_cb (void (*cb)(const char *msg));" -Set the callback function to call on a retryable syscall error (such -as failed select, poll, epoll_wait). The message is a printable string -indicating the system call or subsystem causing the problem. If this -callback is set, then libev will expect it to remedy the sitution, no -matter what, when it returns. That is, libev will generally retry the -requested operation, or, if the condition doesn't go away, do bad stuff -(such as abort). -.Sp -Example: This is basically the same thing that libev does internally, too. -.Sp -.Vb 6 -\& static void -\& fatal_error (const char *msg) -\& { -\& perror (msg); -\& abort (); -\& } -\& -\& ... -\& ev_set_syserr_cb (fatal_error); -.Ve -.SH "FUNCTIONS CONTROLLING THE EVENT LOOP" -.IX Header "FUNCTIONS CONTROLLING THE EVENT LOOP" -An event loop is described by a \f(CW\*(C`struct ev_loop *\*(C'\fR. The library knows two -types of such loops, the \fIdefault\fR loop, which supports signals and child -events, and dynamically created loops which do not. -.IP "struct ev_loop *ev_default_loop (unsigned int flags)" 4 -.IX Item "struct ev_loop *ev_default_loop (unsigned int flags)" -This will initialise the default event loop if it hasn't been initialised -yet and return it. If the default loop could not be initialised, returns -false. If it already was initialised it simply returns it (and ignores the -flags. If that is troubling you, check \f(CW\*(C`ev_backend ()\*(C'\fR afterwards). -.Sp -If you don't know what event loop to use, use the one returned from this -function. -.Sp -Note that this function is \fInot\fR thread-safe, so if you want to use it -from multiple threads, you have to lock (note also that this is unlikely, -as loops cannot bes hared easily between threads anyway). -.Sp -The default loop is the only loop that can handle \f(CW\*(C`ev_signal\*(C'\fR and -\&\f(CW\*(C`ev_child\*(C'\fR watchers, and to do this, it always registers a handler -for \f(CW\*(C`SIGCHLD\*(C'\fR. If this is a problem for your app you can either -create a dynamic loop with \f(CW\*(C`ev_loop_new\*(C'\fR that doesn't do that, or you -can simply overwrite the \f(CW\*(C`SIGCHLD\*(C'\fR signal handler \fIafter\fR calling -\&\f(CW\*(C`ev_default_init\*(C'\fR. -.Sp -The flags argument can be used to specify special behaviour or specific -backends to use, and is usually specified as \f(CW0\fR (or \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). -.Sp -The following flags are supported: -.RS 4 -.ie n .IP """EVFLAG_AUTO""" 4 -.el .IP "\f(CWEVFLAG_AUTO\fR" 4 -.IX Item "EVFLAG_AUTO" -The default flags value. Use this if you have no clue (it's the right -thing, believe me). -.ie n .IP """EVFLAG_NOENV""" 4 -.el .IP "\f(CWEVFLAG_NOENV\fR" 4 -.IX Item "EVFLAG_NOENV" -If this flag bit is ored into the flag value (or the program runs setuid -or setgid) then libev will \fInot\fR look at the environment variable -\&\f(CW\*(C`LIBEV_FLAGS\*(C'\fR. Otherwise (the default), this environment variable will -override the flags completely if it is found in the environment. This is -useful to try out specific backends to test their performance, or to work -around bugs. -.ie n .IP """EVFLAG_FORKCHECK""" 4 -.el .IP "\f(CWEVFLAG_FORKCHECK\fR" 4 -.IX Item "EVFLAG_FORKCHECK" -Instead of calling \f(CW\*(C`ev_default_fork\*(C'\fR or \f(CW\*(C`ev_loop_fork\*(C'\fR manually after -a fork, you can also make libev check for a fork in each iteration by -enabling this flag. -.Sp -This works by calling \f(CW\*(C`getpid ()\*(C'\fR on every iteration of the loop, -and thus this might slow down your event loop if you do a lot of loop -iterations and little real work, but is usually not noticeable (on my -GNU/Linux system for example, \f(CW\*(C`getpid\*(C'\fR is actually a simple 5\-insn sequence -without a syscall and thus \fIvery\fR fast, but my GNU/Linux system also has -\&\f(CW\*(C`pthread_atfork\*(C'\fR which is even faster). -.Sp -The big advantage of this flag is that you can forget about fork (and -forget about forgetting to tell libev about forking) when you use this -flag. -.Sp -This flag setting cannot be overriden or specified in the \f(CW\*(C`LIBEV_FLAGS\*(C'\fR -environment variable. -.ie n .IP """EVBACKEND_SELECT"" (value 1, portable select backend)" 4 -.el .IP "\f(CWEVBACKEND_SELECT\fR (value 1, portable select backend)" 4 -.IX Item "EVBACKEND_SELECT (value 1, portable select backend)" -This is your standard \fIselect\fR\|(2) backend. Not \fIcompletely\fR standard, as -libev tries to roll its own fd_set with no limits on the number of fds, -but if that fails, expect a fairly low limit on the number of fds when -using this backend. It doesn't scale too well (O(highest_fd)), but its -usually the fastest backend for a low number of (low-numbered :) fds. -.Sp -To get good performance out of this backend you need a high amount of -parallelity (most of the file descriptors should be busy). If you are -writing a server, you should \f(CW\*(C`accept ()\*(C'\fR in a loop to accept as many -connections as possible during one iteration. You might also want to have -a look at \f(CW\*(C`ev_set_io_collect_interval ()\*(C'\fR to increase the amount of -readyness notifications you get per iteration. -.ie n .IP """EVBACKEND_POLL"" (value 2, poll backend, available everywhere except on windows)" 4 -.el .IP "\f(CWEVBACKEND_POLL\fR (value 2, poll backend, available everywhere except on windows)" 4 -.IX Item "EVBACKEND_POLL (value 2, poll backend, available everywhere except on windows)" -And this is your standard \fIpoll\fR\|(2) backend. It's more complicated -than select, but handles sparse fds better and has no artificial -limit on the number of fds you can use (except it will slow down -considerably with a lot of inactive fds). It scales similarly to select, -i.e. O(total_fds). See the entry for \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR, above, for -performance tips. -.ie n .IP """EVBACKEND_EPOLL"" (value 4, Linux)" 4 -.el .IP "\f(CWEVBACKEND_EPOLL\fR (value 4, Linux)" 4 -.IX Item "EVBACKEND_EPOLL (value 4, Linux)" -For few fds, this backend is a bit little slower than poll and select, -but it scales phenomenally better. While poll and select usually scale -like O(total_fds) where n is the total number of fds (or the highest fd), -epoll scales either O(1) or O(active_fds). The epoll design has a number -of shortcomings, such as silently dropping events in some hard-to-detect -cases and requiring a syscall per fd change, no fork support and bad -support for dup. -.Sp -While stopping, setting and starting an I/O watcher in the same iteration -will result in some caching, there is still a syscall per such incident -(because the fd could point to a different file description now), so its -best to avoid that. Also, \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors might not work -very well if you register events for both fds. -.Sp -Please note that epoll sometimes generates spurious notifications, so you -need to use non-blocking I/O or other means to avoid blocking when no data -(or space) is available. -.Sp -Best performance from this backend is achieved by not unregistering all -watchers for a file descriptor until it has been closed, if possible, i.e. -keep at least one watcher active per fd at all times. -.Sp -While nominally embeddeble in other event loops, this feature is broken in -all kernel versions tested so far. -.ie n .IP """EVBACKEND_KQUEUE"" (value 8, most \s-1BSD\s0 clones)" 4 -.el .IP "\f(CWEVBACKEND_KQUEUE\fR (value 8, most \s-1BSD\s0 clones)" 4 -.IX Item "EVBACKEND_KQUEUE (value 8, most BSD clones)" -Kqueue deserves special mention, as at the time of this writing, it -was broken on all BSDs except NetBSD (usually it doesn't work reliably -with anything but sockets and pipes, except on Darwin, where of course -it's completely useless). For this reason it's not being \*(L"autodetected\*(R" -unless you explicitly specify it explicitly in the flags (i.e. using -\&\f(CW\*(C`EVBACKEND_KQUEUE\*(C'\fR) or libev was compiled on a known-to-be-good (\-enough) -system like NetBSD. -.Sp -You still can embed kqueue into a normal poll or select backend and use it -only for sockets (after having made sure that sockets work with kqueue on -the target platform). See \f(CW\*(C`ev_embed\*(C'\fR watchers for more info. -.Sp -It scales in the same way as the epoll backend, but the interface to the -kernel is more efficient (which says nothing about its actual speed, of -course). While stopping, setting and starting an I/O watcher does never -cause an extra syscall as with \f(CW\*(C`EVBACKEND_EPOLL\*(C'\fR, it still adds up to -two event changes per incident, support for \f(CW\*(C`fork ()\*(C'\fR is very bad and it -drops fds silently in similarly hard-to-detect cases. -.Sp -This backend usually performs well under most conditions. -.Sp -While nominally embeddable in other event loops, this doesn't work -everywhere, so you might need to test for this. And since it is broken -almost everywhere, you should only use it when you have a lot of sockets -(for which it usually works), by embedding it into another event loop -(e.g. \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR) and using it only for -sockets. -.ie n .IP """EVBACKEND_DEVPOLL"" (value 16, Solaris 8)" 4 -.el .IP "\f(CWEVBACKEND_DEVPOLL\fR (value 16, Solaris 8)" 4 -.IX Item "EVBACKEND_DEVPOLL (value 16, Solaris 8)" -This is not implemented yet (and might never be, unless you send me an -implementation). According to reports, \f(CW\*(C`/dev/poll\*(C'\fR only supports sockets -and is not embeddable, which would limit the usefulness of this backend -immensely. -.ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4 -.el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4 -.IX Item "EVBACKEND_PORT (value 32, Solaris 10)" -This uses the Solaris 10 event port mechanism. As with everything on Solaris, -it's really slow, but it still scales very well (O(active_fds)). -.Sp -Please note that solaris event ports can deliver a lot of spurious -notifications, so you need to use non-blocking I/O or other means to avoid -blocking when no data (or space) is available. -.Sp -While this backend scales well, it requires one system call per active -file descriptor per loop iteration. For small and medium numbers of file -descriptors a \*(L"slow\*(R" \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR backend -might perform better. -.Sp -On the positive side, ignoring the spurious readyness notifications, this -backend actually performed to specification in all tests and is fully -embeddable, which is a rare feat among the OS-specific backends. -.ie n .IP """EVBACKEND_ALL""" 4 -.el .IP "\f(CWEVBACKEND_ALL\fR" 4 -.IX Item "EVBACKEND_ALL" -Try all backends (even potentially broken ones that wouldn't be tried -with \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). Since this is a mask, you can do stuff such as -\&\f(CW\*(C`EVBACKEND_ALL & ~EVBACKEND_KQUEUE\*(C'\fR. -.Sp -It is definitely not recommended to use this flag. -.RE -.RS 4 -.Sp -If one or more of these are ored into the flags value, then only these -backends will be tried (in the reverse order as listed here). If none are -specified, all backends in \f(CW\*(C`ev_recommended_backends ()\*(C'\fR will be tried. -.Sp -The most typical usage is like this: -.Sp -.Vb 2 -\& if (!ev_default_loop (0)) -\& fatal ("could not initialise libev, bad $LIBEV_FLAGS in environment?"); -.Ve -.Sp -Restrict libev to the select and poll backends, and do not allow -environment settings to be taken into account: -.Sp -.Vb 1 -\& ev_default_loop (EVBACKEND_POLL | EVBACKEND_SELECT | EVFLAG_NOENV); -.Ve -.Sp -Use whatever libev has to offer, but make sure that kqueue is used if -available (warning, breaks stuff, best use only with your own private -event loop and only if you know the \s-1OS\s0 supports your types of fds): -.Sp -.Vb 1 -\& ev_default_loop (ev_recommended_backends () | EVBACKEND_KQUEUE); -.Ve -.RE -.IP "struct ev_loop *ev_loop_new (unsigned int flags)" 4 -.IX Item "struct ev_loop *ev_loop_new (unsigned int flags)" -Similar to \f(CW\*(C`ev_default_loop\*(C'\fR, but always creates a new event loop that is -always distinct from the default loop. Unlike the default loop, it cannot -handle signal and child watchers, and attempts to do so will be greeted by -undefined behaviour (or a failed assertion if assertions are enabled). -.Sp -Note that this function \fIis\fR thread-safe, and the recommended way to use -libev with threads is indeed to create one loop per thread, and using the -default loop in the \*(L"main\*(R" or \*(L"initial\*(R" thread. -.Sp -Example: Try to create a event loop that uses epoll and nothing else. -.Sp -.Vb 3 -\& struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV); -\& if (!epoller) -\& fatal ("no epoll found here, maybe it hides under your chair"); -.Ve -.IP "ev_default_destroy ()" 4 -.IX Item "ev_default_destroy ()" -Destroys the default loop again (frees all memory and kernel state -etc.). None of the active event watchers will be stopped in the normal -sense, so e.g. \f(CW\*(C`ev_is_active\*(C'\fR might still return true. It is your -responsibility to either stop all watchers cleanly yoursef \fIbefore\fR -calling this function, or cope with the fact afterwards (which is usually -the easiest thing, you can just ignore the watchers and/or \f(CW\*(C`free ()\*(C'\fR them -for example). -.Sp -Note that certain global state, such as signal state, will not be freed by -this function, and related watchers (such as signal and child watchers) -would need to be stopped manually. -.Sp -In general it is not advisable to call this function except in the -rare occasion where you really need to free e.g. the signal handling -pipe fds. If you need dynamically allocated loops it is better to use -\&\f(CW\*(C`ev_loop_new\*(C'\fR and \f(CW\*(C`ev_loop_destroy\*(C'\fR). -.IP "ev_loop_destroy (loop)" 4 -.IX Item "ev_loop_destroy (loop)" -Like \f(CW\*(C`ev_default_destroy\*(C'\fR, but destroys an event loop created by an -earlier call to \f(CW\*(C`ev_loop_new\*(C'\fR. -.IP "ev_default_fork ()" 4 -.IX Item "ev_default_fork ()" -This function sets a flag that causes subsequent \f(CW\*(C`ev_loop\*(C'\fR iterations -to reinitialise the kernel state for backends that have one. Despite the -name, you can call it anytime, but it makes most sense after forking, in -the child process (or both child and parent, but that again makes little -sense). You \fImust\fR call it in the child before using any of the libev -functions, and it will only take effect at the next \f(CW\*(C`ev_loop\*(C'\fR iteration. -.Sp -On the other hand, you only need to call this function in the child -process if and only if you want to use the event library in the child. If -you just fork+exec, you don't have to call it at all. -.Sp -The function itself is quite fast and it's usually not a problem to call -it just in case after a fork. To make this easy, the function will fit in -quite nicely into a call to \f(CW\*(C`pthread_atfork\*(C'\fR: -.Sp -.Vb 1 -\& pthread_atfork (0, 0, ev_default_fork); -.Ve -.IP "ev_loop_fork (loop)" 4 -.IX Item "ev_loop_fork (loop)" -Like \f(CW\*(C`ev_default_fork\*(C'\fR, but acts on an event loop created by -\&\f(CW\*(C`ev_loop_new\*(C'\fR. Yes, you have to call this on every allocated event loop -after fork, and how you do this is entirely your own problem. -.IP "int ev_is_default_loop (loop)" 4 -.IX Item "int ev_is_default_loop (loop)" -Returns true when the given loop actually is the default loop, false otherwise. -.IP "unsigned int ev_loop_count (loop)" 4 -.IX Item "unsigned int ev_loop_count (loop)" -Returns the count of loop iterations for the loop, which is identical to -the number of times libev did poll for new events. It starts at \f(CW0\fR and -happily wraps around with enough iterations. -.Sp -This value can sometimes be useful as a generation counter of sorts (it -\&\*(L"ticks\*(R" the number of loop iterations), as it roughly corresponds with -\&\f(CW\*(C`ev_prepare\*(C'\fR and \f(CW\*(C`ev_check\*(C'\fR calls. -.IP "unsigned int ev_backend (loop)" 4 -.IX Item "unsigned int ev_backend (loop)" -Returns one of the \f(CW\*(C`EVBACKEND_*\*(C'\fR flags indicating the event backend in -use. -.IP "ev_tstamp ev_now (loop)" 4 -.IX Item "ev_tstamp ev_now (loop)" -Returns the current \*(L"event loop time\*(R", which is the time the event loop -received events and started processing them. This timestamp does not -change as long as callbacks are being processed, and this is also the base -time used for relative timers. You can treat it as the timestamp of the -event occurring (or more correctly, libev finding out about it). -.IP "ev_loop (loop, int flags)" 4 -.IX Item "ev_loop (loop, int flags)" -Finally, this is it, the event handler. This function usually is called -after you initialised all your watchers and you want to start handling -events. -.Sp -If the flags argument is specified as \f(CW0\fR, it will not return until -either no event watchers are active anymore or \f(CW\*(C`ev_unloop\*(C'\fR was called. -.Sp -Please note that an explicit \f(CW\*(C`ev_unloop\*(C'\fR is usually better than -relying on all watchers to be stopped when deciding when a program has -finished (especially in interactive programs), but having a program that -automatically loops as long as it has to and no longer by virtue of -relying on its watchers stopping correctly is a thing of beauty. -.Sp -A flags value of \f(CW\*(C`EVLOOP_NONBLOCK\*(C'\fR will look for new events, will handle -those events and any outstanding ones, but will not block your process in -case there are no events and will return after one iteration of the loop. -.Sp -A flags value of \f(CW\*(C`EVLOOP_ONESHOT\*(C'\fR will look for new events (waiting if -neccessary) and will handle those and any outstanding ones. It will block -your process until at least one new event arrives, and will return after -one iteration of the loop. This is useful if you are waiting for some -external event in conjunction with something not expressible using other -libev watchers. However, a pair of \f(CW\*(C`ev_prepare\*(C'\fR/\f(CW\*(C`ev_check\*(C'\fR watchers is -usually a better approach for this kind of thing. -.Sp -Here are the gory details of what \f(CW\*(C`ev_loop\*(C'\fR does: -.Sp -.Vb 10 -\& \- Before the first iteration, call any pending watchers. -\& * If EVFLAG_FORKCHECK was used, check for a fork. -\& \- If a fork was detected, queue and call all fork watchers. -\& \- Queue and call all prepare watchers. -\& \- If we have been forked, recreate the kernel state. -\& \- Update the kernel state with all outstanding changes. -\& \- Update the "event loop time". -\& \- Calculate for how long to sleep or block, if at all -\& (active idle watchers, EVLOOP_NONBLOCK or not having -\& any active watchers at all will result in not sleeping). -\& \- Sleep if the I/O and timer collect interval say so. -\& \- Block the process, waiting for any events. -\& \- Queue all outstanding I/O (fd) events. -\& \- Update the "event loop time" and do time jump handling. -\& \- Queue all outstanding timers. -\& \- Queue all outstanding periodics. -\& \- If no events are pending now, queue all idle watchers. -\& \- Queue all check watchers. -\& \- Call all queued watchers in reverse order (i.e. check watchers first). -\& Signals and child watchers are implemented as I/O watchers, and will -\& be handled here by queueing them when their watcher gets executed. -\& \- If ev_unloop has been called, or EVLOOP_ONESHOT or EVLOOP_NONBLOCK -\& were used, or there are no active watchers, return, otherwise -\& continue with step *. -.Ve -.Sp -Example: Queue some jobs and then loop until no events are outstanding -anymore. -.Sp -.Vb 4 -\& ... queue jobs here, make sure they register event watchers as long -\& ... as they still have work to do (even an idle watcher will do..) -\& ev_loop (my_loop, 0); -\& ... jobs done. yeah! -.Ve -.IP "ev_unloop (loop, how)" 4 -.IX Item "ev_unloop (loop, how)" -Can be used to make a call to \f(CW\*(C`ev_loop\*(C'\fR return early (but only after it -has processed all outstanding events). The \f(CW\*(C`how\*(C'\fR argument must be either -\&\f(CW\*(C`EVUNLOOP_ONE\*(C'\fR, which will make the innermost \f(CW\*(C`ev_loop\*(C'\fR call return, or -\&\f(CW\*(C`EVUNLOOP_ALL\*(C'\fR, which will make all nested \f(CW\*(C`ev_loop\*(C'\fR calls return. -.Sp -This \*(L"unloop state\*(R" will be cleared when entering \f(CW\*(C`ev_loop\*(C'\fR again. -.IP "ev_ref (loop)" 4 -.IX Item "ev_ref (loop)" -.PD 0 -.IP "ev_unref (loop)" 4 -.IX Item "ev_unref (loop)" -.PD -Ref/unref can be used to add or remove a reference count on the event -loop: Every watcher keeps one reference, and as long as the reference -count is nonzero, \f(CW\*(C`ev_loop\*(C'\fR will not return on its own. If you have -a watcher you never unregister that should not keep \f(CW\*(C`ev_loop\*(C'\fR from -returning, \fIev_unref()\fR after starting, and \fIev_ref()\fR before stopping it. For -example, libev itself uses this for its internal signal pipe: It is not -visible to the libev user and should not keep \f(CW\*(C`ev_loop\*(C'\fR from exiting if -no event watchers registered by it are active. It is also an excellent -way to do this for generic recurring timers or from within third-party -libraries. Just remember to \fIunref after start\fR and \fIref before stop\fR -(but only if the watcher wasn't active before, or was active before, -respectively). -.Sp -Example: Create a signal watcher, but keep it from keeping \f(CW\*(C`ev_loop\*(C'\fR -running when nothing else is active. -.Sp -.Vb 4 -\& struct ev_signal exitsig; -\& ev_signal_init (&exitsig, sig_cb, SIGINT); -\& ev_signal_start (loop, &exitsig); -\& evf_unref (loop); -.Ve -.Sp -Example: For some weird reason, unregister the above signal handler again. -.Sp -.Vb 2 -\& ev_ref (loop); -\& ev_signal_stop (loop, &exitsig); -.Ve -.IP "ev_set_io_collect_interval (loop, ev_tstamp interval)" 4 -.IX Item "ev_set_io_collect_interval (loop, ev_tstamp interval)" -.PD 0 -.IP "ev_set_timeout_collect_interval (loop, ev_tstamp interval)" 4 -.IX Item "ev_set_timeout_collect_interval (loop, ev_tstamp interval)" -.PD -These advanced functions influence the time that libev will spend waiting -for events. Both are by default \f(CW0\fR, meaning that libev will try to -invoke timer/periodic callbacks and I/O callbacks with minimum latency. -.Sp -Setting these to a higher value (the \f(CW\*(C`interval\*(C'\fR \fImust\fR be >= \f(CW0\fR) -allows libev to delay invocation of I/O and timer/periodic callbacks to -increase efficiency of loop iterations. -.Sp -The background is that sometimes your program runs just fast enough to -handle one (or very few) event(s) per loop iteration. While this makes -the program responsive, it also wastes a lot of \s-1CPU\s0 time to poll for new -events, especially with backends like \f(CW\*(C`select ()\*(C'\fR which have a high -overhead for the actual polling but can deliver many events at once. -.Sp -By setting a higher \fIio collect interval\fR you allow libev to spend more -time collecting I/O events, so you can handle more events per iteration, -at the cost of increasing latency. Timeouts (both \f(CW\*(C`ev_periodic\*(C'\fR and -\&\f(CW\*(C`ev_timer\*(C'\fR) will be not affected. Setting this to a non-null value will -introduce an additional \f(CW\*(C`ev_sleep ()\*(C'\fR call into most loop iterations. -.Sp -Likewise, by setting a higher \fItimeout collect interval\fR you allow libev -to spend more time collecting timeouts, at the expense of increased -latency (the watcher callback will be called later). \f(CW\*(C`ev_io\*(C'\fR watchers -will not be affected. Setting this to a non-null value will not introduce -any overhead in libev. -.Sp -Many (busy) programs can usually benefit by setting the io collect -interval to a value near \f(CW0.1\fR or so, which is often enough for -interactive servers (of course not for games), likewise for timeouts. It -usually doesn't make much sense to set it to a lower value than \f(CW0.01\fR, -as this approsaches the timing granularity of most systems. -.SH "ANATOMY OF A WATCHER" -.IX Header "ANATOMY OF A WATCHER" -A watcher is a structure that you create and register to record your -interest in some event. For instance, if you want to wait for \s-1STDIN\s0 to -become readable, you would create an \f(CW\*(C`ev_io\*(C'\fR watcher for that: -.PP -.Vb 5 -\& static void my_cb (struct ev_loop *loop, struct ev_io *w, int revents) -\& { -\& ev_io_stop (w); -\& ev_unloop (loop, EVUNLOOP_ALL); -\& } -\& -\& struct ev_loop *loop = ev_default_loop (0); -\& struct ev_io stdin_watcher; -\& ev_init (&stdin_watcher, my_cb); -\& ev_io_set (&stdin_watcher, STDIN_FILENO, EV_READ); -\& ev_io_start (loop, &stdin_watcher); -\& ev_loop (loop, 0); -.Ve -.PP -As you can see, you are responsible for allocating the memory for your -watcher structures (and it is usually a bad idea to do this on the stack, -although this can sometimes be quite valid). -.PP -Each watcher structure must be initialised by a call to \f(CW\*(C`ev_init -(watcher *, callback)\*(C'\fR, which expects a callback to be provided. This -callback gets invoked each time the event occurs (or, in the case of io -watchers, each time the event loop detects that the file descriptor given -is readable and/or writable). -.PP -Each watcher type has its own \f(CW\*(C`ev__set (watcher *, ...)\*(C'\fR macro -with arguments specific to this watcher type. There is also a macro -to combine initialisation and setting in one call: \f(CW\*(C`ev__init -(watcher *, callback, ...)\*(C'\fR. -.PP -To make the watcher actually watch out for events, you have to start it -with a watcher-specific start function (\f(CW\*(C`ev__start (loop, watcher -*)\*(C'\fR), and you can stop watching for events at any time by calling the -corresponding stop function (\f(CW\*(C`ev__stop (loop, watcher *)\*(C'\fR. -.PP -As long as your watcher is active (has been started but not stopped) you -must not touch the values stored in it. Most specifically you must never -reinitialise it or call its \f(CW\*(C`set\*(C'\fR macro. -.PP -Each and every callback receives the event loop pointer as first, the -registered watcher structure as second, and a bitset of received events as -third argument. -.PP -The received events usually include a single bit per event type received -(you can receive multiple events at the same time). The possible bit masks -are: -.ie n .IP """EV_READ""" 4 -.el .IP "\f(CWEV_READ\fR" 4 -.IX Item "EV_READ" -.PD 0 -.ie n .IP """EV_WRITE""" 4 -.el .IP "\f(CWEV_WRITE\fR" 4 -.IX Item "EV_WRITE" -.PD -The file descriptor in the \f(CW\*(C`ev_io\*(C'\fR watcher has become readable and/or -writable. -.ie n .IP """EV_TIMEOUT""" 4 -.el .IP "\f(CWEV_TIMEOUT\fR" 4 -.IX Item "EV_TIMEOUT" -The \f(CW\*(C`ev_timer\*(C'\fR watcher has timed out. -.ie n .IP """EV_PERIODIC""" 4 -.el .IP "\f(CWEV_PERIODIC\fR" 4 -.IX Item "EV_PERIODIC" -The \f(CW\*(C`ev_periodic\*(C'\fR watcher has timed out. -.ie n .IP """EV_SIGNAL""" 4 -.el .IP "\f(CWEV_SIGNAL\fR" 4 -.IX Item "EV_SIGNAL" -The signal specified in the \f(CW\*(C`ev_signal\*(C'\fR watcher has been received by a thread. -.ie n .IP """EV_CHILD""" 4 -.el .IP "\f(CWEV_CHILD\fR" 4 -.IX Item "EV_CHILD" -The pid specified in the \f(CW\*(C`ev_child\*(C'\fR watcher has received a status change. -.ie n .IP """EV_STAT""" 4 -.el .IP "\f(CWEV_STAT\fR" 4 -.IX Item "EV_STAT" -The path specified in the \f(CW\*(C`ev_stat\*(C'\fR watcher changed its attributes somehow. -.ie n .IP """EV_IDLE""" 4 -.el .IP "\f(CWEV_IDLE\fR" 4 -.IX Item "EV_IDLE" -The \f(CW\*(C`ev_idle\*(C'\fR watcher has determined that you have nothing better to do. -.ie n .IP """EV_PREPARE""" 4 -.el .IP "\f(CWEV_PREPARE\fR" 4 -.IX Item "EV_PREPARE" -.PD 0 -.ie n .IP """EV_CHECK""" 4 -.el .IP "\f(CWEV_CHECK\fR" 4 -.IX Item "EV_CHECK" -.PD -All \f(CW\*(C`ev_prepare\*(C'\fR watchers are invoked just \fIbefore\fR \f(CW\*(C`ev_loop\*(C'\fR starts -to gather new events, and all \f(CW\*(C`ev_check\*(C'\fR watchers are invoked just after -\&\f(CW\*(C`ev_loop\*(C'\fR has gathered them, but before it invokes any callbacks for any -received events. Callbacks of both watcher types can start and stop as -many watchers as they want, and all of them will be taken into account -(for example, a \f(CW\*(C`ev_prepare\*(C'\fR watcher might start an idle watcher to keep -\&\f(CW\*(C`ev_loop\*(C'\fR from blocking). -.ie n .IP """EV_EMBED""" 4 -.el .IP "\f(CWEV_EMBED\fR" 4 -.IX Item "EV_EMBED" -The embedded event loop specified in the \f(CW\*(C`ev_embed\*(C'\fR watcher needs attention. -.ie n .IP """EV_FORK""" 4 -.el .IP "\f(CWEV_FORK\fR" 4 -.IX Item "EV_FORK" -The event loop has been resumed in the child process after fork (see -\&\f(CW\*(C`ev_fork\*(C'\fR). -.ie n .IP """EV_ASYNC""" 4 -.el .IP "\f(CWEV_ASYNC\fR" 4 -.IX Item "EV_ASYNC" -The given async watcher has been asynchronously notified (see \f(CW\*(C`ev_async\*(C'\fR). -.ie n .IP """EV_ERROR""" 4 -.el .IP "\f(CWEV_ERROR\fR" 4 -.IX Item "EV_ERROR" -An unspecified error has occured, the watcher has been stopped. This might -happen because the watcher could not be properly started because libev -ran out of memory, a file descriptor was found to be closed or any other -problem. You best act on it by reporting the problem and somehow coping -with the watcher being stopped. -.Sp -Libev will usually signal a few \*(L"dummy\*(R" events together with an error, -for example it might indicate that a fd is readable or writable, and if -your callbacks is well-written it can just attempt the operation and cope -with the error from \fIread()\fR or \fIwrite()\fR. This will not work in multithreaded -programs, though, so beware. -.Sh "\s-1GENERIC\s0 \s-1WATCHER\s0 \s-1FUNCTIONS\s0" -.IX Subsection "GENERIC WATCHER FUNCTIONS" -In the following description, \f(CW\*(C`TYPE\*(C'\fR stands for the watcher type, -e.g. \f(CW\*(C`timer\*(C'\fR for \f(CW\*(C`ev_timer\*(C'\fR watchers and \f(CW\*(C`io\*(C'\fR for \f(CW\*(C`ev_io\*(C'\fR watchers. -.ie n .IP """ev_init"" (ev_TYPE *watcher, callback)" 4 -.el .IP "\f(CWev_init\fR (ev_TYPE *watcher, callback)" 4 -.IX Item "ev_init (ev_TYPE *watcher, callback)" -This macro initialises the generic portion of a watcher. The contents -of the watcher object can be arbitrary (so \f(CW\*(C`malloc\*(C'\fR will do). Only -the generic parts of the watcher are initialised, you \fIneed\fR to call -the type-specific \f(CW\*(C`ev_TYPE_set\*(C'\fR macro afterwards to initialise the -type-specific parts. For each type there is also a \f(CW\*(C`ev_TYPE_init\*(C'\fR macro -which rolls both calls into one. -.Sp -You can reinitialise a watcher at any time as long as it has been stopped -(or never started) and there are no pending events outstanding. -.Sp -The callback is always of type \f(CW\*(C`void (*)(ev_loop *loop, ev_TYPE *watcher, -int revents)\*(C'\fR. -.ie n .IP """ev_TYPE_set"" (ev_TYPE *, [args])" 4 -.el .IP "\f(CWev_TYPE_set\fR (ev_TYPE *, [args])" 4 -.IX Item "ev_TYPE_set (ev_TYPE *, [args])" -This macro initialises the type-specific parts of a watcher. You need to -call \f(CW\*(C`ev_init\*(C'\fR at least once before you call this macro, but you can -call \f(CW\*(C`ev_TYPE_set\*(C'\fR any number of times. You must not, however, call this -macro on a watcher that is active (it can be pending, however, which is a -difference to the \f(CW\*(C`ev_init\*(C'\fR macro). -.Sp -Although some watcher types do not have type-specific arguments -(e.g. \f(CW\*(C`ev_prepare\*(C'\fR) you still need to call its \f(CW\*(C`set\*(C'\fR macro. -.ie n .IP """ev_TYPE_init"" (ev_TYPE *watcher, callback, [args])" 4 -.el .IP "\f(CWev_TYPE_init\fR (ev_TYPE *watcher, callback, [args])" 4 -.IX Item "ev_TYPE_init (ev_TYPE *watcher, callback, [args])" -This convinience macro rolls both \f(CW\*(C`ev_init\*(C'\fR and \f(CW\*(C`ev_TYPE_set\*(C'\fR macro -calls into a single call. This is the most convinient method to initialise -a watcher. The same limitations apply, of course. -.ie n .IP """ev_TYPE_start"" (loop *, ev_TYPE *watcher)" 4 -.el .IP "\f(CWev_TYPE_start\fR (loop *, ev_TYPE *watcher)" 4 -.IX Item "ev_TYPE_start (loop *, ev_TYPE *watcher)" -Starts (activates) the given watcher. Only active watchers will receive -events. If the watcher is already active nothing will happen. -.ie n .IP """ev_TYPE_stop"" (loop *, ev_TYPE *watcher)" 4 -.el .IP "\f(CWev_TYPE_stop\fR (loop *, ev_TYPE *watcher)" 4 -.IX Item "ev_TYPE_stop (loop *, ev_TYPE *watcher)" -Stops the given watcher again (if active) and clears the pending -status. It is possible that stopped watchers are pending (for example, -non-repeating timers are being stopped when they become pending), but -\&\f(CW\*(C`ev_TYPE_stop\*(C'\fR ensures that the watcher is neither active nor pending. If -you want to free or reuse the memory used by the watcher it is therefore a -good idea to always call its \f(CW\*(C`ev_TYPE_stop\*(C'\fR function. -.IP "bool ev_is_active (ev_TYPE *watcher)" 4 -.IX Item "bool ev_is_active (ev_TYPE *watcher)" -Returns a true value iff the watcher is active (i.e. it has been started -and not yet been stopped). As long as a watcher is active you must not modify -it. -.IP "bool ev_is_pending (ev_TYPE *watcher)" 4 -.IX Item "bool ev_is_pending (ev_TYPE *watcher)" -Returns a true value iff the watcher is pending, (i.e. it has outstanding -events but its callback has not yet been invoked). As long as a watcher -is pending (but not active) you must not call an init function on it (but -\&\f(CW\*(C`ev_TYPE_set\*(C'\fR is safe), you must not change its priority, and you must -make sure the watcher is available to libev (e.g. you cannot \f(CW\*(C`free ()\*(C'\fR -it). -.IP "callback ev_cb (ev_TYPE *watcher)" 4 -.IX Item "callback ev_cb (ev_TYPE *watcher)" -Returns the callback currently set on the watcher. -.IP "ev_cb_set (ev_TYPE *watcher, callback)" 4 -.IX Item "ev_cb_set (ev_TYPE *watcher, callback)" -Change the callback. You can change the callback at virtually any time -(modulo threads). -.IP "ev_set_priority (ev_TYPE *watcher, priority)" 4 -.IX Item "ev_set_priority (ev_TYPE *watcher, priority)" -.PD 0 -.IP "int ev_priority (ev_TYPE *watcher)" 4 -.IX Item "int ev_priority (ev_TYPE *watcher)" -.PD -Set and query the priority of the watcher. The priority is a small -integer between \f(CW\*(C`EV_MAXPRI\*(C'\fR (default: \f(CW2\fR) and \f(CW\*(C`EV_MINPRI\*(C'\fR -(default: \f(CW\*(C`\-2\*(C'\fR). Pending watchers with higher priority will be invoked -before watchers with lower priority, but priority will not keep watchers -from being executed (except for \f(CW\*(C`ev_idle\*(C'\fR watchers). -.Sp -This means that priorities are \fIonly\fR used for ordering callback -invocation after new events have been received. This is useful, for -example, to reduce latency after idling, or more often, to bind two -watchers on the same event and make sure one is called first. -.Sp -If you need to suppress invocation when higher priority events are pending -you need to look at \f(CW\*(C`ev_idle\*(C'\fR watchers, which provide this functionality. -.Sp -You \fImust not\fR change the priority of a watcher as long as it is active or -pending. -.Sp -The default priority used by watchers when no priority has been set is -always \f(CW0\fR, which is supposed to not be too high and not be too low :). -.Sp -Setting a priority outside the range of \f(CW\*(C`EV_MINPRI\*(C'\fR to \f(CW\*(C`EV_MAXPRI\*(C'\fR is -fine, as long as you do not mind that the priority value you query might -or might not have been adjusted to be within valid range. -.IP "ev_invoke (loop, ev_TYPE *watcher, int revents)" 4 -.IX Item "ev_invoke (loop, ev_TYPE *watcher, int revents)" -Invoke the \f(CW\*(C`watcher\*(C'\fR with the given \f(CW\*(C`loop\*(C'\fR and \f(CW\*(C`revents\*(C'\fR. Neither -\&\f(CW\*(C`loop\*(C'\fR nor \f(CW\*(C`revents\*(C'\fR need to be valid as long as the watcher callback -can deal with that fact. -.IP "int ev_clear_pending (loop, ev_TYPE *watcher)" 4 -.IX Item "int ev_clear_pending (loop, ev_TYPE *watcher)" -If the watcher is pending, this function returns clears its pending status -and returns its \f(CW\*(C`revents\*(C'\fR bitset (as if its callback was invoked). If the -watcher isn't pending it does nothing and returns \f(CW0\fR. -.Sh "\s-1ASSOCIATING\s0 \s-1CUSTOM\s0 \s-1DATA\s0 \s-1WITH\s0 A \s-1WATCHER\s0" -.IX Subsection "ASSOCIATING CUSTOM DATA WITH A WATCHER" -Each watcher has, by default, a member \f(CW\*(C`void *data\*(C'\fR that you can change -and read at any time, libev will completely ignore it. This can be used -to associate arbitrary data with your watcher. If you need more data and -don't want to allocate memory and store a pointer to it in that data -member, you can also \*(L"subclass\*(R" the watcher type and provide your own -data: -.PP -.Vb 7 -\& struct my_io -\& { -\& struct ev_io io; -\& int otherfd; -\& void *somedata; -\& struct whatever *mostinteresting; -\& } -.Ve -.PP -And since your callback will be called with a pointer to the watcher, you -can cast it back to your own type: -.PP -.Vb 5 -\& static void my_cb (struct ev_loop *loop, struct ev_io *w_, int revents) -\& { -\& struct my_io *w = (struct my_io *)w_; -\& ... -\& } -.Ve -.PP -More interesting and less C\-conformant ways of casting your callback type -instead have been omitted. -.PP -Another common scenario is having some data structure with multiple -watchers: -.PP -.Vb 6 -\& struct my_biggy -\& { -\& int some_data; -\& ev_timer t1; -\& ev_timer t2; -\& } -.Ve -.PP -In this case getting the pointer to \f(CW\*(C`my_biggy\*(C'\fR is a bit more complicated, -you need to use \f(CW\*(C`offsetof\*(C'\fR: -.PP -.Vb 1 -\& #include -\& -\& static void -\& t1_cb (EV_P_ struct ev_timer *w, int revents) -\& { -\& struct my_biggy big = (struct my_biggy * -\& (((char *)w) \- offsetof (struct my_biggy, t1)); -\& } -\& -\& static void -\& t2_cb (EV_P_ struct ev_timer *w, int revents) -\& { -\& struct my_biggy big = (struct my_biggy * -\& (((char *)w) \- offsetof (struct my_biggy, t2)); -\& } -.Ve -.SH "WATCHER TYPES" -.IX Header "WATCHER TYPES" -This section describes each watcher in detail, but will not repeat -information given in the last section. Any initialisation/set macros, -functions and members specific to the watcher type are explained. -.PP -Members are additionally marked with either \fI[read\-only]\fR, meaning that, -while the watcher is active, you can look at the member and expect some -sensible content, but you must not modify it (you can modify it while the -watcher is stopped to your hearts content), or \fI[read\-write]\fR, which -means you can expect it to have some sensible content while the watcher -is active, but you can also modify it. Modifying it may not do something -sensible or take immediate effect (or do anything at all), but libev will -not crash or malfunction in any way. -.ie n .Sh """ev_io"" \- is this file descriptor readable or writable?" -.el .Sh "\f(CWev_io\fP \- is this file descriptor readable or writable?" -.IX Subsection "ev_io - is this file descriptor readable or writable?" -I/O watchers check whether a file descriptor is readable or writable -in each iteration of the event loop, or, more precisely, when reading -would not block the process and writing would at least be able to write -some data. This behaviour is called level-triggering because you keep -receiving events as long as the condition persists. Remember you can stop -the watcher if you don't want to act on the event and neither want to -receive future events. -.PP -In general you can register as many read and/or write event watchers per -fd as you want (as long as you don't confuse yourself). Setting all file -descriptors to non-blocking mode is also usually a good idea (but not -required if you know what you are doing). -.PP -If you must do this, then force the use of a known-to-be-good backend -(at the time of this writing, this includes only \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR and -\&\f(CW\*(C`EVBACKEND_POLL\*(C'\fR). -.PP -Another thing you have to watch out for is that it is quite easy to -receive \*(L"spurious\*(R" readyness notifications, that is your callback might -be called with \f(CW\*(C`EV_READ\*(C'\fR but a subsequent \f(CW\*(C`read\*(C'\fR(2) will actually block -because there is no data. Not only are some backends known to create a -lot of those (for example solaris ports), it is very easy to get into -this situation even with a relatively standard program structure. Thus -it is best to always use non-blocking I/O: An extra \f(CW\*(C`read\*(C'\fR(2) returning -\&\f(CW\*(C`EAGAIN\*(C'\fR is far preferable to a program hanging until some data arrives. -.PP -If you cannot run the fd in non-blocking mode (for example you should not -play around with an Xlib connection), then you have to seperately re-test -whether a file descriptor is really ready with a known-to-be good interface -such as poll (fortunately in our Xlib example, Xlib already does this on -its own, so its quite safe to use). -.PP -\fIThe special problem of disappearing file descriptors\fR -.IX Subsection "The special problem of disappearing file descriptors" -.PP -Some backends (e.g. kqueue, epoll) need to be told about closing a file -descriptor (either by calling \f(CW\*(C`close\*(C'\fR explicitly or by any other means, -such as \f(CW\*(C`dup\*(C'\fR). The reason is that you register interest in some file -descriptor, but when it goes away, the operating system will silently drop -this interest. If another file descriptor with the same number then is -registered with libev, there is no efficient way to see that this is, in -fact, a different file descriptor. -.PP -To avoid having to explicitly tell libev about such cases, libev follows -the following policy: Each time \f(CW\*(C`ev_io_set\*(C'\fR is being called, libev -will assume that this is potentially a new file descriptor, otherwise -it is assumed that the file descriptor stays the same. That means that -you \fIhave\fR to call \f(CW\*(C`ev_io_set\*(C'\fR (or \f(CW\*(C`ev_io_init\*(C'\fR) when you change the -descriptor even if the file descriptor number itself did not change. -.PP -This is how one would do it normally anyway, the important point is that -the libev application should not optimise around libev but should leave -optimisations to libev. -.PP -\fIThe special problem of dup'ed file descriptors\fR -.IX Subsection "The special problem of dup'ed file descriptors" -.PP -Some backends (e.g. epoll), cannot register events for file descriptors, -but only events for the underlying file descriptions. That means when you -have \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors or weirder constellations, and register -events for them, only one file descriptor might actually receive events. -.PP -There is no workaround possible except not registering events -for potentially \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors, or to resort to -\&\f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR. -.PP -\fIThe special problem of fork\fR -.IX Subsection "The special problem of fork" -.PP -Some backends (epoll, kqueue) do not support \f(CW\*(C`fork ()\*(C'\fR at all or exhibit -useless behaviour. Libev fully supports fork, but needs to be told about -it in the child. -.PP -To support fork in your programs, you either have to call -\&\f(CW\*(C`ev_default_fork ()\*(C'\fR or \f(CW\*(C`ev_loop_fork ()\*(C'\fR after a fork in the child, -enable \f(CW\*(C`EVFLAG_FORKCHECK\*(C'\fR, or resort to \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or -\&\f(CW\*(C`EVBACKEND_POLL\*(C'\fR. -.PP -\fIThe special problem of \s-1SIGPIPE\s0\fR -.IX Subsection "The special problem of SIGPIPE" -.PP -While not really specific to libev, it is easy to forget about \s-1SIGPIPE:\s0 -when reading from a pipe whose other end has been closed, your program -gets send a \s-1SIGPIPE\s0, which, by default, aborts your program. For most -programs this is sensible behaviour, for daemons, this is usually -undesirable. -.PP -So when you encounter spurious, unexplained daemon exits, make sure you -ignore \s-1SIGPIPE\s0 (and maybe make sure you log the exit status of your daemon -somewhere, as that would have given you a big clue). -.PP -\fIWatcher-Specific Functions\fR -.IX Subsection "Watcher-Specific Functions" -.IP "ev_io_init (ev_io *, callback, int fd, int events)" 4 -.IX Item "ev_io_init (ev_io *, callback, int fd, int events)" -.PD 0 -.IP "ev_io_set (ev_io *, int fd, int events)" 4 -.IX Item "ev_io_set (ev_io *, int fd, int events)" -.PD -Configures an \f(CW\*(C`ev_io\*(C'\fR watcher. The \f(CW\*(C`fd\*(C'\fR is the file descriptor to -rceeive events for and events is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or -\&\f(CW\*(C`EV_READ | EV_WRITE\*(C'\fR to receive the given events. -.IP "int fd [read\-only]" 4 -.IX Item "int fd [read-only]" -The file descriptor being watched. -.IP "int events [read\-only]" 4 -.IX Item "int events [read-only]" -The events being watched. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Call \f(CW\*(C`stdin_readable_cb\*(C'\fR when \s-1STDIN_FILENO\s0 has become, well -readable, but only once. Since it is likely line-buffered, you could -attempt to read a whole line in the callback. -.PP -.Vb 6 -\& static void -\& stdin_readable_cb (struct ev_loop *loop, struct ev_io *w, int revents) -\& { -\& ev_io_stop (loop, w); -\& .. read from stdin here (or from w\->fd) and haqndle any I/O errors -\& } -\& -\& ... -\& struct ev_loop *loop = ev_default_init (0); -\& struct ev_io stdin_readable; -\& ev_io_init (&stdin_readable, stdin_readable_cb, STDIN_FILENO, EV_READ); -\& ev_io_start (loop, &stdin_readable); -\& ev_loop (loop, 0); -.Ve -.ie n .Sh """ev_timer"" \- relative and optionally repeating timeouts" -.el .Sh "\f(CWev_timer\fP \- relative and optionally repeating timeouts" -.IX Subsection "ev_timer - relative and optionally repeating timeouts" -Timer watchers are simple relative timers that generate an event after a -given time, and optionally repeating in regular intervals after that. -.PP -The timers are based on real time, that is, if you register an event that -times out after an hour and you reset your system clock to last years -time, it will still time out after (roughly) and hour. \*(L"Roughly\*(R" because -detecting time jumps is hard, and some inaccuracies are unavoidable (the -monotonic clock option helps a lot here). -.PP -The relative timeouts are calculated relative to the \f(CW\*(C`ev_now ()\*(C'\fR -time. This is usually the right thing as this timestamp refers to the time -of the event triggering whatever timeout you are modifying/starting. If -you suspect event processing to be delayed and you \fIneed\fR to base the timeout -on the current time, use something like this to adjust for this: -.PP -.Vb 1 -\& ev_timer_set (&timer, after + ev_now () \- ev_time (), 0.); -.Ve -.PP -The callback is guarenteed to be invoked only when its timeout has passed, -but if multiple timers become ready during the same loop iteration then -order of execution is undefined. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_timer_init (ev_timer *, callback, ev_tstamp after, ev_tstamp repeat)" 4 -.IX Item "ev_timer_init (ev_timer *, callback, ev_tstamp after, ev_tstamp repeat)" -.PD 0 -.IP "ev_timer_set (ev_timer *, ev_tstamp after, ev_tstamp repeat)" 4 -.IX Item "ev_timer_set (ev_timer *, ev_tstamp after, ev_tstamp repeat)" -.PD -Configure the timer to trigger after \f(CW\*(C`after\*(C'\fR seconds. If \f(CW\*(C`repeat\*(C'\fR is -\&\f(CW0.\fR, then it will automatically be stopped. If it is positive, then the -timer will automatically be configured to trigger again \f(CW\*(C`repeat\*(C'\fR seconds -later, again, and again, until stopped manually. -.Sp -The timer itself will do a best-effort at avoiding drift, that is, if you -configure a timer to trigger every 10 seconds, then it will trigger at -exactly 10 second intervals. If, however, your program cannot keep up with -the timer (because it takes longer than those 10 seconds to do stuff) the -timer will not fire more than once per event loop iteration. -.IP "ev_timer_again (loop, ev_timer *)" 4 -.IX Item "ev_timer_again (loop, ev_timer *)" -This will act as if the timer timed out and restart it again if it is -repeating. The exact semantics are: -.Sp -If the timer is pending, its pending status is cleared. -.Sp -If the timer is started but nonrepeating, stop it (as if it timed out). -.Sp -If the timer is repeating, either start it if necessary (with the -\&\f(CW\*(C`repeat\*(C'\fR value), or reset the running timer to the \f(CW\*(C`repeat\*(C'\fR value. -.Sp -This sounds a bit complicated, but here is a useful and typical -example: Imagine you have a tcp connection and you want a so-called idle -timeout, that is, you want to be called when there have been, say, 60 -seconds of inactivity on the socket. The easiest way to do this is to -configure an \f(CW\*(C`ev_timer\*(C'\fR with a \f(CW\*(C`repeat\*(C'\fR value of \f(CW60\fR and then call -\&\f(CW\*(C`ev_timer_again\*(C'\fR each time you successfully read or write some data. If -you go into an idle state where you do not expect data to travel on the -socket, you can \f(CW\*(C`ev_timer_stop\*(C'\fR the timer, and \f(CW\*(C`ev_timer_again\*(C'\fR will -automatically restart it if need be. -.Sp -That means you can ignore the \f(CW\*(C`after\*(C'\fR value and \f(CW\*(C`ev_timer_start\*(C'\fR -altogether and only ever use the \f(CW\*(C`repeat\*(C'\fR value and \f(CW\*(C`ev_timer_again\*(C'\fR: -.Sp -.Vb 8 -\& ev_timer_init (timer, callback, 0., 5.); -\& ev_timer_again (loop, timer); -\& ... -\& timer\->again = 17.; -\& ev_timer_again (loop, timer); -\& ... -\& timer\->again = 10.; -\& ev_timer_again (loop, timer); -.Ve -.Sp -This is more slightly efficient then stopping/starting the timer each time -you want to modify its timeout value. -.IP "ev_tstamp repeat [read\-write]" 4 -.IX Item "ev_tstamp repeat [read-write]" -The current \f(CW\*(C`repeat\*(C'\fR value. Will be used each time the watcher times out -or \f(CW\*(C`ev_timer_again\*(C'\fR is called and determines the next timeout (if any), -which is also when any modifications are taken into account. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Create a timer that fires after 60 seconds. -.PP -.Vb 5 -\& static void -\& one_minute_cb (struct ev_loop *loop, struct ev_timer *w, int revents) -\& { -\& .. one minute over, w is actually stopped right here -\& } -\& -\& struct ev_timer mytimer; -\& ev_timer_init (&mytimer, one_minute_cb, 60., 0.); -\& ev_timer_start (loop, &mytimer); -.Ve -.PP -Example: Create a timeout timer that times out after 10 seconds of -inactivity. -.PP -.Vb 5 -\& static void -\& timeout_cb (struct ev_loop *loop, struct ev_timer *w, int revents) -\& { -\& .. ten seconds without any activity -\& } -\& -\& struct ev_timer mytimer; -\& ev_timer_init (&mytimer, timeout_cb, 0., 10.); /* note, only repeat used */ -\& ev_timer_again (&mytimer); /* start timer */ -\& ev_loop (loop, 0); -\& -\& // and in some piece of code that gets executed on any "activity": -\& // reset the timeout to start ticking again at 10 seconds -\& ev_timer_again (&mytimer); -.Ve -.ie n .Sh """ev_periodic"" \- to cron or not to cron?" -.el .Sh "\f(CWev_periodic\fP \- to cron or not to cron?" -.IX Subsection "ev_periodic - to cron or not to cron?" -Periodic watchers are also timers of a kind, but they are very versatile -(and unfortunately a bit complex). -.PP -Unlike \f(CW\*(C`ev_timer\*(C'\fR's, they are not based on real time (or relative time) -but on wallclock time (absolute time). You can tell a periodic watcher -to trigger \*(L"at\*(R" some specific point in time. For example, if you tell a -periodic watcher to trigger in 10 seconds (by specifiying e.g. \f(CW\*(C`ev_now () -+ 10.\*(C'\fR) and then reset your system clock to the last year, then it will -take a year to trigger the event (unlike an \f(CW\*(C`ev_timer\*(C'\fR, which would trigger -roughly 10 seconds later). -.PP -They can also be used to implement vastly more complex timers, such as -triggering an event on each midnight, local time or other, complicated, -rules. -.PP -As with timers, the callback is guarenteed to be invoked only when the -time (\f(CW\*(C`at\*(C'\fR) has been passed, but if multiple periodic timers become ready -during the same loop iteration then order of execution is undefined. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_periodic_init (ev_periodic *, callback, ev_tstamp at, ev_tstamp interval, reschedule_cb)" 4 -.IX Item "ev_periodic_init (ev_periodic *, callback, ev_tstamp at, ev_tstamp interval, reschedule_cb)" -.PD 0 -.IP "ev_periodic_set (ev_periodic *, ev_tstamp after, ev_tstamp repeat, reschedule_cb)" 4 -.IX Item "ev_periodic_set (ev_periodic *, ev_tstamp after, ev_tstamp repeat, reschedule_cb)" -.PD -Lots of arguments, lets sort it out... There are basically three modes of -operation, and we will explain them from simplest to complex: -.RS 4 -.IP "\(bu" 4 -absolute timer (at = time, interval = reschedule_cb = 0) -.Sp -In this configuration the watcher triggers an event at the wallclock time -\&\f(CW\*(C`at\*(C'\fR and doesn't repeat. It will not adjust when a time jump occurs, -that is, if it is to be run at January 1st 2011 then it will run when the -system time reaches or surpasses this time. -.IP "\(bu" 4 -repeating interval timer (at = offset, interval > 0, reschedule_cb = 0) -.Sp -In this mode the watcher will always be scheduled to time out at the next -\&\f(CW\*(C`at + N * interval\*(C'\fR time (for some integer N, which can also be negative) -and then repeat, regardless of any time jumps. -.Sp -This can be used to create timers that do not drift with respect to system -time: -.Sp -.Vb 1 -\& ev_periodic_set (&periodic, 0., 3600., 0); -.Ve -.Sp -This doesn't mean there will always be 3600 seconds in between triggers, -but only that the the callback will be called when the system time shows a -full hour (\s-1UTC\s0), or more correctly, when the system time is evenly divisible -by 3600. -.Sp -Another way to think about it (for the mathematically inclined) is that -\&\f(CW\*(C`ev_periodic\*(C'\fR will try to run the callback in this mode at the next possible -time where \f(CW\*(C`time = at (mod interval)\*(C'\fR, regardless of any time jumps. -.Sp -For numerical stability it is preferable that the \f(CW\*(C`at\*(C'\fR value is near -\&\f(CW\*(C`ev_now ()\*(C'\fR (the current time), but there is no range requirement for -this value. -.IP "\(bu" 4 -manual reschedule mode (at and interval ignored, reschedule_cb = callback) -.Sp -In this mode the values for \f(CW\*(C`interval\*(C'\fR and \f(CW\*(C`at\*(C'\fR are both being -ignored. Instead, each time the periodic watcher gets scheduled, the -reschedule callback will be called with the watcher as first, and the -current time as second argument. -.Sp -\&\s-1NOTE:\s0 \fIThis callback \s-1MUST\s0 \s-1NOT\s0 stop or destroy any periodic watcher, -ever, or make any event loop modifications\fR. If you need to stop it, -return \f(CW\*(C`now + 1e30\*(C'\fR (or so, fudge fudge) and stop it afterwards (e.g. by -starting an \f(CW\*(C`ev_prepare\*(C'\fR watcher, which is legal). -.Sp -Its prototype is \f(CW\*(C`ev_tstamp (*reschedule_cb)(struct ev_periodic *w, -ev_tstamp now)\*(C'\fR, e.g.: -.Sp -.Vb 4 -\& static ev_tstamp my_rescheduler (struct ev_periodic *w, ev_tstamp now) -\& { -\& return now + 60.; -\& } -.Ve -.Sp -It must return the next time to trigger, based on the passed time value -(that is, the lowest time value larger than to the second argument). It -will usually be called just before the callback will be triggered, but -might be called at other times, too. -.Sp -\&\s-1NOTE:\s0 \fIThis callback must always return a time that is later than the -passed \f(CI\*(C`now\*(C'\fI value\fR. Not even \f(CW\*(C`now\*(C'\fR itself will do, it \fImust\fR be larger. -.Sp -This can be used to create very complex timers, such as a timer that -triggers on each midnight, local time. To do this, you would calculate the -next midnight after \f(CW\*(C`now\*(C'\fR and return the timestamp value for this. How -you do this is, again, up to you (but it is not trivial, which is the main -reason I omitted it as an example). -.RE -.RS 4 -.RE -.IP "ev_periodic_again (loop, ev_periodic *)" 4 -.IX Item "ev_periodic_again (loop, ev_periodic *)" -Simply stops and restarts the periodic watcher again. This is only useful -when you changed some parameters or the reschedule callback would return -a different time than the last time it was called (e.g. in a crond like -program when the crontabs have changed). -.IP "ev_tstamp ev_periodic_at (ev_periodic *)" 4 -.IX Item "ev_tstamp ev_periodic_at (ev_periodic *)" -When active, returns the absolute time that the watcher is supposed to -trigger next. -.IP "ev_tstamp offset [read\-write]" 4 -.IX Item "ev_tstamp offset [read-write]" -When repeating, this contains the offset value, otherwise this is the -absolute point in time (the \f(CW\*(C`at\*(C'\fR value passed to \f(CW\*(C`ev_periodic_set\*(C'\fR). -.Sp -Can be modified any time, but changes only take effect when the periodic -timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called. -.IP "ev_tstamp interval [read\-write]" 4 -.IX Item "ev_tstamp interval [read-write]" -The current interval value. Can be modified any time, but changes only -take effect when the periodic timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being -called. -.IP "ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) [read\-write]" 4 -.IX Item "ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) [read-write]" -The current reschedule callback, or \f(CW0\fR, if this functionality is -switched off. Can be changed any time, but changes only take effect when -the periodic timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Call a callback every hour, or, more precisely, whenever the -system clock is divisible by 3600. The callback invocation times have -potentially a lot of jittering, but good long-term stability. -.PP -.Vb 5 -\& static void -\& clock_cb (struct ev_loop *loop, struct ev_io *w, int revents) -\& { -\& ... its now a full hour (UTC, or TAI or whatever your clock follows) -\& } -\& -\& struct ev_periodic hourly_tick; -\& ev_periodic_init (&hourly_tick, clock_cb, 0., 3600., 0); -\& ev_periodic_start (loop, &hourly_tick); -.Ve -.PP -Example: The same as above, but use a reschedule callback to do it: -.PP -.Vb 1 -\& #include -\& -\& static ev_tstamp -\& my_scheduler_cb (struct ev_periodic *w, ev_tstamp now) -\& { -\& return fmod (now, 3600.) + 3600.; -\& } -\& -\& ev_periodic_init (&hourly_tick, clock_cb, 0., 0., my_scheduler_cb); -.Ve -.PP -Example: Call a callback every hour, starting now: -.PP -.Vb 4 -\& struct ev_periodic hourly_tick; -\& ev_periodic_init (&hourly_tick, clock_cb, -\& fmod (ev_now (loop), 3600.), 3600., 0); -\& ev_periodic_start (loop, &hourly_tick); -.Ve -.ie n .Sh """ev_signal"" \- signal me when a signal gets signalled!" -.el .Sh "\f(CWev_signal\fP \- signal me when a signal gets signalled!" -.IX Subsection "ev_signal - signal me when a signal gets signalled!" -Signal watchers will trigger an event when the process receives a specific -signal one or more times. Even though signals are very asynchronous, libev -will try it's best to deliver signals synchronously, i.e. as part of the -normal event processing, like any other event. -.PP -You can configure as many watchers as you like per signal. Only when the -first watcher gets started will libev actually register a signal watcher -with the kernel (thus it coexists with your own signal handlers as long -as you don't register any with libev). Similarly, when the last signal -watcher for a signal is stopped libev will reset the signal handler to -\&\s-1SIG_DFL\s0 (regardless of what it was set to before). -.PP -If possible and supported, libev will install its handlers with -\&\f(CW\*(C`SA_RESTART\*(C'\fR behaviour enabled, so syscalls should not be unduly -interrupted. If you have a problem with syscalls getting interrupted by -signals you can block all signals in an \f(CW\*(C`ev_check\*(C'\fR watcher and unblock -them in an \f(CW\*(C`ev_prepare\*(C'\fR watcher. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_signal_init (ev_signal *, callback, int signum)" 4 -.IX Item "ev_signal_init (ev_signal *, callback, int signum)" -.PD 0 -.IP "ev_signal_set (ev_signal *, int signum)" 4 -.IX Item "ev_signal_set (ev_signal *, int signum)" -.PD -Configures the watcher to trigger on the given signal number (usually one -of the \f(CW\*(C`SIGxxx\*(C'\fR constants). -.IP "int signum [read\-only]" 4 -.IX Item "int signum [read-only]" -The signal the watcher watches out for. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Try to exit cleanly on \s-1SIGINT\s0 and \s-1SIGTERM\s0. -.PP -.Vb 5 -\& static void -\& sigint_cb (struct ev_loop *loop, struct ev_signal *w, int revents) -\& { -\& ev_unloop (loop, EVUNLOOP_ALL); -\& } -\& -\& struct ev_signal signal_watcher; -\& ev_signal_init (&signal_watcher, sigint_cb, SIGINT); -\& ev_signal_start (loop, &sigint_cb); -.Ve -.ie n .Sh """ev_child"" \- watch out for process status changes" -.el .Sh "\f(CWev_child\fP \- watch out for process status changes" -.IX Subsection "ev_child - watch out for process status changes" -Child watchers trigger when your process receives a \s-1SIGCHLD\s0 in response to -some child status changes (most typically when a child of yours dies). It -is permissible to install a child watcher \fIafter\fR the child has been -forked (which implies it might have already exited), as long as the event -loop isn't entered (or is continued from a watcher). -.PP -Only the default event loop is capable of handling signals, and therefore -you can only rgeister child watchers in the default event loop. -.PP -\fIProcess Interaction\fR -.IX Subsection "Process Interaction" -.PP -Libev grabs \f(CW\*(C`SIGCHLD\*(C'\fR as soon as the default event loop is -initialised. This is necessary to guarantee proper behaviour even if -the first child watcher is started after the child exits. The occurance -of \f(CW\*(C`SIGCHLD\*(C'\fR is recorded asynchronously, but child reaping is done -synchronously as part of the event loop processing. Libev always reaps all -children, even ones not watched. -.PP -\fIOverriding the Built-In Processing\fR -.IX Subsection "Overriding the Built-In Processing" -.PP -Libev offers no special support for overriding the built-in child -processing, but if your application collides with libev's default child -handler, you can override it easily by installing your own handler for -\&\f(CW\*(C`SIGCHLD\*(C'\fR after initialising the default loop, and making sure the -default loop never gets destroyed. You are encouraged, however, to use an -event-based approach to child reaping and thus use libev's support for -that, so other libev users can use \f(CW\*(C`ev_child\*(C'\fR watchers freely. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_child_init (ev_child *, callback, int pid, int trace)" 4 -.IX Item "ev_child_init (ev_child *, callback, int pid, int trace)" -.PD 0 -.IP "ev_child_set (ev_child *, int pid, int trace)" 4 -.IX Item "ev_child_set (ev_child *, int pid, int trace)" -.PD -Configures the watcher to wait for status changes of process \f(CW\*(C`pid\*(C'\fR (or -\&\fIany\fR process if \f(CW\*(C`pid\*(C'\fR is specified as \f(CW0\fR). The callback can look -at the \f(CW\*(C`rstatus\*(C'\fR member of the \f(CW\*(C`ev_child\*(C'\fR watcher structure to see -the status word (use the macros from \f(CW\*(C`sys/wait.h\*(C'\fR and see your systems -\&\f(CW\*(C`waitpid\*(C'\fR documentation). The \f(CW\*(C`rpid\*(C'\fR member contains the pid of the -process causing the status change. \f(CW\*(C`trace\*(C'\fR must be either \f(CW0\fR (only -activate the watcher when the process terminates) or \f(CW1\fR (additionally -activate the watcher when the process is stopped or continued). -.IP "int pid [read\-only]" 4 -.IX Item "int pid [read-only]" -The process id this watcher watches out for, or \f(CW0\fR, meaning any process id. -.IP "int rpid [read\-write]" 4 -.IX Item "int rpid [read-write]" -The process id that detected a status change. -.IP "int rstatus [read\-write]" 4 -.IX Item "int rstatus [read-write]" -The process exit/trace status caused by \f(CW\*(C`rpid\*(C'\fR (see your systems -\&\f(CW\*(C`waitpid\*(C'\fR and \f(CW\*(C`sys/wait.h\*(C'\fR documentation for details). -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: \f(CW\*(C`fork()\*(C'\fR a new process and install a child handler to wait for -its completion. -.PP -.Vb 1 -\& ev_child cw; -\& -\& static void -\& child_cb (EV_P_ struct ev_child *w, int revents) -\& { -\& ev_child_stop (EV_A_ w); -\& printf ("process %d exited with status %x\en", w\->rpid, w\->rstatus); -\& } -\& -\& pid_t pid = fork (); -\& -\& if (pid < 0) -\& // error -\& else if (pid == 0) -\& { -\& // the forked child executes here -\& exit (1); -\& } -\& else -\& { -\& ev_child_init (&cw, child_cb, pid, 0); -\& ev_child_start (EV_DEFAULT_ &cw); -\& } -.Ve -.ie n .Sh """ev_stat"" \- did the file attributes just change?" -.el .Sh "\f(CWev_stat\fP \- did the file attributes just change?" -.IX Subsection "ev_stat - did the file attributes just change?" -This watches a filesystem path for attribute changes. That is, it calls -\&\f(CW\*(C`stat\*(C'\fR regularly (or when the \s-1OS\s0 says it changed) and sees if it changed -compared to the last time, invoking the callback if it did. -.PP -The path does not need to exist: changing from \*(L"path exists\*(R" to \*(L"path does -not exist\*(R" is a status change like any other. The condition \*(L"path does -not exist\*(R" is signified by the \f(CW\*(C`st_nlink\*(C'\fR field being zero (which is -otherwise always forced to be at least one) and all the other fields of -the stat buffer having unspecified contents. -.PP -The path \fIshould\fR be absolute and \fImust not\fR end in a slash. If it is -relative and your working directory changes, the behaviour is undefined. -.PP -Since there is no standard to do this, the portable implementation simply -calls \f(CW\*(C`stat (2)\*(C'\fR regularly on the path to see if it changed somehow. You -can specify a recommended polling interval for this case. If you specify -a polling interval of \f(CW0\fR (highly recommended!) then a \fIsuitable, -unspecified default\fR value will be used (which you can expect to be around -five seconds, although this might change dynamically). Libev will also -impose a minimum interval which is currently around \f(CW0.1\fR, but thats -usually overkill. -.PP -This watcher type is not meant for massive numbers of stat watchers, -as even with OS-supported change notifications, this can be -resource-intensive. -.PP -At the time of this writing, only the Linux inotify interface is -implemented (implementing kqueue support is left as an exercise for the -reader, note, however, that the author sees no way of implementing ev_stat -semantics with kqueue). Inotify will be used to give hints only and should -not change the semantics of \f(CW\*(C`ev_stat\*(C'\fR watchers, which means that libev -sometimes needs to fall back to regular polling again even with inotify, -but changes are usually detected immediately, and if the file exists there -will be no polling. -.PP -\fI\s-1ABI\s0 Issues (Largefile Support)\fR -.IX Subsection "ABI Issues (Largefile Support)" -.PP -Libev by default (unless the user overrides this) uses the default -compilation environment, which means that on systems with optionally -disabled large file support, you get the 32 bit version of the stat -structure. When using the library from programs that change the \s-1ABI\s0 to -use 64 bit file offsets the programs will fail. In that case you have to -compile libev with the same flags to get binary compatibility. This is -obviously the case with any flags that change the \s-1ABI\s0, but the problem is -most noticably with ev_stat and largefile support. -.PP -\fIInotify\fR -.IX Subsection "Inotify" -.PP -When \f(CW\*(C`inotify (7)\*(C'\fR support has been compiled into libev (generally only -available on Linux) and present at runtime, it will be used to speed up -change detection where possible. The inotify descriptor will be created lazily -when the first \f(CW\*(C`ev_stat\*(C'\fR watcher is being started. -.PP -Inotify presence does not change the semantics of \f(CW\*(C`ev_stat\*(C'\fR watchers -except that changes might be detected earlier, and in some cases, to avoid -making regular \f(CW\*(C`stat\*(C'\fR calls. Even in the presence of inotify support -there are many cases where libev has to resort to regular \f(CW\*(C`stat\*(C'\fR polling. -.PP -(There is no support for kqueue, as apparently it cannot be used to -implement this functionality, due to the requirement of having a file -descriptor open on the object at all times). -.PP -\fIThe special problem of stat time resolution\fR -.IX Subsection "The special problem of stat time resolution" -.PP -The \f(CW\*(C`stat ()\*(C'\fR syscall only supports full-second resolution portably, and -even on systems where the resolution is higher, many filesystems still -only support whole seconds. -.PP -That means that, if the time is the only thing that changes, you can -easily miss updates: on the first update, \f(CW\*(C`ev_stat\*(C'\fR detects a change and -calls your callback, which does something. When there is another update -within the same second, \f(CW\*(C`ev_stat\*(C'\fR will be unable to detect it as the stat -data does not change. -.PP -The solution to this is to delay acting on a change for slightly more -than second (or till slightly after the next full second boundary), using -a roughly one-second-delay \f(CW\*(C`ev_timer\*(C'\fR (e.g. \f(CW\*(C`ev_timer_set (w, 0., 1.02); -ev_timer_again (loop, w)\*(C'\fR). -.PP -The \f(CW.02\fR offset is added to work around small timing inconsistencies -of some operating systems (where the second counter of the current time -might be be delayed. One such system is the Linux kernel, where a call to -\&\f(CW\*(C`gettimeofday\*(C'\fR might return a timestamp with a full second later than -a subsequent \f(CW\*(C`time\*(C'\fR call \- if the equivalent of \f(CW\*(C`time ()\*(C'\fR is used to -update file times then there will be a small window where the kernel uses -the previous second to update file times but libev might already execute -the timer callback). -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_stat_init (ev_stat *, callback, const char *path, ev_tstamp interval)" 4 -.IX Item "ev_stat_init (ev_stat *, callback, const char *path, ev_tstamp interval)" -.PD 0 -.IP "ev_stat_set (ev_stat *, const char *path, ev_tstamp interval)" 4 -.IX Item "ev_stat_set (ev_stat *, const char *path, ev_tstamp interval)" -.PD -Configures the watcher to wait for status changes of the given -\&\f(CW\*(C`path\*(C'\fR. The \f(CW\*(C`interval\*(C'\fR is a hint on how quickly a change is expected to -be detected and should normally be specified as \f(CW0\fR to let libev choose -a suitable value. The memory pointed to by \f(CW\*(C`path\*(C'\fR must point to the same -path for as long as the watcher is active. -.Sp -The callback will receive \f(CW\*(C`EV_STAT\*(C'\fR when a change was detected, relative -to the attributes at the time the watcher was started (or the last change -was detected). -.IP "ev_stat_stat (loop, ev_stat *)" 4 -.IX Item "ev_stat_stat (loop, ev_stat *)" -Updates the stat buffer immediately with new values. If you change the -watched path in your callback, you could call this function to avoid -detecting this change (while introducing a race condition if you are not -the only one changing the path). Can also be useful simply to find out the -new values. -.IP "ev_statdata attr [read\-only]" 4 -.IX Item "ev_statdata attr [read-only]" -The most-recently detected attributes of the file. Although the type is -\&\f(CW\*(C`ev_statdata\*(C'\fR, this is usually the (or one of the) \f(CW\*(C`struct stat\*(C'\fR types -suitable for your system, but you can only rely on the POSIX-standardised -members to be present. If the \f(CW\*(C`st_nlink\*(C'\fR member is \f(CW0\fR, then there was -some error while \f(CW\*(C`stat\*(C'\fRing the file. -.IP "ev_statdata prev [read\-only]" 4 -.IX Item "ev_statdata prev [read-only]" -The previous attributes of the file. The callback gets invoked whenever -\&\f(CW\*(C`prev\*(C'\fR != \f(CW\*(C`attr\*(C'\fR, or, more precisely, one or more of these members -differ: \f(CW\*(C`st_dev\*(C'\fR, \f(CW\*(C`st_ino\*(C'\fR, \f(CW\*(C`st_mode\*(C'\fR, \f(CW\*(C`st_nlink\*(C'\fR, \f(CW\*(C`st_uid\*(C'\fR, -\&\f(CW\*(C`st_gid\*(C'\fR, \f(CW\*(C`st_rdev\*(C'\fR, \f(CW\*(C`st_size\*(C'\fR, \f(CW\*(C`st_atime\*(C'\fR, \f(CW\*(C`st_mtime\*(C'\fR, \f(CW\*(C`st_ctime\*(C'\fR. -.IP "ev_tstamp interval [read\-only]" 4 -.IX Item "ev_tstamp interval [read-only]" -The specified interval. -.IP "const char *path [read\-only]" 4 -.IX Item "const char *path [read-only]" -The filesystem path that is being watched. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Watch \f(CW\*(C`/etc/passwd\*(C'\fR for attribute changes. -.PP -.Vb 10 -\& static void -\& passwd_cb (struct ev_loop *loop, ev_stat *w, int revents) -\& { -\& /* /etc/passwd changed in some way */ -\& if (w\->attr.st_nlink) -\& { -\& printf ("passwd current size %ld\en", (long)w\->attr.st_size); -\& printf ("passwd current atime %ld\en", (long)w\->attr.st_mtime); -\& printf ("passwd current mtime %ld\en", (long)w\->attr.st_mtime); -\& } -\& else -\& /* you shalt not abuse printf for puts */ -\& puts ("wow, /etc/passwd is not there, expect problems. " -\& "if this is windows, they already arrived\en"); -\& } -\& -\& ... -\& ev_stat passwd; -\& -\& ev_stat_init (&passwd, passwd_cb, "/etc/passwd", 0.); -\& ev_stat_start (loop, &passwd); -.Ve -.PP -Example: Like above, but additionally use a one-second delay so we do not -miss updates (however, frequent updates will delay processing, too, so -one might do the work both on \f(CW\*(C`ev_stat\*(C'\fR callback invocation \fIand\fR on -\&\f(CW\*(C`ev_timer\*(C'\fR callback invocation). -.PP -.Vb 2 -\& static ev_stat passwd; -\& static ev_timer timer; -\& -\& static void -\& timer_cb (EV_P_ ev_timer *w, int revents) -\& { -\& ev_timer_stop (EV_A_ w); -\& -\& /* now it\*(Aqs one second after the most recent passwd change */ -\& } -\& -\& static void -\& stat_cb (EV_P_ ev_stat *w, int revents) -\& { -\& /* reset the one\-second timer */ -\& ev_timer_again (EV_A_ &timer); -\& } -\& -\& ... -\& ev_stat_init (&passwd, stat_cb, "/etc/passwd", 0.); -\& ev_stat_start (loop, &passwd); -\& ev_timer_init (&timer, timer_cb, 0., 1.02); -.Ve -.ie n .Sh """ev_idle"" \- when you've got nothing better to do..." -.el .Sh "\f(CWev_idle\fP \- when you've got nothing better to do..." -.IX Subsection "ev_idle - when you've got nothing better to do..." -Idle watchers trigger events when no other events of the same or higher -priority are pending (prepare, check and other idle watchers do not -count). -.PP -That is, as long as your process is busy handling sockets or timeouts -(or even signals, imagine) of the same or higher priority it will not be -triggered. But when your process is idle (or only lower-priority watchers -are pending), the idle watchers are being called once per event loop -iteration \- until stopped, that is, or your process receives more events -and becomes busy again with higher priority stuff. -.PP -The most noteworthy effect is that as long as any idle watchers are -active, the process will not block when waiting for new events. -.PP -Apart from keeping your process non-blocking (which is a useful -effect on its own sometimes), idle watchers are a good place to do -\&\*(L"pseudo-background processing\*(R", or delay processing stuff to after the -event loop has handled all outstanding events. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_idle_init (ev_signal *, callback)" 4 -.IX Item "ev_idle_init (ev_signal *, callback)" -Initialises and configures the idle watcher \- it has no parameters of any -kind. There is a \f(CW\*(C`ev_idle_set\*(C'\fR macro, but using it is utterly pointless, -believe me. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Dynamically allocate an \f(CW\*(C`ev_idle\*(C'\fR watcher, start it, and in the -callback, free it. Also, use no error checking, as usual. -.PP -.Vb 7 -\& static void -\& idle_cb (struct ev_loop *loop, struct ev_idle *w, int revents) -\& { -\& free (w); -\& // now do something you wanted to do when the program has -\& // no longer anything immediate to do. -\& } -\& -\& struct ev_idle *idle_watcher = malloc (sizeof (struct ev_idle)); -\& ev_idle_init (idle_watcher, idle_cb); -\& ev_idle_start (loop, idle_cb); -.Ve -.ie n .Sh """ev_prepare""\fP and \f(CW""ev_check"" \- customise your event loop!" -.el .Sh "\f(CWev_prepare\fP and \f(CWev_check\fP \- customise your event loop!" -.IX Subsection "ev_prepare and ev_check - customise your event loop!" -Prepare and check watchers are usually (but not always) used in tandem: -prepare watchers get invoked before the process blocks and check watchers -afterwards. -.PP -You \fImust not\fR call \f(CW\*(C`ev_loop\*(C'\fR or similar functions that enter -the current event loop from either \f(CW\*(C`ev_prepare\*(C'\fR or \f(CW\*(C`ev_check\*(C'\fR -watchers. Other loops than the current one are fine, however. The -rationale behind this is that you do not need to check for recursion in -those watchers, i.e. the sequence will always be \f(CW\*(C`ev_prepare\*(C'\fR, blocking, -\&\f(CW\*(C`ev_check\*(C'\fR so if you have one watcher of each kind they will always be -called in pairs bracketing the blocking call. -.PP -Their main purpose is to integrate other event mechanisms into libev and -their use is somewhat advanced. This could be used, for example, to track -variable changes, implement your own watchers, integrate net-snmp or a -coroutine library and lots more. They are also occasionally useful if -you cache some data and want to flush it before blocking (for example, -in X programs you might want to do an \f(CW\*(C`XFlush ()\*(C'\fR in an \f(CW\*(C`ev_prepare\*(C'\fR -watcher). -.PP -This is done by examining in each prepare call which file descriptors need -to be watched by the other library, registering \f(CW\*(C`ev_io\*(C'\fR watchers for -them and starting an \f(CW\*(C`ev_timer\*(C'\fR watcher for any timeouts (many libraries -provide just this functionality). Then, in the check watcher you check for -any events that occured (by checking the pending status of all watchers -and stopping them) and call back into the library. The I/O and timer -callbacks will never actually be called (but must be valid nevertheless, -because you never know, you know?). -.PP -As another example, the Perl Coro module uses these hooks to integrate -coroutines into libev programs, by yielding to other active coroutines -during each prepare and only letting the process block if no coroutines -are ready to run (it's actually more complicated: it only runs coroutines -with priority higher than or equal to the event loop and one coroutine -of lower priority, but only once, using idle watchers to keep the event -loop from blocking if lower-priority coroutines are active, thus mapping -low-priority coroutines to idle/background tasks). -.PP -It is recommended to give \f(CW\*(C`ev_check\*(C'\fR watchers highest (\f(CW\*(C`EV_MAXPRI\*(C'\fR) -priority, to ensure that they are being run before any other watchers -after the poll. Also, \f(CW\*(C`ev_check\*(C'\fR watchers (and \f(CW\*(C`ev_prepare\*(C'\fR watchers, -too) should not activate (\*(L"feed\*(R") events into libev. While libev fully -supports this, they might get executed before other \f(CW\*(C`ev_check\*(C'\fR watchers -did their job. As \f(CW\*(C`ev_check\*(C'\fR watchers are often used to embed other -(non-libev) event loops those other event loops might be in an unusable -state until their \f(CW\*(C`ev_check\*(C'\fR watcher ran (always remind yourself to -coexist peacefully with others). -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_prepare_init (ev_prepare *, callback)" 4 -.IX Item "ev_prepare_init (ev_prepare *, callback)" -.PD 0 -.IP "ev_check_init (ev_check *, callback)" 4 -.IX Item "ev_check_init (ev_check *, callback)" -.PD -Initialises and configures the prepare or check watcher \- they have no -parameters of any kind. There are \f(CW\*(C`ev_prepare_set\*(C'\fR and \f(CW\*(C`ev_check_set\*(C'\fR -macros, but using them is utterly, utterly and completely pointless. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -There are a number of principal ways to embed other event loops or modules -into libev. Here are some ideas on how to include libadns into libev -(there is a Perl module named \f(CW\*(C`EV::ADNS\*(C'\fR that does this, which you could -use as a working example. Another Perl module named \f(CW\*(C`EV::Glib\*(C'\fR embeds a -Glib main context into libev, and finally, \f(CW\*(C`Glib::EV\*(C'\fR embeds \s-1EV\s0 into the -Glib event loop). -.PP -Method 1: Add \s-1IO\s0 watchers and a timeout watcher in a prepare handler, -and in a check watcher, destroy them and call into libadns. What follows -is pseudo-code only of course. This requires you to either use a low -priority for the check watcher or use \f(CW\*(C`ev_clear_pending\*(C'\fR explicitly, as -the callbacks for the IO/timeout watchers might not have been called yet. -.PP -.Vb 2 -\& static ev_io iow [nfd]; -\& static ev_timer tw; -\& -\& static void -\& io_cb (ev_loop *loop, ev_io *w, int revents) -\& { -\& } -\& -\& // create io watchers for each fd and a timer before blocking -\& static void -\& adns_prepare_cb (ev_loop *loop, ev_prepare *w, int revents) -\& { -\& int timeout = 3600000; -\& struct pollfd fds [nfd]; -\& // actual code will need to loop here and realloc etc. -\& adns_beforepoll (ads, fds, &nfd, &timeout, timeval_from (ev_time ())); -\& -\& /* the callback is illegal, but won\*(Aqt be called as we stop during check */ -\& ev_timer_init (&tw, 0, timeout * 1e\-3); -\& ev_timer_start (loop, &tw); -\& -\& // create one ev_io per pollfd -\& for (int i = 0; i < nfd; ++i) -\& { -\& ev_io_init (iow + i, io_cb, fds [i].fd, -\& ((fds [i].events & POLLIN ? EV_READ : 0) -\& | (fds [i].events & POLLOUT ? EV_WRITE : 0))); -\& -\& fds [i].revents = 0; -\& ev_io_start (loop, iow + i); -\& } -\& } -\& -\& // stop all watchers after blocking -\& static void -\& adns_check_cb (ev_loop *loop, ev_check *w, int revents) -\& { -\& ev_timer_stop (loop, &tw); -\& -\& for (int i = 0; i < nfd; ++i) -\& { -\& // set the relevant poll flags -\& // could also call adns_processreadable etc. here -\& struct pollfd *fd = fds + i; -\& int revents = ev_clear_pending (iow + i); -\& if (revents & EV_READ ) fd\->revents |= fd\->events & POLLIN; -\& if (revents & EV_WRITE) fd\->revents |= fd\->events & POLLOUT; -\& -\& // now stop the watcher -\& ev_io_stop (loop, iow + i); -\& } -\& -\& adns_afterpoll (adns, fds, nfd, timeval_from (ev_now (loop)); -\& } -.Ve -.PP -Method 2: This would be just like method 1, but you run \f(CW\*(C`adns_afterpoll\*(C'\fR -in the prepare watcher and would dispose of the check watcher. -.PP -Method 3: If the module to be embedded supports explicit event -notification (adns does), you can also make use of the actual watcher -callbacks, and only destroy/create the watchers in the prepare watcher. -.PP -.Vb 5 -\& static void -\& timer_cb (EV_P_ ev_timer *w, int revents) -\& { -\& adns_state ads = (adns_state)w\->data; -\& update_now (EV_A); -\& -\& adns_processtimeouts (ads, &tv_now); -\& } -\& -\& static void -\& io_cb (EV_P_ ev_io *w, int revents) -\& { -\& adns_state ads = (adns_state)w\->data; -\& update_now (EV_A); -\& -\& if (revents & EV_READ ) adns_processreadable (ads, w\->fd, &tv_now); -\& if (revents & EV_WRITE) adns_processwriteable (ads, w\->fd, &tv_now); -\& } -\& -\& // do not ever call adns_afterpoll -.Ve -.PP -Method 4: Do not use a prepare or check watcher because the module you -want to embed is too inflexible to support it. Instead, youc na override -their poll function. The drawback with this solution is that the main -loop is now no longer controllable by \s-1EV\s0. The \f(CW\*(C`Glib::EV\*(C'\fR module does -this. -.PP -.Vb 4 -\& static gint -\& event_poll_func (GPollFD *fds, guint nfds, gint timeout) -\& { -\& int got_events = 0; -\& -\& for (n = 0; n < nfds; ++n) -\& // create/start io watcher that sets the relevant bits in fds[n] and increment got_events -\& -\& if (timeout >= 0) -\& // create/start timer -\& -\& // poll -\& ev_loop (EV_A_ 0); -\& -\& // stop timer again -\& if (timeout >= 0) -\& ev_timer_stop (EV_A_ &to); -\& -\& // stop io watchers again \- their callbacks should have set -\& for (n = 0; n < nfds; ++n) -\& ev_io_stop (EV_A_ iow [n]); -\& -\& return got_events; -\& } -.Ve -.ie n .Sh """ev_embed"" \- when one backend isn't enough..." -.el .Sh "\f(CWev_embed\fP \- when one backend isn't enough..." -.IX Subsection "ev_embed - when one backend isn't enough..." -This is a rather advanced watcher type that lets you embed one event loop -into another (currently only \f(CW\*(C`ev_io\*(C'\fR events are supported in the embedded -loop, other types of watchers might be handled in a delayed or incorrect -fashion and must not be used). -.PP -There are primarily two reasons you would want that: work around bugs and -prioritise I/O. -.PP -As an example for a bug workaround, the kqueue backend might only support -sockets on some platform, so it is unusable as generic backend, but you -still want to make use of it because you have many sockets and it scales -so nicely. In this case, you would create a kqueue-based loop and embed it -into your default loop (which might use e.g. poll). Overall operation will -be a bit slower because first libev has to poll and then call kevent, but -at least you can use both at what they are best. -.PP -As for prioritising I/O: rarely you have the case where some fds have -to be watched and handled very quickly (with low latency), and even -priorities and idle watchers might have too much overhead. In this case -you would put all the high priority stuff in one loop and all the rest in -a second one, and embed the second one in the first. -.PP -As long as the watcher is active, the callback will be invoked every time -there might be events pending in the embedded loop. The callback must then -call \f(CW\*(C`ev_embed_sweep (mainloop, watcher)\*(C'\fR to make a single sweep and invoke -their callbacks (you could also start an idle watcher to give the embedded -loop strictly lower priority for example). You can also set the callback -to \f(CW0\fR, in which case the embed watcher will automatically execute the -embedded loop sweep. -.PP -As long as the watcher is started it will automatically handle events. The -callback will be invoked whenever some events have been handled. You can -set the callback to \f(CW0\fR to avoid having to specify one if you are not -interested in that. -.PP -Also, there have not currently been made special provisions for forking: -when you fork, you not only have to call \f(CW\*(C`ev_loop_fork\*(C'\fR on both loops, -but you will also have to stop and restart any \f(CW\*(C`ev_embed\*(C'\fR watchers -yourself. -.PP -Unfortunately, not all backends are embeddable, only the ones returned by -\&\f(CW\*(C`ev_embeddable_backends\*(C'\fR are, which, unfortunately, does not include any -portable one. -.PP -So when you want to use this feature you will always have to be prepared -that you cannot get an embeddable loop. The recommended way to get around -this is to have a separate variables for your embeddable loop, try to -create it, and if that fails, use the normal loop for everything. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop)" 4 -.IX Item "ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop)" -.PD 0 -.IP "ev_embed_set (ev_embed *, callback, struct ev_loop *embedded_loop)" 4 -.IX Item "ev_embed_set (ev_embed *, callback, struct ev_loop *embedded_loop)" -.PD -Configures the watcher to embed the given loop, which must be -embeddable. If the callback is \f(CW0\fR, then \f(CW\*(C`ev_embed_sweep\*(C'\fR will be -invoked automatically, otherwise it is the responsibility of the callback -to invoke it (it will continue to be called until the sweep has been done, -if you do not want thta, you need to temporarily stop the embed watcher). -.IP "ev_embed_sweep (loop, ev_embed *)" 4 -.IX Item "ev_embed_sweep (loop, ev_embed *)" -Make a single, non-blocking sweep over the embedded loop. This works -similarly to \f(CW\*(C`ev_loop (embedded_loop, EVLOOP_NONBLOCK)\*(C'\fR, but in the most -apropriate way for embedded loops. -.IP "struct ev_loop *other [read\-only]" 4 -.IX Item "struct ev_loop *other [read-only]" -The embedded event loop. -.PP -\fIExamples\fR -.IX Subsection "Examples" -.PP -Example: Try to get an embeddable event loop and embed it into the default -event loop. If that is not possible, use the default loop. The default -loop is stored in \f(CW\*(C`loop_hi\*(C'\fR, while the mebeddable loop is stored in -\&\f(CW\*(C`loop_lo\*(C'\fR (which is \f(CW\*(C`loop_hi\*(C'\fR in the acse no embeddable loop can be -used). -.PP -.Vb 3 -\& struct ev_loop *loop_hi = ev_default_init (0); -\& struct ev_loop *loop_lo = 0; -\& struct ev_embed embed; -\& -\& // see if there is a chance of getting one that works -\& // (remember that a flags value of 0 means autodetection) -\& loop_lo = ev_embeddable_backends () & ev_recommended_backends () -\& ? ev_loop_new (ev_embeddable_backends () & ev_recommended_backends ()) -\& : 0; -\& -\& // if we got one, then embed it, otherwise default to loop_hi -\& if (loop_lo) -\& { -\& ev_embed_init (&embed, 0, loop_lo); -\& ev_embed_start (loop_hi, &embed); -\& } -\& else -\& loop_lo = loop_hi; -.Ve -.PP -Example: Check if kqueue is available but not recommended and create -a kqueue backend for use with sockets (which usually work with any -kqueue implementation). Store the kqueue/socket\-only event loop in -\&\f(CW\*(C`loop_socket\*(C'\fR. (One might optionally use \f(CW\*(C`EVFLAG_NOENV\*(C'\fR, too). -.PP -.Vb 3 -\& struct ev_loop *loop = ev_default_init (0); -\& struct ev_loop *loop_socket = 0; -\& struct ev_embed embed; -\& -\& if (ev_supported_backends () & ~ev_recommended_backends () & EVBACKEND_KQUEUE) -\& if ((loop_socket = ev_loop_new (EVBACKEND_KQUEUE)) -\& { -\& ev_embed_init (&embed, 0, loop_socket); -\& ev_embed_start (loop, &embed); -\& } -\& -\& if (!loop_socket) -\& loop_socket = loop; -\& -\& // now use loop_socket for all sockets, and loop for everything else -.Ve -.ie n .Sh """ev_fork"" \- the audacity to resume the event loop after a fork" -.el .Sh "\f(CWev_fork\fP \- the audacity to resume the event loop after a fork" -.IX Subsection "ev_fork - the audacity to resume the event loop after a fork" -Fork watchers are called when a \f(CW\*(C`fork ()\*(C'\fR was detected (usually because -whoever is a good citizen cared to tell libev about it by calling -\&\f(CW\*(C`ev_default_fork\*(C'\fR or \f(CW\*(C`ev_loop_fork\*(C'\fR). The invocation is done before the -event loop blocks next and before \f(CW\*(C`ev_check\*(C'\fR watchers are being called, -and only in the child after the fork. If whoever good citizen calling -\&\f(CW\*(C`ev_default_fork\*(C'\fR cheats and calls it in the wrong process, the fork -handlers will be invoked, too, of course. -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_fork_init (ev_signal *, callback)" 4 -.IX Item "ev_fork_init (ev_signal *, callback)" -Initialises and configures the fork watcher \- it has no parameters of any -kind. There is a \f(CW\*(C`ev_fork_set\*(C'\fR macro, but using it is utterly pointless, -believe me. -.ie n .Sh """ev_async"" \- how to wake up another event loop" -.el .Sh "\f(CWev_async\fP \- how to wake up another event loop" -.IX Subsection "ev_async - how to wake up another event loop" -In general, you cannot use an \f(CW\*(C`ev_loop\*(C'\fR from multiple threads or other -asynchronous sources such as signal handlers (as opposed to multiple event -loops \- those are of course safe to use in different threads). -.PP -Sometimes, however, you need to wake up another event loop you do not -control, for example because it belongs to another thread. This is what -\&\f(CW\*(C`ev_async\*(C'\fR watchers do: as long as the \f(CW\*(C`ev_async\*(C'\fR watcher is active, you -can signal it by calling \f(CW\*(C`ev_async_send\*(C'\fR, which is thread\- and signal -safe. -.PP -This functionality is very similar to \f(CW\*(C`ev_signal\*(C'\fR watchers, as signals, -too, are asynchronous in nature, and signals, too, will be compressed -(i.e. the number of callback invocations may be less than the number of -\&\f(CW\*(C`ev_async_sent\*(C'\fR calls). -.PP -Unlike \f(CW\*(C`ev_signal\*(C'\fR watchers, \f(CW\*(C`ev_async\*(C'\fR works with any event loop, not -just the default loop. -.PP -\fIQueueing\fR -.IX Subsection "Queueing" -.PP -\&\f(CW\*(C`ev_async\*(C'\fR does not support queueing of data in any way. The reason -is that the author does not know of a simple (or any) algorithm for a -multiple-writer-single-reader queue that works in all cases and doesn't -need elaborate support such as pthreads. -.PP -That means that if you want to queue data, you have to provide your own -queue. But at least I can tell you would implement locking around your -queue: -.IP "queueing from a signal handler context" 4 -.IX Item "queueing from a signal handler context" -To implement race-free queueing, you simply add to the queue in the signal -handler but you block the signal handler in the watcher callback. Here is an example that does that for -some fictitiuous \s-1SIGUSR1\s0 handler: -.Sp -.Vb 1 -\& static ev_async mysig; -\& -\& static void -\& sigusr1_handler (void) -\& { -\& sometype data; -\& -\& // no locking etc. -\& queue_put (data); -\& ev_async_send (EV_DEFAULT_ &mysig); -\& } -\& -\& static void -\& mysig_cb (EV_P_ ev_async *w, int revents) -\& { -\& sometype data; -\& sigset_t block, prev; -\& -\& sigemptyset (&block); -\& sigaddset (&block, SIGUSR1); -\& sigprocmask (SIG_BLOCK, &block, &prev); -\& -\& while (queue_get (&data)) -\& process (data); -\& -\& if (sigismember (&prev, SIGUSR1) -\& sigprocmask (SIG_UNBLOCK, &block, 0); -\& } -.Ve -.Sp -(Note: pthreads in theory requires you to use \f(CW\*(C`pthread_setmask\*(C'\fR -instead of \f(CW\*(C`sigprocmask\*(C'\fR when you use threads, but libev doesn't do it -either...). -.IP "queueing from a thread context" 4 -.IX Item "queueing from a thread context" -The strategy for threads is different, as you cannot (easily) block -threads but you can easily preempt them, so to queue safely you need to -employ a traditional mutex lock, such as in this pthread example: -.Sp -.Vb 2 -\& static ev_async mysig; -\& static pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER; -\& -\& static void -\& otherthread (void) -\& { -\& // only need to lock the actual queueing operation -\& pthread_mutex_lock (&mymutex); -\& queue_put (data); -\& pthread_mutex_unlock (&mymutex); -\& -\& ev_async_send (EV_DEFAULT_ &mysig); -\& } -\& -\& static void -\& mysig_cb (EV_P_ ev_async *w, int revents) -\& { -\& pthread_mutex_lock (&mymutex); -\& -\& while (queue_get (&data)) -\& process (data); -\& -\& pthread_mutex_unlock (&mymutex); -\& } -.Ve -.PP -\fIWatcher-Specific Functions and Data Members\fR -.IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_async_init (ev_async *, callback)" 4 -.IX Item "ev_async_init (ev_async *, callback)" -Initialises and configures the async watcher \- it has no parameters of any -kind. There is a \f(CW\*(C`ev_asynd_set\*(C'\fR macro, but using it is utterly pointless, -believe me. -.IP "ev_async_send (loop, ev_async *)" 4 -.IX Item "ev_async_send (loop, ev_async *)" -Sends/signals/activates the given \f(CW\*(C`ev_async\*(C'\fR watcher, that is, feeds -an \f(CW\*(C`EV_ASYNC\*(C'\fR event on the watcher into the event loop. Unlike -\&\f(CW\*(C`ev_feed_event\*(C'\fR, this call is safe to do in other threads, signal or -similar contexts (see the dicusssion of \f(CW\*(C`EV_ATOMIC_T\*(C'\fR in the embedding -section below on what exactly this means). -.Sp -This call incurs the overhead of a syscall only once per loop iteration, -so while the overhead might be noticable, it doesn't apply to repeated -calls to \f(CW\*(C`ev_async_send\*(C'\fR. -.IP "bool = ev_async_pending (ev_async *)" 4 -.IX Item "bool = ev_async_pending (ev_async *)" -Returns a non-zero value when \f(CW\*(C`ev_async_send\*(C'\fR has been called on the -watcher but the event has not yet been processed (or even noted) by the -event loop. -.Sp -\&\f(CW\*(C`ev_async_send\*(C'\fR sets a flag in the watcher and wakes up the loop. When -the loop iterates next and checks for the watcher to have become active, -it will reset the flag again. \f(CW\*(C`ev_async_pending\*(C'\fR can be used to very -quickly check wether invoking the loop might be a good idea. -.Sp -Not that this does \fInot\fR check wether the watcher itself is pending, only -wether it has been requested to make this watcher pending. -.SH "OTHER FUNCTIONS" -.IX Header "OTHER FUNCTIONS" -There are some other functions of possible interest. Described. Here. Now. -.IP "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)" 4 -.IX Item "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)" -This function combines a simple timer and an I/O watcher, calls your -callback on whichever event happens first and automatically stop both -watchers. This is useful if you want to wait for a single event on an fd -or timeout without having to allocate/configure/start/stop/free one or -more watchers yourself. -.Sp -If \f(CW\*(C`fd\*(C'\fR is less than 0, then no I/O watcher will be started and events -is being ignored. Otherwise, an \f(CW\*(C`ev_io\*(C'\fR watcher for the given \f(CW\*(C`fd\*(C'\fR and -\&\f(CW\*(C`events\*(C'\fR set will be craeted and started. -.Sp -If \f(CW\*(C`timeout\*(C'\fR is less than 0, then no timeout watcher will be -started. Otherwise an \f(CW\*(C`ev_timer\*(C'\fR watcher with after = \f(CW\*(C`timeout\*(C'\fR (and -repeat = 0) will be started. While \f(CW0\fR is a valid timeout, it is of -dubious value. -.Sp -The callback has the type \f(CW\*(C`void (*cb)(int revents, void *arg)\*(C'\fR and gets -passed an \f(CW\*(C`revents\*(C'\fR set like normal event callbacks (a combination of -\&\f(CW\*(C`EV_ERROR\*(C'\fR, \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or \f(CW\*(C`EV_TIMEOUT\*(C'\fR) and the \f(CW\*(C`arg\*(C'\fR -value passed to \f(CW\*(C`ev_once\*(C'\fR: -.Sp -.Vb 7 -\& static void stdin_ready (int revents, void *arg) -\& { -\& if (revents & EV_TIMEOUT) -\& /* doh, nothing entered */; -\& else if (revents & EV_READ) -\& /* stdin might have data for us, joy! */; -\& } -\& -\& ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); -.Ve -.IP "ev_feed_event (ev_loop *, watcher *, int revents)" 4 -.IX Item "ev_feed_event (ev_loop *, watcher *, int revents)" -Feeds the given event set into the event loop, as if the specified event -had happened for the specified watcher (which must be a pointer to an -initialised but not necessarily started event watcher). -.IP "ev_feed_fd_event (ev_loop *, int fd, int revents)" 4 -.IX Item "ev_feed_fd_event (ev_loop *, int fd, int revents)" -Feed an event on the given fd, as if a file descriptor backend detected -the given events it. -.IP "ev_feed_signal_event (ev_loop *loop, int signum)" 4 -.IX Item "ev_feed_signal_event (ev_loop *loop, int signum)" -Feed an event as if the given signal occured (\f(CW\*(C`loop\*(C'\fR must be the default -loop!). -.SH "LIBEVENT EMULATION" -.IX Header "LIBEVENT EMULATION" -Libev offers a compatibility emulation layer for libevent. It cannot -emulate the internals of libevent, so here are some usage hints: -.IP "\(bu" 4 -Use it by including , as usual. -.IP "\(bu" 4 -The following members are fully supported: ev_base, ev_callback, -ev_arg, ev_fd, ev_res, ev_events. -.IP "\(bu" 4 -Avoid using ev_flags and the EVLIST_*\-macros, while it is -maintained by libev, it does not work exactly the same way as in libevent (consider -it a private \s-1API\s0). -.IP "\(bu" 4 -Priorities are not currently supported. Initialising priorities -will fail and all watchers will have the same priority, even though there -is an ev_pri field. -.IP "\(bu" 4 -In libevent, the last base created gets the signals, in libev, the -first base created (== the default loop) gets the signals. -.IP "\(bu" 4 -Other members are not supported. -.IP "\(bu" 4 -The libev emulation is \fInot\fR \s-1ABI\s0 compatible to libevent, you need -to use the libev header file and library. -.SH "\*(C+ SUPPORT" -.IX Header " SUPPORT" -Libev comes with some simplistic wrapper classes for \*(C+ that mainly allow -you to use some convinience methods to start/stop watchers and also change -the callback model to a model using method callbacks on objects. -.PP -To use it, -.PP -.Vb 1 -\& #include -.Ve -.PP -This automatically includes \fIev.h\fR and puts all of its definitions (many -of them macros) into the global namespace. All \*(C+ specific things are -put into the \f(CW\*(C`ev\*(C'\fR namespace. It should support all the same embedding -options as \fIev.h\fR, most notably \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. -.PP -Care has been taken to keep the overhead low. The only data member the \*(C+ -classes add (compared to plain C\-style watchers) is the event loop pointer -that the watcher is associated with (or no additional members at all if -you disable \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR when embedding libev). -.PP -Currently, functions, and static and non-static member functions can be -used as callbacks. Other types should be easy to add as long as they only -need one additional pointer for context. If you need support for other -types of functors please contact the author (preferably after implementing -it). -.PP -Here is a list of things available in the \f(CW\*(C`ev\*(C'\fR namespace: -.ie n .IP """ev::READ""\fR, \f(CW""ev::WRITE"" etc." 4 -.el .IP "\f(CWev::READ\fR, \f(CWev::WRITE\fR etc." 4 -.IX Item "ev::READ, ev::WRITE etc." -These are just enum values with the same values as the \f(CW\*(C`EV_READ\*(C'\fR etc. -macros from \fIev.h\fR. -.ie n .IP """ev::tstamp""\fR, \f(CW""ev::now""" 4 -.el .IP "\f(CWev::tstamp\fR, \f(CWev::now\fR" 4 -.IX Item "ev::tstamp, ev::now" -Aliases to the same types/functions as with the \f(CW\*(C`ev_\*(C'\fR prefix. -.ie n .IP """ev::io""\fR, \f(CW""ev::timer""\fR, \f(CW""ev::periodic""\fR, \f(CW""ev::idle""\fR, \f(CW""ev::sig"" etc." 4 -.el .IP "\f(CWev::io\fR, \f(CWev::timer\fR, \f(CWev::periodic\fR, \f(CWev::idle\fR, \f(CWev::sig\fR etc." 4 -.IX Item "ev::io, ev::timer, ev::periodic, ev::idle, ev::sig etc." -For each \f(CW\*(C`ev_TYPE\*(C'\fR watcher in \fIev.h\fR there is a corresponding class of -the same name in the \f(CW\*(C`ev\*(C'\fR namespace, with the exception of \f(CW\*(C`ev_signal\*(C'\fR -which is called \f(CW\*(C`ev::sig\*(C'\fR to avoid clashes with the \f(CW\*(C`signal\*(C'\fR macro -defines by many implementations. -.Sp -All of those classes have these methods: -.RS 4 -.IP "ev::TYPE::TYPE ()" 4 -.IX Item "ev::TYPE::TYPE ()" -.PD 0 -.IP "ev::TYPE::TYPE (struct ev_loop *)" 4 -.IX Item "ev::TYPE::TYPE (struct ev_loop *)" -.IP "ev::TYPE::~TYPE" 4 -.IX Item "ev::TYPE::~TYPE" -.PD -The constructor (optionally) takes an event loop to associate the watcher -with. If it is omitted, it will use \f(CW\*(C`EV_DEFAULT\*(C'\fR. -.Sp -The constructor calls \f(CW\*(C`ev_init\*(C'\fR for you, which means you have to call the -\&\f(CW\*(C`set\*(C'\fR method before starting it. -.Sp -It will not set a callback, however: You have to call the templated \f(CW\*(C`set\*(C'\fR -method to set a callback before you can start the watcher. -.Sp -(The reason why you have to use a method is a limitation in \*(C+ which does -not allow explicit template arguments for constructors). -.Sp -The destructor automatically stops the watcher if it is active. -.IP "w\->set (object *)" 4 -.IX Item "w->set (object *)" -This method sets the callback method to call. The method has to have a -signature of \f(CW\*(C`void (*)(ev_TYPE &, int)\*(C'\fR, it receives the watcher as -first argument and the \f(CW\*(C`revents\*(C'\fR as second. The object must be given as -parameter and is stored in the \f(CW\*(C`data\*(C'\fR member of the watcher. -.Sp -This method synthesizes efficient thunking code to call your method from -the C callback that libev requires. If your compiler can inline your -callback (i.e. it is visible to it at the place of the \f(CW\*(C`set\*(C'\fR call and -your compiler is good :), then the method will be fully inlined into the -thunking function, making it as fast as a direct C callback. -.Sp -Example: simple class declaration and watcher initialisation -.Sp -.Vb 4 -\& struct myclass -\& { -\& void io_cb (ev::io &w, int revents) { } -\& } -\& -\& myclass obj; -\& ev::io iow; -\& iow.set (&obj); -.Ve -.IP "w\->set (void *data = 0)" 4 -.IX Item "w->set (void *data = 0)" -Also sets a callback, but uses a static method or plain function as -callback. The optional \f(CW\*(C`data\*(C'\fR argument will be stored in the watcher's -\&\f(CW\*(C`data\*(C'\fR member and is free for you to use. -.Sp -The prototype of the \f(CW\*(C`function\*(C'\fR must be \f(CW\*(C`void (*)(ev::TYPE &w, int)\*(C'\fR. -.Sp -See the method\-\f(CW\*(C`set\*(C'\fR above for more details. -.Sp -Example: -.Sp -.Vb 2 -\& static void io_cb (ev::io &w, int revents) { } -\& iow.set (); -.Ve -.IP "w\->set (struct ev_loop *)" 4 -.IX Item "w->set (struct ev_loop *)" -Associates a different \f(CW\*(C`struct ev_loop\*(C'\fR with this watcher. You can only -do this when the watcher is inactive (and not pending either). -.IP "w\->set ([args])" 4 -.IX Item "w->set ([args])" -Basically the same as \f(CW\*(C`ev_TYPE_set\*(C'\fR, with the same args. Must be -called at least once. Unlike the C counterpart, an active watcher gets -automatically stopped and restarted when reconfiguring it with this -method. -.IP "w\->start ()" 4 -.IX Item "w->start ()" -Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the -constructor already stores the event loop. -.IP "w\->stop ()" 4 -.IX Item "w->stop ()" -Stops the watcher if it is active. Again, no \f(CW\*(C`loop\*(C'\fR argument. -.ie n .IP "w\->again () (""ev::timer""\fR, \f(CW""ev::periodic"" only)" 4 -.el .IP "w\->again () (\f(CWev::timer\fR, \f(CWev::periodic\fR only)" 4 -.IX Item "w->again () (ev::timer, ev::periodic only)" -For \f(CW\*(C`ev::timer\*(C'\fR and \f(CW\*(C`ev::periodic\*(C'\fR, this invokes the corresponding -\&\f(CW\*(C`ev_TYPE_again\*(C'\fR function. -.ie n .IP "w\->sweep () (""ev::embed"" only)" 4 -.el .IP "w\->sweep () (\f(CWev::embed\fR only)" 4 -.IX Item "w->sweep () (ev::embed only)" -Invokes \f(CW\*(C`ev_embed_sweep\*(C'\fR. -.ie n .IP "w\->update () (""ev::stat"" only)" 4 -.el .IP "w\->update () (\f(CWev::stat\fR only)" 4 -.IX Item "w->update () (ev::stat only)" -Invokes \f(CW\*(C`ev_stat_stat\*(C'\fR. -.RE -.RS 4 -.RE -.PP -Example: Define a class with an \s-1IO\s0 and idle watcher, start one of them in -the constructor. -.PP -.Vb 4 -\& class myclass -\& { -\& ev::io io; void io_cb (ev::io &w, int revents); -\& ev:idle idle void idle_cb (ev::idle &w, int revents); -\& -\& myclass (int fd) -\& { -\& io .set (this); -\& idle.set (this); -\& -\& io.start (fd, ev::READ); -\& } -\& }; -.Ve -.SH "OTHER LANGUAGE BINDINGS" -.IX Header "OTHER LANGUAGE BINDINGS" -Libev does not offer other language bindings itself, but bindings for a -numbe rof languages exist in the form of third-party packages. If you know -any interesting language binding in addition to the ones listed here, drop -me a note. -.IP "Perl" 4 -.IX Item "Perl" -The \s-1EV\s0 module implements the full libev \s-1API\s0 and is actually used to test -libev. \s-1EV\s0 is developed together with libev. Apart from the \s-1EV\s0 core module, -there are additional modules that implement libev-compatible interfaces -to \f(CW\*(C`libadns\*(C'\fR (\f(CW\*(C`EV::ADNS\*(C'\fR), \f(CW\*(C`Net::SNMP\*(C'\fR (\f(CW\*(C`Net::SNMP::EV\*(C'\fR) and the -\&\f(CW\*(C`libglib\*(C'\fR event core (\f(CW\*(C`Glib::EV\*(C'\fR and \f(CW\*(C`EV::Glib\*(C'\fR). -.Sp -It can be found and installed via \s-1CPAN\s0, its homepage is found at -. -.IP "Ruby" 4 -.IX Item "Ruby" -Tony Arcieri has written a ruby extension that offers access to a subset -of the libev \s-1API\s0 and adds filehandle abstractions, asynchronous \s-1DNS\s0 and -more on top of it. It can be found via gem servers. Its homepage is at -. -.IP "D" 4 -.IX Item "D" -Leandro Lucarella has written a D language binding (\fIev.d\fR) for libev, to -be found at . -.SH "MACRO MAGIC" -.IX Header "MACRO MAGIC" -Libev can be compiled with a variety of options, the most fundamantal -of which is \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. This option determines whether (most) -functions and callbacks have an initial \f(CW\*(C`struct ev_loop *\*(C'\fR argument. -.PP -To make it easier to write programs that cope with either variant, the -following macros are defined: -.ie n .IP """EV_A""\fR, \f(CW""EV_A_""" 4 -.el .IP "\f(CWEV_A\fR, \f(CWEV_A_\fR" 4 -.IX Item "EV_A, EV_A_" -This provides the loop \fIargument\fR for functions, if one is required (\*(L"ev -loop argument\*(R"). The \f(CW\*(C`EV_A\*(C'\fR form is used when this is the sole argument, -\&\f(CW\*(C`EV_A_\*(C'\fR is used when other arguments are following. Example: -.Sp -.Vb 3 -\& ev_unref (EV_A); -\& ev_timer_add (EV_A_ watcher); -\& ev_loop (EV_A_ 0); -.Ve -.Sp -It assumes the variable \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR is in scope, -which is often provided by the following macro. -.ie n .IP """EV_P""\fR, \f(CW""EV_P_""" 4 -.el .IP "\f(CWEV_P\fR, \f(CWEV_P_\fR" 4 -.IX Item "EV_P, EV_P_" -This provides the loop \fIparameter\fR for functions, if one is required (\*(L"ev -loop parameter\*(R"). The \f(CW\*(C`EV_P\*(C'\fR form is used when this is the sole parameter, -\&\f(CW\*(C`EV_P_\*(C'\fR is used when other parameters are following. Example: -.Sp -.Vb 2 -\& // this is how ev_unref is being declared -\& static void ev_unref (EV_P); -\& -\& // this is how you can declare your typical callback -\& static void cb (EV_P_ ev_timer *w, int revents) -.Ve -.Sp -It declares a parameter \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR, quite -suitable for use with \f(CW\*(C`EV_A\*(C'\fR. -.ie n .IP """EV_DEFAULT""\fR, \f(CW""EV_DEFAULT_""" 4 -.el .IP "\f(CWEV_DEFAULT\fR, \f(CWEV_DEFAULT_\fR" 4 -.IX Item "EV_DEFAULT, EV_DEFAULT_" -Similar to the other two macros, this gives you the value of the default -loop, if multiple loops are supported (\*(L"ev loop default\*(R"). -.ie n .IP """EV_DEFAULT_UC""\fR, \f(CW""EV_DEFAULT_UC_""" 4 -.el .IP "\f(CWEV_DEFAULT_UC\fR, \f(CWEV_DEFAULT_UC_\fR" 4 -.IX Item "EV_DEFAULT_UC, EV_DEFAULT_UC_" -Usage identical to \f(CW\*(C`EV_DEFAULT\*(C'\fR and \f(CW\*(C`EV_DEFAULT_\*(C'\fR, but requires that the -default loop has been initialised (\f(CW\*(C`UC\*(C'\fR == unchecked). Their behaviour -is undefined when the default loop has not been initialised by a previous -execution of \f(CW\*(C`EV_DEFAULT\*(C'\fR, \f(CW\*(C`EV_DEFAULT_\*(C'\fR or \f(CW\*(C`ev_default_init (...)\*(C'\fR. -.Sp -It is often prudent to use \f(CW\*(C`EV_DEFAULT\*(C'\fR when initialising the first -watcher in a function but use \f(CW\*(C`EV_DEFAULT_UC\*(C'\fR afterwards. -.PP -Example: Declare and initialise a check watcher, utilising the above -macros so it will work regardless of whether multiple loops are supported -or not. -.PP -.Vb 5 -\& static void -\& check_cb (EV_P_ ev_timer *w, int revents) -\& { -\& ev_check_stop (EV_A_ w); -\& } -\& -\& ev_check check; -\& ev_check_init (&check, check_cb); -\& ev_check_start (EV_DEFAULT_ &check); -\& ev_loop (EV_DEFAULT_ 0); -.Ve -.SH "EMBEDDING" -.IX Header "EMBEDDING" -Libev can (and often is) directly embedded into host -applications. Examples of applications that embed it include the Deliantra -Game Server, the \s-1EV\s0 perl module, the \s-1GNU\s0 Virtual Private Ethernet (gvpe) -and rxvt-unicode. -.PP -The goal is to enable you to just copy the necessary files into your -source directory without having to change even a single line in them, so -you can easily upgrade by simply copying (or having a checked-out copy of -libev somewhere in your source tree). -.Sh "\s-1FILESETS\s0" -.IX Subsection "FILESETS" -Depending on what features you need you need to include one or more sets of files -in your app. -.PP -\fI\s-1CORE\s0 \s-1EVENT\s0 \s-1LOOP\s0\fR -.IX Subsection "CORE EVENT LOOP" -.PP -To include only the libev core (all the \f(CW\*(C`ev_*\*(C'\fR functions), with manual -configuration (no autoconf): -.PP -.Vb 2 -\& #define EV_STANDALONE 1 -\& #include "ev.c" -.Ve -.PP -This will automatically include \fIev.h\fR, too, and should be done in a -single C source file only to provide the function implementations. To use -it, do the same for \fIev.h\fR in all files wishing to use this \s-1API\s0 (best -done by writing a wrapper around \fIev.h\fR that you can include instead and -where you can put other configuration options): -.PP -.Vb 2 -\& #define EV_STANDALONE 1 -\& #include "ev.h" -.Ve -.PP -Both header files and implementation files can be compiled with a \*(C+ -compiler (at least, thats a stated goal, and breakage will be treated -as a bug). -.PP -You need the following files in your source tree, or in a directory -in your include path (e.g. in libev/ when using \-Ilibev): -.PP -.Vb 4 -\& ev.h -\& ev.c -\& ev_vars.h -\& ev_wrap.h -\& -\& ev_win32.c required on win32 platforms only -\& -\& ev_select.c only when select backend is enabled (which is enabled by default) -\& ev_poll.c only when poll backend is enabled (disabled by default) -\& ev_epoll.c only when the epoll backend is enabled (disabled by default) -\& ev_kqueue.c only when the kqueue backend is enabled (disabled by default) -\& ev_port.c only when the solaris port backend is enabled (disabled by default) -.Ve -.PP -\&\fIev.c\fR includes the backend files directly when enabled, so you only need -to compile this single file. -.PP -\fI\s-1LIBEVENT\s0 \s-1COMPATIBILITY\s0 \s-1API\s0\fR -.IX Subsection "LIBEVENT COMPATIBILITY API" -.PP -To include the libevent compatibility \s-1API\s0, also include: -.PP -.Vb 1 -\& #include "event.c" -.Ve -.PP -in the file including \fIev.c\fR, and: -.PP -.Vb 1 -\& #include "event.h" -.Ve -.PP -in the files that want to use the libevent \s-1API\s0. This also includes \fIev.h\fR. -.PP -You need the following additional files for this: -.PP -.Vb 2 -\& event.h -\& event.c -.Ve -.PP -\fI\s-1AUTOCONF\s0 \s-1SUPPORT\s0\fR -.IX Subsection "AUTOCONF SUPPORT" -.PP -Instead of using \f(CW\*(C`EV_STANDALONE=1\*(C'\fR and providing your config in -whatever way you want, you can also \f(CW\*(C`m4_include([libev.m4])\*(C'\fR in your -\&\fIconfigure.ac\fR and leave \f(CW\*(C`EV_STANDALONE\*(C'\fR undefined. \fIev.c\fR will then -include \fIconfig.h\fR and configure itself accordingly. -.PP -For this of course you need the m4 file: -.PP -.Vb 1 -\& libev.m4 -.Ve -.Sh "\s-1PREPROCESSOR\s0 \s-1SYMBOLS/MACROS\s0" -.IX Subsection "PREPROCESSOR SYMBOLS/MACROS" -Libev can be configured via a variety of preprocessor symbols you have to -define before including any of its files. The default in the absense of -autoconf is noted for every option. -.IP "\s-1EV_STANDALONE\s0" 4 -.IX Item "EV_STANDALONE" -Must always be \f(CW1\fR if you do not use autoconf configuration, which -keeps libev from including \fIconfig.h\fR, and it also defines dummy -implementations for some libevent functions (such as logging, which is not -supported). It will also not define any of the structs usually found in -\&\fIevent.h\fR that are not directly supported by the libev core alone. -.IP "\s-1EV_USE_MONOTONIC\s0" 4 -.IX Item "EV_USE_MONOTONIC" -If defined to be \f(CW1\fR, libev will try to detect the availability of the -monotonic clock option at both compiletime and runtime. Otherwise no use -of the monotonic clock option will be attempted. If you enable this, you -usually have to link against librt or something similar. Enabling it when -the functionality isn't available is safe, though, although you have -to make sure you link against any libraries where the \f(CW\*(C`clock_gettime\*(C'\fR -function is hiding in (often \fI\-lrt\fR). -.IP "\s-1EV_USE_REALTIME\s0" 4 -.IX Item "EV_USE_REALTIME" -If defined to be \f(CW1\fR, libev will try to detect the availability of the -realtime clock option at compiletime (and assume its availability at -runtime if successful). Otherwise no use of the realtime clock option will -be attempted. This effectively replaces \f(CW\*(C`gettimeofday\*(C'\fR by \f(CW\*(C`clock_get -(CLOCK_REALTIME, ...)\*(C'\fR and will not normally affect correctness. See the -note about libraries in the description of \f(CW\*(C`EV_USE_MONOTONIC\*(C'\fR, though. -.IP "\s-1EV_USE_NANOSLEEP\s0" 4 -.IX Item "EV_USE_NANOSLEEP" -If defined to be \f(CW1\fR, libev will assume that \f(CW\*(C`nanosleep ()\*(C'\fR is available -and will use it for delays. Otherwise it will use \f(CW\*(C`select ()\*(C'\fR. -.IP "\s-1EV_USE_EVENTFD\s0" 4 -.IX Item "EV_USE_EVENTFD" -If defined to be \f(CW1\fR, then libev will assume that \f(CW\*(C`eventfd ()\*(C'\fR is -available and will probe for kernel support at runtime. This will improve -\&\f(CW\*(C`ev_signal\*(C'\fR and \f(CW\*(C`ev_async\*(C'\fR performance and reduce resource consumption. -If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc -2.7 or newer, otherwise disabled. -.IP "\s-1EV_USE_SELECT\s0" 4 -.IX Item "EV_USE_SELECT" -If undefined or defined to be \f(CW1\fR, libev will compile in support for the -\&\f(CW\*(C`select\*(C'\fR(2) backend. No attempt at autodetection will be done: if no -other method takes over, select will be it. Otherwise the select backend -will not be compiled in. -.IP "\s-1EV_SELECT_USE_FD_SET\s0" 4 -.IX Item "EV_SELECT_USE_FD_SET" -If defined to \f(CW1\fR, then the select backend will use the system \f(CW\*(C`fd_set\*(C'\fR -structure. This is useful if libev doesn't compile due to a missing -\&\f(CW\*(C`NFDBITS\*(C'\fR or \f(CW\*(C`fd_mask\*(C'\fR definition or it misguesses the bitset layout on -exotic systems. This usually limits the range of file descriptors to some -low limit such as 1024 or might have other limitations (winsocket only -allows 64 sockets). The \f(CW\*(C`FD_SETSIZE\*(C'\fR macro, set before compilation, might -influence the size of the \f(CW\*(C`fd_set\*(C'\fR used. -.IP "\s-1EV_SELECT_IS_WINSOCKET\s0" 4 -.IX Item "EV_SELECT_IS_WINSOCKET" -When defined to \f(CW1\fR, the select backend will assume that -select/socket/connect etc. don't understand file descriptors but -wants osf handles on win32 (this is the case when the select to -be used is the winsock select). This means that it will call -\&\f(CW\*(C`_get_osfhandle\*(C'\fR on the fd to convert it to an \s-1OS\s0 handle. Otherwise, -it is assumed that all these functions actually work on fds, even -on win32. Should not be defined on non\-win32 platforms. -.IP "\s-1EV_FD_TO_WIN32_HANDLE\s0" 4 -.IX Item "EV_FD_TO_WIN32_HANDLE" -If \f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR is enabled, then libev needs a way to map -file descriptors to socket handles. When not defining this symbol (the -default), then libev will call \f(CW\*(C`_get_osfhandle\*(C'\fR, which is usually -correct. In some cases, programs use their own file descriptor management, -in which case they can provide this function to map fds to socket handles. -.IP "\s-1EV_USE_POLL\s0" 4 -.IX Item "EV_USE_POLL" -If defined to be \f(CW1\fR, libev will compile in support for the \f(CW\*(C`poll\*(C'\fR(2) -backend. Otherwise it will be enabled on non\-win32 platforms. It -takes precedence over select. -.IP "\s-1EV_USE_EPOLL\s0" 4 -.IX Item "EV_USE_EPOLL" -If defined to be \f(CW1\fR, libev will compile in support for the Linux -\&\f(CW\*(C`epoll\*(C'\fR(7) backend. Its availability will be detected at runtime, -otherwise another method will be used as fallback. This is the preferred -backend for GNU/Linux systems. If undefined, it will be enabled if the -headers indicate GNU/Linux + Glibc 2.4 or newer, otherwise disabled. -.IP "\s-1EV_USE_KQUEUE\s0" 4 -.IX Item "EV_USE_KQUEUE" -If defined to be \f(CW1\fR, libev will compile in support for the \s-1BSD\s0 style -\&\f(CW\*(C`kqueue\*(C'\fR(2) backend. Its actual availability will be detected at runtime, -otherwise another method will be used as fallback. This is the preferred -backend for \s-1BSD\s0 and BSD-like systems, although on most BSDs kqueue only -supports some types of fds correctly (the only platform we found that -supports ptys for example was NetBSD), so kqueue might be compiled in, but -not be used unless explicitly requested. The best way to use it is to find -out whether kqueue supports your type of fd properly and use an embedded -kqueue loop. -.IP "\s-1EV_USE_PORT\s0" 4 -.IX Item "EV_USE_PORT" -If defined to be \f(CW1\fR, libev will compile in support for the Solaris -10 port style backend. Its availability will be detected at runtime, -otherwise another method will be used as fallback. This is the preferred -backend for Solaris 10 systems. -.IP "\s-1EV_USE_DEVPOLL\s0" 4 -.IX Item "EV_USE_DEVPOLL" -reserved for future expansion, works like the \s-1USE\s0 symbols above. -.IP "\s-1EV_USE_INOTIFY\s0" 4 -.IX Item "EV_USE_INOTIFY" -If defined to be \f(CW1\fR, libev will compile in support for the Linux inotify -interface to speed up \f(CW\*(C`ev_stat\*(C'\fR watchers. Its actual availability will -be detected at runtime. If undefined, it will be enabled if the headers -indicate GNU/Linux + Glibc 2.4 or newer, otherwise disabled. -.IP "\s-1EV_ATOMIC_T\s0" 4 -.IX Item "EV_ATOMIC_T" -Libev requires an integer type (suitable for storing \f(CW0\fR or \f(CW1\fR) whose -access is atomic with respect to other threads or signal contexts. No such -type is easily found in the C language, so you can provide your own type -that you know is safe for your purposes. It is used both for signal handler \*(L"locking\*(R" -as well as for signal and thread safety in \f(CW\*(C`ev_async\*(C'\fR watchers. -.Sp -In the absense of this define, libev will use \f(CW\*(C`sig_atomic_t volatile\*(C'\fR -(from \fIsignal.h\fR), which is usually good enough on most platforms. -.IP "\s-1EV_H\s0" 4 -.IX Item "EV_H" -The name of the \fIev.h\fR header file used to include it. The default if -undefined is \f(CW"ev.h"\fR in \fIevent.h\fR, \fIev.c\fR and \fIev++.h\fR. This can be -used to virtually rename the \fIev.h\fR header file in case of conflicts. -.IP "\s-1EV_CONFIG_H\s0" 4 -.IX Item "EV_CONFIG_H" -If \f(CW\*(C`EV_STANDALONE\*(C'\fR isn't \f(CW1\fR, this variable can be used to override -\&\fIev.c\fR's idea of where to find the \fIconfig.h\fR file, similarly to -\&\f(CW\*(C`EV_H\*(C'\fR, above. -.IP "\s-1EV_EVENT_H\s0" 4 -.IX Item "EV_EVENT_H" -Similarly to \f(CW\*(C`EV_H\*(C'\fR, this macro can be used to override \fIevent.c\fR's idea -of how the \fIevent.h\fR header can be found, the default is \f(CW"event.h"\fR. -.IP "\s-1EV_PROTOTYPES\s0" 4 -.IX Item "EV_PROTOTYPES" -If defined to be \f(CW0\fR, then \fIev.h\fR will not define any function -prototypes, but still define all the structs and other symbols. This is -occasionally useful if you want to provide your own wrapper functions -around libev functions. -.IP "\s-1EV_MULTIPLICITY\s0" 4 -.IX Item "EV_MULTIPLICITY" -If undefined or defined to \f(CW1\fR, then all event-loop-specific functions -will have the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument, and you can create -additional independent event loops. Otherwise there will be no support -for multiple event loops and there is no first event loop pointer -argument. Instead, all functions act on the single default loop. -.IP "\s-1EV_MINPRI\s0" 4 -.IX Item "EV_MINPRI" -.PD 0 -.IP "\s-1EV_MAXPRI\s0" 4 -.IX Item "EV_MAXPRI" -.PD -The range of allowed priorities. \f(CW\*(C`EV_MINPRI\*(C'\fR must be smaller or equal to -\&\f(CW\*(C`EV_MAXPRI\*(C'\fR, but otherwise there are no non-obvious limitations. You can -provide for more priorities by overriding those symbols (usually defined -to be \f(CW\*(C`\-2\*(C'\fR and \f(CW2\fR, respectively). -.Sp -When doing priority-based operations, libev usually has to linearly search -all the priorities, so having many of them (hundreds) uses a lot of space -and time, so using the defaults of five priorities (\-2 .. +2) is usually -fine. -.Sp -If your embedding app does not need any priorities, defining these both to -\&\f(CW0\fR will save some memory and cpu. -.IP "\s-1EV_PERIODIC_ENABLE\s0" 4 -.IX Item "EV_PERIODIC_ENABLE" -If undefined or defined to be \f(CW1\fR, then periodic timers are supported. If -defined to be \f(CW0\fR, then they are not. Disabling them saves a few kB of -code. -.IP "\s-1EV_IDLE_ENABLE\s0" 4 -.IX Item "EV_IDLE_ENABLE" -If undefined or defined to be \f(CW1\fR, then idle watchers are supported. If -defined to be \f(CW0\fR, then they are not. Disabling them saves a few kB of -code. -.IP "\s-1EV_EMBED_ENABLE\s0" 4 -.IX Item "EV_EMBED_ENABLE" -If undefined or defined to be \f(CW1\fR, then embed watchers are supported. If -defined to be \f(CW0\fR, then they are not. -.IP "\s-1EV_STAT_ENABLE\s0" 4 -.IX Item "EV_STAT_ENABLE" -If undefined or defined to be \f(CW1\fR, then stat watchers are supported. If -defined to be \f(CW0\fR, then they are not. -.IP "\s-1EV_FORK_ENABLE\s0" 4 -.IX Item "EV_FORK_ENABLE" -If undefined or defined to be \f(CW1\fR, then fork watchers are supported. If -defined to be \f(CW0\fR, then they are not. -.IP "\s-1EV_ASYNC_ENABLE\s0" 4 -.IX Item "EV_ASYNC_ENABLE" -If undefined or defined to be \f(CW1\fR, then async watchers are supported. If -defined to be \f(CW0\fR, then they are not. -.IP "\s-1EV_MINIMAL\s0" 4 -.IX Item "EV_MINIMAL" -If you need to shave off some kilobytes of code at the expense of some -speed, define this symbol to \f(CW1\fR. Currently this is used to override some -inlining decisions, saves roughly 30% codesize of amd64. It also selects a -much smaller 2\-heap for timer management over the default 4\-heap. -.IP "\s-1EV_PID_HASHSIZE\s0" 4 -.IX Item "EV_PID_HASHSIZE" -\&\f(CW\*(C`ev_child\*(C'\fR watchers use a small hash table to distribute workload by -pid. The default size is \f(CW16\fR (or \f(CW1\fR with \f(CW\*(C`EV_MINIMAL\*(C'\fR), usually more -than enough. If you need to manage thousands of children you might want to -increase this value (\fImust\fR be a power of two). -.IP "\s-1EV_INOTIFY_HASHSIZE\s0" 4 -.IX Item "EV_INOTIFY_HASHSIZE" -\&\f(CW\*(C`ev_stat\*(C'\fR watchers use a small hash table to distribute workload by -inotify watch id. The default size is \f(CW16\fR (or \f(CW1\fR with \f(CW\*(C`EV_MINIMAL\*(C'\fR), -usually more than enough. If you need to manage thousands of \f(CW\*(C`ev_stat\*(C'\fR -watchers you might want to increase this value (\fImust\fR be a power of -two). -.IP "\s-1EV_USE_4HEAP\s0" 4 -.IX Item "EV_USE_4HEAP" -Heaps are not very cache-efficient. To improve the cache-efficiency of the -timer and periodics heap, libev uses a 4\-heap when this symbol is defined -to \f(CW1\fR. The 4\-heap uses more complicated (longer) code but has a -noticable after performance with many (thousands) of watchers. -.Sp -The default is \f(CW1\fR unless \f(CW\*(C`EV_MINIMAL\*(C'\fR is set in which case it is \f(CW0\fR -(disabled). -.IP "\s-1EV_HEAP_CACHE_AT\s0" 4 -.IX Item "EV_HEAP_CACHE_AT" -Heaps are not very cache-efficient. To improve the cache-efficiency of the -timer and periodics heap, libev can cache the timestamp (\fIat\fR) within -the heap structure (selected by defining \f(CW\*(C`EV_HEAP_CACHE_AT\*(C'\fR to \f(CW1\fR), -which uses 8\-12 bytes more per watcher and a few hundred bytes more code, -but avoids random read accesses on heap changes. This noticably improves -performance noticably with with many (hundreds) of watchers. -.Sp -The default is \f(CW1\fR unless \f(CW\*(C`EV_MINIMAL\*(C'\fR is set in which case it is \f(CW0\fR -(disabled). -.IP "\s-1EV_COMMON\s0" 4 -.IX Item "EV_COMMON" -By default, all watchers have a \f(CW\*(C`void *data\*(C'\fR member. By redefining -this macro to a something else you can include more and other types of -members. You have to define it each time you include one of the files, -though, and it must be identical each time. -.Sp -For example, the perl \s-1EV\s0 module uses something like this: -.Sp -.Vb 3 -\& #define EV_COMMON \e -\& SV *self; /* contains this struct */ \e -\& SV *cb_sv, *fh /* note no trailing ";" */ -.Ve -.IP "\s-1EV_CB_DECLARE\s0 (type)" 4 -.IX Item "EV_CB_DECLARE (type)" -.PD 0 -.IP "\s-1EV_CB_INVOKE\s0 (watcher, revents)" 4 -.IX Item "EV_CB_INVOKE (watcher, revents)" -.IP "ev_set_cb (ev, cb)" 4 -.IX Item "ev_set_cb (ev, cb)" -.PD -Can be used to change the callback member declaration in each watcher, -and the way callbacks are invoked and set. Must expand to a struct member -definition and a statement, respectively. See the \fIev.h\fR header file for -their default definitions. One possible use for overriding these is to -avoid the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument in all cases, or to use -method calls instead of plain function calls in \*(C+. -.Sh "\s-1EXPORTED\s0 \s-1API\s0 \s-1SYMBOLS\s0" -.IX Subsection "EXPORTED API SYMBOLS" -If you need to re-export the \s-1API\s0 (e.g. via a dll) and you need a list of -exported symbols, you can use the provided \fISymbol.*\fR files which list -all public symbols, one per line: -.PP -.Vb 2 -\& Symbols.ev for libev proper -\& Symbols.event for the libevent emulation -.Ve -.PP -This can also be used to rename all public symbols to avoid clashes with -multiple versions of libev linked together (which is obviously bad in -itself, but sometimes it is inconvinient to avoid this). -.PP -A sed command like this will create wrapper \f(CW\*(C`#define\*(C'\fR's that you need to -include before including \fIev.h\fR: -.PP -.Vb 1 -\& wrap.h -.Ve -.PP -This would create a file \fIwrap.h\fR which essentially looks like this: -.PP -.Vb 4 -\& #define ev_backend myprefix_ev_backend -\& #define ev_check_start myprefix_ev_check_start -\& #define ev_check_stop myprefix_ev_check_stop -\& ... -.Ve -.Sh "\s-1EXAMPLES\s0" -.IX Subsection "EXAMPLES" -For a real-world example of a program the includes libev -verbatim, you can have a look at the \s-1EV\s0 perl module -(). It has the libev files in -the \fIlibev/\fR subdirectory and includes them in the \fI\s-1EV/EVAPI\s0.h\fR (public -interface) and \fI\s-1EV\s0.xs\fR (implementation) files. Only the \fI\s-1EV\s0.xs\fR file -will be compiled. It is pretty complex because it provides its own header -file. -.PP -The usage in rxvt-unicode is simpler. It has a \fIev_cpp.h\fR header file -that everybody includes and which overrides some configure choices: -.PP -.Vb 9 -\& #define EV_MINIMAL 1 -\& #define EV_USE_POLL 0 -\& #define EV_MULTIPLICITY 0 -\& #define EV_PERIODIC_ENABLE 0 -\& #define EV_STAT_ENABLE 0 -\& #define EV_FORK_ENABLE 0 -\& #define EV_CONFIG_H -\& #define EV_MINPRI 0 -\& #define EV_MAXPRI 0 -\& -\& #include "ev++.h" -.Ve -.PP -And a \fIev_cpp.C\fR implementation file that contains libev proper and is compiled: -.PP -.Vb 2 -\& #include "ev_cpp.h" -\& #include "ev.c" -.Ve -.SH "THREADS AND COROUTINES" -.IX Header "THREADS AND COROUTINES" -.Sh "\s-1THREADS\s0" -.IX Subsection "THREADS" -Libev itself is completely threadsafe, but it uses no locking. This -means that you can use as many loops as you want in parallel, as long as -only one thread ever calls into one libev function with the same loop -parameter. -.PP -Or put differently: calls with different loop parameters can be done in -parallel from multiple threads, calls with the same loop parameter must be -done serially (but can be done from different threads, as long as only one -thread ever is inside a call at any point in time, e.g. by using a mutex -per loop). -.PP -If you want to know which design is best for your problem, then I cannot -help you but by giving some generic advice: -.IP "\(bu" 4 -most applications have a main thread: use the default libev loop -in that thread, or create a seperate thread running only the default loop. -.Sp -This helps integrating other libraries or software modules that use libev -themselves and don't care/know about threading. -.IP "\(bu" 4 -one loop per thread is usually a good model. -.Sp -Doing this is almost never wrong, sometimes a better-performance model -exists, but it is always a good start. -.IP "\(bu" 4 -other models exist, such as the leader/follower pattern, where one -loop is handed through multiple threads in a kind of round-robbin fashion. -.Sp -Chosing a model is hard \- look around, learn, know that usually you cna do -better than you currently do :\-) -.IP "\(bu" 4 -often you need to talk to some other thread which blocks in the -event loop \- \f(CW\*(C`ev_async\*(C'\fR watchers can be used to wake them up from other -threads safely (or from signal contexts...). -.Sh "\s-1COROUTINES\s0" -.IX Subsection "COROUTINES" -Libev is much more accomodating to coroutines (\*(L"cooperative threads\*(R"): -libev fully supports nesting calls to it's functions from different -coroutines (e.g. you can call \f(CW\*(C`ev_loop\*(C'\fR on the same loop from two -different coroutines and switch freely between both coroutines running the -loop, as long as you don't confuse yourself). The only exception is that -you must not do this from \f(CW\*(C`ev_periodic\*(C'\fR reschedule callbacks. -.PP -Care has been invested into making sure that libev does not keep local -state inside \f(CW\*(C`ev_loop\*(C'\fR, and other calls do not usually allow coroutine -switches. -.SH "COMPLEXITIES" -.IX Header "COMPLEXITIES" -In this section the complexities of (many of) the algorithms used inside -libev will be explained. For complexity discussions about backends see the -documentation for \f(CW\*(C`ev_default_init\*(C'\fR. -.PP -All of the following are about amortised time: If an array needs to be -extended, libev needs to realloc and move the whole array, but this -happens asymptotically never with higher number of elements, so O(1) might -mean it might do a lengthy realloc operation in rare cases, but on average -it is much faster and asymptotically approaches constant time. -.IP "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 4 -.IX Item "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" -This means that, when you have a watcher that triggers in one hour and -there are 100 watchers that would trigger before that then inserting will -have to skip roughly seven (\f(CW\*(C`ld 100\*(C'\fR) of these watchers. -.IP "Changing timer/periodic watchers (by autorepeat or calling again): O(log skipped_other_timers)" 4 -.IX Item "Changing timer/periodic watchers (by autorepeat or calling again): O(log skipped_other_timers)" -That means that changing a timer costs less than removing/adding them -as only the relative motion in the event queue has to be paid for. -.IP "Starting io/check/prepare/idle/signal/child/fork/async watchers: O(1)" 4 -.IX Item "Starting io/check/prepare/idle/signal/child/fork/async watchers: O(1)" -These just add the watcher into an array or at the head of a list. -.IP "Stopping check/prepare/idle/fork/async watchers: O(1)" 4 -.IX Item "Stopping check/prepare/idle/fork/async watchers: O(1)" -.PD 0 -.IP "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % \s-1EV_PID_HASHSIZE\s0))" 4 -.IX Item "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))" -.PD -These watchers are stored in lists then need to be walked to find the -correct watcher to remove. The lists are usually short (you don't usually -have many watchers waiting for the same fd or signal). -.IP "Finding the next timer in each loop iteration: O(1)" 4 -.IX Item "Finding the next timer in each loop iteration: O(1)" -By virtue of using a binary or 4\-heap, the next timer is always found at a -fixed position in the storage array. -.IP "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)" 4 -.IX Item "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)" -A change means an I/O watcher gets started or stopped, which requires -libev to recalculate its status (and possibly tell the kernel, depending -on backend and wether \f(CW\*(C`ev_io_set\*(C'\fR was used). -.IP "Activating one watcher (putting it into the pending state): O(1)" 4 -.IX Item "Activating one watcher (putting it into the pending state): O(1)" -.PD 0 -.IP "Priority handling: O(number_of_priorities)" 4 -.IX Item "Priority handling: O(number_of_priorities)" -.PD -Priorities are implemented by allocating some space for each -priority. When doing priority-based operations, libev usually has to -linearly search all the priorities, but starting/stopping and activating -watchers becomes O(1) w.r.t. priority handling. -.IP "Sending an ev_async: O(1)" 4 -.IX Item "Sending an ev_async: O(1)" -.PD 0 -.IP "Processing ev_async_send: O(number_of_async_watchers)" 4 -.IX Item "Processing ev_async_send: O(number_of_async_watchers)" -.IP "Processing signals: O(max_signal_number)" 4 -.IX Item "Processing signals: O(max_signal_number)" -.PD -Sending involves a syscall \fIiff\fR there were no other \f(CW\*(C`ev_async_send\*(C'\fR -calls in the current loop iteration. Checking for async and signal events -involves iterating over all running async watchers or all signal numbers. -.SH "Win32 platform limitations and workarounds" -.IX Header "Win32 platform limitations and workarounds" -Win32 doesn't support any of the standards (e.g. \s-1POSIX\s0) that libev -requires, and its I/O model is fundamentally incompatible with the \s-1POSIX\s0 -model. Libev still offers limited functionality on this platform in -the form of the \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR backend, and only supports socket -descriptors. This only applies when using Win32 natively, not when using -e.g. cygwin. -.PP -Lifting these limitations would basically require the full -re-implementation of the I/O system. If you are into these kinds of -things, then note that glib does exactly that for you in a very portable -way (note also that glib is the slowest event library known to man). -.PP -There is no supported compilation method available on windows except -embedding it into other applications. -.PP -Due to the many, low, and arbitrary limits on the win32 platform and -the abysmal performance of winsockets, using a large number of sockets -is not recommended (and not reasonable). If your program needs to use -more than a hundred or so sockets, then likely it needs to use a totally -different implementation for windows, as libev offers the \s-1POSIX\s0 readyness -notification model, which cannot be implemented efficiently on windows -(microsoft monopoly games). -.IP "The winsocket select function" 4 -.IX Item "The winsocket select function" -The winsocket \f(CW\*(C`select\*(C'\fR function doesn't follow \s-1POSIX\s0 in that it requires -socket \fIhandles\fR and not socket \fIfile descriptors\fR. This makes select -very inefficient, and also requires a mapping from file descriptors -to socket handles. See the discussion of the \f(CW\*(C`EV_SELECT_USE_FD_SET\*(C'\fR, -\&\f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR and \f(CW\*(C`EV_FD_TO_WIN32_HANDLE\*(C'\fR preprocessor -symbols for more info. -.Sp -The configuration for a \*(L"naked\*(R" win32 using the microsoft runtime -libraries and raw winsocket select is: -.Sp -.Vb 2 -\& #define EV_USE_SELECT 1 -\& #define EV_SELECT_IS_WINSOCKET 1 /* forces EV_SELECT_USE_FD_SET, too */ -.Ve -.Sp -Note that winsockets handling of fd sets is O(n), so you can easily get a -complexity in the O(nA\*^X) range when using win32. -.IP "Limited number of file descriptors" 4 -.IX Item "Limited number of file descriptors" -Windows has numerous arbitrary (and low) limits on things. -.Sp -Early versions of winsocket's select only supported waiting for a maximum -of \f(CW64\fR handles (probably owning to the fact that all windows kernels -can only wait for \f(CW64\fR things at the same time internally; microsoft -recommends spawning a chain of threads and wait for 63 handles and the -previous thread in each. Great). -.Sp -Newer versions support more handles, but you need to define \f(CW\*(C`FD_SETSIZE\*(C'\fR -to some high number (e.g. \f(CW2048\fR) before compiling the winsocket select -call (which might be in libev or elsewhere, for example, perl does its own -select emulation on windows). -.Sp -Another limit is the number of file descriptors in the microsoft runtime -libraries, which by default is \f(CW64\fR (there must be a hidden \fI64\fR fetish -or something like this inside microsoft). You can increase this by calling -\&\f(CW\*(C`_setmaxstdio\*(C'\fR, which can increase this limit to \f(CW2048\fR (another -arbitrary limit), but is broken in many versions of the microsoft runtime -libraries. -.Sp -This might get you to about \f(CW512\fR or \f(CW2048\fR sockets (depending on -windows version and/or the phase of the moon). To get more, you need to -wrap all I/O functions and provide your own fd management, but the cost of -calling select (O(nA\*^X)) will likely make this unworkable. -.SH "PORTABILITY REQUIREMENTS" -.IX Header "PORTABILITY REQUIREMENTS" -In addition to a working ISO-C implementation, libev relies on a few -additional extensions: -.ie n .IP """sig_atomic_t volatile"" must be thread-atomic as well" 4 -.el .IP "\f(CWsig_atomic_t volatile\fR must be thread-atomic as well" 4 -.IX Item "sig_atomic_t volatile must be thread-atomic as well" -The type \f(CW\*(C`sig_atomic_t volatile\*(C'\fR (or whatever is defined as -\&\f(CW\*(C`EV_ATOMIC_T\*(C'\fR) must be atomic w.r.t. accesses from different -threads. This is not part of the specification for \f(CW\*(C`sig_atomic_t\*(C'\fR, but is -believed to be sufficiently portable. -.ie n .IP """sigprocmask"" must work in a threaded environment" 4 -.el .IP "\f(CWsigprocmask\fR must work in a threaded environment" 4 -.IX Item "sigprocmask must work in a threaded environment" -Libev uses \f(CW\*(C`sigprocmask\*(C'\fR to temporarily block signals. This is not -allowed in a threaded program (\f(CW\*(C`pthread_sigmask\*(C'\fR has to be used). Typical -pthread implementations will either allow \f(CW\*(C`sigprocmask\*(C'\fR in the \*(L"main -thread\*(R" or will block signals process-wide, both behaviours would -be compatible with libev. Interaction between \f(CW\*(C`sigprocmask\*(C'\fR and -\&\f(CW\*(C`pthread_sigmask\*(C'\fR could complicate things, however. -.Sp -The most portable way to handle signals is to block signals in all threads -except the initial one, and run the default loop in the initial thread as -well. -.ie n .IP """long"" must be large enough for common memory allocation sizes" 4 -.el .IP "\f(CWlong\fR must be large enough for common memory allocation sizes" 4 -.IX Item "long must be large enough for common memory allocation sizes" -To improve portability and simplify using libev, libev uses \f(CW\*(C`long\*(C'\fR -internally instead of \f(CW\*(C`size_t\*(C'\fR when allocating its data structures. On -non-POSIX systems (Microsoft...) this might be unexpectedly low, but -is still at least 31 bits everywhere, which is enough for hundreds of -millions of watchers. -.ie n .IP """double"" must hold a time value in seconds with enough accuracy" 4 -.el .IP "\f(CWdouble\fR must hold a time value in seconds with enough accuracy" 4 -.IX Item "double must hold a time value in seconds with enough accuracy" -The type \f(CW\*(C`double\*(C'\fR is used to represent timestamps. It is required to -have at least 51 bits of mantissa (and 9 bits of exponent), which is good -enough for at least into the year 4000. This requirement is fulfilled by -implementations implementing \s-1IEEE\s0 754 (basically all existing ones). -.PP -If you know of other additional requirements drop me a note. -.SH "AUTHOR" -.IX Header "AUTHOR" -Marc Lehmann . -.SH "POD ERRORS" -.IX Header "POD ERRORS" -Hey! \fBThe above document had some coding errors, which are explained below:\fR -.IP "Around line 3052:" 4 -.IX Item "Around line 3052:" -You forgot a '=back' before '=head2' diff --git a/deps/uv/src/unix/eio/eio.c b/deps/uv/src/unix/eio/eio.c deleted file mode 100644 index 3dfba0a4e6..0000000000 --- a/deps/uv/src/unix/eio/eio.c +++ /dev/null @@ -1,2593 +0,0 @@ -/* - * libeio implementation - * - * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann - * All rights reserved. - * - * 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 - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- - * CIAL, 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 OTH- - * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License ("GPL") version 2 or any later version, - * in which case the provisions of the GPL are applicable instead of - * the above. If you wish to allow the use of your version of this file - * only under the terms of the GPL and not to allow others to use your - * version of this file under the BSD license, indicate your decision - * by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL. If you do not delete the - * provisions above, a recipient may use your version of this file under - * either the BSD or the GPL. - */ - -#ifdef EIO_CONFIG_H -# include EIO_CONFIG_H -#endif - -/* Undone by libuv for easy build scripts. - * #ifndef _WIN32 - * # include "config.h" - * #endif - */ - -#include "eio.h" -#include "ecb.h" - -#ifdef EIO_STACKSIZE -# define X_STACKSIZE EIO_STACKSIZE -#endif -#include "xthread.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* intptr_t comes from unistd.h, says POSIX/UNIX/tradition */ -/* intptr_t only comes from stdint.h, says idiot openbsd coder */ -#if HAVE_STDINT_H -# include -#endif - -#ifndef ECANCELED -# define ECANCELED EDOM -#endif -#ifndef ELOOP -# define ELOOP EDOM -#endif - -#if !defined(ENOTSOCK) && defined(WSAENOTSOCK) -# define ENOTSOCK WSAENOTSOCK -#endif - -static void eio_destroy (eio_req *req); - -#ifndef EIO_FINISH -# define EIO_FINISH(req) ((req)->finish) && !EIO_CANCELLED (req) ? (req)->finish (req) : 0 -#endif - -#ifndef EIO_DESTROY -# define EIO_DESTROY(req) do { if ((req)->destroy) (req)->destroy (req); } while (0) -#endif - -#ifndef EIO_FEED -# define EIO_FEED(req) do { if ((req)->feed ) (req)->feed (req); } while (0) -#endif - -#ifndef EIO_FD_TO_WIN32_HANDLE -# define EIO_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd) -#endif -#ifndef EIO_WIN32_HANDLE_TO_FD -# define EIO_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (handle, 0) -#endif - -#define EIO_ERRNO(errval,retval) ((errno = errval), retval) - -#define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1) - -#ifdef __sun -# define futimes(fd, times) futimesat (fd, NULL, times) -#endif - -#ifdef _WIN32 - - #include - - #undef PAGESIZE - #define PAGESIZE 4096 /* GetSystemInfo? */ - - /* TODO: look at how perl does stat (non-sloppy), unlink (ro-files), utime, link */ - - #ifdef EIO_STRUCT_STATI64 - /* look at perl's non-sloppy stat */ - #define stat(path,buf) _stati64 (path,buf) - #define fstat(fd,buf) _fstati64 (fd,buf) - #endif - #define lstat(path,buf) stat (path,buf) - #define fsync(fd) (FlushFileBuffers ((HANDLE)EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1)) - #define mkdir(path,mode) _mkdir (path) - #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1)) - - #define chmod(path,mode) _chmod (path, mode) - #define dup(fd) _dup (fd) - #define dup2(fd1,fd2) _dup2 (fd1, fd2) - - #define fchmod(fd,mode) EIO_ENOSYS () - #define chown(path,uid,gid) EIO_ENOSYS () - #define fchown(fd,uid,gid) EIO_ENOSYS () - #define truncate(path,offs) EIO_ENOSYS () /* far-miss: SetEndOfFile */ - #define ftruncate(fd,offs) EIO_ENOSYS () /* near-miss: SetEndOfFile */ - #define mknod(path,mode,dev) EIO_ENOSYS () - #define sync() EIO_ENOSYS () - #define readlink(path,buf,s) EIO_ENOSYS () - #define statvfs(path,buf) EIO_ENOSYS () - #define fstatvfs(fd,buf) EIO_ENOSYS () - - #define getcwd(buf,s) _getcwd(buf, s) - #define rmdir(path) _rmdir(path) - - /* rename() uses MoveFile, which fails to overwrite */ - #define rename(old,neu) eio__rename (old, neu) - - static int - eio__rename (const char *old, const char *neu) - { - if (MoveFileEx (old, neu, MOVEFILE_REPLACE_EXISTING)) - return 0; - - /* should steal _dosmaperr */ - switch (GetLastError ()) - { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - case ERROR_INVALID_DRIVE: - case ERROR_NO_MORE_FILES: - case ERROR_BAD_NETPATH: - case ERROR_BAD_NET_NAME: - case ERROR_BAD_PATHNAME: - case ERROR_FILENAME_EXCED_RANGE: - errno = ENOENT; - break; - - default: - errno = EACCES; - break; - } - - return -1; - } - - /* we could even stat and see if it exists */ - static int - symlink (const char *old, const char *neu) - { - #if WINVER >= 0x0600 - if (CreateSymbolicLink (neu, old, 1)) - return 0; - - if (CreateSymbolicLink (neu, old, 0)) - return 0; - #endif - - return EIO_ERRNO (ENOENT, -1); - } - - /* POSIX API only */ - #ifndef CreateHardLink - # define CreateHardLink(neu,old,flags) 0 - #endif - #define CreateSymbolicLink(neu,old,flags) 0 - - struct statvfs - { - int dummy; - }; - - #define DT_DIR EIO_DT_DIR - #define DT_REG EIO_DT_REG - #define D_NAME(entp) entp.cFileName - #define D_TYPE(entp) (entp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? DT_DIR : DT_REG) - -#include -#define utime(path, times) _utime(path, times) -#define utimbuf _utimbuf - -#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) - #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 -#else - #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL -#endif - -struct timezone -{ - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - -static int gettimeofday(struct timeval *tv, struct timezone *tz) -{ - FILETIME ft; - unsigned __int64 tmpres = 0; - static int tzflag; - - if (NULL != tv) - { - GetSystemTimeAsFileTime(&ft); - - tmpres |= ft.dwHighDateTime; - tmpres <<= 32; - tmpres |= ft.dwLowDateTime; - - /*converting file time to unix epoch*/ - tmpres -= DELTA_EPOCH_IN_MICROSECS; - tmpres /= 10; /*convert into microseconds*/ - tv->tv_sec = (long)(tmpres / 1000000UL); - tv->tv_usec = (long)(tmpres % 1000000UL); - } - - if (NULL != tz) - { - if (!tzflag) - { - _tzset(); - tzflag++; - } - tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; - } - - return 0; -} - -#else - - #include - #include - #include - #include - #include - #include - - #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES - #include - #endif - - #define D_NAME(entp) entp->d_name - - /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ - #if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ - #define _DIRENT_HAVE_D_TYPE /* sigh */ - #define D_INO(de) (de)->d_fileno - #define D_NAMLEN(de) (de)->d_namlen - #elif __linux || defined d_ino || _XOPEN_SOURCE >= 600 - #define D_INO(de) (de)->d_ino - #endif - - #ifdef _D_EXACT_NAMLEN - #undef D_NAMLEN - #define D_NAMLEN(de) _D_EXACT_NAMLEN (de) - #endif - - #ifdef _DIRENT_HAVE_D_TYPE - #define D_TYPE(de) (de)->d_type - #endif - - #ifndef EIO_STRUCT_DIRENT - #define EIO_STRUCT_DIRENT struct dirent - #endif - -#endif - -#if HAVE_UTIMES -# include -#endif - -#if HAVE_SYS_SYSCALL_H -# include -#endif - -#if HAVE_SYS_PRCTL_H -# include -#endif - -#if HAVE_SENDFILE -# if __linux -# include -# elif __FreeBSD__ || __DragonFly__ || defined __APPLE__ -# include -# include -# elif __hpux -# include -# elif __solaris -# include -# else -# error sendfile support requested but not available -# endif -#endif - -#ifndef D_TYPE -# define D_TYPE(de) 0 -#endif -#ifndef D_INO -# define D_INO(de) 0 -#endif -#ifndef D_NAMLEN -# define D_NAMLEN(entp) strlen (D_NAME (entp)) -#endif - -/* used for struct dirent, AIX doesn't provide it */ -#ifndef NAME_MAX -# define NAME_MAX 4096 -#endif - -/* used for readlink etc. */ -#ifndef PATH_MAX -# define PATH_MAX 4096 -#endif - -/* buffer size for various temporary buffers */ -#define EIO_BUFSIZE 65536 - -#define dBUF \ - char *eio_buf = malloc (EIO_BUFSIZE); \ - errno = ENOMEM; \ - if (!eio_buf) \ - return -1 - -#define FUBd \ - free (eio_buf) - -#define EIO_TICKS ((1000000 + 1023) >> 10) - -struct etp_worker; - -#define ETP_DESTROY(req) eio_destroy (req) -static int eio_finish (eio_req *req); -#define ETP_FINISH(req) eio_finish (req) -static void eio_execute (struct etp_worker *self, eio_req *req); -#define ETP_EXECUTE(wrk,req) eio_execute (wrk,req) - -/*****************************************************************************/ - -/* calculate time difference in ~1/EIO_TICKS of a second */ -ecb_inline int -tvdiff (struct timeval *tv1, struct timeval *tv2) -{ - return (tv2->tv_sec - tv1->tv_sec ) * EIO_TICKS - + ((tv2->tv_usec - tv1->tv_usec) >> 10); -} - -static unsigned int started, idle, wanted = 4; - -static void (*want_poll_cb) (eio_channel *); -static void (*done_poll_cb) (eio_channel *); - -static unsigned int max_poll_time; /* reslock */ -static unsigned int max_poll_reqs; /* reslock */ - -static unsigned int nreqs; /* reqlock */ -static unsigned int nready; /* reqlock */ -static unsigned int npending; /* reqlock */ -static unsigned int max_idle = 4; /* maximum number of threads that can idle indefinitely */ -static unsigned int idle_timeout = 10; /* number of seconds after which an idle threads exit */ - -static xmutex_t wrklock; -static xmutex_t reslock; -static xmutex_t reqlock; -static xcond_t reqwait; - -/* Fix for test-fs-sir-writes-alot */ -/* Apple's OSX can't safely write() concurrently from 2 threads */ -/* for more info see the thread "fs.write Data Munging" in the nodejs google group */ -/* http://groups.google.com/group/nodejs/browse_thread/thread/c11f8b683f37cef/b18ad9e0a15314c5 */ -/* And the thread "write()s and pwrite()s from multiple threads in OSX" in libev@lists.schmorp.de */ -/* http://lists.schmorp.de/pipermail/libev/2010q4/001185.html */ -#if defined (__APPLE__) -static xmutex_t apple_bug_writelock = X_MUTEX_INIT; -#endif - -#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 -{ - /* locked by wrklock */ - struct etp_worker *prev, *next; - - xthread_t tid; - - /* locked by reslock, reqlock or wrklock */ - ETP_REQ *req; /* currently processed request */ - -#ifdef ETP_WORKER_COMMON - ETP_WORKER_COMMON -#endif -} etp_worker; - -static etp_worker wrk_first; /* NOT etp */ - -#define ETP_WORKER_LOCK(wrk) X_LOCK (wrklock) -#define ETP_WORKER_UNLOCK(wrk) X_UNLOCK (wrklock) - -/* worker threads management */ - -static void ecb_cold -etp_worker_clear (etp_worker *wrk) -{ -} - -static void ecb_cold -etp_worker_free (etp_worker *wrk) -{ - wrk->next->prev = wrk->prev; - wrk->prev->next = wrk->next; - - free (wrk); -} - -static unsigned int -etp_nreqs (void) -{ - int retval; - if (WORDACCESS_UNSAFE) X_LOCK (reqlock); - retval = nreqs; - if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); - return retval; -} - -static unsigned int -etp_nready (void) -{ - unsigned int retval; - - if (WORDACCESS_UNSAFE) X_LOCK (reqlock); - retval = nready; - if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); - - return retval; -} - -static unsigned int -etp_npending (void) -{ - unsigned int retval; - - if (WORDACCESS_UNSAFE) X_LOCK (reqlock); - retval = npending; - if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); - - return retval; -} - -static unsigned int -etp_nthreads (void) -{ - unsigned int retval; - - if (WORDACCESS_UNSAFE) X_LOCK (reqlock); - retval = started; - if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); - - return retval; -} - -static etp_reqq req_queue; -static eio_channel default_channel; - -static void ecb_noinline ecb_cold -reqq_init (etp_reqq *q) -{ - int pri; - - for (pri = 0; pri < ETP_NUM_PRI; ++pri) - q->qs[pri] = q->qe[pri] = 0; - - q->size = 0; -} - -static int ecb_noinline -reqq_push (etp_reqq *q, ETP_REQ *req) -{ - int pri = req->pri; - req->next = 0; - - if (q->qe[pri]) - { - q->qe[pri]->next = req; - q->qe[pri] = req; - } - else - q->qe[pri] = q->qs[pri] = req; - - return q->size++; -} - -static ETP_REQ * ecb_noinline -reqq_shift (etp_reqq *q) -{ - int pri; - - if (!q->size) - return 0; - - --q->size; - - for (pri = ETP_NUM_PRI; pri--; ) - { - eio_req *req = q->qs[pri]; - - if (req) - { - if (!(q->qs[pri] = (eio_req *)req->next)) - q->qe[pri] = 0; - - return req; - } - } - - abort (); -} - -static int ecb_cold -etp_init (void (*want_poll)(eio_channel *), void (*done_poll)(eio_channel *)) -{ - X_MUTEX_CREATE (wrklock); - X_MUTEX_CREATE (reslock); - X_MUTEX_CREATE (reqlock); - X_COND_CREATE (reqwait); - - reqq_init (&req_queue); - eio_channel_init (&default_channel, 0); - - wrk_first.next = - wrk_first.prev = &wrk_first; - - started = 0; - idle = 0; - nreqs = 0; - nready = 0; - npending = 0; - - want_poll_cb = want_poll; - done_poll_cb = done_poll; - - return 0; -} - -X_THREAD_PROC (etp_proc); - -static void ecb_cold -etp_start_thread (void) -{ - etp_worker *wrk = calloc (1, sizeof (etp_worker)); - - /*TODO*/ - assert (("unable to allocate worker thread data", wrk)); - - X_LOCK (wrklock); - - if (xthread_create (&wrk->tid, etp_proc, (void *)wrk)) - { - wrk->prev = &wrk_first; - wrk->next = wrk_first.next; - wrk_first.next->prev = wrk; - wrk_first.next = wrk; - ++started; - } - else - free (wrk); - - X_UNLOCK (wrklock); -} - -static void -etp_maybe_start_thread (void) -{ - if (ecb_expect_true (etp_nthreads () >= wanted)) - return; - - /* todo: maybe use idle here, but might be less exact */ - if (ecb_expect_true (0 <= (int)etp_nthreads () + (int)etp_npending () - (int)etp_nreqs ())) - return; - - etp_start_thread (); -} - -static void ecb_cold -etp_end_thread (void) -{ - eio_req *req = calloc (1, sizeof (eio_req)); - - req->type = -1; - req->pri = ETP_PRI_MAX - ETP_PRI_MIN; - - X_LOCK (reqlock); - reqq_push (&req_queue, req); - X_COND_SIGNAL (reqwait); - X_UNLOCK (reqlock); - - X_LOCK (wrklock); - --started; - X_UNLOCK (wrklock); -} - -void -eio_channel_init(eio_channel *channel, void *data) { - reqq_init(&channel->res_queue); - channel->data = data; -} - -static int -etp_poll (eio_channel *channel) -{ - unsigned int maxreqs; - unsigned int maxtime; - struct timeval tv_start, tv_now; - if(!channel) channel = &default_channel; - - X_LOCK (reslock); - maxreqs = max_poll_reqs; - maxtime = max_poll_time; - X_UNLOCK (reslock); - - if (maxtime) - gettimeofday (&tv_start, 0); - - for (;;) - { - ETP_REQ *req; - - etp_maybe_start_thread (); - - X_LOCK (reslock); - req = reqq_shift (&channel->res_queue); - - if (req) - { - --npending; - - if (!channel->res_queue.size && done_poll_cb) - done_poll_cb (channel); - } - - X_UNLOCK (reslock); - - if (!req) - return 0; - - X_LOCK (reqlock); - --nreqs; - X_UNLOCK (reqlock); - - if (ecb_expect_false (req->type == EIO_GROUP && req->size)) - { - req->int1 = 1; /* mark request as delayed */ - continue; - } - else - { - int res = ETP_FINISH (req); - if (ecb_expect_false (res)) - return res; - } - - if (ecb_expect_false (maxreqs && !--maxreqs)) - break; - - if (maxtime) - { - gettimeofday (&tv_now, 0); - - if (tvdiff (&tv_start, &tv_now) >= maxtime) - break; - } - } - - errno = EAGAIN; - return -1; -} - -static void -etp_cancel (ETP_REQ *req) -{ - req->cancelled = 1; - - eio_grp_cancel (req); -} - -static void -etp_submit (ETP_REQ *req) -{ - req->pri -= ETP_PRI_MIN; - - if (ecb_expect_false (req->pri < ETP_PRI_MIN - ETP_PRI_MIN)) req->pri = ETP_PRI_MIN - ETP_PRI_MIN; - if (ecb_expect_false (req->pri > ETP_PRI_MAX - ETP_PRI_MIN)) req->pri = ETP_PRI_MAX - ETP_PRI_MIN; - - if (ecb_expect_false (req->type == EIO_GROUP)) - { - /* I hope this is worth it :/ */ - X_LOCK (reqlock); - ++nreqs; - X_UNLOCK (reqlock); - - X_LOCK (reslock); - - ++npending; - - if (!reqq_push (&req->channel->res_queue, req) && want_poll_cb) - want_poll_cb (req->channel); - - X_UNLOCK (reslock); - } - else - { - X_LOCK (reqlock); - ++nreqs; - ++nready; - reqq_push (&req_queue, req); - X_COND_SIGNAL (reqwait); - X_UNLOCK (reqlock); - - etp_maybe_start_thread (); - } -} - -static void ecb_cold -etp_set_max_poll_time (double nseconds) -{ - if (WORDACCESS_UNSAFE) X_LOCK (reslock); - max_poll_time = nseconds * EIO_TICKS; - if (WORDACCESS_UNSAFE) X_UNLOCK (reslock); -} - -static void ecb_cold -etp_set_max_poll_reqs (unsigned int maxreqs) -{ - if (WORDACCESS_UNSAFE) X_LOCK (reslock); - max_poll_reqs = maxreqs; - if (WORDACCESS_UNSAFE) X_UNLOCK (reslock); -} - -static void ecb_cold -etp_set_max_idle (unsigned int nthreads) -{ - if (WORDACCESS_UNSAFE) X_LOCK (reqlock); - max_idle = nthreads; - if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); -} - -static void ecb_cold -etp_set_idle_timeout (unsigned int seconds) -{ - if (WORDACCESS_UNSAFE) X_LOCK (reqlock); - idle_timeout = seconds; - if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); -} - -static void ecb_cold -etp_set_min_parallel (unsigned int nthreads) -{ - if (wanted < nthreads) - wanted = nthreads; -} - -static void ecb_cold -etp_set_max_parallel (unsigned int nthreads) -{ - if (wanted > nthreads) - wanted = nthreads; - - while (started > wanted) - etp_end_thread (); -} - -/*****************************************************************************/ - -static void -grp_try_feed (eio_req *grp) -{ - while (grp->size < grp->int2 && !EIO_CANCELLED (grp)) - { - grp->flags &= ~EIO_FLAG_GROUPADD; - - EIO_FEED (grp); - - /* stop if no progress has been made */ - if (!(grp->flags & EIO_FLAG_GROUPADD)) - { - grp->feed = 0; - break; - } - } -} - -static int -grp_dec (eio_req *grp) -{ - --grp->size; - - /* call feeder, if applicable */ - grp_try_feed (grp); - - /* finish, if done */ - if (!grp->size && grp->int1) - return eio_finish (grp); - else - return 0; -} - -static void -eio_destroy (eio_req *req) -{ - if ((req)->flags & EIO_FLAG_PTR1_FREE) free (req->ptr1); - if ((req)->flags & EIO_FLAG_PTR2_FREE) free (req->ptr2); - - EIO_DESTROY (req); -} - -static int -eio_finish (eio_req *req) -{ - int res = EIO_FINISH (req); - - if (req->grp) - { - int res2; - eio_req *grp = req->grp; - - /* unlink request */ - if (req->grp_next) req->grp_next->grp_prev = req->grp_prev; - if (req->grp_prev) req->grp_prev->grp_next = req->grp_next; - - if (grp->grp_first == req) - grp->grp_first = req->grp_next; - - res2 = grp_dec (grp); - - if (!res) - res = res2; - } - - eio_destroy (req); - - return res; -} - -void -eio_grp_cancel (eio_req *grp) -{ - for (grp = grp->grp_first; grp; grp = grp->grp_next) - eio_cancel (grp); -} - -void -eio_cancel (eio_req *req) -{ - etp_cancel (req); -} - -void -eio_submit (eio_req *req) -{ - etp_submit (req); -} - -unsigned int -eio_nreqs (void) -{ - return etp_nreqs (); -} - -unsigned int -eio_nready (void) -{ - return etp_nready (); -} - -unsigned int -eio_npending (void) -{ - return etp_npending (); -} - -unsigned int ecb_cold -eio_nthreads (void) -{ - return etp_nthreads (); -} - -void ecb_cold -eio_set_max_poll_time (double nseconds) -{ - etp_set_max_poll_time (nseconds); -} - -void ecb_cold -eio_set_max_poll_reqs (unsigned int maxreqs) -{ - etp_set_max_poll_reqs (maxreqs); -} - -void ecb_cold -eio_set_max_idle (unsigned int nthreads) -{ - etp_set_max_idle (nthreads); -} - -void ecb_cold -eio_set_idle_timeout (unsigned int seconds) -{ - etp_set_idle_timeout (seconds); -} - -void ecb_cold -eio_set_min_parallel (unsigned int nthreads) -{ - etp_set_min_parallel (nthreads); -} - -void ecb_cold -eio_set_max_parallel (unsigned int nthreads) -{ - etp_set_max_parallel (nthreads); -} - -int eio_poll (eio_channel *channel) -{ - return etp_poll (channel); -} - -/*****************************************************************************/ -/* work around various missing functions */ - -#if !HAVE_PREADWRITE -# undef pread -# undef pwrite -# define pread eio__pread -# define pwrite eio__pwrite - -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; -} - -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 -# define utimes(path,times) eio__utimes (path, times) - -static int -eio__utimes (const char *filename, const struct timeval times[2]) -{ - if (times) - { - struct utimbuf buf; - - buf.actime = times[0].tv_sec; - buf.modtime = times[1].tv_sec; - - return utime (filename, &buf); - } - else - return utime (filename, 0); -} - -#endif - -#ifndef HAVE_FUTIMES - -# undef futimes -# define futimes(fd,times) eio__futimes (fd, times) - -static int -eio__futimes (int fd, const struct timeval tv[2]) -{ -#if defined(__linux) && defined(__NR_utimensat) - struct timespec ts[2]; - ts[0].tv_sec = tv[0].tv_sec, ts[0].tv_nsec = tv[0].tv_usec * 1000; - ts[1].tv_sec = tv[1].tv_sec, ts[1].tv_nsec = tv[1].tv_usec * 1000; - return syscall(__NR_utimensat, fd, NULL, ts, 0); -#else - errno = ENOSYS; - return -1; -#endif -} - -#endif - -#if !HAVE_FDATASYNC -# undef fdatasync -# define fdatasync(fd) fsync (fd) -#endif - -static int -eio__syncfs (int fd) -{ - int res; - -#if HAVE_SYS_SYNCFS - res = (int)syscall (__NR_syncfs, (int)(fd)); -#else - res = -1; - errno = ENOSYS; -#endif - - if (res < 0 && errno == ENOSYS && fd >= 0) - sync (); - - return res; -} - -/* sync_file_range always needs emulation */ -static int -eio__sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags) -{ -#if HAVE_SYNC_FILE_RANGE - int res; - - if (EIO_SYNC_FILE_RANGE_WAIT_BEFORE != SYNC_FILE_RANGE_WAIT_BEFORE - || EIO_SYNC_FILE_RANGE_WRITE != SYNC_FILE_RANGE_WRITE - || EIO_SYNC_FILE_RANGE_WAIT_AFTER != SYNC_FILE_RANGE_WAIT_AFTER) - { - flags = 0 - | (flags & EIO_SYNC_FILE_RANGE_WAIT_BEFORE ? SYNC_FILE_RANGE_WAIT_BEFORE : 0) - | (flags & EIO_SYNC_FILE_RANGE_WRITE ? SYNC_FILE_RANGE_WRITE : 0) - | (flags & EIO_SYNC_FILE_RANGE_WAIT_AFTER ? SYNC_FILE_RANGE_WAIT_AFTER : 0); - } - - res = sync_file_range (fd, offset, nbytes, flags); - - if (!res || errno != ENOSYS) - return res; -#endif - - /* even though we could play tricks with the flags, it's better to always - * call fdatasync, as that matches the expectation of its users best */ - return fdatasync (fd); -} - -static int -eio__fallocate (int fd, int mode, off_t offset, size_t len) -{ -#if HAVE_FALLOCATE - return fallocate (fd, mode, offset, len); -#else - errno = ENOSYS; - return -1; -#endif -} - -#if !HAVE_READAHEAD -# undef readahead -# define readahead(fd,offset,count) eio__readahead (fd, offset, count, self) - -static eio_ssize_t -eio__readahead (int fd, off_t offset, size_t count, etp_worker *self) -{ - size_t todo = count; - dBUF; - - while (todo > 0) - { - size_t len = todo < EIO_BUFSIZE ? todo : EIO_BUFSIZE; - - pread (fd, eio_buf, len, offset); - offset += len; - todo -= len; - } - - FUBd; - - errno = 0; - return count; -} - -#endif - -/* sendfile always needs emulation */ -static eio_ssize_t -eio__sendfile (int ofd, int ifd, off_t offset, size_t count) -{ - eio_ssize_t written = 0; - eio_ssize_t res; - - if (!count) - return 0; - - for (;;) - { -#ifdef __APPLE__ -# undef HAVE_SENDFILE /* broken, as everything on os x */ -#endif -#if HAVE_SENDFILE -# if __linux - off_t soffset = offset; - res = sendfile (ofd, ifd, &soffset, count); - -# elif __FreeBSD__ - /* - * Of course, the freebsd sendfile is a dire hack with no thoughts - * wasted on making it similar to other I/O functions. - */ - off_t sbytes; - res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); - - #if 0 /* according to the manpage, this is correct, but broken behaviour */ - /* freebsd' sendfile will return 0 on success */ - /* freebsd 8 documents it as only setting *sbytes on EINTR and EAGAIN, but */ - /* not on e.g. EIO or EPIPE - sounds broken */ - if ((res < 0 && (errno == EAGAIN || errno == EINTR) && sbytes) || res == 0) - res = sbytes; - #endif - - /* according to source inspection, this is correct, and useful behaviour */ - if (sbytes) - res = sbytes; - -# elif defined (__APPLE__) - off_t sbytes = count; - res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); - - /* according to the manpage, sbytes is always valid */ - if (sbytes) - res = sbytes; - -# elif __hpux - res = sendfile (ofd, ifd, offset, count, 0, 0); - -# elif __solaris - struct sendfilevec vec; - size_t sbytes; - - vec.sfv_fd = ifd; - vec.sfv_flag = 0; - vec.sfv_off = offset; - vec.sfv_len = count; - - res = sendfilev (ofd, &vec, 1, &sbytes); - - if (res < 0 && sbytes) - res = sbytes; - -# endif - -#elif defined (_WIN32) && 0 - /* does not work, just for documentation of what would need to be done */ - /* actually, cannot be done like this, as TransmitFile changes the file offset, */ - /* libeio guarantees that the file offset does not change, and windows */ - /* has no way to get an independent handle to the same file description */ - HANDLE h = TO_SOCKET (ifd); - SetFilePointer (h, offset, 0, FILE_BEGIN); - res = TransmitFile (TO_SOCKET (ofd), h, count, 0, 0, 0, 0); - -#else - res = -1; - errno = ENOSYS; -#endif - - /* we assume sendfile can copy at least 128mb in one go */ - if (res <= 128 * 1024 * 1024) - { - if (res > 0) - written += res; - - if (written) - return written; - - break; - } - else - { - /* if we requested more, then probably the kernel was lazy */ - written += res; - offset += res; - count -= res; - - if (!count) - return written; - } - } - - if (res < 0 - && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK - /* BSDs */ -#ifdef ENOTSUP /* sigh, if the steenking pile called openbsd would only try to at least compile posix code... */ - || errno == ENOTSUP -#endif -#ifdef EOPNOTSUPP /* windows */ - || errno == EOPNOTSUPP /* BSDs */ -#endif -#if __solaris - || errno == EAFNOSUPPORT || errno == EPROTOTYPE -#endif - ) - ) - { - /* emulate sendfile. this is a major pain in the ass */ - dBUF; - - res = 0; - - while (count) - { - eio_ssize_t cnt; - - cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset); - - if (cnt <= 0) - { - if (cnt && !res) res = -1; - break; - } - - cnt = write (ofd, eio_buf, cnt); - - if (cnt <= 0) - { - if (cnt && !res) res = -1; - break; - } - - offset += cnt; - res += cnt; - count -= cnt; - } - - FUBd; - } - - return res; -} - -#ifdef PAGESIZE -# define eio_pagesize() PAGESIZE -#else -static intptr_t -eio_pagesize (void) -{ - static intptr_t page; - - if (!page) - page = sysconf (_SC_PAGESIZE); - - return page; -} -#endif - -static void -eio_page_align (void **addr, size_t *length) -{ - intptr_t mask = eio_pagesize () - 1; - - /* round down addr */ - intptr_t adj = mask & (intptr_t)*addr; - - *addr = (void *)((intptr_t)*addr - adj); - *length += adj; - - /* round up length */ - *length = (*length + mask) & ~mask; -} - -#if !_POSIX_MEMLOCK -# define eio__mlockall(a) EIO_ENOSYS () -#else - -static int -eio__mlockall (int flags) -{ - #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 - extern int mallopt (int, int); - mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */ - #endif - - if (EIO_MCL_CURRENT != MCL_CURRENT - || EIO_MCL_FUTURE != MCL_FUTURE) - { - flags = 0 - | (flags & EIO_MCL_CURRENT ? MCL_CURRENT : 0) - | (flags & EIO_MCL_FUTURE ? MCL_FUTURE : 0); - } - - return mlockall (flags); -} -#endif - -#if !_POSIX_MEMLOCK_RANGE -# define eio__mlock(a,b) EIO_ENOSYS () -#else - -static int -eio__mlock (void *addr, size_t length) -{ - eio_page_align (&addr, &length); - - return mlock (addr, length); -} - -#endif - -#if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO) -# define eio__msync(a,b,c) EIO_ENOSYS () -#else - -static int -eio__msync (void *mem, size_t len, int flags) -{ - eio_page_align (&mem, &len); - - if (EIO_MS_ASYNC != MS_SYNC - || EIO_MS_INVALIDATE != MS_INVALIDATE - || EIO_MS_SYNC != MS_SYNC) - { - flags = 0 - | (flags & EIO_MS_ASYNC ? MS_ASYNC : 0) - | (flags & EIO_MS_INVALIDATE ? MS_INVALIDATE : 0) - | (flags & EIO_MS_SYNC ? MS_SYNC : 0); - } - - return msync (mem, len, flags); -} - -#endif - -static int -eio__mtouch (eio_req *req) -{ - void *mem = req->ptr2; - size_t len = req->size; - int flags = req->int1; - - eio_page_align (&mem, &len); - - { - intptr_t addr = (intptr_t)mem; - intptr_t end = addr + len; - intptr_t page = eio_pagesize (); - - if (addr < end) - if (flags & EIO_MT_MODIFY) /* modify */ - do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len && !EIO_CANCELLED (req)); - else - do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len && !EIO_CANCELLED (req)); - } - - return 0; -} - -/*****************************************************************************/ -/* requests implemented outside eio_execute, because they are so large */ - -static void -eio__realpath (eio_req *req, etp_worker *self) -{ - char *rel = req->ptr1; - char *res; - char *tmp1, *tmp2; -#if SYMLOOP_MAX > 32 - int symlinks = SYMLOOP_MAX; -#else - int symlinks = 32; -#endif - - req->result = -1; - - errno = EINVAL; - if (!rel) - return; - - errno = ENOENT; - if (!*rel) - return; - - if (!req->ptr2) - { - X_LOCK (wrklock); - req->flags |= EIO_FLAG_PTR2_FREE; - X_UNLOCK (wrklock); - req->ptr2 = malloc (PATH_MAX * 3); - - errno = ENOMEM; - if (!req->ptr2) - return; - } - - res = req->ptr2; - tmp1 = res + PATH_MAX; - tmp2 = tmp1 + PATH_MAX; - -#if 0 /* disabled, the musl way to do things is just too racy */ -#if __linux && defined(O_NONBLOCK) && defined(O_NOATIME) - /* on linux we may be able to ask the kernel */ - { - int fd = open (rel, O_RDONLY | O_NONBLOCK | O_NOCTTY | O_NOATIME); - - if (fd >= 0) - { - sprintf (tmp1, "/proc/self/fd/%d", fd); - req->result = readlink (tmp1, res, PATH_MAX); - close (fd); - - /* here we should probably stat the open file and the disk file, to make sure they still match */ - - if (req->result > 0) - goto done; - } - else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO) - return; - } -#endif -#endif - - if (*rel != '/') - { - if (!getcwd (res, PATH_MAX)) - return; - - if (res [1]) /* only use if not / */ - res += strlen (res); - } - - while (*rel) - { - eio_ssize_t len, linklen; - char *beg = rel; - - while (*rel && *rel != '/') - ++rel; - - len = rel - beg; - - if (!len) /* skip slashes */ - { - ++rel; - continue; - } - - if (beg [0] == '.') - { - if (len == 1) - continue; /* . - nop */ - - if (beg [1] == '.' && len == 2) - { - /* .. - back up one component, if possible */ - - while (res != req->ptr2) - if (*--res == '/') - break; - - continue; - } - } - - errno = ENAMETOOLONG; - if (res + 1 + len + 1 >= tmp1) - return; - - /* copy one component */ - *res = '/'; - memcpy (res + 1, beg, len); - - /* zero-terminate, for readlink */ - res [len + 1] = 0; - - /* now check if it's a symlink */ - linklen = readlink (req->ptr2, tmp1, PATH_MAX); - - if (linklen < 0) - { - if (errno != EINVAL) - return; - - /* it's a normal directory. hopefully */ - res += len + 1; - } - else - { - /* yay, it was a symlink - build new path in tmp2 */ - int rellen = strlen (rel); - - errno = ENAMETOOLONG; - if (linklen + 1 + rellen >= PATH_MAX) - return; - - errno = ELOOP; - if (!--symlinks) - return; - - if (*tmp1 == '/') - res = req->ptr2; /* symlink resolves to an absolute path */ - - /* we need to be careful, as rel might point into tmp2 already */ - memmove (tmp2 + linklen + 1, rel, rellen + 1); - tmp2 [linklen] = '/'; - memcpy (tmp2, tmp1, linklen); - - rel = tmp2; - } - } - - /* special case for the lone root path */ - if (res == req->ptr2) - *res++ = '/'; - - req->result = res - (char *)req->ptr2; - -done: - req->ptr2 = realloc (req->ptr2, req->result); /* trade time for space savings */ -} - -static signed char -eio_dent_cmp (const eio_dirent *a, const eio_dirent *b) -{ - return a->score - b->score ? a->score - b->score /* works because our signed char is always 0..100 */ - : a->inode < b->inode ? -1 - : a->inode > b->inode ? 1 - : 0; -} - -#define EIO_DENT_CMP(i,op,j) eio_dent_cmp (&i, &j) op 0 - -#define EIO_SORT_CUTOFF 30 /* quite high, but performs well on many filesystems */ -#define EIO_SORT_FAST 60 /* when to only use insertion sort */ - -static void -eio_dent_radix_sort (eio_dirent *dents, int size, signed char score_bits, eio_ino_t inode_bits) -{ - unsigned char bits [9 + sizeof (eio_ino_t) * 8]; - unsigned char *bit = bits; - - assert (CHAR_BIT == 8); - assert (sizeof (eio_dirent) * 8 < 256); - assert (offsetof (eio_dirent, inode)); /* we use bit #0 as sentinel */ - assert (offsetof (eio_dirent, score)); /* we use bit #0 as sentinel */ - - if (size <= EIO_SORT_FAST) - return; - - /* first prepare an array of bits to test in our radix sort */ - /* try to take endianness into account, as well as differences in eio_ino_t sizes */ - /* inode_bits must contain all inodes ORed together */ - /* which is used to skip bits that are 0 everywhere, which is very common */ - { - eio_ino_t endianness; - int i, j; - - /* we store the byte offset of byte n into byte n of "endianness" */ - for (i = 0; i < sizeof (eio_ino_t); ++i) - ((unsigned char *)&endianness)[i] = i; - - *bit++ = 0; - - for (i = 0; i < sizeof (eio_ino_t); ++i) - { - /* shifting off the byte offsets out of "endianness" */ - int offs = (offsetof (eio_dirent, inode) + (endianness & 0xff)) * 8; - endianness >>= 8; - - for (j = 0; j < 8; ++j) - if (inode_bits & (((eio_ino_t)1) << (i * 8 + j))) - *bit++ = offs + j; - } - - for (j = 0; j < 8; ++j) - if (score_bits & (1 << j)) - *bit++ = offsetof (eio_dirent, score) * 8 + j; - } - - /* now actually do the sorting (a variant of MSD radix sort) */ - { - eio_dirent *base_stk [9 + sizeof (eio_ino_t) * 8], *base; - eio_dirent *end_stk [9 + sizeof (eio_ino_t) * 8], *end; - unsigned char *bit_stk [9 + sizeof (eio_ino_t) * 8]; - int stk_idx = 0; - - base_stk [stk_idx] = dents; - end_stk [stk_idx] = dents + size; - bit_stk [stk_idx] = bit - 1; - - do - { - base = base_stk [stk_idx]; - end = end_stk [stk_idx]; - bit = bit_stk [stk_idx]; - - for (;;) - { - unsigned char O = *bit >> 3; - unsigned char M = 1 << (*bit & 7); - - eio_dirent *a = base; - eio_dirent *b = end; - - if (b - a < EIO_SORT_CUTOFF) - break; - - /* now bit-partition the array on the bit */ - /* this ugly asymmetric loop seems to perform much better than typical */ - /* partition algos found in the literature */ - do - if (!(((unsigned char *)a)[O] & M)) - ++a; - else if (!(((unsigned char *)--b)[O] & M)) - { - eio_dirent tmp = *a; *a = *b; *b = tmp; - ++a; - } - while (b > a); - - /* next bit, or stop, if no bits left in this path */ - if (!*--bit) - break; - - base_stk [stk_idx] = a; - end_stk [stk_idx] = end; - bit_stk [stk_idx] = bit; - ++stk_idx; - - end = a; - } - } - while (stk_idx--); - } -} - -static void -eio_dent_insertion_sort (eio_dirent *dents, int size) -{ - /* first move the smallest element to the front, to act as a sentinel */ - { - int i; - eio_dirent *min = dents; - - /* the radix pre-pass ensures that the minimum element is in the first EIO_SORT_CUTOFF + 1 elements */ - for (i = size > EIO_SORT_FAST ? EIO_SORT_CUTOFF + 1 : size; --i; ) - if (EIO_DENT_CMP (dents [i], <, *min)) - min = &dents [i]; - - /* swap elements 0 and j (minimum) */ - { - eio_dirent tmp = *dents; *dents = *min; *min = tmp; - } - } - - /* then do standard insertion sort, assuming that all elements are >= dents [0] */ - { - eio_dirent *i, *j; - - for (i = dents + 1; i < dents + size; ++i) - { - eio_dirent value = *i; - - for (j = i - 1; EIO_DENT_CMP (*j, >, value); --j) - j [1] = j [0]; - - j [1] = value; - } - } -} - -static void -eio_dent_sort (eio_dirent *dents, int size, signed char score_bits, eio_ino_t inode_bits) -{ - if (size <= 1) - return; /* our insertion sort relies on size > 0 */ - - /* first we use a radix sort, but only for dirs >= EIO_SORT_FAST */ - /* and stop sorting when the partitions are <= EIO_SORT_CUTOFF */ - eio_dent_radix_sort (dents, size, score_bits, inode_bits); - - /* use an insertion sort at the end, or for small arrays, */ - /* as insertion sort is more efficient for small partitions */ - eio_dent_insertion_sort (dents, size); -} - -/* read a full directory */ -static void -eio__scandir (eio_req *req, etp_worker *self) -{ - char *name, *names; - int namesalloc = 4096 - sizeof (void *) * 4; - int namesoffs = 0; - int flags = req->int1; - eio_dirent *dents = 0; - int dentalloc = 128; - int dentoffs = 0; - eio_ino_t inode_bits = 0; -#ifdef _WIN32 - HANDLE dirp; - WIN32_FIND_DATA entp; -#else - DIR *dirp; - EIO_STRUCT_DIRENT *entp; -#endif - - req->result = -1; - - if (!(flags & EIO_READDIR_DENTS)) - flags &= ~(EIO_READDIR_DIRS_FIRST | EIO_READDIR_STAT_ORDER); - -#ifdef _WIN32 - { - int len = strlen ((const char *)req->ptr1); - char *path = malloc (MAX_PATH); - const char *fmt; - - if (!len) - fmt = "./*"; - else if (((const char *)req->ptr1)[len - 1] == '/' || ((const char *)req->ptr1)[len - 1] == '\\') - fmt = "%s*"; - else - fmt = "%s/*"; - - _snprintf (path, MAX_PATH, fmt, (const char *)req->ptr1); - dirp = FindFirstFile (path, &entp); - free (path); - - if (dirp == INVALID_HANDLE_VALUE) - { - dirp = 0; - - /* should steal _dosmaperr */ - switch (GetLastError ()) - { - case ERROR_FILE_NOT_FOUND: - req->result = 0; - break; - - case ERROR_INVALID_NAME: - case ERROR_PATH_NOT_FOUND: - case ERROR_NO_MORE_FILES: - errno = ENOENT; - break; - - case ERROR_NOT_ENOUGH_MEMORY: - errno = ENOMEM; - break; - - default: - errno = EINVAL; - break; - } - } - } -#else - dirp = opendir (req->ptr1); -#endif - - if (req->flags & EIO_FLAG_PTR1_FREE) - free (req->ptr1); - - req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE; - req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0; - req->ptr2 = names = malloc (namesalloc); - - if (dirp && names && (!flags || dents)) - for (;;) - { - int done; - -#ifdef _WIN32 - done = !dirp; -#else - errno = 0; - entp = readdir (dirp); - done = !entp; -#endif - - if (done) - { -#ifndef _WIN32 - int old_errno = errno; - closedir (dirp); - errno = old_errno; - - if (errno) - break; -#endif - - /* sort etc. */ - req->int1 = flags; - req->result = dentoffs; - - if (flags & EIO_READDIR_STAT_ORDER) - eio_dent_sort (dents, dentoffs, flags & EIO_READDIR_DIRS_FIRST ? 7 : 0, inode_bits); - else if (flags & EIO_READDIR_DIRS_FIRST) - if (flags & EIO_READDIR_FOUND_UNKNOWN) - eio_dent_sort (dents, dentoffs, 7, inode_bits); /* sort by score and inode */ - else - { - /* in this case, all is known, and we just put dirs first and sort them */ - eio_dirent *oth = dents + dentoffs; - eio_dirent *dir = dents; - - /* now partition dirs to the front, and non-dirs to the back */ - /* by walking from both sides and swapping if necessary */ - while (oth > dir) - { - if (dir->type == EIO_DT_DIR) - ++dir; - else if ((--oth)->type == EIO_DT_DIR) - { - eio_dirent tmp = *dir; *dir = *oth; *oth = tmp; - - ++dir; - } - } - - /* now sort the dirs only (dirs all have the same score) */ - eio_dent_sort (dents, dir - dents, 0, inode_bits); - } - - break; - } - - /* now add the entry to our list(s) */ - name = D_NAME (entp); - - /* skip . and .. entries */ - if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2]))) - { - int len = D_NAMLEN (entp) + 1; - - while (ecb_expect_false (namesoffs + len > namesalloc)) - { - namesalloc *= 2; - req->ptr2 = names = realloc (names, namesalloc); - - if (!names) - break; - } - - memcpy (names + namesoffs, name, len); - - if (dents) - { - struct eio_dirent *ent; - - if (ecb_expect_false (dentoffs == dentalloc)) - { - dentalloc *= 2; - req->ptr1 = dents = realloc (dents, dentalloc * sizeof (eio_dirent)); - - if (!dents) - break; - } - - ent = dents + dentoffs; - - ent->nameofs = namesoffs; /* rather dirtily we store the offset in the pointer */ - ent->namelen = len - 1; - ent->inode = D_INO (entp); - - inode_bits |= ent->inode; - - switch (D_TYPE (entp)) - { - default: - ent->type = EIO_DT_UNKNOWN; - flags |= EIO_READDIR_FOUND_UNKNOWN; - break; - - #ifdef DT_FIFO - case DT_FIFO: ent->type = EIO_DT_FIFO; break; - #endif - #ifdef DT_CHR - case DT_CHR: ent->type = EIO_DT_CHR; break; - #endif - #ifdef DT_MPC - case DT_MPC: ent->type = EIO_DT_MPC; break; - #endif - #ifdef DT_DIR - case DT_DIR: ent->type = EIO_DT_DIR; break; - #endif - #ifdef DT_NAM - case DT_NAM: ent->type = EIO_DT_NAM; break; - #endif - #ifdef DT_BLK - case DT_BLK: ent->type = EIO_DT_BLK; break; - #endif - #ifdef DT_MPB - case DT_MPB: ent->type = EIO_DT_MPB; break; - #endif - #ifdef DT_REG - case DT_REG: ent->type = EIO_DT_REG; break; - #endif - #ifdef DT_NWK - case DT_NWK: ent->type = EIO_DT_NWK; break; - #endif - #ifdef DT_CMP - case DT_CMP: ent->type = EIO_DT_CMP; break; - #endif - #ifdef DT_LNK - case DT_LNK: ent->type = EIO_DT_LNK; break; - #endif - #ifdef DT_SOCK - case DT_SOCK: ent->type = EIO_DT_SOCK; break; - #endif - #ifdef DT_DOOR - case DT_DOOR: ent->type = EIO_DT_DOOR; break; - #endif - #ifdef DT_WHT - case DT_WHT: ent->type = EIO_DT_WHT; break; - #endif - } - - ent->score = 7; - - if (flags & EIO_READDIR_DIRS_FIRST) - { - if (ent->type == EIO_DT_UNKNOWN) - { - if (*name == '.') /* leading dots are likely directories, and, in any case, rare */ - ent->score = 1; - else if (!strchr (name, '.')) /* absense of dots indicate likely dirs */ - ent->score = len <= 2 ? 4 - len : len <= 4 ? 4 : len <= 7 ? 5 : 6; /* shorter == more likely dir, but avoid too many classes */ - } - else if (ent->type == EIO_DT_DIR) - ent->score = 0; - } - } - - namesoffs += len; - ++dentoffs; - } - - if (EIO_CANCELLED (req)) - { - errno = ECANCELED; - break; - } - -#ifdef _WIN32 - if (!FindNextFile (dirp, &entp)) - { - FindClose (dirp); - dirp = 0; - } -#endif - } -} - -/*****************************************************************************/ - -#define ALLOC(len) \ - if (!req->ptr2) \ - { \ - X_LOCK (wrklock); \ - req->flags |= EIO_FLAG_PTR2_FREE; \ - X_UNLOCK (wrklock); \ - req->ptr2 = malloc (len); \ - if (!req->ptr2) \ - { \ - errno = ENOMEM; \ - req->result = -1; \ - break; \ - } \ - } - -X_THREAD_PROC (etp_proc) -{ - ETP_REQ *req; - struct timespec ts; - etp_worker *self = (etp_worker *)thr_arg; - -#if HAVE_PRCTL_SET_NAME - prctl (PR_SET_NAME, (unsigned long)"eio_thread", 0, 0, 0); -#endif - - /* try to distribute timeouts somewhat evenly */ - ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); - - for (;;) - { - ts.tv_sec = 0; - - X_LOCK (reqlock); - - for (;;) - { - self->req = req = reqq_shift (&req_queue); - - if (req) - break; - - if (ts.tv_sec == 1) /* no request, but timeout detected, let's quit */ - { - X_UNLOCK (reqlock); - X_LOCK (wrklock); - --started; - X_UNLOCK (wrklock); - goto quit; - } - - ++idle; - - if (idle <= max_idle) - /* we are allowed to idle, so do so without any timeout */ - X_COND_WAIT (reqwait, reqlock); - else - { - /* initialise timeout once */ - if (!ts.tv_sec) - ts.tv_sec = time (0) + idle_timeout; - - if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) == ETIMEDOUT) - ts.tv_sec = 1; /* assuming this is not a value computed above.,.. */ - } - - --idle; - } - - --nready; - - X_UNLOCK (reqlock); - - if (req->type < 0) - goto quit; - - ETP_EXECUTE (self, req); - - X_LOCK (reslock); - - ++npending; - - if (!reqq_push (&req->channel->res_queue, req) && want_poll_cb) - want_poll_cb (req->channel); - - self->req = 0; - etp_worker_clear (self); - - X_UNLOCK (reslock); - } - -quit: - X_LOCK (wrklock); - etp_worker_free (self); - X_UNLOCK (wrklock); - - return 0; -} - -/*****************************************************************************/ - -int ecb_cold -eio_init (void (*want_poll)(eio_channel *), void (*done_poll)(eio_channel *)) -{ -#if !HAVE_PREADWRITE - X_MUTEX_CREATE (preadwritelock); -#endif - - return etp_init (want_poll, done_poll); -} - -ecb_inline void -eio_api_destroy (eio_req *req) -{ - free (req); -} - -#define REQ(rtype) \ - eio_req *req; \ - \ - req = (eio_req *)calloc (1, sizeof *req); \ - if (!req) \ - return 0; \ - \ - req->type = rtype; \ - req->pri = pri; \ - req->finish = cb; \ - req->data = data; \ - req->destroy = eio_api_destroy; \ - req->channel = channel - -#define SEND eio_submit (req); return req - -#define PATH \ - req->flags |= EIO_FLAG_PTR1_FREE; \ - req->ptr1 = strdup (path); \ - if (!req->ptr1) \ - { \ - eio_api_destroy (req); \ - return 0; \ - } - -static void -eio_execute (etp_worker *self, eio_req *req) -{ - if (ecb_expect_false (EIO_CANCELLED (req))) - { - req->result = -1; - req->errorno = ECANCELED; - return; - } - - switch (req->type) - { - case EIO_READ: ALLOC (req->size); - req->result = req->offs >= 0 - ? pread (req->int1, req->ptr2, req->size, req->offs) - : read (req->int1, req->ptr2, req->size); break; - - case EIO_WRITE: -#if defined (__APPLE__) - pthread_mutex_lock (&apple_bug_writelock); -#endif - - req->result = req->offs >= 0 - ? pwrite (req->int1, req->ptr2, req->size, req->offs) - : write (req->int1, req->ptr2, req->size); - -#if defined (__APPLE__) - pthread_mutex_unlock (&apple_bug_writelock); -#endif - break; - - case EIO_READAHEAD: req->result = readahead (req->int1, req->offs, req->size); break; - case EIO_SENDFILE: req->result = eio__sendfile (req->int1, req->int2, req->offs, req->size); break; - - case EIO_STAT: ALLOC (sizeof (EIO_STRUCT_STAT)); - req->result = stat (req->ptr1, (EIO_STRUCT_STAT *)req->ptr2); break; - case EIO_LSTAT: ALLOC (sizeof (EIO_STRUCT_STAT)); - req->result = lstat (req->ptr1, (EIO_STRUCT_STAT *)req->ptr2); break; - case EIO_FSTAT: ALLOC (sizeof (EIO_STRUCT_STAT)); - req->result = fstat (req->int1, (EIO_STRUCT_STAT *)req->ptr2); break; - - case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS)); - req->result = statvfs (req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break; - case EIO_FSTATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS)); - req->result = fstatvfs (req->int1, (EIO_STRUCT_STATVFS *)req->ptr2); break; - - case EIO_CHOWN: req->result = chown (req->ptr1, req->int2, req->int3); break; - case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break; - case EIO_CHMOD: req->result = chmod (req->ptr1, (eio_mode_t)req->int2); break; - case EIO_FCHMOD: req->result = fchmod (req->int1, (eio_mode_t)req->int2); break; - case EIO_TRUNCATE: req->result = truncate (req->ptr1, req->offs); break; - case EIO_FTRUNCATE: req->result = ftruncate (req->int1, req->offs); break; - - case EIO_OPEN: req->result = open (req->ptr1, req->int1, (eio_mode_t)req->int2); break; - case EIO_CLOSE: req->result = close (req->int1); break; - case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break; - case EIO_UNLINK: req->result = unlink (req->ptr1); break; - case EIO_RMDIR: req->result = rmdir (req->ptr1); break; - case EIO_MKDIR: req->result = mkdir (req->ptr1, (eio_mode_t)req->int2); break; - case EIO_RENAME: req->result = rename (req->ptr1, req->ptr2); break; - case EIO_LINK: req->result = link (req->ptr1, req->ptr2); break; - case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break; - case EIO_MKNOD: req->result = mknod (req->ptr1, (eio_mode_t)req->int2, (dev_t)req->offs); break; - - case EIO_REALPATH: eio__realpath (req, self); break; - - case EIO_READLINK: ALLOC (PATH_MAX); - req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break; - - case EIO_SYNC: req->result = 0; sync (); break; - case EIO_FSYNC: req->result = fsync (req->int1); break; - case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; - case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break; - case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break; - case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break; - case EIO_MTOUCH: req->result = eio__mtouch (req); break; - case EIO_MLOCK: req->result = eio__mlock (req->ptr2, req->size); break; - case EIO_MLOCKALL: req->result = eio__mlockall (req->int1); break; - case EIO_FALLOCATE: req->result = eio__fallocate (req->int1, req->int2, req->offs, req->size); break; - - case EIO_READDIR: eio__scandir (req, self); break; - - case EIO_BUSY: -#ifdef _WIN32 - Sleep (req->nv1 * 1e3); -#else - { - struct timeval tv; - - tv.tv_sec = req->nv1; - tv.tv_usec = (req->nv1 - tv.tv_sec) * 1e6; - - req->result = select (0, 0, 0, 0, &tv); - } -#endif - break; - - case EIO_UTIME: - case EIO_FUTIME: - { - struct timeval tv[2]; - struct timeval *times; - - if (req->nv1 != -1. || req->nv2 != -1.) - { - tv[0].tv_sec = req->nv1; - tv[0].tv_usec = (req->nv1 - tv[0].tv_sec) * 1000000.; - tv[1].tv_sec = req->nv2; - tv[1].tv_usec = (req->nv2 - tv[1].tv_sec) * 1000000.; - - times = tv; - } - else - times = 0; - - req->result = req->type == EIO_FUTIME - ? futimes (req->int1, times) - : utimes (req->ptr1, times); - } - break; - - case EIO_GROUP: - abort (); /* handled in eio_request */ - - case EIO_NOP: - req->result = 0; - break; - - case EIO_CUSTOM: - req->feed (req); - break; - - default: - errno = ENOSYS; - req->result = -1; - break; - } - - req->errorno = errno; -} - -#ifndef EIO_NO_WRAPPERS - -eio_req *eio_nop (int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_NOP); SEND; -} - -eio_req *eio_busy (double delay, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_BUSY); req->nv1 = delay; SEND; -} - -eio_req *eio_sync (int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_SYNC); SEND; -} - -eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FSYNC); req->int1 = fd; SEND; -} - -eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_MSYNC); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; -} - -eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FDATASYNC); req->int1 = fd; SEND; -} - -eio_req *eio_syncfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_SYNCFS); req->int1 = fd; SEND; -} - -eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_SYNC_FILE_RANGE); req->int1 = fd; req->offs = offset; req->size = nbytes; req->int2 = flags; SEND; -} - -eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_MTOUCH); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; -} - -eio_req *eio_mlock (void *addr, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_MLOCK); req->ptr2 = addr; req->size = length; SEND; -} - -eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_MLOCKALL); req->int1 = flags; SEND; -} - -eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FALLOCATE); req->int1 = fd; req->int2 = mode; req->offs = offset; req->size = len; SEND; -} - -eio_req *eio_close (int fd, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_CLOSE); req->int1 = fd; SEND; -} - -eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_READAHEAD); req->int1 = fd; req->offs = offset; req->size = length; SEND; -} - -eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_READ); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND; -} - -eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_WRITE); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND; -} - -eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FSTAT); req->int1 = fd; SEND; -} - -eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FSTATVFS); req->int1 = fd; SEND; -} - -eio_req *eio_futime (int fd, double atime, double mtime, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FUTIME); req->int1 = fd; req->nv1 = atime; req->nv2 = mtime; SEND; -} - -eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FTRUNCATE); req->int1 = fd; req->offs = offset; SEND; -} - -eio_req *eio_fchmod (int fd, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; -} - -eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; -} - -eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_DUP2); req->int1 = fd; req->int2 = fd2; SEND; -} - -eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_SENDFILE); req->int1 = out_fd; req->int2 = in_fd; req->offs = in_offset; req->size = length; SEND; -} - -eio_req *eio_open (const char *path, int flags, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_OPEN); PATH; req->int1 = flags; req->int2 = (long)mode; SEND; -} - -eio_req *eio_utime (const char *path, double atime, double mtime, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_UTIME); PATH; req->nv1 = atime; req->nv2 = mtime; SEND; -} - -eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; -} - -eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; -} - -eio_req *eio_chmod (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_CHMOD); PATH; req->int2 = (long)mode; SEND; -} - -eio_req *eio_mkdir (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_MKDIR); PATH; req->int2 = (long)mode; SEND; -} - -static eio_req * -eio__1path (int type, const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (type); PATH; SEND; -} - -eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__1path (EIO_READLINK, path, pri, cb, data, channel); -} - -eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__1path (EIO_REALPATH, path, pri, cb, data, channel); -} - -eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__1path (EIO_STAT, path, pri, cb, data, channel); -} - -eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__1path (EIO_LSTAT, path, pri, cb, data, channel); -} - -eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__1path (EIO_STATVFS, path, pri, cb, data, channel); -} - -eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__1path (EIO_UNLINK, path, pri, cb, data, channel); -} - -eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__1path (EIO_RMDIR, path, pri, cb, data, channel); -} - -eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_READDIR); PATH; req->int1 = flags; SEND; -} - -eio_req *eio_mknod (const char *path, eio_mode_t mode, dev_t dev, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->offs = (off_t)dev; SEND; -} - -static eio_req * -eio__2path (int type, const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (type); PATH; - - req->flags |= EIO_FLAG_PTR2_FREE; - req->ptr2 = strdup (new_path); - if (!req->ptr2) - { - eio_api_destroy (req); - return 0; - } - - SEND; -} - -eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__2path (EIO_LINK, path, new_path, pri, cb, data, channel); -} - -eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__2path (EIO_SYMLINK, path, new_path, pri, cb, data, channel); -} - -eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel) -{ - return eio__2path (EIO_RENAME, path, new_path, pri, cb, data, channel); -} - -eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data, eio_channel *channel) -{ - REQ (EIO_CUSTOM); req->feed = execute; SEND; -} - -#endif - -eio_req *eio_grp (eio_cb cb, void *data, eio_channel *channel) -{ - const int pri = EIO_PRI_MAX; - - REQ (EIO_GROUP); SEND; -} - -#undef REQ -#undef PATH -#undef SEND - -/*****************************************************************************/ -/* grp functions */ - -void -eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit) -{ - grp->int2 = limit; - grp->feed = feed; - - grp_try_feed (grp); -} - -void -eio_grp_limit (eio_req *grp, int limit) -{ - grp->int2 = limit; - - grp_try_feed (grp); -} - -void -eio_grp_add (eio_req *grp, eio_req *req) -{ - assert (("cannot add requests to IO::AIO::GRP after the group finished", grp->int1 != 2)); - - grp->flags |= EIO_FLAG_GROUPADD; - - ++grp->size; - req->grp = grp; - - req->grp_prev = 0; - req->grp_next = grp->grp_first; - - if (grp->grp_first) - grp->grp_first->grp_prev = req; - - grp->grp_first = req; -} - -/*****************************************************************************/ -/* misc garbage */ - -eio_ssize_t -eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) -{ - return eio__sendfile (ofd, ifd, offset, count); -} - diff --git a/deps/uv/src/unix/eio/eio.pod b/deps/uv/src/unix/eio/eio.pod deleted file mode 100644 index da5f33c01d..0000000000 --- a/deps/uv/src/unix/eio/eio.pod +++ /dev/null @@ -1,969 +0,0 @@ -=head1 NAME - -libeio - truly asynchronous POSIX I/O - -=head1 SYNOPSIS - - #include - -=head1 DESCRIPTION - -The newest version of this document is also available as an html-formatted -web page you might find easier to navigate when reading it for the first -time: L. - -Note that this library is a by-product of the C perl -module, and many of the subtler points regarding requests lifetime -and so on are only documented in its documentation at the -moment: L. - -=head2 FEATURES - -This library provides fully asynchronous versions of most POSIX functions -dealing with I/O. Unlike most asynchronous libraries, this not only -includes C and C, but also C, C, C and -similar functions, as well as less rarely ones such as C, C -or C. - -It also offers wrappers around C (Solaris, Linux, HP-UX and -FreeBSD, with emulation on other platforms) and C (Linux, with -emulation elsewhere>). - -The goal is to enable you to write fully non-blocking programs. For -example, in a game server, you would not want to freeze for a few seconds -just because the server is running a backup and you happen to call -C. - -=head2 TIME REPRESENTATION - -Libeio represents time as a single floating point number, representing the -(fractional) number of seconds since the (POSIX) epoch (somewhere near -the beginning of 1970, details are complicated, don't ask). This type is -called C, but it is guaranteed to be of type C (or -better), so you can freely use C yourself. - -Unlike the name component C might indicate, it is also used for -time differences throughout libeio. - -=head2 FORK SUPPORT - -Usage of pthreads in a program changes the semantics of fork -considerably. Specifically, only async-safe functions can be called after -fork. Libeio uses pthreads, so this applies, and makes using fork hard for -anything but relatively fork + exec uses. - -This library only works in the process that initialised it: Forking is -fully supported, but using libeio in any other process than the one that -called C is not. - -You might get around by not I libeio before (or after) forking in -the parent, and using it in the child afterwards. You could also try to -call the L function again in the child, which will brutally -reinitialise all data structures, which isn't POSIX conformant, but -typically works. - -Otherwise, the only recommendation you should follow is: treat fork code -the same way you treat signal handlers, and only ever call C in -the process that uses it, and only once ever. - -=head1 INITIALISATION/INTEGRATION - -Before you can call any eio functions you first have to initialise the -library. The library integrates into any event loop, but can also be used -without one, including in polling mode. - -You have to provide the necessary glue yourself, however. - -=over 4 - -=item int eio_init (void (*want_poll)(void), void (*done_poll)(void)) - -This function initialises the library. On success it returns C<0>, on -failure it returns C<-1> and sets C appropriately. - -It accepts two function pointers specifying callbacks as argument, both of -which can be C<0>, in which case the callback isn't called. - -There is currently no way to change these callbacks later, or to -"uninitialise" the library again. - -=item want_poll callback - -The C callback is invoked whenever libeio wants attention (i.e. -it wants to be polled by calling C). It is "edge-triggered", -that is, it will only be called once when eio wants attention, until all -pending requests have been handled. - -This callback is called while locks are being held, so I. That includes -C. What you should do is notify some other thread, or wake up -your event loop, and then call C. - -=item done_poll callback - -This callback is invoked when libeio detects that all pending requests -have been handled. It is "edge-triggered", that is, it will only be -called once after C. To put it differently, C and -C are invoked in pairs: after C you have to call -C until either C indicates that everything has been -handled or C has been called, which signals the same. - -Note that C might return after C and C -have been called again, so watch out for races in your code. - -As with C, this callback is called while locks are being held, -so you I. - -=item int eio_poll () - -This function has to be called whenever there are pending requests that -need finishing. You usually call this after C has indicated -that you should do so, but you can also call this function regularly to -poll for new results. - -If any request invocation returns a non-zero value, then C -immediately returns with that value as return value. - -Otherwise, if all requests could be handled, it returns C<0>. If for some -reason not all requests have been handled, i.e. some are still pending, it -returns C<-1>. - -=back - -For libev, you would typically use an C watcher: the -C callback would invoke C to wake up the event -loop. Inside the callback set for the watcher, one would call C. - -If C is configured to not handle all results in one go -(i.e. it returns C<-1>) then you should start an idle watcher that calls -C until it returns something C. - -A full-featured connector between libeio and libev would look as follows -(if C is handling all requests, it can of course be simplified a -lot by removing the idle watcher logic): - - static struct ev_loop *loop; - static ev_idle repeat_watcher; - static ev_async ready_watcher; - - /* idle watcher callback, only used when eio_poll */ - /* didn't handle all results in one call */ - static void - repeat (EV_P_ ev_idle *w, int revents) - { - if (eio_poll () != -1) - ev_idle_stop (EV_A_ w); - } - - /* eio has some results, process them */ - static void - ready (EV_P_ ev_async *w, int revents) - { - if (eio_poll () == -1) - ev_idle_start (EV_A_ &repeat_watcher); - } - - /* wake up the event loop */ - static void - want_poll (void) - { - ev_async_send (loop, &ready_watcher) - } - - void - my_init_eio () - { - loop = EV_DEFAULT; - - ev_idle_init (&repeat_watcher, repeat); - ev_async_init (&ready_watcher, ready); - ev_async_start (loop &watcher); - - eio_init (want_poll, 0); - } - -For most other event loops, you would typically use a pipe - the event -loop should be told to wait for read readiness on the read end. In -C you would write a single byte, in C you would try -to read that byte, and in the callback for the read end, you would call -C. - -You don't have to take special care in the case C doesn't handle -all requests, as the done callback will not be invoked, so the event loop -will still signal readiness for the pipe until I results have been -processed. - - -=head1 HIGH LEVEL REQUEST API - -Libeio has both a high-level API, which consists of calling a request -function with a callback to be called on completion, and a low-level API -where you fill out request structures and submit them. - -This section describes the high-level API. - -=head2 REQUEST SUBMISSION AND RESULT PROCESSING - -You submit a request by calling the relevant C function with the -required parameters, a callback of type C -(called C below) and a freely usable C argument. - -The return value will either be 0, in case something went really wrong -(which can basically only happen on very fatal errors, such as C -returning 0, which is rather unlikely), or a pointer to the newly-created -and submitted C. - -The callback will be called with an C which contains the -results of the request. The members you can access inside that structure -vary from request to request, except for: - -=over 4 - -=item C - -This contains the result value from the call (usually the same as the -syscall of the same name). - -=item C - -This contains the value of C after the call. - -=item C - -The C member simply stores the value of the C argument. - -=back - -The return value of the callback is normally C<0>, which tells libeio to -continue normally. If a callback returns a nonzero value, libeio will -stop processing results (in C) and will return the value to its -caller. - -Memory areas passed to libeio must stay valid as long as a request -executes, with the exception of paths, which are being copied -internally. Any memory libeio itself allocates will be freed after the -finish callback has been called. If you want to manage all memory passed -to libeio yourself you can use the low-level API. - -For example, to open a file, you could do this: - - static int - file_open_done (eio_req *req) - { - if (req->result < 0) - { - /* open() returned -1 */ - errno = req->errorno; - perror ("open"); - } - else - { - int fd = req->result; - /* now we have the new fd in fd */ - } - - return 0; - } - - /* the first three arguments are passed to open(2) */ - /* the remaining are priority, callback and data */ - if (!eio_open ("/etc/passwd", O_RDONLY, 0, 0, file_open_done, 0)) - abort (); /* something went wrong, we will all die!!! */ - -Note that you additionally need to call C when the C -indicates that requests are ready to be processed. - -=head2 CANCELLING REQUESTS - -Sometimes the need for a request goes away before the request is -finished. In that case, one can cancel the request by a call to -C: - -=over 4 - -=item eio_cancel (eio_req *req) - -Cancel the request (and all its subrequests). If the request is currently -executing it might still continue to execute, and in other cases it might -still take a while till the request is cancelled. - -Even if cancelled, the finish callback will still be invoked - the -callbacks of all cancellable requests need to check whether the request -has been cancelled by calling C: - - static int - my_eio_cb (eio_req *req) - { - if (EIO_CANCELLED (req)) - return 0; - } - -In addition, cancelled requests will I have C<< req->result >> -set to C<-1> and C to C, or I they were -successfully executed, despite being cancelled (e.g. when they have -already been executed at the time they were cancelled). - -C is still true for requests that have successfully -executed, as long as C was called on them at some point. - -=back - -=head2 AVAILABLE REQUESTS - -The following request functions are available. I of them return the -C on success and C<0> on failure, and I of them have the -same three trailing arguments: C, C and C. The C is -mandatory, but in most cases, you pass in C<0> as C and C<0> or some -custom data value as C. - -=head3 POSIX API WRAPPERS - -These requests simply wrap the POSIX call of the same name, with the same -arguments. If a function is not implemented by the OS and cannot be emulated -in some way, then all of these return C<-1> and set C to C. - -=over 4 - -=item eio_open (const char *path, int flags, mode_t mode, int pri, eio_cb cb, void *data) - -=item eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data) - -=item eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) - -=item eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data) - -=item eio_mkdir (const char *path, mode_t mode, int pri, eio_cb cb, void *data) - -=item eio_rmdir (const char *path, int pri, eio_cb cb, void *data) - -=item eio_unlink (const char *path, int pri, eio_cb cb, void *data) - -=item eio_utime (const char *path, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data) - -=item eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data) - -=item eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data) - -=item eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data) - -=item eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data) - -=item eio_mlock (void *addr, size_t length, int pri, eio_cb cb, void *data) - -=item eio_close (int fd, int pri, eio_cb cb, void *data) - -=item eio_sync (int pri, eio_cb cb, void *data) - -=item eio_fsync (int fd, int pri, eio_cb cb, void *data) - -=item eio_fdatasync (int fd, int pri, eio_cb cb, void *data) - -=item eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data) - -=item eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data) - -=item eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data) - -=item eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) - -=item eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data) - -These have the same semantics as the syscall of the same name, their -return value is available as C<< req->result >> later. - -=item eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data) - -=item eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data) - -These two requests are called C and C, but actually wrap -C and C. On systems that lack these calls (such as cygwin), -libeio uses lseek/read_or_write/lseek and a mutex to serialise the -requests, so all these requests run serially and do not disturb each -other. However, they still disturb the file offset while they run, so it's -not safe to call these functions concurrently with non-libeio functions on -the same fd on these systems. - -Not surprisingly, pread and pwrite are not thread-safe on Darwin (OS/X), -so it is advised not to submit multiple requests on the same fd on this -horrible pile of garbage. - -=item eio_mlockall (int flags, int pri, eio_cb cb, void *data) - -Like C, but the flag value constants are called -C and C. - -=item eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) - -Just like msync, except that the flag values are called C, -C and C. - -=item eio_readlink (const char *path, int pri, eio_cb cb, void *data) - -If successful, the path read by C can be accessed via C<< -req->ptr2 >> and is I null-terminated, with the length specified as -C<< req->result >>. - - if (req->result >= 0) - { - char *target = strndup ((char *)req->ptr2, req->result); - - free (target); - } - -=item eio_realpath (const char *path, int pri, eio_cb cb, void *data) - -Similar to the realpath libc function, but unlike that one, C<< -req->result >> is C<-1> on failure. On success, the result is the length -of the returned path in C (which is I 0-terminated) - this is -similar to readlink. - -=item eio_stat (const char *path, int pri, eio_cb cb, void *data) - -=item eio_lstat (const char *path, int pri, eio_cb cb, void *data) - -=item eio_fstat (int fd, int pri, eio_cb cb, void *data) - -Stats a file - if C<< req->result >> indicates success, then you can -access the C-like structure via C<< req->ptr2 >>: - - EIO_STRUCT_STAT *statdata = (EIO_STRUCT_STAT *)req->ptr2; - -=item eio_statvfs (const char *path, int pri, eio_cb cb, void *data) - -=item eio_fstatvfs (int fd, int pri, eio_cb cb, void *data) - -Stats a filesystem - if C<< req->result >> indicates success, then you can -access the C-like structure via C<< req->ptr2 >>: - - EIO_STRUCT_STATVFS *statdata = (EIO_STRUCT_STATVFS *)req->ptr2; - -=back - -=head3 READING DIRECTORIES - -Reading directories sounds simple, but can be rather demanding, especially -if you want to do stuff such as traversing a directory hierarchy or -processing all files in a directory. Libeio can assist these complex tasks -with it's C call. - -=over 4 - -=item eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data) - -This is a very complex call. It basically reads through a whole directory -(via the C, C and C calls) and returns either -the names or an array of C, depending on the C -argument. - -The C<< req->result >> indicates either the number of files found, or -C<-1> on error. On success, null-terminated names can be found as C<< req->ptr2 >>, -and C, if requested by C, can be found via C<< -req->ptr1 >>. - -Here is an example that prints all the names: - - int i; - char *names = (char *)req->ptr2; - - for (i = 0; i < req->result; ++i) - { - printf ("name #%d: %s\n", i, names); - - /* move to next name */ - names += strlen (names) + 1; - } - -Pseudo-entries such as F<.> and F<..> are never returned by C. - -C can be any combination of: - -=over 4 - -=item EIO_READDIR_DENTS - -If this flag is specified, then, in addition to the names in C, -also an array of C is returned, in C. A C looks like this: - - struct eio_dirent - { - int nameofs; /* offset of null-terminated name string in (char *)req->ptr2 */ - unsigned short namelen; /* size of filename without trailing 0 */ - unsigned char type; /* one of EIO_DT_* */ - signed char score; /* internal use */ - ino_t inode; /* the inode number, if available, otherwise unspecified */ - }; - -The only members you normally would access are C, which is the -byte-offset from C to the start of the name, C and C. - -C can be one of: - -C - if the type is not known (very common) and you have to C -the name yourself if you need to know, -one of the "standard" POSIX file types (C, C, C, -C, C, C, C) -or some OS-specific type (currently -C - multiplexed char device (v7+coherent), -C - xenix special named file, -C - multiplexed block device (v7+coherent), -C - HP-UX network special, -C - VxFS compressed, -C - solaris door, or -C). - -This example prints all names and their type: - - int i; - struct eio_dirent *ents = (struct eio_dirent *)req->ptr1; - char *names = (char *)req->ptr2; - - for (i = 0; i < req->result; ++i) - { - struct eio_dirent *ent = ents + i; - char *name = names + ent->nameofs; - - printf ("name #%d: %s (type %d)\n", i, name, ent->type); - } - -=item EIO_READDIR_DIRS_FIRST - -When this flag is specified, then the names will be returned in an order -where likely directories come first, in optimal C order. This is -useful when you need to quickly find directories, or you want to find all -directories while avoiding to stat() each entry. - -If the system returns type information in readdir, then this is used -to find directories directly. Otherwise, likely directories are names -beginning with ".", or otherwise names with no dots, of which names with -short names are tried first. - -=item EIO_READDIR_STAT_ORDER - -When this flag is specified, then the names will be returned in an order -suitable for stat()'ing each one. That is, when you plan to stat() -all files in the given directory, then the returned order will likely -be fastest. - -If both this flag and C are specified, then the -likely directories come first, resulting in a less optimal stat order. - -=item EIO_READDIR_FOUND_UNKNOWN - -This flag should not be specified when calling C. Instead, -it is being set by C (you can access the C via C<< -req->int1 >>, when any of the C's found were C. The -absence of this flag therefore indicates that all C's are known, -which can be used to speed up some algorithms. - -A typical use case would be to identify all subdirectories within a -directory - you would ask C for C. If -then this flag is I set, then all the entries at the beginning of the -returned array of type C are the directories. Otherwise, you -should start C'ing the entries starting at the beginning of the -array, stopping as soon as you found all directories (the count can be -deduced by the link count of the directory). - -=back - -=back - -=head3 OS-SPECIFIC CALL WRAPPERS - -These wrap OS-specific calls (usually Linux ones), and might or might not -be emulated on other operating systems. Calls that are not emulated will -return C<-1> and set C to C. - -=over 4 - -=item eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data) - -Wraps the C syscall. The arguments follow the Linux version, but -libeio supports and will use similar calls on FreeBSD, HP/UX, Solaris and -Darwin. - -If the OS doesn't support some sendfile-like call, or the call fails, -indicating support for the given file descriptor type (for example, -Linux's sendfile might not support file to file copies), then libeio will -emulate the call in userspace, so there are almost no limitations on its -use. - -=item eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data) - -Calls C. If the syscall is missing, then the call is -emulated by simply reading the data (currently in 64kiB chunks). - -=item eio_syncfs (int fd, int pri, eio_cb cb, void *data) - -Calls Linux' C syscall, if available. Returns C<-1> and sets -C to C if the call is missing I, -if the C is C<< >= 0 >>, so you can probe for the availability of the -syscall with a negative C argument and checking for C<-1/ENOSYS>. - -=item eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data) - -Calls C. If the syscall is missing, then this is the same -as calling C. - -Flags can be any combination of C, -C and C. - -=item eio_fallocate (int fd, int mode, off_t offset, off_t len, int pri, eio_cb cb, void *data) - -Calls C (note: I C!). If the syscall is -missing, then it returns failure and sets C to C. - -The C argument can be C<0> (for behaviour similar to -C), or C, which keeps the size -of the file unchanged (but still preallocates space beyond end of file). - -=back - -=head3 LIBEIO-SPECIFIC REQUESTS - -These requests are specific to libeio and do not correspond to any OS call. - -=over 4 - -=item eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) - -Reads (C) or modifies (C as parameter and is expected to read -and modify any request-specific members. Specifically, it should set C<< -req->result >> to the result value, just like other requests. - -Here is an example that simply calls C, like C, but it -uses the C member as filename and uses a hardcoded C. If -you want to pass more/other parameters, you either need to pass some -struct or so via C or provide your own wrapper using the low-level -API. - - static int - my_open_done (eio_req *req) - { - int fd = req->result; - - return 0; - } - - static void - my_open (eio_req *req) - { - req->result = open (req->data, O_RDONLY); - } - - eio_custom (my_open, 0, my_open_done, "/etc/passwd"); - -=item eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data) - -This is a request that takes C seconds to execute, but otherwise -does nothing - it simply puts one of the worker threads to sleep for this -long. - -This request can be used to artificially increase load, e.g. for debugging -or benchmarking reasons. - -=item eio_nop (int pri, eio_cb cb, void *data) - -This request does nothing, except go through the whole request cycle. This -can be used to measure latency or in some cases to simplify code, but is -not really of much use. - -=back - -=head3 GROUPING AND LIMITING REQUESTS - -There is one more rather special request, C. It is a very special -aio request: Instead of doing something, it is a container for other eio -requests. - -There are two primary use cases for this: a) bundle many requests into a -single, composite, request with a definite callback and the ability to -cancel the whole request with its subrequests and b) limiting the number -of "active" requests. - -Further below you will find more discussion of these topics - first -follows the reference section detailing the request generator and other -methods. - -=over 4 - -=item eio_req *grp = eio_grp (eio_cb cb, void *data) - -Creates, submits and returns a group request. Note that it doesn't have a -priority, unlike all other requests. - -=item eio_grp_add (eio_req *grp, eio_req *req) - -Adds a request to the request group. - -=item eio_grp_cancel (eio_req *grp) - -Cancels all requests I the group, but I the group request -itself. You can cancel the group request I all subrequests via a -normal C call. - -=back - -=head4 GROUP REQUEST LIFETIME - -Left alone, a group request will instantly move to the pending state and -will be finished at the next call of C. - -The usefulness stems from the fact that, if a subrequest is added to a -group I a call to C, via C, then the group -will not finish until all the subrequests have finished. - -So the usage cycle of a group request is like this: after it is created, -you normally instantly add a subrequest. If none is added, the group -request will finish on it's own. As long as subrequests are added before -the group request is finished it will be kept from finishing, that is the -callbacks of any subrequests can, in turn, add more requests to the group, -and as long as any requests are active, the group request itself will not -finish. - -=head4 CREATING COMPOSITE REQUESTS - -Imagine you wanted to create an C request that opens a file, -reads it and closes it. This means it has to execute at least three eio -requests, but for various reasons it might be nice if that request looked -like any other eio request. - -This can be done with groups: - -=over 4 - -=item 1) create the request object - -Create a group that contains all further requests. This is the request you -can return as "the load request". - -=item 2) open the file, maybe - -Next, open the file with C and add the request to the group -request and you are finished setting up the request. - -If, for some reason, you cannot C (path is a null ptr?) you -can set C<< grp->result >> to C<-1> to signal an error and let the group -request finish on its own. - -=item 3) open callback adds more requests - -In the open callback, if the open was not successful, copy C<< -req->errorno >> to C<< grp->errorno >> and set C<< grp->errorno >> to -C<-1> to signal an error. - -Otherwise, malloc some memory or so and issue a read request, adding the -read request to the group. - -=item 4) continue issuing requests till finished - -In the real callback, check for errors and possibly continue with -C or any other eio request in the same way. - -As soon as no new requests are added the group request will finish. Make -sure you I set C<< grp->result >> to some sensible value. - -=back - -=head4 REQUEST LIMITING - - -#TODO - -void eio_grp_limit (eio_req *grp, int limit); - - -=back - - -=head1 LOW LEVEL REQUEST API - -#TODO - - -=head1 ANATOMY AND LIFETIME OF AN EIO REQUEST - -A request is represented by a structure of type C. To initialise -it, clear it to all zero bytes: - - eio_req req; - - memset (&req, 0, sizeof (req)); - -A more common way to initialise a new C is to use C: - - eio_req *req = calloc (1, sizeof (*req)); - -In either case, libeio neither allocates, initialises or frees the -C structure for you - it merely uses it. - -zero - -#TODO - -=head2 CONFIGURATION - -The functions in this section can sometimes be useful, but the default -configuration will do in most case, so you should skip this section on -first reading. - -=over 4 - -=item eio_set_max_poll_time (eio_tstamp nseconds) - -This causes C to return after it has detected that it was -running for C seconds or longer (this number can be fractional). - -This can be used to limit the amount of time spent handling eio requests, -for example, in interactive programs, you might want to limit this time to -C<0.01> seconds or so. - -Note that: - -=over 4 - -=item a) libeio doesn't know how long your request callbacks take, so the -time spent in C is up to one callback invocation longer then -this interval. - -=item b) this is implemented by calling C after each -request, which can be costly. - -=item c) at least one request will be handled. - -=back - -=item eio_set_max_poll_reqs (unsigned int nreqs) - -When C is non-zero, then C will not handle more than -C requests per invocation. This is a less costly way to limit the -amount of work done by C then setting a time limit. - -If you know your callbacks are generally fast, you could use this to -encourage interactiveness in your programs by setting it to C<10>, C<100> -or even C<1000>. - -=item eio_set_min_parallel (unsigned int nthreads) - -Make sure libeio can handle at least this many requests in parallel. It -might be able handle more. - -=item eio_set_max_parallel (unsigned int nthreads) - -Set the maximum number of threads that libeio will spawn. - -=item eio_set_max_idle (unsigned int nthreads) - -Libeio uses threads internally to handle most requests, and will start and stop threads on demand. - -This call can be used to limit the number of idle threads (threads without -work to do): libeio will keep some threads idle in preparation for more -requests, but never longer than C threads. - -In addition to this, libeio will also stop threads when they are idle for -a few seconds, regardless of this setting. - -=item unsigned int eio_nthreads () - -Return the number of worker threads currently running. - -=item unsigned int eio_nreqs () - -Return the number of requests currently handled by libeio. This is the -total number of requests that have been submitted to libeio, but not yet -destroyed. - -=item unsigned int eio_nready () - -Returns the number of ready requests, i.e. requests that have been -submitted but have not yet entered the execution phase. - -=item unsigned int eio_npending () - -Returns the number of pending requests, i.e. requests that have been -executed and have results, but have not been finished yet by a call to -C). - -=back - -=head1 EMBEDDING - -Libeio can be embedded directly into programs. This functionality is not -documented and not (yet) officially supported. - -Note that, when including C, you are responsible for defining -the compilation environment (C<_LARGEFILE_SOURCE>, C<_GNU_SOURCE> etc.). - -If you need to know how, check the C perl module, which does -exactly that. - - -=head1 COMPILETIME CONFIGURATION - -These symbols, if used, must be defined when compiling F. - -=over 4 - -=item EIO_STACKSIZE - -This symbol governs the stack size for each eio thread. Libeio itself -was written to use very little stackspace, but when using C -requests, you might want to increase this. - -If this symbol is undefined (the default) then libeio will use its default -stack size (C currently). If it is defined, but -C<0>, then the default operating system stack size will be used. In all -other cases, the value must be an expression that evaluates to the desired -stack size. - -=back - - -=head1 PORTABILITY REQUIREMENTS - -In addition to a working ISO-C implementation, libeio relies on a few -additional extensions: - -=over 4 - -=item POSIX threads - -To be portable, this module uses threads, specifically, the POSIX threads -library must be available (and working, which partially excludes many xBSD -systems, where C is buggy). - -=item POSIX-compatible filesystem API - -This is actually a harder portability requirement: The libeio API is quite -demanding regarding POSIX API calls (symlinks, user/group management -etc.). - -=item C must hold a time value in seconds with enough accuracy - -The type C is used to represent timestamps. It is required to -have at least 51 bits of mantissa (and 9 bits of exponent), which is good -enough for at least into the year 4000. This requirement is fulfilled by -implementations implementing IEEE 754 (basically all existing ones). - -=back - -If you know of other additional requirements drop me a note. - - -=head1 AUTHOR - -Marc Lehmann . - diff --git a/deps/uv/src/unix/eio/libeio.m4 b/deps/uv/src/unix/eio/libeio.m4 deleted file mode 100644 index 59151f5348..0000000000 --- a/deps/uv/src/unix/eio/libeio.m4 +++ /dev/null @@ -1,195 +0,0 @@ -dnl openbsd in it's neverending brokenness requires stdint.h for intptr_t, -dnl but that header isn't very portable... -AC_CHECK_HEADERS([stdint.h sys/syscall.h sys/prctl.h]) - -AC_SEARCH_LIBS( - pthread_create, - [pthread pthreads pthreadVC2], - , - [AC_MSG_ERROR(pthread functions not found)] -) - -AC_CACHE_CHECK(for utimes, ac_cv_utimes, [AC_LINK_IFELSE([[ -#include -#include -#include -struct timeval tv[2]; -int res; -int main (void) -{ - res = utimes ("/", tv); - return 0; -} -]],ac_cv_utimes=yes,ac_cv_utimes=no)]) -test $ac_cv_utimes = yes && AC_DEFINE(HAVE_UTIMES, 1, utimes(2) is available) - -AC_CACHE_CHECK(for futimes, ac_cv_futimes, [AC_LINK_IFELSE([[ -#include -#include -#include -struct timeval tv[2]; -int res; -int fd; -int main (void) -{ - res = futimes (fd, tv); - return 0; -} -]],ac_cv_futimes=yes,ac_cv_futimes=no)]) -test $ac_cv_futimes = yes && AC_DEFINE(HAVE_FUTIMES, 1, futimes(2) is available) - -AC_CACHE_CHECK(for readahead, ac_cv_readahead, [AC_LINK_IFELSE([ -#include -int main (void) -{ - int fd = 0; - size_t count = 2; - ssize_t res; - res = readahead (fd, 0, count); - return 0; -} -],ac_cv_readahead=yes,ac_cv_readahead=no)]) -test $ac_cv_readahead = yes && AC_DEFINE(HAVE_READAHEAD, 1, readahead(2) is available (linux)) - -AC_CACHE_CHECK(for fdatasync, ac_cv_fdatasync, [AC_LINK_IFELSE([ -#include -int main (void) -{ - int fd = 0; - fdatasync (fd); - return 0; -} -],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 -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 -#if __linux -# include -#elif __FreeBSD__ || defined __APPLE__ -# include -# include -#elif __hpux -# include -#else -# error unsupported architecture -#endif -int main (void) -{ - int fd = 0; - off_t offset = 1; - size_t count = 2; - ssize_t res; -#if __linux - res = sendfile (fd, fd, offset, count); -#elif __FreeBSD__ - res = sendfile (fd, fd, offset, count, 0, &offset, 0); -#elif __hpux - res = sendfile (fd, fd, offset, count, 0, 0); -#endif - return 0; -} -],ac_cv_sendfile=yes,ac_cv_sendfile=no)]) -test $ac_cv_sendfile = yes && AC_DEFINE(HAVE_SENDFILE, 1, sendfile(2) is available and supported) - -AC_CACHE_CHECK(for sync_file_range, ac_cv_sync_file_range, [AC_LINK_IFELSE([ -#include -int main (void) -{ - int fd = 0; - off64_t offset = 1; - off64_t nbytes = 1; - unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|SYNC_FILE_RANGE_WAIT_AFTER; - ssize_t res; - res = sync_file_range (fd, offset, nbytes, flags); - return 0; -} -],ac_cv_sync_file_range=yes,ac_cv_sync_file_range=no)]) -test $ac_cv_sync_file_range = yes && AC_DEFINE(HAVE_SYNC_FILE_RANGE, 1, sync_file_range(2) is available) - -AC_CACHE_CHECK(for fallocate, ac_cv_fallocate, [AC_LINK_IFELSE([ -#include -int main (void) -{ - int fd = 0; - int mode = 0; - off_t offset = 1; - off_t len = 1; - int res; - res = fallocate (fd, mode, offset, len); - return 0; -} -],ac_cv_fallocate=yes,ac_cv_fallocate=no)]) -test $ac_cv_fallocate = yes && AC_DEFINE(HAVE_FALLOCATE, 1, fallocate(2) is available) - -AC_CACHE_CHECK(for sys_syncfs, ac_cv_sys_syncfs, [AC_LINK_IFELSE([ -#include -#include -int main (void) -{ - int res = syscall (__NR_syncfs, (int)0); -} -],ac_cv_sys_syncfs=yes,ac_cv_sys_syncfs=no)]) -test $ac_cv_sys_syncfs = yes && AC_DEFINE(HAVE_SYS_SYNCFS, 1, syscall(__NR_syncfs) is available) - -AC_CACHE_CHECK(for prctl_set_name, ac_cv_prctl_set_name, [AC_LINK_IFELSE([ -#include -int main (void) -{ - char name[] = "test123"; - int res = prctl (PR_SET_NAME, (unsigned long)name, 0, 0, 0); -} -],ac_cv_prctl_set_name=yes,ac_cv_prctl_set_name=no)]) -test $ac_cv_prctl_set_name = yes && AC_DEFINE(HAVE_PRCTL_SET_NAME, 1, prctl(PR_SET_NAME) is available) - -dnl ############################################################################# -dnl # these checks exist for the benefit of IO::AIO - -dnl at least uclibc defines _POSIX_ADVISORY_INFO without *any* of the required -dnl functionality actually being present. ugh. -AC_CACHE_CHECK(for posix_madvise, ac_cv_posix_madvise, [AC_LINK_IFELSE([ -#include -int main (void) -{ - int res = posix_madvise ((void *)0, (size_t)0, POSIX_MADV_NORMAL); - int a = POSIX_MADV_SEQUENTIAL; - int b = POSIX_MADV_RANDOM; - int c = POSIX_MADV_WILLNEED; - int d = POSIX_MADV_DONTNEED; - return 0; -} -],ac_cv_posix_madvise=yes,ac_cv_posix_madvise=no)]) -test $ac_cv_posix_madvise = yes && AC_DEFINE(HAVE_POSIX_MADVISE, 1, posix_madvise(2) is available) - -AC_CACHE_CHECK(for posix_fadvise, ac_cv_posix_fadvise, [AC_LINK_IFELSE([ -#define _XOPEN_SOURCE 600 -#include -int main (void) -{ - int res = posix_fadvise ((int)0, (off_t)0, (off_t)0, POSIX_FADV_NORMAL); - int a = POSIX_FADV_SEQUENTIAL; - int b = POSIX_FADV_NOREUSE; - int c = POSIX_FADV_RANDOM; - int d = POSIX_FADV_WILLNEED; - int e = POSIX_FADV_DONTNEED; - return 0; -} -],ac_cv_posix_fadvise=yes,ac_cv_posix_fadvise=no)]) -test $ac_cv_posix_fadvise = yes && AC_DEFINE(HAVE_POSIX_FADVISE, 1, posix_fadvise(2) is available) - diff --git a/deps/uv/src/unix/eio/xthread.h b/deps/uv/src/unix/eio/xthread.h deleted file mode 100644 index 1d7aeba211..0000000000 --- a/deps/uv/src/unix/eio/xthread.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef XTHREAD_H_ -#define XTHREAD_H_ - -/* whether word reads are potentially non-atomic. - * this is conservative, likely most arches this runs - * on have atomic word read/writes. - */ -#ifndef WORDACCESS_UNSAFE -# if __i386 || __x86_64 -# define WORDACCESS_UNSAFE 0 -# else -# define WORDACCESS_UNSAFE 1 -# endif -#endif - -///////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - -#include //D -#include -#include -#include -#include -#include -#include -#include -#define sigset_t int -#define sigfillset(a) -#define pthread_sigmask(a,b,c) -#define sigaddset(a,b) -#define sigemptyset(s) - -typedef pthread_mutex_t xmutex_t; -#define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER -#define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0) -#define X_LOCK(mutex) pthread_mutex_lock (&(mutex)) -#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex)) - -typedef pthread_cond_t xcond_t; -#define X_COND_INIT PTHREAD_COND_INITIALIZER -#define X_COND_CREATE(cond) pthread_cond_init (&(cond), 0) -#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond)) -#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex)) -#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to)) - -typedef pthread_t xthread_t; -#define X_THREAD_PROC(name) void *name (void *thr_arg) -#define X_THREAD_ATFORK(a,b,c) - -static int -xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg) -{ - int retval; - pthread_attr_t attr; - - pthread_attr_init (&attr); - pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - - retval = pthread_create (tid, &attr, proc, arg) == 0; - - pthread_attr_destroy (&attr); - - return retval; -} - -#define respipe_read(a,b,c) PerlSock_recv ((a), (b), (c), 0) -#define respipe_write(a,b,c) send ((a), (b), (c), 0) -#define respipe_close(a) PerlSock_closesocket ((a)) - -#else -///////////////////////////////////////////////////////////////////////////// - -#if __linux && !defined(_GNU_SOURCE) -# define _GNU_SOURCE -#endif - -/* just in case */ -#define _REENTRANT 1 - -#if __solaris -# define _POSIX_PTHREAD_SEMANTICS 1 -/* try to bribe solaris headers into providing a current pthread API - * despite environment being configured for an older version. - */ -# define __EXTENSIONS__ 1 -#endif - -#include -#include -#include -#include -#include - -typedef pthread_mutex_t xmutex_t; -#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) -# define X_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -# define X_MUTEX_CREATE(mutex) \ - do { \ - pthread_mutexattr_t attr; \ - pthread_mutexattr_init (&attr); \ - pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP); \ - pthread_mutex_init (&(mutex), &attr); \ - } while (0) -#else -# define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER -# define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0) -#endif -#define X_LOCK(mutex) pthread_mutex_lock (&(mutex)) -#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex)) - -typedef pthread_cond_t xcond_t; -#define X_COND_INIT PTHREAD_COND_INITIALIZER -#define X_COND_CREATE(cond) pthread_cond_init (&(cond), 0) -#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond)) -#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex)) -#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to)) - -typedef pthread_t xthread_t; -#define X_THREAD_PROC(name) static void *name (void *thr_arg) -#define X_THREAD_ATFORK(prepare,parent,child) pthread_atfork (prepare, parent, child) - -// the broken bsd's once more -#ifndef PTHREAD_STACK_MIN -# define PTHREAD_STACK_MIN 0 -#endif - -#ifndef XTHREAD_STACKSIZE -# define XTHREAD_STACKSIZE sizeof (void *) * 4096 -#endif - -static int -xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg) -{ - int retval; - sigset_t fullsigset, oldsigset; - pthread_attr_t attr; - - pthread_attr_init (&attr); - pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN < X_STACKSIZE ? X_STACKSIZE : PTHREAD_STACK_MIN); -#ifdef PTHREAD_SCOPE_PROCESS - pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS); -#endif - - sigfillset (&fullsigset); - - pthread_sigmask (SIG_SETMASK, &fullsigset, &oldsigset); - retval = pthread_create (tid, &attr, proc, arg) == 0; - pthread_sigmask (SIG_SETMASK, &oldsigset, 0); - - pthread_attr_destroy (&attr); - - return retval; -} - -#define respipe_read(a,b,c) read ((a), (b), (c)) -#define respipe_write(a,b,c) write ((a), (b), (c)) -#define respipe_close(a) close ((a)) - -#endif - -#endif - diff --git a/deps/uv/src/unix/error.c b/deps/uv/src/unix/error.c index 2acc047992..9e3e84ad9a 100644 --- a/deps/uv/src/unix/error.c +++ b/deps/uv/src/unix/error.c @@ -102,6 +102,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) { case ENOSPC: return UV_ENOSPC; case EROFS: return UV_EROFS; case ENOMEM: return UV_ENOMEM; + case EDQUOT: return UV_ENOSPC; default: return UV_UNKNOWN; } UNREACHABLE(); diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 875f0b943f..1e1c653bd5 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -21,719 +21,799 @@ #include "uv.h" #include "internal.h" -#include "eio.h" +#include #include #include #include + +#include +#include +#include +#include #include -#include -#include -#include #include +#include #include -#include +#include +#if defined(__linux__) || defined(__sun) +# include +#elif defined(__APPLE__) || defined(__FreeBSD__) +# include +# include +#endif -#define ARGS1(a) (a) -#define ARGS2(a,b) (a), (b) -#define ARGS3(a,b,c) (a), (b), (c) -#define ARGS4(a,b,c,d) (a), (b), (c), (d) - -#define WRAP_EIO(type, eiofunc, func, args) \ - uv_fs_req_init(loop, req, type, path, cb); \ - if (cb) { \ - /* async */ \ - req->eio = eiofunc(args, EIO_PRI_DEFAULT, uv__fs_after, req, &loop->uv_eio_channel); \ - if (!req->eio) { \ - uv__set_sys_error(loop, ENOMEM); \ - return -1; \ - } \ - } else { \ - /* sync */ \ - req->result = func(args); \ - if (req->result) { \ - uv__set_sys_error(loop, errno); \ - } \ - return req->result; \ - } \ - return 0; - - -static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req, uv_fs_type fs_type, - const char* path, uv_fs_cb cb) { - /* Make sure the thread pool is initialized. */ - uv_eio_init(loop); - - uv__req_init(loop, req, UV_FS); - req->loop = loop; - req->fs_type = fs_type; - req->cb = cb; - req->result = 0; - req->ptr = NULL; - req->path = path ? strdup(path) : NULL; - req->file = -1; - req->errorno = 0; - req->eio = NULL; - - /* synchronous requests don't increase the reference count */ - if (!req->cb) - uv__req_unregister(req->loop, req); +#define INIT(type) \ + do { \ + uv__req_init((loop), (req), UV_FS_ ## type); \ + (req)->fs_type = UV_FS_ ## type; \ + (req)->errorno = 0; \ + (req)->result = 0; \ + (req)->ptr = NULL; \ + (req)->loop = loop; \ + (req)->path = NULL; \ + (req)->new_path = NULL; \ + (req)->cb = (cb); \ + } \ + while (0) + +#define PATH \ + do { \ + if (NULL == ((req)->path = strdup((path)))) \ + return uv__set_sys_error((loop), ENOMEM); \ + } \ + while (0) + +#define PATH2 \ + do { \ + size_t path_len; \ + size_t new_path_len; \ + \ + path_len = strlen((path)) + 1; \ + new_path_len = strlen((new_path)) + 1; \ + \ + if (NULL == ((req)->path = malloc(path_len + new_path_len))) \ + return uv__set_sys_error((loop), ENOMEM); \ + \ + (req)->new_path = (req)->path + path_len; \ + memcpy((void*) (req)->path, (path), path_len); \ + memcpy((void*) (req)->new_path, (new_path), new_path_len); \ + } \ + while (0) + +#define POST \ + do { \ + if ((cb) != NULL) { \ + uv__work_submit((loop), &(req)->work_req, uv__fs_work, uv__fs_done); \ + return 0; \ + } \ + else { \ + uv__fs_work(&(req)->work_req); \ + uv__fs_done(&(req)->work_req); \ + return (req)->result; \ + } \ + } \ + while (0) + + +static ssize_t uv__fs_fdatasync(uv_fs_t* req) { +#if defined(__linux__) || defined(__sun) || defined(__NetBSD__) + return fdatasync(req->file); +#elif defined(__APPLE__) && defined(F_FULLFSYNC) + return fcntl(req->file, F_FULLFSYNC); +#else + return fsync(req->file); +#endif } -void uv_fs_req_cleanup(uv_fs_t* req) { - if (req->cb) - uv__req_unregister(req->loop, req); - - free((void*)req->path); - req->path = NULL; - - switch (req->fs_type) { - case UV_FS_READDIR: - assert(req->result > 0 ? (req->ptr != NULL) : (req->ptr == NULL)); - free(req->ptr); - req->ptr = NULL; - break; - - case UV_FS_STAT: - case UV_FS_LSTAT: - req->ptr = NULL; - break; - - default: - break; - } +static ssize_t uv__fs_futime(uv_fs_t* req) { +#if defined(__linux__) + /* utimesat() has nanosecond resolution but we stick to microseconds + * for the sake of consistency with other platforms. + */ + struct timespec ts[2]; + ts[0].tv_sec = req->atime; + ts[0].tv_nsec = (unsigned long)(req->atime * 1000000) % 1000000 * 1000; + ts[1].tv_sec = req->mtime; + ts[1].tv_nsec = (unsigned long)(req->mtime * 1000000) % 1000000 * 1000; + return uv__utimesat(req->file, NULL, ts, 0); +#elif HAVE_FUTIMES + struct timeval tv[2]; + tv[0].tv_sec = req->atime; + tv[0].tv_usec = (unsigned long)(req->atime * 1000000) % 1000000; + tv[1].tv_sec = req->mtime; + tv[1].tv_usec = (unsigned long)(req->mtime * 1000000) % 1000000; + return futimes(req->file, tv); +#else /* !HAVE_FUTIMES */ + errno = ENOSYS; + return -1; +#endif } -static int uv__fs_after(eio_req* eio) { - char* name; - int namelen; - int buflen = 0; - uv_fs_t* req = eio->data; - int i; - - assert(req->cb); - - req->result = req->eio->result; - req->errorno = uv_translate_sys_error(req->eio->errorno); - - switch (req->fs_type) { - case UV_FS_READDIR: - /* - * XXX This is pretty bad. - * We alloc and copy the large null terminated string list from libeio. - * This is done because libeio is going to free eio->ptr2 after this - * callback. We must keep it until uv_fs_req_cleanup. If we get rid of - * libeio this can be avoided. - */ - buflen = 0; - name = req->eio->ptr2; - - for (i = 0; i < req->result; i++) { - namelen = strlen(name); - buflen += namelen + 1; - name += namelen; - assert(*name == '\0'); - name++; - } - - if (buflen) { - if ((req->ptr = malloc(buflen))) - memcpy(req->ptr, req->eio->ptr2, buflen); - else - uv__set_sys_error(req->loop, ENOMEM); - } - break; - - case UV_FS_STAT: - case UV_FS_LSTAT: - case UV_FS_FSTAT: - req->ptr = req->eio->ptr2; - break; - - case UV_FS_READLINK: - if (req->result == -1) { - req->ptr = NULL; - break; - } - assert(req->result > 0); - - /* Make zero-terminated copy of req->eio->ptr2 */ - if ((req->ptr = name = malloc(req->result + 1))) { - memcpy(name, req->eio->ptr2, req->result); - name[req->result] = '\0'; - req->result = 0; - } - else { - req->errorno = ENOMEM; - req->result = -1; - } - break; - - default: - break; - } +static ssize_t uv__fs_pwrite(uv_fs_t* req) { +#if defined(__APPLE__) + /* Serialize writes on OS X, concurrent pwrite() calls result in data loss. + * We can't use a per-file descriptor lock, the descriptor may be a dup(). + */ + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + ssize_t r; - req->eio = NULL; /* Freed by libeio */ - req->cb(req); + pthread_mutex_lock(&lock); + r = pwrite(req->file, req->buf, req->len, req->off); + pthread_mutex_unlock(&lock); - return 0; + return r; +#else + return pwrite(req->file, req->buf, req->len, req->off); +#endif } - -int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - char* path = NULL; - WRAP_EIO(UV_FS_CLOSE, eio_close, close, ARGS1(file)); +static ssize_t uv__fs_read(uv_fs_t* req) { + if (req->off < 0) + return read(req->file, req->buf, req->len); + else + return pread(req->file, req->buf, req->len, req->off); } -int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, - int mode, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_OPEN, path, cb); +#if defined(__APPLE__) || defined(__OpenBSD__) +static int uv__fs_readdir_filter(struct dirent* dent) { +#else +static int uv__fs_readdir_filter(const struct dirent* dent) { +#endif + return strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0; +} - if (cb) { - /* async */ - req->eio = eio_open(path, flags, mode, EIO_PRI_DEFAULT, uv__fs_after, req, &loop->uv_eio_channel); - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; - } - } else { - /* sync */ - req->result = open(path, flags, mode); - if (req->result < 0) { - uv__set_sys_error(loop, errno); - return -1; - } +/* This should have been called uv__fs_scandir(). */ +static ssize_t uv__fs_readdir(uv_fs_t* req) { + struct dirent **dents; + int saved_errno; + size_t off; + size_t len; + char *buf; + int i; + int n; - uv__cloexec(req->result, 1); + n = scandir(req->path, &dents, uv__fs_readdir_filter, alphasort); - return req->result; - } + if (n == -1 || n == 0) + return n; - return 0; -} + len = 0; + for (i = 0; i < n; i++) + len += strlen(dents[i]->d_name) + 1; -int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file fd, void* buf, - size_t length, int64_t offset, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_READ, NULL, cb); + buf = malloc(len); - if (cb) { - /* async */ - req->eio = eio_read(fd, buf, length, offset, EIO_PRI_DEFAULT, - uv__fs_after, req, &loop->uv_eio_channel); + if (buf == NULL) { + errno = ENOMEM; + n = -1; + goto out; + } - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; - } + off = 0; - } else { - /* sync */ - req->result = offset < 0 ? - read(fd, buf, length) : - pread(fd, buf, length, offset); + for (i = 0; i < n; i++) { + len = strlen(dents[i]->d_name) + 1; + memcpy(buf + off, dents[i]->d_name, len); + off += len; + } - if (req->result < 0) { - uv__set_sys_error(loop, errno); - return -1; - } + req->ptr = buf; - return req->result; +out: + saved_errno = errno; + { + for (i = 0; i < n; i++) + free(dents[i]); + free(dents); } + errno = saved_errno; - return 0; + return n; } -int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - WRAP_EIO(UV_FS_UNLINK, eio_unlink, unlink, ARGS1(path)) -} +static ssize_t uv__fs_readlink(uv_fs_t* req) { + ssize_t len; + char* buf; + len = pathconf(req->path, _PC_PATH_MAX); -int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, - size_t length, int64_t offset, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_WRITE, NULL, cb); + if (len == -1) { +#if defined(PATH_MAX) + len = PATH_MAX; +#else + len = 4096; +#endif + } - if (cb) { - /* async */ - req->eio = eio_write(file, buf, length, offset, EIO_PRI_DEFAULT, - uv__fs_after, req, &loop->uv_eio_channel); - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; - } + buf = malloc(len + 1); - } else { - /* sync */ - req->result = offset < 0 ? - write(file, buf, length) : - pwrite(file, buf, length, offset); + if (buf == NULL) { + errno = ENOMEM; + return -1; + } - if (req->result < 0) { - uv__set_sys_error(loop, errno); - return -1; - } + len = readlink(req->path, buf, len); - return req->result; + if (len == -1) { + free(buf); + return -1; } + buf[len] = '\0'; + req->ptr = buf; + return 0; } -int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, - uv_fs_cb cb) { - WRAP_EIO(UV_FS_MKDIR, eio_mkdir, mkdir, ARGS2(path, mode)) -} +static ssize_t uv__fs_sendfile_emul(uv_fs_t* req) { + struct pollfd pfd; + int use_pread; + off_t offset; + ssize_t nsent; + ssize_t nread; + ssize_t nwritten; + size_t buflen; + size_t len; + ssize_t n; + int in_fd; + int out_fd; + char buf[8192]; + + len = req->len; + in_fd = req->flags; + out_fd = req->file; + offset = req->off; + use_pread = 1; + + /* Here are the rules regarding errors: + * + * 1. Read errors are reported only if nsent==0, otherwise we return nsent. + * The user needs to know that some data has already been sent, to stop + * him from sending it twice. + * + * 2. Write errors are always reported. Write errors are bad because they + * mean data loss: we've read data but now we can't write it out. + * + * We try to use pread() and fall back to regular read() if the source fd + * doesn't support positional reads, for example when it's a pipe fd. + * + * If we get EAGAIN when writing to the target fd, we poll() on it until + * it becomes writable again. + * + * FIXME: If we get a write error when use_pread==1, it should be safe to + * return the number of sent bytes instead of an error because pread() + * is, in theory, idempotent. However, special files in /dev or /proc + * may support pread() but not necessarily return the same data on + * successive reads. + * + * FIXME: There is no way now to signal that we managed to send *some* data + * before a write error. + */ + for (nsent = 0; (size_t) nsent < len; ) { + buflen = len - nsent; + if (buflen > sizeof(buf)) + buflen = sizeof(buf); -int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - WRAP_EIO(UV_FS_RMDIR, eio_rmdir, rmdir, ARGS1(path)) -} + do + if (use_pread) + nread = pread(in_fd, buf, buflen, offset); + else + nread = read(in_fd, buf, buflen); + while (nread == -1 && errno == EINTR); + if (nread == 0) + goto out; -int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, - uv_fs_cb cb) { - int r; - struct dirent* entry; - size_t size = 0; - size_t d_namlen = 0; + if (nread == -1) { + if (use_pread && nsent == 0 && (errno == EIO || errno == ESPIPE)) { + use_pread = 0; + continue; + } - uv_fs_req_init(loop, req, UV_FS_READDIR, path, cb); + if (nsent == 0) + nsent = -1; - if (cb) { - /* async */ - req->eio = eio_readdir(path, flags, EIO_PRI_DEFAULT, uv__fs_after, req, &loop->uv_eio_channel); - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; + goto out; } - } else { - /* sync */ - DIR* dir = opendir(path); - if (!dir) { - uv__set_sys_error(loop, errno); - req->result = -1; - return -1; - } + for (nwritten = 0; nwritten < nread; ) { + do + n = write(out_fd, buf + nwritten, nread - nwritten); + while (n == -1 && errno == EINTR); - /* req->result stores number of entries */ - req->result = 0; - - while ((entry = readdir(dir))) { - d_namlen = strlen(entry->d_name); - - /* Skip . and .. */ - if ((d_namlen == 1 && entry->d_name[0] == '.') || - (d_namlen == 2 && entry->d_name[0] == '.' && - entry->d_name[1] == '.')) { + if (n != -1) { + nwritten += n; continue; } - req->ptr = realloc(req->ptr, size + d_namlen + 1); - /* TODO check ENOMEM */ - memcpy((char*)req->ptr + size, entry->d_name, d_namlen); - size += d_namlen; - ((char*)req->ptr)[size] = '\0'; - size++; - req->result++; - } + if (errno != EAGAIN && errno != EWOULDBLOCK) { + nsent = -1; + goto out; + } + + pfd.fd = out_fd; + pfd.events = POLLOUT; + pfd.revents = 0; + + do + n = poll(&pfd, 1, -1); + while (n == -1 && errno == EINTR); - r = closedir(dir); - if (r) { - uv__set_sys_error(loop, errno); - req->result = -1; - return -1; + if (n == -1 || (pfd.revents & ~POLLOUT) != 0) { + nsent = -1; + goto out; + } } - return req->result; + offset += nread; + nsent += nread; } - return 0; +out: + if (nsent != -1) + req->off = offset; + + return nsent; } -int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - char* pathdup; - int pathlen; +static ssize_t uv__fs_sendfile(uv_fs_t* req) { + int in_fd; + int out_fd; - uv_fs_req_init(loop, req, UV_FS_STAT, path, cb); + in_fd = req->flags; + out_fd = req->file; - /* TODO do this without duplicating the string. */ - /* TODO security */ - pathdup = strdup(path); - pathlen = strlen(path); +#if defined(__linux__) || defined(__sun) + { + off_t off; + ssize_t r; - if (pathlen > 0 && path[pathlen - 1] == '\\') { - /* TODO do not modify input string */ - pathdup[pathlen - 1] = '\0'; - } - - if (cb) { - /* async */ - req->eio = eio_stat(pathdup, EIO_PRI_DEFAULT, uv__fs_after, req, &loop->uv_eio_channel); + off = req->off; + r = sendfile(out_fd, in_fd, &off, req->len); - free(pathdup); + /* sendfile() on SunOS returns EINVAL if the target fd is not a socket but + * it still writes out data. Fortunately, we can detect it by checking if + * the offset has been updated. + */ + if (r != -1 || off > req->off) { + r = off - req->off; + req->off = off; + return r; + } - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; + if (errno == EINVAL || + errno == EIO || + errno == ENOTSOCK || + errno == EXDEV) { + return uv__fs_sendfile_emul(req); } - } else { - /* sync */ - req->result = stat(pathdup, &req->statbuf); + return -1; + } +#elif defined(__FreeBSD__) || defined(__APPLE__) + { + off_t len; + ssize_t r; + + /* sendfile() on FreeBSD and Darwin returns EAGAIN if the target fd is in + * non-blocking mode and not all data could be written. If a non-zero + * number of bytes have been sent, we don't consider it an error. + */ + len = 0; - free(pathdup); +#if defined(__FreeBSD__) + r = sendfile(in_fd, out_fd, req->off, req->len, NULL, &len, 0); +#else + r = sendfile(in_fd, out_fd, req->off, &len, NULL, 0); +#endif - if (req->result < 0) { - uv__set_sys_error(loop, errno); - return -1; + if (r != -1 || len != 0) { + req->off += len; + return (ssize_t) len; } - req->ptr = &req->statbuf; - return req->result; - } + if (errno == EINVAL || + errno == EIO || + errno == ENOTSOCK || + errno == EXDEV) { + return uv__fs_sendfile_emul(req); + } - return 0; + return -1; + } +#else + return uv__fs_sendfile_emul(req); +#endif } -int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - uv_fs_req_init(loop, req, UV_FS_FSTAT, NULL, cb); - - if (cb) { - /* async */ - req->eio = eio_fstat(file, EIO_PRI_DEFAULT, uv__fs_after, req, &loop->uv_eio_channel); - - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; +static ssize_t uv__fs_utime(uv_fs_t* req) { + struct utimbuf buf; + buf.actime = req->atime; + buf.modtime = req->mtime; + return utime(req->path, &buf); /* TODO use utimes() where available */ +} + + +static ssize_t uv__fs_write(uv_fs_t* req) { + if (req->off < 0) + return write(req->file, req->buf, req->len); + else + return uv__fs_pwrite(req); +} + + +static void uv__fs_work(struct uv__work* w) { + int retry_on_eintr; + uv_fs_t* req; + ssize_t r; + + req = container_of(w, uv_fs_t, work_req); + retry_on_eintr = !(req->fs_type == UV_FS_CLOSE); + + do { + errno = 0; + +#define X(type, action) \ + case UV_FS_ ## type: \ + r = action; \ + break; + + switch (req->fs_type) { + X(CHMOD, chmod(req->path, req->mode)); + X(CHOWN, chown(req->path, req->uid, req->gid)); + X(CLOSE, close(req->file)); + X(FCHMOD, fchmod(req->file, req->mode)); + X(FCHOWN, fchown(req->file, req->uid, req->gid)); + X(FDATASYNC, uv__fs_fdatasync(req)); + X(FSTAT, fstat(req->file, &req->statbuf)); + X(FSYNC, fsync(req->file)); + X(FTRUNCATE, ftruncate(req->file, req->off)); + X(FUTIME, uv__fs_futime(req)); + X(LSTAT, lstat(req->path, &req->statbuf)); + X(LINK, link(req->path, req->new_path)); + X(MKDIR, mkdir(req->path, req->mode)); + X(OPEN, open(req->path, req->flags, req->mode)); + X(READ, uv__fs_read(req)); + X(READDIR, uv__fs_readdir(req)); + X(READLINK, uv__fs_readlink(req)); + X(RENAME, rename(req->path, req->new_path)); + X(RMDIR, rmdir(req->path)); + X(SENDFILE, uv__fs_sendfile(req)); + X(STAT, stat(req->path, &req->statbuf)); + X(SYMLINK, symlink(req->path, req->new_path)); + X(UNLINK, unlink(req->path)); + X(UTIME, uv__fs_utime(req)); + X(WRITE, uv__fs_write(req)); + default: abort(); } - } else { - /* sync */ - req->result = fstat(file, &req->statbuf); +#undef X + } + while (r == -1 && errno == EINTR && retry_on_eintr); - if (req->result < 0) { - uv__set_sys_error(loop, errno); - return -1; - } + req->errorno = errno; + req->result = r; + if (r == 0 && (req->fs_type == UV_FS_STAT || + req->fs_type == UV_FS_FSTAT || + req->fs_type == UV_FS_LSTAT)) { req->ptr = &req->statbuf; - return req->result; } - - return 0; } -int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, - uv_fs_cb cb) { - WRAP_EIO(UV_FS_RENAME, eio_rename, rename, ARGS2(path, new_path)) -} +static void uv__fs_done(struct uv__work* w) { + uv_fs_t* req; + req = container_of(w, uv_fs_t, work_req); + uv__req_unregister(req->loop, req); -int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - char* path = NULL; - WRAP_EIO(UV_FS_FSYNC, eio_fsync, fsync, ARGS1(file)) + if (req->errorno != 0) { + req->errorno = uv_translate_sys_error(req->errorno); + uv__set_artificial_error(req->loop, req->errorno); + } + + if (req->cb != NULL) + req->cb(req); } -#if defined(__APPLE__) && defined(F_FULLFSYNC) -ssize_t uv__fs_fdatasync(uv_file file) { - return fcntl(file, F_FULLFSYNC); +int uv_fs_chmod(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb) { + INIT(CHMOD); + PATH; + req->mode = mode; + POST; } -void uv__fs_fdatasync_work(eio_req* eio) { - uv_fs_t* req = eio->data; - - eio->result = uv__fs_fdatasync(req->file); +int uv_fs_chown(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int uid, + int gid, + uv_fs_cb cb) { + INIT(CHOWN); + PATH; + req->uid = uid; + req->gid = gid; + POST; } -#endif -int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { - char* path = NULL; -#if defined(__FreeBSD__) \ - || (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060) - /* freebsd and pre-10.6 darwin don't have fdatasync, - * do a full fsync instead. - */ - WRAP_EIO(UV_FS_FDATASYNC, eio_fdatasync, fsync, ARGS1(file)) -#elif defined(__APPLE__) && defined(F_FULLFSYNC) - /* OSX >= 10.6 does have fdatasync, but better use fcntl anyway */ - uv_fs_req_init(loop, req, UV_FS_FDATASYNC, path, cb); +int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { + INIT(CLOSE); req->file = file; - - if (cb) { - /* async */ - req->eio = eio_custom(uv__fs_fdatasync_work, - EIO_PRI_DEFAULT, - uv__fs_after, - req, - &loop->uv_eio_channel); - if (req->eio == NULL) { - uv__set_sys_error(loop, ENOMEM); - return -1; - } - } else { - /* sync */ - req->result = uv__fs_fdatasync(file); - if (req->result) { - uv__set_sys_error(loop, errno); - } - return req->result; - } - return 0; -#else - WRAP_EIO(UV_FS_FDATASYNC, eio_fdatasync, fdatasync, ARGS1(file)) -#endif + POST; } -int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, int64_t offset, - uv_fs_cb cb) { - char* path = NULL; - WRAP_EIO(UV_FS_FTRUNCATE, eio_ftruncate, ftruncate, ARGS2(file, offset)) +int uv_fs_fchmod(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + int mode, + uv_fs_cb cb) { + INIT(FCHMOD); + req->file = file; + req->mode = mode; + POST; } -int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_file in_fd, - int64_t in_offset, size_t length, uv_fs_cb cb) { - char* path = NULL; - WRAP_EIO(UV_FS_SENDFILE, eio_sendfile, eio_sendfile_sync, - ARGS4(out_fd, in_fd, in_offset, length)) +int uv_fs_fchown(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + int uid, + int gid, + uv_fs_cb cb) { + INIT(FCHOWN); + req->file = file; + req->uid = uid; + req->gid = gid; + POST; } -int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, - uv_fs_cb cb) { - WRAP_EIO(UV_FS_CHMOD, eio_chmod, chmod, ARGS2(path, mode)) +int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { + INIT(FDATASYNC); + req->file = file; + POST; } -static int _utime(const char* path, double atime, double mtime) { - struct utimbuf buf; - buf.actime = atime; - buf.modtime = mtime; - return utime(path, &buf); +int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { + INIT(FSTAT); + req->file = file; + POST; } -int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, - double mtime, uv_fs_cb cb) { - WRAP_EIO(UV_FS_UTIME, eio_utime, _utime, ARGS3(path, atime, mtime)) +int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { + INIT(FSYNC); + req->file = file; + POST; } -static int _futime(const uv_file fd, double atime, double mtime) { -#if __linux__ - /* utimesat() has nanosecond resolution but we stick to microseconds - * for the sake of consistency with other platforms. - */ - struct timespec ts[2]; - ts[0].tv_sec = atime; - ts[0].tv_nsec = (unsigned long)(atime * 1000000) % 1000000 * 1000; - ts[1].tv_sec = mtime; - ts[1].tv_nsec = (unsigned long)(mtime * 1000000) % 1000000 * 1000; - return uv__utimesat(fd, NULL, ts, 0); -#elif HAVE_FUTIMES - struct timeval tv[2]; - tv[0].tv_sec = atime; - tv[0].tv_usec = (unsigned long)(atime * 1000000) % 1000000; - tv[1].tv_sec = mtime; - tv[1].tv_usec = (unsigned long)(mtime * 1000000) % 1000000; - return futimes(fd, tv); -#else /* !HAVE_FUTIMES */ - errno = ENOSYS; - return -1; -#endif +int uv_fs_ftruncate(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + int64_t off, + uv_fs_cb cb) { + INIT(FTRUNCATE); + req->file = file; + req->off = off; + POST; } -int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, - double mtime, uv_fs_cb cb) { - const char* path = NULL; - WRAP_EIO(UV_FS_FUTIME, eio_futime, _futime, ARGS3(file, atime, mtime)) +int uv_fs_futime(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + double atime, + double mtime, + uv_fs_cb cb) { + INIT(FUTIME); + req->file = file; + req->atime = atime; + req->mtime = mtime; + POST; } int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { - char* pathdup; - int pathlen; - - uv_fs_req_init(loop, req, UV_FS_LSTAT, path, cb); - - /* TODO do this without duplicating the string. */ - /* TODO security */ - pathdup = strdup(path); - pathlen = strlen(path); - - if (pathlen > 0 && path[pathlen - 1] == '\\') { - /* TODO do not modify input string */ - pathdup[pathlen - 1] = '\0'; - } - - if (cb) { - /* async */ - req->eio = eio_lstat(pathdup, EIO_PRI_DEFAULT, uv__fs_after, req, &loop->uv_eio_channel); - - free(pathdup); - - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; - } - - } else { - /* sync */ - req->result = lstat(pathdup, &req->statbuf); - - free(pathdup); - - if (req->result < 0) { - uv__set_sys_error(loop, errno); - return -1; - } - - req->ptr = &req->statbuf; - return req->result; - } - - return 0; + INIT(LSTAT); + PATH; + POST; } -int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, uv_fs_cb cb) { - WRAP_EIO(UV_FS_LINK, eio_link, link, ARGS2(path, new_path)) +int uv_fs_link(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + uv_fs_cb cb) { + INIT(LINK); + PATH2; + POST; } -int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - const char* new_path, int flags, uv_fs_cb cb) { - WRAP_EIO(UV_FS_SYMLINK, eio_symlink, symlink, ARGS2(path, new_path)) +int uv_fs_mkdir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb) { + INIT(MKDIR); + PATH; + req->mode = mode; + POST; } -int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, - uv_fs_cb cb) { - ssize_t size; - char* buf; - - uv_fs_req_init(loop, req, UV_FS_READLINK, path, cb); - - if (cb) { - if ((req->eio = eio_readlink(path, EIO_PRI_DEFAULT, uv__fs_after, req, &loop->uv_eio_channel))) { - return 0; - } else { - uv__set_sys_error(loop, ENOMEM); - return -1; - } - } else { - /* pathconf(_PC_PATH_MAX) may return -1 to signify that path - * lengths have no upper limit or aren't suitable for malloc'ing. - */ - if ((size = pathconf(path, _PC_PATH_MAX)) == -1) { -#if defined(PATH_MAX) - size = PATH_MAX; -#else - size = 4096; -#endif - } +int uv_fs_open(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int flags, + int mode, + uv_fs_cb cb) { + INIT(OPEN); + PATH; + req->flags = flags; + req->mode = mode; + POST; +} - if ((buf = malloc(size + 1)) == NULL) { - uv__set_sys_error(loop, ENOMEM); - return -1; - } - if ((size = readlink(path, buf, size)) == -1) { - req->errorno = errno; - req->result = -1; - free(buf); - } else { - /* Cannot conceivably fail since it shrinks the buffer. */ - buf = realloc(buf, size + 1); - buf[size] = '\0'; - req->result = 0; - req->ptr = buf; - } +int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, + uv_file file, + void* buf, + size_t len, + int64_t off, + uv_fs_cb cb) { + INIT(READ); + req->file = file; + req->buf = buf; + req->len = len; + req->off = off; + POST; +} - return req->result; - } - assert(0 && "unreachable"); +int uv_fs_readdir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int flags, + uv_fs_cb cb) { + INIT(READDIR); + PATH; + req->flags = flags; + POST; } -int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, - uv_fs_cb cb) { - char* path = NULL; - WRAP_EIO(UV_FS_FCHMOD, eio_fchmod, fchmod, ARGS2(file, mode)) +int uv_fs_readlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb) { + INIT(READLINK); + PATH; + POST; } -int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid, - int gid, uv_fs_cb cb) { - WRAP_EIO(UV_FS_CHOWN, eio_chown, chown, ARGS3(path, uid, gid)) +int uv_fs_rename(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + uv_fs_cb cb) { + INIT(RENAME); + PATH2; + POST; } -int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid, int gid, - uv_fs_cb cb) { - char* path = NULL; - WRAP_EIO(UV_FS_FCHOWN, eio_fchown, fchown, ARGS3(file, uid, gid)) +int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { + INIT(RMDIR); + PATH; + POST; } -static void uv__work(eio_req* eio) { - uv_work_t* req = eio->data; - if (req->work_cb) { - req->work_cb(req); - } +int uv_fs_sendfile(uv_loop_t* loop, + uv_fs_t* req, + uv_file out_fd, + uv_file in_fd, + int64_t off, + size_t len, + uv_fs_cb cb) { + INIT(SENDFILE); + req->flags = in_fd; /* hack */ + req->file = out_fd; + req->off = off; + req->len = len; + POST; } -static int uv__after_work(eio_req *eio) { - uv_work_t* req = eio->data; - uv__req_unregister(req->loop, req); - if (req->after_work_cb) { - req->after_work_cb(req); - } - return 0; +int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { + INIT(STAT); + PATH; + POST; } -int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, - uv_after_work_cb after_work_cb) { - void* data = req->data; +int uv_fs_symlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + int flags, + uv_fs_cb cb) { + INIT(SYMLINK); + PATH2; + req->flags = flags; + POST; +} - uv_eio_init(loop); - uv__req_init(loop, req, UV_WORK); - req->loop = loop; - req->data = data; - req->work_cb = work_cb; - req->after_work_cb = after_work_cb; +int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { + INIT(UNLINK); + PATH; + POST; +} + + +int uv_fs_utime(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + double atime, + double mtime, + uv_fs_cb cb) { + INIT(UTIME); + PATH; + req->atime = atime; + req->mtime = mtime; + POST; +} + + +int uv_fs_write(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + void* buf, + size_t len, + int64_t off, + uv_fs_cb cb) { + INIT(WRITE); + req->file = file; + req->buf = buf; + req->len = len; + req->off = off; + POST; +} - req->eio = eio_custom(uv__work, - EIO_PRI_DEFAULT, - uv__after_work, - req, - &loop->uv_eio_channel); - if (!req->eio) { - uv__set_sys_error(loop, ENOMEM); - return -1; - } +void uv_fs_req_cleanup(uv_fs_t* req) { + free((void*) req->path); + req->path = NULL; + req->new_path = NULL; - return 0; + if (req->ptr != &req->statbuf) + free(req->ptr); + req->ptr = NULL; } diff --git a/deps/uv/src/unix/fsevents.c b/deps/uv/src/unix/fsevents.c index 17dd11afa8..ac58d4f18e 100644 --- a/deps/uv/src/unix/fsevents.c +++ b/deps/uv/src/unix/fsevents.c @@ -66,14 +66,9 @@ void uv__fsevents_cb(uv_async_t* cb, int status) { handle = cb->data; UV__FSEVENTS_WALK(handle, { - if (handle->fd != -1) { -#ifdef MAC_OS_X_VERSION_10_7 - handle->cb(handle, event->path, event->events, 0); -#else - handle->cb(handle, NULL, event->events, 0); -#endif /* MAC_OS_X_VERSION_10_7 */ - } - }) + if (handle->fd != -1) + handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0); + }); if ((handle->flags & (UV_CLOSING | UV_CLOSED)) == 0 && handle->fd == -1) uv__fsevents_close(handle); @@ -94,6 +89,17 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, uv_fs_event_t* handle; uv__fsevents_event_t* event; ngx_queue_t add_list; + int kFSEventsModified; + int kFSEventsRenamed; + + kFSEventsModified = kFSEventStreamEventFlagItemFinderInfoMod | + kFSEventStreamEventFlagItemModified | + kFSEventStreamEventFlagItemInodeMetaMod | + kFSEventStreamEventFlagItemChangeOwner | + kFSEventStreamEventFlagItemXattrMod; + kFSEventsRenamed = kFSEventStreamEventFlagItemCreated | + kFSEventStreamEventFlagItemRemoved | + kFSEventStreamEventFlagItemRenamed; handle = info; paths = eventPaths; @@ -151,7 +157,8 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, memcpy(event->path, path, len + 1); - if (eventFlags[i] & kFSEventStreamEventFlagItemModified) + if ((eventFlags[i] & kFSEventsModified) != 0 && + (eventFlags[i] & kFSEventsRenamed) == 0) event->events = UV_CHANGE; else event->events = UV_RENAME; diff --git a/deps/uv/src/unix/getaddrinfo.c b/deps/uv/src/unix/getaddrinfo.c new file mode 100644 index 0000000000..d6bc698812 --- /dev/null +++ b/deps/uv/src/unix/getaddrinfo.c @@ -0,0 +1,144 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "internal.h" + +#include +#include /* NULL */ +#include +#include + + +static void uv__getaddrinfo_work(struct uv__work* w) { + uv_getaddrinfo_t* req = container_of(w, uv_getaddrinfo_t, work_req); + + req->retcode = getaddrinfo(req->hostname, + req->service, + req->hints, + &req->res); +} + + +static void uv__getaddrinfo_done(struct uv__work* w) { + uv_getaddrinfo_t* req = container_of(w, uv_getaddrinfo_t, work_req); + struct addrinfo *res = req->res; +#if __sun + size_t hostlen = strlen(req->hostname); +#endif + + req->res = NULL; + + uv__req_unregister(req->loop, req); + + /* see initialization in uv_getaddrinfo() */ + if (req->hints) + free(req->hints); + else if (req->service) + free(req->service); + else if (req->hostname) + free(req->hostname); + else + assert(0); + + if (req->retcode == 0) { + /* OK */ +#if EAI_NODATA /* FreeBSD deprecated EAI_NODATA */ + } else if (req->retcode == EAI_NONAME || req->retcode == EAI_NODATA) { +#else + } else if (req->retcode == EAI_NONAME) { +#endif + uv__set_sys_error(req->loop, ENOENT); /* FIXME compatibility hack */ +#if __sun + } else if (req->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) { + uv__set_sys_error(req->loop, ENOENT); +#endif + } else { + req->loop->last_err.code = UV_EADDRINFO; + req->loop->last_err.sys_errno_ = req->retcode; + } + + req->cb(req, req->retcode, res); +} + + +int uv_getaddrinfo(uv_loop_t* loop, + uv_getaddrinfo_t* req, + uv_getaddrinfo_cb cb, + const char* hostname, + const char* service, + const struct addrinfo* hints) { + size_t hostname_len; + size_t service_len; + size_t hints_len; + size_t len; + char* buf; + + if (req == NULL || cb == NULL || (hostname == NULL && service == NULL)) + return uv__set_artificial_error(loop, UV_EINVAL); + + hostname_len = hostname ? strlen(hostname) + 1 : 0; + service_len = service ? strlen(service) + 1 : 0; + hints_len = hints ? sizeof(*hints) : 0; + buf = malloc(hostname_len + service_len + hints_len); + + if (buf == NULL) + return uv__set_artificial_error(loop, UV_ENOMEM); + + uv__req_init(loop, req, UV_GETADDRINFO); + req->loop = loop; + req->cb = cb; + req->res = NULL; + req->hints = NULL; + req->service = NULL; + req->hostname = NULL; + req->retcode = 0; + + /* order matters, see uv_getaddrinfo_done() */ + len = 0; + + if (hints) { + req->hints = memcpy(buf + len, hints, sizeof(*hints)); + len += sizeof(*hints); + } + + if (service) { + req->service = memcpy(buf + len, service, service_len); + len += service_len; + } + + if (hostname) { + req->hostname = memcpy(buf + len, hostname, hostname_len); + len += hostname_len; + } + + uv__work_submit(loop, + &req->work_req, + uv__getaddrinfo_work, + uv__getaddrinfo_done); + + return 0; +} + + +void uv_freeaddrinfo(struct addrinfo* ai) { + if (ai) + freeaddrinfo(ai); +} diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 20dd23c718..5685e1a84d 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -23,7 +23,6 @@ #define UV_UNIX_INTERNAL_H_ #include "uv-common.h" -#include "uv-eio.h" #include #include /* abort */ @@ -101,11 +100,6 @@ enum { UV_TCP_SINGLE_ACCEPT = 0x400 /* Only accept() when idle. */ }; -/* loop flags */ -enum { - UV_LOOP_EIO_INITIALIZED = 1 -}; - __attribute__((unused)) __attribute__((always_inline)) static void uv__req_init(uv_loop_t* loop, uv_req_t* req, uv_req_type type) { @@ -165,6 +159,13 @@ unsigned int uv__next_timeout(uv_loop_t* loop); void uv__signal_close(uv_signal_t* handle); void uv__signal_unregister(uv_loop_t* loop); +/* thread pool */ +void uv__work_submit(uv_loop_t* loop, + struct uv__work *w, + void (*work)(struct uv__work *w), + void (*done)(struct uv__work *w)); +void uv__work_done(uv_async_t* handle, int status); + /* platform specific */ int uv__platform_loop_init(uv_loop_t* loop, int default_loop); void uv__platform_loop_delete(uv_loop_t* loop); diff --git a/deps/uv/src/unix/linux/linux-core.c b/deps/uv/src/unix/linux/linux-core.c index 167423f14c..a773b0794d 100644 --- a/deps/uv/src/unix/linux/linux-core.c +++ b/deps/uv/src/unix/linux/linux-core.c @@ -57,6 +57,7 @@ #endif static char buf[MAXPATHLEN + 1]; +static void* args_mem; static struct { char *str; @@ -69,6 +70,12 @@ static void read_times(unsigned int numcpus, uv_cpu_info_t* ci); static unsigned long read_cpufreq(unsigned int cpunum); +__attribute__((destructor)) +static void free_args_mem(void) { + free(args_mem); /* keep valgrind happy */ +} + + int uv__platform_loop_init(uv_loop_t* loop, int default_loop) { loop->inotify_watchers = NULL; loop->inotify_fd = -1; @@ -147,11 +154,12 @@ char** uv_setup_args(int argc, char** argv) { size += (argc + 1) * sizeof(char **); size += (envc + 1) * sizeof(char **); - if ((s = (char *) malloc(size)) == NULL) { + if (NULL == (s = malloc(size))) { process_title.str = NULL; process_title.len = 0; return argv; } + args_mem = s; new_argv = (char **) s; new_env = new_argv + argc + 1; diff --git a/deps/uv/src/unix/loop.c b/deps/uv/src/unix/loop.c index 5cd3bd0c81..7d41c005af 100644 --- a/deps/uv/src/unix/loop.c +++ b/deps/uv/src/unix/loop.c @@ -38,8 +38,8 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) { #endif memset(loop, 0, sizeof(*loop)); - RB_INIT(&loop->timer_handles); + ngx_queue_init(&loop->wq); ngx_queue_init(&loop->active_reqs); ngx_queue_init(&loop->idle_handles); ngx_queue_init(&loop->async_handles); @@ -54,7 +54,6 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) { loop->emfile_fd = -1; loop->ev = (default_loop ? ev_default_loop : ev_loop_new)(flags); ev_set_userdata(loop->ev, loop); - eio_channel_init(&loop->uv_eio_channel, loop); uv_signal_init(loop, &loop->child_watcher); uv__handle_unref(&loop->child_watcher); @@ -63,6 +62,15 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) { for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++) ngx_queue_init(loop->process_handles + i); + if (uv_mutex_init(&loop->wq_mutex)) + abort(); + + if (uv_async_init(loop, &loop->wq_async, uv__work_done)) + abort(); + + uv__handle_unref(&loop->wq_async); + loop->wq_async.flags |= UV__HANDLE_INTERNAL; + if (uv__platform_loop_init(loop, default_loop)) return -1; @@ -75,8 +83,23 @@ void uv__loop_delete(uv_loop_t* loop) { uv__signal_unregister(loop); ev_loop_destroy(loop->ev); + if (loop->async_pipefd[0] != -1) { + close(loop->async_pipefd[0]); + loop->async_pipefd[0] = -1; + } + + if (loop->async_pipefd[1] != -1) { + close(loop->async_pipefd[1]); + loop->async_pipefd[1] = -1; + } + if (loop->emfile_fd != -1) { close(loop->emfile_fd); loop->emfile_fd = -1; } + + uv_mutex_lock(&loop->wq_mutex); + assert(ngx_queue_empty(&loop->wq) && "thread pool work queue not empty!"); + uv_mutex_unlock(&loop->wq_mutex); + uv_mutex_destroy(&loop->wq_mutex); } diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index b00cfb5b86..7743ce5aa7 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -101,6 +101,8 @@ void uv__stream_init(uv_loop_t* loop, uv_stream_t* stream, uv_handle_type type) { uv__handle_init(loop, (uv_handle_t*)stream, type); + stream->read_cb = NULL; + stream->read2_cb = NULL; stream->alloc_cb = NULL; stream->close_cb = NULL; stream->connection_cb = NULL; diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index f85de1a4ab..f50961c921 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -26,6 +26,12 @@ #include #include +#if defined(__APPLE__) && defined(__MACH__) +#include +#endif /* defined(__APPLE__) && defined(__MACH__) */ + +#undef NANOSEC +#define NANOSEC ((uint64_t) 1e9) int uv_thread_join(uv_thread_t *tid) { if (pthread_join(*tid, NULL)) @@ -258,3 +264,109 @@ int uv_sem_trywait(uv_sem_t* sem) { } #endif /* defined(__APPLE__) && defined(__MACH__) */ + + +#if defined(__APPLE__) && defined(__MACH__) + +int uv_cond_init(uv_cond_t* cond) { + if (pthread_cond_init(cond, NULL)) + return -1; + else + return 0; +} + +#else /* !(defined(__APPLE__) && defined(__MACH__)) */ + +int uv_cond_init(uv_cond_t* cond) { + pthread_condattr_t attr; + + if (pthread_condattr_init(&attr)) + return -1; + + if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC)) + goto error2; + + if (pthread_cond_init(cond, &attr)) + goto error2; + + if (pthread_condattr_destroy(&attr)) + goto error; + + return 0; + +error: + pthread_cond_destroy(cond); +error2: + pthread_condattr_destroy(&attr); + return -1; +} + +#endif /* defined(__APPLE__) && defined(__MACH__) */ + +void uv_cond_destroy(uv_cond_t* cond) { + if (pthread_cond_destroy(cond)) + abort(); +} + +void uv_cond_signal(uv_cond_t* cond) { + if (pthread_cond_signal(cond)) + abort(); +} + +void uv_cond_broadcast(uv_cond_t* cond) { + if (pthread_cond_broadcast(cond)) + abort(); +} + +void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { + if (pthread_cond_wait(cond, mutex)) + abort(); +} + +#if defined(__APPLE__) && defined(__MACH__) + +int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { + int r; + struct timeval tv; + struct timespec ts; + uint64_t abstime; + + gettimeofday(&tv, NULL); + abstime = tv.tv_sec * 1e9 + tv.tv_usec * 1e3 + timeout; + ts.tv_sec = abstime / NANOSEC; + ts.tv_nsec = abstime % NANOSEC; + r = pthread_cond_timedwait(cond, mutex, &ts); + + if (r == 0) + return 0; + + if (r == ETIMEDOUT) + return -1; + + abort(); + return -1; /* Satisfy the compiler. */ +} + +#else /* !(defined(__APPLE__) && defined(__MACH__)) */ + +int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { + int r; + struct timespec ts; + uint64_t abstime; + + abstime = uv_hrtime() + timeout; + ts.tv_sec = abstime / NANOSEC; + ts.tv_nsec = abstime % NANOSEC; + r = pthread_cond_timedwait(cond, mutex, &ts); + + if (r == 0) + return 0; + + if (r == ETIMEDOUT) + return -1; + + abort(); + return -1; /* Satisfy the compiler. */ +} + +#endif /* defined(__APPLE__) && defined(__MACH__) */ diff --git a/deps/uv/src/unix/threadpool.c b/deps/uv/src/unix/threadpool.c new file mode 100644 index 0000000000..0a02766e65 --- /dev/null +++ b/deps/uv/src/unix/threadpool.c @@ -0,0 +1,176 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "internal.h" + +#include +#include + +/* TODO add condvar support to libuv */ +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +static pthread_once_t once = PTHREAD_ONCE_INIT; +static pthread_t threads[4]; +static ngx_queue_t exit_message; +static ngx_queue_t wq = { &wq, &wq }; + + +static void* worker(void* arg) { + struct uv__work* w; + ngx_queue_t* q; + + (void) arg; + + for (;;) { + if (pthread_mutex_lock(&mutex)) + abort(); + + while (ngx_queue_empty(&wq)) + if (pthread_cond_wait(&cond, &mutex)) + abort(); + + q = ngx_queue_head(&wq); + + if (q == &exit_message) + pthread_cond_signal(&cond); + else + ngx_queue_remove(q); + + if (pthread_mutex_unlock(&mutex)) + abort(); + + if (q == &exit_message) + break; + + w = ngx_queue_data(q, struct uv__work, wq); + w->work(w); + + uv_mutex_lock(&w->loop->wq_mutex); + ngx_queue_insert_tail(&w->loop->wq, &w->wq); + uv_mutex_unlock(&w->loop->wq_mutex); + uv_async_send(&w->loop->wq_async); + } + + return NULL; +} + + +static void post(ngx_queue_t* q) { + pthread_mutex_lock(&mutex); + ngx_queue_insert_tail(&wq, q); + pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); +} + + +static void init_once(void) { + unsigned int i; + + ngx_queue_init(&wq); + + for (i = 0; i < ARRAY_SIZE(threads); i++) + if (pthread_create(threads + i, NULL, worker, NULL)) + abort(); +} + + +__attribute__((destructor)) +static void cleanup(void) { + unsigned int i; + int err; + + post(&exit_message); + + for (i = 0; i < ARRAY_SIZE(threads); i++) { + err = pthread_join(threads[i], NULL); + assert(err == 0 || err == EINVAL || err == ESRCH); + (void) err; /* Silence compiler warning in release builds. */ + } +} + + +void uv__work_submit(uv_loop_t* loop, + struct uv__work* w, + void (*work)(struct uv__work* w), + void (*done)(struct uv__work* w)) { + pthread_once(&once, init_once); + w->loop = loop; + w->work = work; + w->done = done; + post(&w->wq); +} + + +void uv__work_done(uv_async_t* handle, int status) { + struct uv__work* w; + uv_loop_t* loop; + ngx_queue_t* q; + ngx_queue_t wq; + + loop = container_of(handle, uv_loop_t, wq_async); + ngx_queue_init(&wq); + + uv_mutex_lock(&loop->wq_mutex); + if (!ngx_queue_empty(&loop->wq)) { + q = ngx_queue_head(&loop->wq); + ngx_queue_split(&loop->wq, q, &wq); + } + uv_mutex_unlock(&loop->wq_mutex); + + while (!ngx_queue_empty(&wq)) { + q = ngx_queue_head(&wq); + ngx_queue_remove(q); + + w = container_of(q, struct uv__work, wq); + w->done(w); + } +} + + +static void uv__queue_work(struct uv__work* w) { + uv_work_t* req = container_of(w, uv_work_t, work_req); + + if (req->work_cb) + req->work_cb(req); +} + + +static void uv__queue_done(struct uv__work* w) { + uv_work_t* req = container_of(w, uv_work_t, work_req); + + uv__req_unregister(req->loop, req); + + if (req->after_work_cb) + req->after_work_cb(req); +} + + +int uv_queue_work(uv_loop_t* loop, + uv_work_t* req, + uv_work_cb work_cb, + uv_after_work_cb after_work_cb) { + uv__req_init(loop, req, UV_WORK); + req->loop = loop; + req->work_cb = work_cb; + req->after_work_cb = after_work_cb; + uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done); + return 0; +} diff --git a/deps/uv/src/unix/uv-eio.c b/deps/uv/src/unix/uv-eio.c deleted file mode 100644 index e5ba2f2715..0000000000 --- a/deps/uv/src/unix/uv-eio.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* This file integrates the libuv event loop with the libeio thread pool */ - -#include "uv.h" -#include "eio.h" -#include "internal.h" - -#include -#include - - -static uv_once_t uv__eio_init_once_guard = UV_ONCE_INIT; - - -static void uv_eio_do_poll(uv_idle_t* watcher, int status) { - uv_loop_t* loop = watcher->loop; - assert(watcher == &loop->uv_eio_poller); - if (eio_poll(&loop->uv_eio_channel) != -1) - uv_idle_stop(watcher); -} - - -/* Called from the main thread. */ -static void uv_eio_want_poll_notifier_cb(uv_async_t* watcher, int status) { - uv_loop_t* loop = watcher->loop; - assert(watcher == &loop->uv_eio_want_poll_notifier); - if (eio_poll(&loop->uv_eio_channel) == -1) - uv_idle_start(&loop->uv_eio_poller, uv_eio_do_poll); -} - - -static void uv_eio_done_poll_notifier_cb(uv_async_t* watcher, int revents) { - uv_loop_t* loop = watcher->loop; - assert(watcher == &loop->uv_eio_done_poll_notifier); - if (eio_poll(&loop->uv_eio_channel) != -1) - uv_idle_stop(&loop->uv_eio_poller); -} - - -/* - * uv_eio_want_poll() is called from the EIO thread pool each time an EIO - * request (that is, one of the node.fs.* functions) has completed. - */ -static void uv_eio_want_poll(eio_channel *channel) { - /* Signal the main thread that eio_poll need to be processed. */ - uv_loop_t* loop = channel->data; - uv_async_send(&loop->uv_eio_want_poll_notifier); -} - - -static void uv_eio_done_poll(eio_channel *channel) { - /* - * Signal the main thread that we should stop calling eio_poll(). - * from the idle watcher. - */ - uv_loop_t* loop = channel->data; - uv_async_send(&loop->uv_eio_done_poll_notifier); -} - - -static void uv__eio_init(void) { - eio_init(uv_eio_want_poll, uv_eio_done_poll); -} - - -void uv_eio_init(uv_loop_t* loop) { - if (loop->flags & UV_LOOP_EIO_INITIALIZED) return; - loop->flags |= UV_LOOP_EIO_INITIALIZED; - - uv_idle_init(loop, &loop->uv_eio_poller); - uv_idle_start(&loop->uv_eio_poller, uv_eio_do_poll); - loop->uv_eio_poller.flags |= UV__HANDLE_INTERNAL; - - loop->uv_eio_want_poll_notifier.data = loop; - uv_async_init(loop, - &loop->uv_eio_want_poll_notifier, - uv_eio_want_poll_notifier_cb); - loop->uv_eio_want_poll_notifier.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&loop->uv_eio_want_poll_notifier); - - uv_async_init(loop, - &loop->uv_eio_done_poll_notifier, - uv_eio_done_poll_notifier_cb); - loop->uv_eio_done_poll_notifier.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&loop->uv_eio_done_poll_notifier); - - uv_once(&uv__eio_init_once_guard, uv__eio_init); -} diff --git a/deps/uv/src/unix/uv-eio.h b/deps/uv/src/unix/uv-eio.h deleted file mode 100644 index 711d0cf281..0000000000 --- a/deps/uv/src/unix/uv-eio.h +++ /dev/null @@ -1,13 +0,0 @@ -/* This header is private to libuv */ -#ifndef UV_EIO_H_ -#define UV_EIO_H_ - -#include "eio.h" - -/* - * Call this function to integrate libeio into the libuv event loop. It is - * safe to call more than once. - * TODO: uv_eio_deinit - */ -void uv_eio_init(uv_loop_t*); -#endif diff --git a/deps/uv/src/win/thread.c b/deps/uv/src/win/thread.c index cb2ba4ec61..da6138ad7d 100644 --- a/deps/uv/src/win/thread.c +++ b/deps/uv/src/win/thread.c @@ -27,6 +27,7 @@ #define HAVE_SRWLOCK_API() (pTryAcquireSRWLockShared != NULL) +#define HAVE_CONDVAR_API() (pInitializeConditionVariable != NULL) #ifdef _MSC_VER /* msvc */ # define inline __inline @@ -56,6 +57,23 @@ inline static int uv__rwlock_fallback_trywrlock(uv_rwlock_t* rwlock); inline static void uv__rwlock_fallback_wrunlock(uv_rwlock_t* rwlock); +inline static int uv_cond_fallback_init(uv_cond_t* cond); +inline static void uv_cond_fallback_destroy(uv_cond_t* cond); +inline static void uv_cond_fallback_signal(uv_cond_t* cond); +inline static void uv_cond_fallback_broadcast(uv_cond_t* cond); +inline static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex); +inline static int uv_cond_fallback_timedwait(uv_cond_t* cond, + uv_mutex_t* mutex, uint64_t timeout); + +inline static int uv_cond_condvar_init(uv_cond_t* cond); +inline static void uv_cond_condvar_destroy(uv_cond_t* cond); +inline static void uv_cond_condvar_signal(uv_cond_t* cond); +inline static void uv_cond_condvar_broadcast(uv_cond_t* cond); +inline static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex); +inline static int uv_cond_condvar_timedwait(uv_cond_t* cond, + uv_mutex_t* mutex, uint64_t timeout); + + static NOINLINE void uv__once_inner(uv_once_t* guard, void (*callback)(void)) { DWORD result; @@ -81,7 +99,7 @@ static NOINLINE void uv__once_inner(uv_once_t* guard, } else { /* We lost the race. Destroy the event we created and wait for the */ - /* existing one to become signaled. */ + /* existing one todv become signaled. */ CloseHandle(created_event); result = WaitForSingleObject(existing_event, INFINITE); assert(result == WAIT_OBJECT_0); @@ -140,6 +158,8 @@ void uv_mutex_unlock(uv_mutex_t* mutex) { int uv_rwlock_init(uv_rwlock_t* rwlock) { + uv__once_init(); + if (HAVE_SRWLOCK_API()) return uv__rwlock_srwlock_init(rwlock); else @@ -365,3 +385,228 @@ inline static int uv__rwlock_fallback_trywrlock(uv_rwlock_t* rwlock) { inline static void uv__rwlock_fallback_wrunlock(uv_rwlock_t* rwlock) { uv_mutex_unlock(&rwlock->fallback_.write_mutex_); } + + + +/* This condition variable implementation is based on the SetEvent solution + * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html + * We could not use the SignalObjectAndWait solution (section 3.4) because + * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and + * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. + */ + +inline static int uv_cond_fallback_init(uv_cond_t* cond) { + /* Initialize the count to 0. */ + cond->fallback.waiters_count = 0; + + InitializeCriticalSection(&cond->fallback.waiters_count_lock); + + /* Create an auto-reset event. */ + cond->fallback.signal_event = CreateEvent(NULL, /* no security */ + FALSE, /* auto-reset event */ + FALSE, /* non-signaled initially */ + NULL); /* unnamed */ + if (!cond->fallback.signal_event) + goto error2; + + /* Create a manual-reset event. */ + cond->fallback.broadcast_event = CreateEvent(NULL, /* no security */ + TRUE, /* manual-reset */ + FALSE, /* non-signaled */ + NULL); /* unnamed */ + if (!cond->fallback.broadcast_event) + goto error; + + return 0; + +error: + CloseHandle(cond->fallback.signal_event); +error2: + DeleteCriticalSection(&cond->fallback.waiters_count_lock); + return -1; +} + + +inline static int uv_cond_condvar_init(uv_cond_t* cond) { + pInitializeConditionVariable(&cond->cond_var); + return 0; +} + + +int uv_cond_init(uv_cond_t* cond) { + uv__once_init(); + + if (HAVE_CONDVAR_API()) + return uv_cond_condvar_init(cond); + else + return uv_cond_fallback_init(cond); +} + + +inline static void uv_cond_fallback_destroy(uv_cond_t* cond) { + if (!CloseHandle(cond->fallback.broadcast_event)) + abort(); + if (!CloseHandle(cond->fallback.signal_event)) + abort(); + DeleteCriticalSection(&cond->fallback.waiters_count_lock); +} + + +inline static void uv_cond_condvar_destroy(uv_cond_t* cond) { + /* nothing to do */ +} + + +void uv_cond_destroy(uv_cond_t* cond) { + if (HAVE_CONDVAR_API()) + uv_cond_condvar_destroy(cond); + else + uv_cond_fallback_destroy(cond); +} + + +inline static void uv_cond_fallback_signal(uv_cond_t* cond) { + int have_waiters; + + /* Avoid race conditions. */ + EnterCriticalSection(&cond->fallback.waiters_count_lock); + have_waiters = cond->fallback.waiters_count > 0; + LeaveCriticalSection(&cond->fallback.waiters_count_lock); + + if (have_waiters) + SetEvent(cond->fallback.signal_event); +} + + +inline static void uv_cond_condvar_signal(uv_cond_t* cond) { + pWakeConditionVariable(&cond->cond_var); +} + + +void uv_cond_signal(uv_cond_t* cond) { + if (HAVE_CONDVAR_API()) + uv_cond_condvar_signal(cond); + else + uv_cond_fallback_signal(cond); +} + + +inline static void uv_cond_fallback_broadcast(uv_cond_t* cond) { + int have_waiters; + + /* Avoid race conditions. */ + EnterCriticalSection(&cond->fallback.waiters_count_lock); + have_waiters = cond->fallback.waiters_count > 0; + LeaveCriticalSection(&cond->fallback.waiters_count_lock); + + if (have_waiters) + SetEvent(cond->fallback.broadcast_event); +} + + +inline static void uv_cond_condvar_broadcast(uv_cond_t* cond) { + pWakeAllConditionVariable(&cond->cond_var); +} + + +void uv_cond_broadcast(uv_cond_t* cond) { + if (HAVE_CONDVAR_API()) + uv_cond_condvar_broadcast(cond); + else + uv_cond_fallback_broadcast(cond); +} + + +inline int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex, + DWORD dwMilliseconds) { + DWORD result; + int last_waiter; + HANDLE handles[2] = { + cond->fallback.signal_event, + cond->fallback.broadcast_event + }; + + /* Avoid race conditions. */ + EnterCriticalSection(&cond->fallback.waiters_count_lock); + cond->fallback.waiters_count++; + LeaveCriticalSection(&cond->fallback.waiters_count_lock); + + /* It's ok to release the here since Win32 manual-reset events */ + /* maintain state when used with . This avoids the "lost wakeup" */ + /* bug. */ + uv_mutex_unlock(mutex); + + /* Wait for either event to become signaled due to being */ + /* called or being called. */ + result = WaitForMultipleObjects(2, handles, FALSE, dwMilliseconds); + + EnterCriticalSection(&cond->fallback.waiters_count_lock); + cond->fallback.waiters_count--; + last_waiter = result == WAIT_OBJECT_0 + 1 + && cond->fallback.waiters_count == 0; + LeaveCriticalSection(&cond->fallback.waiters_count_lock); + + /* Some thread called . */ + if (last_waiter) { + /* We're the last waiter to be notified or to stop waiting, so reset the */ + /* the manual-reset event. */ + ResetEvent(cond->fallback.broadcast_event); + } + + /* Reacquire the . */ + uv_mutex_lock(mutex); + + if (result == WAIT_OBJECT_0 || result == WAIT_OBJECT_0 + 1) + return 0; + + if (result == WAIT_TIMEOUT) + return -1; + + abort(); + return -1; /* Satisfy the compiler. */ +} + + +inline static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex) { + if (uv_cond_wait_helper(cond, mutex, INFINITE)) + abort(); +} + + +inline static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex) { + if (!pSleepConditionVariableCS(&cond->cond_var, mutex, INFINITE)) + abort(); +} + + +void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { + if (HAVE_CONDVAR_API()) + uv_cond_condvar_wait(cond, mutex); + else + uv_cond_fallback_wait(cond, mutex); +} + + +inline static int uv_cond_fallback_timedwait(uv_cond_t* cond, + uv_mutex_t* mutex, uint64_t timeout) { + return uv_cond_wait_helper(cond, mutex, (DWORD)(timeout / 1e6)); +} + + +inline static int uv_cond_condvar_timedwait(uv_cond_t* cond, + uv_mutex_t* mutex, uint64_t timeout) { + if (pSleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6))) + return 0; + if (GetLastError() != ERROR_TIMEOUT) + abort(); + return -1; +} + + +int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, + uint64_t timeout) { + if (HAVE_CONDVAR_API()) + return uv_cond_condvar_timedwait(cond, mutex, timeout); + else + return uv_cond_fallback_timedwait(cond, mutex, timeout); +} diff --git a/deps/uv/src/win/winapi.c b/deps/uv/src/win/winapi.c index ab5513ab6f..ab68bba742 100644 --- a/deps/uv/src/win/winapi.c +++ b/deps/uv/src/win/winapi.c @@ -45,6 +45,11 @@ sTryAcquireSRWLockShared pTryAcquireSRWLockShared; sTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive; sReleaseSRWLockShared pReleaseSRWLockShared; sReleaseSRWLockExclusive pReleaseSRWLockExclusive; +sInitializeConditionVariable pInitializeConditionVariable; +sSleepConditionVariableCS pSleepConditionVariableCS; +sSleepConditionVariableSRW pSleepConditionVariableSRW; +sWakeAllConditionVariable pWakeAllConditionVariable; +sWakeConditionVariable pWakeConditionVariable; void uv_winapi_init() { @@ -129,4 +134,19 @@ void uv_winapi_init() { pReleaseSRWLockExclusive = (sReleaseSRWLockExclusive) GetProcAddress(kernel32_module, "ReleaseSRWLockExclusive"); + + pInitializeConditionVariable = (sInitializeConditionVariable) + GetProcAddress(kernel32_module, "InitializeConditionVariable"); + + pSleepConditionVariableCS = (sSleepConditionVariableCS) + GetProcAddress(kernel32_module, "SleepConditionVariableCS"); + + pSleepConditionVariableSRW = (sSleepConditionVariableSRW) + GetProcAddress(kernel32_module, "SleepConditionVariableSRW"); + + pWakeAllConditionVariable = (sWakeAllConditionVariable) + GetProcAddress(kernel32_module, "WakeAllConditionVariable"); + + pWakeConditionVariable = (sWakeConditionVariable) + GetProcAddress(kernel32_module, "WakeConditionVariable"); } diff --git a/deps/uv/src/win/winapi.h b/deps/uv/src/win/winapi.h index 1bf6304b5e..e023beed5d 100644 --- a/deps/uv/src/win/winapi.h +++ b/deps/uv/src/win/winapi.h @@ -4426,6 +4426,25 @@ typedef VOID (WINAPI* sReleaseSRWLockShared) typedef VOID (WINAPI* sReleaseSRWLockExclusive) (PSRWLOCK SRWLock); +typedef VOID (WINAPI* sInitializeConditionVariable) + (PCONDITION_VARIABLE ConditionVariable); + +typedef BOOL (WINAPI* sSleepConditionVariableCS) + (PCONDITION_VARIABLE ConditionVariable, + PCRITICAL_SECTION CriticalSection, + DWORD dwMilliseconds); + +typedef BOOL (WINAPI* sSleepConditionVariableSRW) + (PCONDITION_VARIABLE ConditionVariable, + PSRWLOCK SRWLock, + DWORD dwMilliseconds, + ULONG Flags); + +typedef VOID (WINAPI* sWakeAllConditionVariable) + (PCONDITION_VARIABLE ConditionVariable); + +typedef VOID (WINAPI* sWakeConditionVariable) + (PCONDITION_VARIABLE ConditionVariable); /* Ntdll function pointers */ @@ -4448,5 +4467,10 @@ extern sTryAcquireSRWLockShared pTryAcquireSRWLockShared; extern sTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive; extern sReleaseSRWLockShared pReleaseSRWLockShared; extern sReleaseSRWLockExclusive pReleaseSRWLockExclusive; +extern sInitializeConditionVariable pInitializeConditionVariable; +extern sSleepConditionVariableCS pSleepConditionVariableCS; +extern sSleepConditionVariableSRW pSleepConditionVariableSRW; +extern sWakeAllConditionVariable pWakeAllConditionVariable; +extern sWakeConditionVariable pWakeConditionVariable; #endif /* UV_WIN_WINAPI_H_ */ diff --git a/deps/uv/test/benchmark-multi-accept.c b/deps/uv/test/benchmark-multi-accept.c index ce3f353d24..3b2c16c3aa 100644 --- a/deps/uv/test/benchmark-multi-accept.c +++ b/deps/uv/test/benchmark-multi-accept.c @@ -415,7 +415,6 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) { free(clients); free(servers); - uv_loop_delete(uv_default_loop()); /* Silence valgrind. */ return 0; } diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index 668dc95e6f..1a54a1adb9 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -55,8 +55,13 @@ void platform_init(int argc, char **argv) { /* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ /* Make sure that all stdio output of the processes is buffered up. */ -int process_start(char* name, char* part, process_info_t* p) { - FILE* stdout_file = tmpfile(); +int process_start(char* name, char* part, process_info_t* p, int is_helper) { + FILE* stdout_file; + const char* arg; + char* args[16]; + int n; + + stdout_file = tmpfile(); if (!stdout_file) { perror("tmpfile"); return -1; @@ -68,17 +73,34 @@ int process_start(char* name, char* part, process_info_t* p) { pid_t pid = fork(); if (pid < 0) { - perror("vfork"); + perror("fork"); return -1; } if (pid == 0) { /* child */ + arg = getenv("UV_USE_VALGRIND"); + n = 0; + + /* Disable valgrind for helpers, it complains about helpers leaking memory. + * They're killed after the test and as such never get a chance to clean up. + */ + if (is_helper == 0 && arg != NULL && atoi(arg) != 0) { + args[n++] = "valgrind"; + args[n++] = "--quiet"; + args[n++] = "--leak-check=full"; + args[n++] = "--show-reachable=yes"; + args[n++] = "--error-exitcode=125"; + } + + args[n++] = executable_path; + args[n++] = name; + args[n++] = part; + args[n++] = NULL; + dup2(fileno(stdout_file), STDOUT_FILENO); dup2(fileno(stdout_file), STDERR_FILENO); - - char* args[] = { executable_path, name, part, NULL }; - execvp(executable_path, args); + execvp(args[0], args); perror("execvp()"); _exit(127); } diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c index 2f44ff33a9..cf75c703d5 100644 --- a/deps/uv/test/runner-win.c +++ b/deps/uv/test/runner-win.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "task.h" #include "runner.h" @@ -57,7 +56,7 @@ void platform_init(int argc, char **argv) { } -int process_start(char *name, char *part, process_info_t *p) { +int process_start(char *name, char *part, process_info_t *p, int is_helper) { HANDLE file = INVALID_HANDLE_VALUE; HANDLE nul = INVALID_HANDLE_VALUE; WCHAR path[MAX_PATH], filename[MAX_PATH]; diff --git a/deps/uv/test/runner-win.h b/deps/uv/test/runner-win.h index f69976e987..c94b89bd5e 100644 --- a/deps/uv/test/runner-win.h +++ b/deps/uv/test/runner-win.h @@ -26,6 +26,7 @@ #pragma warning(disable : 4996) +#include #include #include diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c index b34acc8430..d7098123b0 100644 --- a/deps/uv/test/runner.c +++ b/deps/uv/test/runner.c @@ -24,6 +24,7 @@ #include "runner.h" #include "task.h" +#include "uv.h" char executable_path[PATHMAX] = { '\0' }; @@ -147,7 +148,8 @@ int run_test(const char* test, int timeout, int benchmark_output) { if (process_start(task->task_name, task->process_name, - &processes[process_count]) == -1) { + &processes[process_count], + 1 /* is_helper */) == -1) { snprintf(errmsg, sizeof errmsg, "Process `%s` failed to start.", @@ -173,7 +175,8 @@ int run_test(const char* test, int timeout, int benchmark_output) { if (process_start(task->task_name, task->process_name, - &processes[process_count]) == -1) { + &processes[process_count], + 0 /* !is_helper */) == -1) { snprintf(errmsg, sizeof errmsg, "Process `%s` failed to start.", @@ -291,11 +294,14 @@ out: */ int run_test_part(const char* test, const char* part) { task_entry_t* task; + int r; for (task = TASKS; task->main; task++) { - if (strcmp(test, task->task_name) == 0 - && strcmp(part, task->process_name) == 0) { - return task->main(); + if (strcmp(test, task->task_name) == 0 && + strcmp(part, task->process_name) == 0) { + r = task->main(); + uv_loop_delete(uv_default_loop()); + return r; } } diff --git a/deps/uv/test/runner.h b/deps/uv/test/runner.h index 5cee695ed2..0358d7e255 100644 --- a/deps/uv/test/runner.h +++ b/deps/uv/test/runner.h @@ -127,7 +127,7 @@ void platform_init(); /* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ /* Make sure that all stdio output of the processes is buffered up. */ -int process_start(char *name, char* part, process_info_t *p); +int process_start(char *name, char* part, process_info_t *p, int is_helper); /* Wait for all `n` processes in `vec` to terminate. */ /* Time out after `timeout` msec, or never if timeout == -1 */ diff --git a/deps/uv/test/test-async.c b/deps/uv/test/test-async.c index 7cdad0983a..9b2ce7bcf1 100644 --- a/deps/uv/test/test-async.c +++ b/deps/uv/test/test-async.c @@ -114,5 +114,7 @@ TEST_IMPL(async) { ASSERT(async_cb_called == 3); ASSERT(close_cb_called == 2); + ASSERT(0 == uv_thread_join(&thread)); + return 0; } diff --git a/deps/uv/test/test-condvar.c b/deps/uv/test/test-condvar.c new file mode 100644 index 0000000000..065dd4ec6c --- /dev/null +++ b/deps/uv/test/test-condvar.c @@ -0,0 +1,173 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "task.h" + +#include +#include + +typedef struct { + uv_mutex_t mutex; + uv_cond_t cond; + int delay; + int use_broadcast; + volatile int posted; +} worker_config; + + +static void worker(void* arg) { + worker_config* c = arg; + + if (c->delay) + uv_sleep(c->delay); + + uv_mutex_lock(&c->mutex); + ASSERT(c->posted == 0); + c->posted = 1; + if (c->use_broadcast) + uv_cond_broadcast(&c->cond); + else + uv_cond_signal(&c->cond); + uv_mutex_unlock(&c->mutex); +} + + +TEST_IMPL(condvar_1) { + uv_thread_t thread; + worker_config wc; + + memset(&wc, 0, sizeof(wc)); + + ASSERT(0 == uv_cond_init(&wc.cond)); + ASSERT(0 == uv_mutex_init(&wc.mutex)); + ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + + uv_mutex_lock(&wc.mutex); + uv_sleep(100); + uv_cond_wait(&wc.cond, &wc.mutex); + ASSERT(wc.posted == 1); + uv_mutex_unlock(&wc.mutex); + + ASSERT(0 == uv_thread_join(&thread)); + uv_mutex_destroy(&wc.mutex); + uv_cond_destroy(&wc.cond); + + return 0; +} + + +TEST_IMPL(condvar_2) { + uv_thread_t thread; + worker_config wc; + + memset(&wc, 0, sizeof(wc)); + wc.delay = 100; + + ASSERT(0 == uv_cond_init(&wc.cond)); + ASSERT(0 == uv_mutex_init(&wc.mutex)); + ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + + uv_mutex_lock(&wc.mutex); + uv_cond_wait(&wc.cond, &wc.mutex); + uv_mutex_unlock(&wc.mutex); + + ASSERT(0 == uv_thread_join(&thread)); + uv_mutex_destroy(&wc.mutex); + uv_cond_destroy(&wc.cond); + + return 0; +} + + +TEST_IMPL(condvar_3) { + uv_thread_t thread; + worker_config wc; + int r; + + memset(&wc, 0, sizeof(wc)); + wc.delay = 100; + + ASSERT(0 == uv_cond_init(&wc.cond)); + ASSERT(0 == uv_mutex_init(&wc.mutex)); + ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + + uv_mutex_lock(&wc.mutex); + r = uv_cond_timedwait(&wc.cond, &wc.mutex, (uint64_t)(50 * 1e6)); + ASSERT(r == -1); + uv_mutex_unlock(&wc.mutex); + + ASSERT(0 == uv_thread_join(&thread)); + uv_mutex_destroy(&wc.mutex); + uv_cond_destroy(&wc.cond); + + return 0; +} + + +TEST_IMPL(condvar_4) { + uv_thread_t thread; + worker_config wc; + int r; + + memset(&wc, 0, sizeof(wc)); + wc.delay = 100; + + ASSERT(0 == uv_cond_init(&wc.cond)); + ASSERT(0 == uv_mutex_init(&wc.mutex)); + ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + + uv_mutex_lock(&wc.mutex); + r = uv_cond_timedwait(&wc.cond, &wc.mutex, (uint64_t)(150 * 1e6)); + ASSERT(r == 0); + uv_mutex_unlock(&wc.mutex); + + ASSERT(0 == uv_thread_join(&thread)); + uv_mutex_destroy(&wc.mutex); + uv_cond_destroy(&wc.cond); + + return 0; +} + + +TEST_IMPL(condvar_5) { + uv_thread_t thread; + worker_config wc; + + memset(&wc, 0, sizeof(wc)); + wc.use_broadcast = 1; + + ASSERT(0 == uv_cond_init(&wc.cond)); + ASSERT(0 == uv_mutex_init(&wc.mutex)); + ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + + uv_mutex_lock(&wc.mutex); + uv_sleep(100); + uv_cond_wait(&wc.cond, &wc.mutex); + ASSERT(wc.posted == 1); + uv_mutex_unlock(&wc.mutex); + + ASSERT(0 == uv_thread_join(&thread)); + uv_mutex_destroy(&wc.mutex); + uv_cond_destroy(&wc.cond); + + return 0; +} diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c index 4d4cfbc31b..dd10915fb8 100644 --- a/deps/uv/test/test-fs-event.c +++ b/deps/uv/test/test-fs-event.c @@ -174,14 +174,13 @@ static void timer_cb_watch_twice(uv_timer_t* handle, int status) { } TEST_IMPL(fs_event_watch_dir) { - uv_fs_t fs_req; uv_loop_t* loop = uv_default_loop(); int r; /* Setup */ - uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); - uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); - uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); + remove("watch_dir/file2"); + remove("watch_dir/file1"); + remove("watch_dir/"); create_dir(loop, "watch_dir"); r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_cb_dir, 0); @@ -198,22 +197,21 @@ TEST_IMPL(fs_event_watch_dir) { ASSERT(close_cb_called == 2); /* Cleanup */ - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); - r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); + remove("watch_dir/file2"); + remove("watch_dir/file1"); + remove("watch_dir/"); return 0; } TEST_IMPL(fs_event_watch_file) { - uv_fs_t fs_req; uv_loop_t* loop = uv_default_loop(); int r; /* Setup */ - uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); - uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); - uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); + remove("watch_dir/file2"); + remove("watch_dir/file1"); + remove("watch_dir/"); create_dir(loop, "watch_dir"); create_file(loop, "watch_dir/file1"); create_file(loop, "watch_dir/file2"); @@ -232,9 +230,9 @@ TEST_IMPL(fs_event_watch_file) { ASSERT(close_cb_called == 2); /* Cleanup */ - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); - r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); + remove("watch_dir/file2"); + remove("watch_dir/file1"); + remove("watch_dir/"); return 0; } @@ -260,13 +258,12 @@ TEST_IMPL(fs_event_watch_file_twice) { TEST_IMPL(fs_event_watch_file_current_dir) { uv_timer_t timer; uv_loop_t* loop; - uv_fs_t fs_req; int r; loop = uv_default_loop(); /* Setup */ - uv_fs_unlink(loop, &fs_req, "watch_file", NULL); + remove("watch_file"); create_file(loop, "watch_file"); r = uv_fs_event_init(loop, &fs_event, "watch_file", @@ -290,19 +287,19 @@ TEST_IMPL(fs_event_watch_file_current_dir) { ASSERT(close_cb_called == 1); /* Cleanup */ - r = uv_fs_unlink(loop, &fs_req, "watch_file", NULL); + remove("watch_file"); + return 0; } TEST_IMPL(fs_event_no_callback_on_close) { - uv_fs_t fs_req; uv_loop_t* loop = uv_default_loop(); int r; /* Setup */ - uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); - uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); + remove("watch_dir/file1"); + remove("watch_dir/"); create_dir(loop, "watch_dir"); create_file(loop, "watch_dir/file1"); @@ -321,8 +318,8 @@ TEST_IMPL(fs_event_no_callback_on_close) { ASSERT(close_cb_called == 1); /* Cleanup */ - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); - r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); + remove("watch_dir/file1"); + remove("watch_dir/"); return 0; } @@ -370,7 +367,6 @@ TEST_IMPL(fs_event_immediate_close) { TEST_IMPL(fs_event_close_with_pending_event) { uv_loop_t* loop; - uv_fs_t fs_req; int r; loop = uv_default_loop(); @@ -391,10 +387,8 @@ TEST_IMPL(fs_event_close_with_pending_event) { ASSERT(close_cb_called == 1); /* Clean up */ - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file", NULL); - ASSERT(r == 0); - r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); - ASSERT(r == 0); + remove("watch_dir/file"); + remove("watch_dir/"); return 0; } @@ -427,7 +421,6 @@ static void fs_event_cb_close(uv_fs_event_t* handle, const char* filename, TEST_IMPL(fs_event_close_in_callback) { uv_loop_t* loop; - uv_fs_t fs_req; int r; loop = uv_default_loop(); @@ -455,18 +448,12 @@ TEST_IMPL(fs_event_close_in_callback) { ASSERT(fs_event_cb_called == 3); /* Clean up */ - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); - ASSERT(r == 0); - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); - ASSERT(r == 0); - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file3", NULL); - ASSERT(r == 0); - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file4", NULL); - ASSERT(r == 0); - r = uv_fs_unlink(loop, &fs_req, "watch_dir/file5", NULL); - ASSERT(r == 0); - r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); - ASSERT(r == 0); + remove("watch_dir/file1"); + remove("watch_dir/file2"); + remove("watch_dir/file3"); + remove("watch_dir/file4"); + remove("watch_dir/file5"); + remove("watch_dir/"); return 0; } diff --git a/deps/uv/test/test-fs-poll.c b/deps/uv/test/test-fs-poll.c index 00a73b6c99..4380b561ef 100644 --- a/deps/uv/test/test-fs-poll.c +++ b/deps/uv/test/test-fs-poll.c @@ -140,7 +140,6 @@ TEST_IMPL(fs_poll) { ASSERT(poll_cb_called == 5); ASSERT(timer_cb_called == 2); ASSERT(close_cb_called == 1); - uv_loop_delete(loop); return 0; } diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 76ced14a94..e59e5ed11d 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -53,6 +53,7 @@ typedef struct { } utime_check_t; +static int dummy_cb_count; static int close_cb_count; static int create_cb_count; static int open_cb_count; @@ -127,6 +128,12 @@ void check_permission(const char* filename, int mode) { } +static void dummy_cb(uv_fs_t* req) { + (void) req; + dummy_cb_count++; +} + + static void link_cb(uv_fs_t* req) { ASSERT(req->fs_type == UV_FS_LINK); ASSERT(req->result == 0); @@ -787,7 +794,7 @@ TEST_IMPL(fs_async_dir) { ASSERT(r == 0); uv_run(loop); - r = uv_fs_stat(loop, &stat_req, "test_dir\\", stat_cb); + r = uv_fs_stat(loop, &stat_req, "test_dir/", stat_cb); ASSERT(r == 0); uv_run(loop); @@ -795,7 +802,7 @@ TEST_IMPL(fs_async_dir) { ASSERT(r == 0); uv_run(loop); - r = uv_fs_lstat(loop, &stat_req, "test_dir\\", stat_cb); + r = uv_fs_lstat(loop, &stat_req, "test_dir/", stat_cb); ASSERT(r == 0); uv_run(loop); @@ -1183,6 +1190,28 @@ TEST_IMPL(fs_link) { } +TEST_IMPL(fs_readlink) { + uv_fs_t req; + + loop = uv_default_loop(); + ASSERT(0 == uv_fs_readlink(loop, &req, "no_such_file", dummy_cb)); + ASSERT(0 == uv_run(loop)); + ASSERT(dummy_cb_count == 1); + ASSERT(req.ptr == NULL); + ASSERT(req.result == -1); + ASSERT(req.errorno == UV_ENOENT); + uv_fs_req_cleanup(&req); + + ASSERT(-1 == uv_fs_readlink(loop, &req, "no_such_file", NULL)); + ASSERT(req.ptr == NULL); + ASSERT(req.result == -1); + ASSERT(req.errorno == UV_ENOENT); + uv_fs_req_cleanup(&req); + + return 0; +} + + TEST_IMPL(fs_symlink) { int r; uv_fs_t req; @@ -1251,6 +1280,8 @@ TEST_IMPL(fs_symlink) { r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL); ASSERT(r != -1); + uv_fs_req_cleanup(&req); + r = uv_fs_readlink(loop, &req, "test_file_symlink_symlink", NULL); ASSERT(r != -1); ASSERT(strcmp(req.ptr, "test_file_symlink") == 0); @@ -1278,6 +1309,8 @@ TEST_IMPL(fs_symlink) { r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL); ASSERT(r != -1); + uv_fs_req_cleanup(&req); + r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb); ASSERT(r != -1); uv_run(loop); @@ -1608,6 +1641,7 @@ TEST_IMPL(fs_readdir_file) { r = uv_fs_readdir(loop, &readdir_req, path, 0, NULL); ASSERT(r == -1); ASSERT(uv_last_error(loop).code == UV_ENOTDIR); + uv_fs_req_cleanup(&readdir_req); r = uv_fs_readdir(loop, &readdir_req, path, 0, file_readdir_cb); ASSERT(r == 0); diff --git a/deps/uv/test/test-getsockname.c b/deps/uv/test/test-getsockname.c index ff28beb922..2bfb71ad56 100644 --- a/deps/uv/test/test-getsockname.c +++ b/deps/uv/test/test-getsockname.c @@ -238,9 +238,9 @@ static void udp_recv(uv_udp_t* handle, int r; ASSERT(nread >= 0); + free(buf.base); if (nread == 0) { - free(buf.base); return; } diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index ce70c1f915..893be1a5f3 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -22,6 +22,11 @@ TEST_DECLARE (platform_output) TEST_DECLARE (callback_order) TEST_DECLARE (run_once) +TEST_DECLARE (condvar_1) +TEST_DECLARE (condvar_2) +TEST_DECLARE (condvar_3) +TEST_DECLARE (condvar_4) +TEST_DECLARE (condvar_5) TEST_DECLARE (semaphore_1) TEST_DECLARE (semaphore_2) TEST_DECLARE (semaphore_3) @@ -152,6 +157,7 @@ TEST_DECLARE (fs_fstat) TEST_DECLARE (fs_chmod) TEST_DECLARE (fs_chown) TEST_DECLARE (fs_link) +TEST_DECLARE (fs_readlink) TEST_DECLARE (fs_symlink) TEST_DECLARE (fs_symlink_dir) TEST_DECLARE (fs_utime) @@ -207,6 +213,11 @@ TASK_LIST_START TEST_ENTRY (callback_order) #endif TEST_ENTRY (run_once) + TEST_ENTRY (condvar_1) + TEST_ENTRY (condvar_2) + TEST_ENTRY (condvar_3) + TEST_ENTRY (condvar_4) + TEST_ENTRY (condvar_5) TEST_ENTRY (semaphore_1) TEST_ENTRY (semaphore_2) TEST_ENTRY (semaphore_3) @@ -405,6 +416,7 @@ TASK_LIST_START TEST_ENTRY (fs_chown) TEST_ENTRY (fs_utime) TEST_ENTRY (fs_futime) + TEST_ENTRY (fs_readlink) TEST_ENTRY (fs_symlink) TEST_ENTRY (fs_symlink_dir) TEST_ENTRY (fs_stat_missing_path) diff --git a/deps/uv/test/test-ping-pong.c b/deps/uv/test/test-ping-pong.c index 1bdcc3bc24..92e40e550d 100644 --- a/deps/uv/test/test-ping-pong.c +++ b/deps/uv/test/test-ping-pong.c @@ -52,10 +52,7 @@ void pinger_try_read(pinger_t* pinger); static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { - uv_buf_t buf; - buf.base = (char*)malloc(size); - buf.len = size; - return buf; + return uv_buf_init(malloc(size), size); } @@ -103,10 +100,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) { ASSERT(uv_last_error(uv_default_loop()).code == UV_EOF); puts("got EOF"); - - if (buf.base) { - free(buf.base); - } + free(buf.base); uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close); @@ -117,17 +111,22 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) { for (i = 0; i < nread; i++) { ASSERT(buf.base[i] == PING[pinger->state]); pinger->state = (pinger->state + 1) % (sizeof(PING) - 1); - if (pinger->state == 0) { - printf("PONG %d\n", pinger->pongs); - pinger->pongs++; - if (pinger->pongs < NUM_PINGS) { - pinger_write_ping(pinger); - } else { - uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close); - return; - } + + if (pinger->state != 0) + continue; + + printf("PONG %d\n", pinger->pongs); + pinger->pongs++; + + if (pinger->pongs < NUM_PINGS) { + pinger_write_ping(pinger); + } else { + uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close); + break; } } + + free(buf.base); } diff --git a/deps/uv/test/test-ref.c b/deps/uv/test/test-ref.c index e0c38858ec..95e92a86c4 100644 --- a/deps/uv/test/test-ref.c +++ b/deps/uv/test/test-ref.c @@ -36,6 +36,21 @@ static int req_cb_called; static int connect_cb_called; static int write_cb_called; static int shutdown_cb_called; +static int close_cb_called; + + +static void close_cb(uv_handle_t* handle) { + close_cb_called++; +} + + +static void do_close(void* handle) { + close_cb_called = 0; + uv_close((uv_handle_t*)handle, close_cb); + ASSERT(close_cb_called == 0); + uv_run(uv_default_loop()); + ASSERT(close_cb_called == 1); +} static void fail_cb(void) { @@ -91,6 +106,7 @@ TEST_IMPL(idle_ref) { uv_idle_start(&h, NULL); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -100,6 +116,7 @@ TEST_IMPL(async_ref) { uv_async_init(uv_default_loop(), &h, NULL); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -110,6 +127,7 @@ TEST_IMPL(prepare_ref) { uv_prepare_start(&h, NULL); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -120,6 +138,7 @@ TEST_IMPL(check_ref) { uv_check_start(&h, NULL); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -136,6 +155,7 @@ TEST_IMPL(unref_in_prepare_cb) { uv_prepare_init(uv_default_loop(), &h); uv_prepare_start(&h, prepare_cb); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -145,6 +165,7 @@ TEST_IMPL(timer_ref) { uv_timer_init(uv_default_loop(), &h); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -155,6 +176,7 @@ TEST_IMPL(timer_ref2) { uv_timer_start(&h, (uv_timer_cb)fail_cb, 42, 42); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -164,6 +186,7 @@ TEST_IMPL(fs_event_ref) { uv_fs_event_init(uv_default_loop(), &h, ".", (uv_fs_event_cb)fail_cb, 0); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -174,6 +197,7 @@ TEST_IMPL(fs_poll_ref) { uv_fs_poll_start(&h, NULL, ".", 999); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -183,6 +207,7 @@ TEST_IMPL(tcp_ref) { uv_tcp_init(uv_default_loop(), &h); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -193,6 +218,7 @@ TEST_IMPL(tcp_ref2) { uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -206,6 +232,7 @@ TEST_IMPL(tcp_ref3) { uv_run(uv_default_loop()); ASSERT(connect_cb_called == 1); ASSERT(shutdown_cb_called == 1); + do_close(&h); return 0; } @@ -220,6 +247,7 @@ TEST_IMPL(tcp_ref4) { ASSERT(connect_cb_called == 1); ASSERT(write_cb_called == 1); ASSERT(shutdown_cb_called == 1); + do_close(&h); return 0; } @@ -229,6 +257,7 @@ TEST_IMPL(udp_ref) { uv_udp_init(uv_default_loop(), &h); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -241,6 +270,7 @@ TEST_IMPL(udp_ref2) { uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -256,6 +286,7 @@ TEST_IMPL(udp_ref3) { uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); ASSERT(req_cb_called == 1); + do_close(&h); return 0; } @@ -266,6 +297,7 @@ TEST_IMPL(pipe_ref) { uv_pipe_init(uv_default_loop(), &h, 0); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -276,6 +308,7 @@ TEST_IMPL(pipe_ref2) { uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop()); + do_close(&h); return 0; } @@ -288,6 +321,7 @@ TEST_IMPL(pipe_ref3) { uv_run(uv_default_loop()); ASSERT(connect_cb_called == 1); ASSERT(shutdown_cb_called == 1); + do_close(&h); return 0; } @@ -301,6 +335,7 @@ TEST_IMPL(pipe_ref4) { ASSERT(connect_cb_called == 1); ASSERT(write_cb_called == 1); ASSERT(shutdown_cb_called == 1); + do_close(&h); return 0; } @@ -334,5 +369,7 @@ TEST_IMPL(process_ref) { r = uv_process_kill(&h, /* SIGTERM */ 15); ASSERT(r == 0); + do_close(&h); + return 0; } diff --git a/deps/uv/test/test-tcp-writealot.c b/deps/uv/test/test-tcp-writealot.c index 841df3c0d9..16d141ad32 100644 --- a/deps/uv/test/test-tcp-writealot.c +++ b/deps/uv/test/test-tcp-writealot.c @@ -145,7 +145,7 @@ TEST_IMPL(tcp_writealot) { uv_tcp_t client; int r; - send_buffer = malloc(TOTAL_BYTES); + send_buffer = calloc(1, TOTAL_BYTES); ASSERT(send_buffer != NULL); r = uv_tcp_init(uv_default_loop(), &client); diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index a7993e1d69..622b234646 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -6,7 +6,6 @@ '_LARGEFILE_SOURCE', '_FILE_OFFSET_BITS=64', '_GNU_SOURCE', - 'EIO_STACKSIZE=262144' ], 'conditions': [ ['OS=="solaris"', { @@ -53,7 +52,6 @@ [ 'OS=="win"', { 'defines': [ '_WIN32_WINNT=0x0600', - 'EIO_STACKSIZE=262144', '_GNU_SOURCE', ], 'sources': [ @@ -108,7 +106,6 @@ '-Wno-unused-parameter' ], 'sources': [ - 'include/uv-private/eio.h', 'include/uv-private/ev.h', 'include/uv-private/uv-unix.h', 'include/uv-private/uv-linux.h', @@ -118,15 +115,13 @@ 'src/unix/async.c', 'src/unix/core.c', 'src/unix/dl.c', - 'src/unix/eio/ecb.h', - 'src/unix/eio/eio.c', - 'src/unix/eio/xthread.h', 'src/unix/error.c', 'src/unix/ev/ev.c', 'src/unix/ev/ev_vars.h', 'src/unix/ev/ev_wrap.h', 'src/unix/ev/event.h', 'src/unix/fs.c', + 'src/unix/getaddrinfo.c', 'src/unix/internal.h', 'src/unix/loop.c', 'src/unix/loop-watcher.c', @@ -137,11 +132,10 @@ 'src/unix/stream.c', 'src/unix/tcp.c', 'src/unix/thread.c', + 'src/unix/threadpool.c', 'src/unix/timer.c', 'src/unix/tty.c', 'src/unix/udp.c', - 'src/unix/uv-eio.c', - 'src/unix/uv-eio.h', ], 'include_dirs': [ 'src/unix/ev', ], 'libraries': [ '-lm' ] @@ -156,7 +150,6 @@ 'defines': [ '_DARWIN_USE_64_BIT_INODE=1', 'EV_CONFIG_H="config_darwin.h"', - 'EIO_CONFIG_H="config_darwin.h"', ] }], [ 'OS=="linux"', { @@ -168,7 +161,6 @@ ], 'defines': [ 'EV_CONFIG_H="config_linux.h"', - 'EIO_CONFIG_H="config_linux.h"', ], 'direct_dependent_settings': { 'libraries': [ '-lrt' ], @@ -180,13 +172,13 @@ '__EXTENSIONS__', '_XOPEN_SOURCE=500', 'EV_CONFIG_H="config_sunos.h"', - 'EIO_CONFIG_H="config_sunos.h"', ], 'direct_dependent_settings': { 'libraries': [ '-lkstat', - '-lsocket', '-lnsl', + '-lsendfile', + '-lsocket', ], }, }], @@ -197,7 +189,6 @@ '_ALL_SOURCE', '_XOPEN_SOURCE=500', 'EV_CONFIG_H="config_aix.h"', - 'EIO_CONFIG_H="config_aix.h"', ], 'direct_dependent_settings': { 'libraries': [ @@ -209,7 +200,6 @@ 'sources': [ 'src/unix/freebsd.c' ], 'defines': [ 'EV_CONFIG_H="config_freebsd.h"', - 'EIO_CONFIG_H="config_freebsd.h"', ], 'direct_dependent_settings': { 'libraries': [ @@ -221,14 +211,12 @@ 'sources': [ 'src/unix/openbsd.c' ], 'defines': [ 'EV_CONFIG_H="config_openbsd.h"', - 'EIO_CONFIG_H="config_openbsd.h"', ], }], [ 'OS=="netbsd"', { 'sources': [ 'src/unix/netbsd.c' ], 'defines': [ 'EV_CONFIG_H="config_netbsd.h"', - 'EIO_CONFIG_H="config_netbsd.h"', ], 'direct_dependent_settings': { 'libraries': [ @@ -239,6 +227,9 @@ [ 'OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', { 'sources': [ 'src/unix/kqueue.c' ], }], + ['library=="shared_library"', { + 'defines': [ 'BUILDING_UV_SHARED=1' ] + }] ] }, @@ -314,6 +305,7 @@ 'test/test-mutexes.c', 'test/test-signal.c', 'test/test-thread.c', + 'test/test-condvar.c', 'test/test-timer-again.c', 'test/test-timer.c', 'test/test-tty.c', diff --git a/deps/uv/vcbuild.bat b/deps/uv/vcbuild.bat index 644f574c22..12e5480aea 100644 --- a/deps/uv/vcbuild.bat +++ b/deps/uv/vcbuild.bat @@ -17,6 +17,10 @@ set target=Build set noprojgen= set nobuild= set run= +set target_arch=ia32 +set vs_toolset=x86 +set platform=WIN32 +set library=static_library :next-arg if "%1"=="" goto args-done @@ -27,11 +31,36 @@ if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok if /i "%1"=="clean" set target=Clean&goto arg-ok if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok +if /i "%1"=="x86" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok +if /i "%1"=="ia32" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok +if /i "%1"=="x64" set target_arch=x64&set platform=amd64&set vs_toolset=x64&goto arg-ok +if /i "%1"=="shared" set library=shared_library&goto arg-ok +if /i "%1"=="static" set library=static_library&goto arg-ok :arg-ok shift goto next-arg :args-done +@rem Look for Visual Studio 2010 +if not defined VS100COMNTOOLS goto vc-set-2008 +if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008 +call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% +set GYP_MSVS_VERSION=2010 +goto select-target + +:vc-set-2008 +@rem Look for Visual Studio 2008 +if not defined VS90COMNTOOLS goto vc-set-notfound +if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound +call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% +echo Warning: building with Visual Studio 2008 is currently not supported. +set GYP_MSVS_VERSION=2008 +goto select-target + +:vc-set-notfound +echo Warning: Visual Studio not found + +:select-target if not "%config%"=="" goto project-gen if "%run%"=="run-tests.exe" set config=Debug& goto project-gen if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen @@ -42,7 +71,6 @@ set config=Debug if defined noprojgen goto msbuild @rem Generate the VS project. - if exist build\gyp goto have_gyp echo svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp @@ -50,12 +78,12 @@ if errorlevel 1 goto gyp_install_failed goto have_gyp :gyp_install_failed -echo Failed to download gyp. Make sure you have subversion installed, or +echo Failed to download gyp. Make sure you have subversion installed, or echo manually install gyp into %~dp0build\gyp. goto exit :have_gyp -python gyp_uv +python gyp_uv -Dtarget_arch=%target_arch% -Dlibrary=%library% if errorlevel 1 goto create-msvs-files-failed if not exist uv.sln goto create-msvs-files-failed echo Project files generated. @@ -64,12 +92,7 @@ echo Project files generated. @rem Skip project generation if requested. if defined nobuild goto run -@rem If not running in the VS build env, try to start it. If that fails, bail -@rem out. -if defined VCINSTALLDIR goto msbuild-found -if not defined VS100COMNTOOLS goto msbuild-not-found -if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found -call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" +@rem Check if VS build env is available if not defined VCINSTALLDIR goto msbuild-not-found goto msbuild-found @@ -79,7 +102,7 @@ goto run @rem Build the sln with msbuild. :msbuild-found -msbuild uv.sln /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo +msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo if errorlevel 1 goto exit :run @@ -91,11 +114,11 @@ echo running '%config%\%run%' goto exit :create-msvs-files-failed -echo Failed to create vc project files. +echo Failed to create vc project files. goto exit :help -echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] +echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared] echo Examples: echo vcbuild.bat : builds debug build echo vcbuild.bat test : builds debug build and runs tests